/**
 * TrustWeb Builder — Extra Widgets CSS
 * Facebook Page + Testimonial + Login
 *
 * @package TrustWeb_Builder
 * @since   3.3.2
 */

/* ─────────────────────────────────────────────────────────────────────────────
   FACEBOOK PAGE WIDGET
   ───────────────────────────────────────────────────────────────────────────── */

.twb-fb-wrap {
    display: flex;
    justify-content: center;
}

.twb-facebook-page__inner {
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    position: relative;
}

/* Editor placeholder */
.twb-fb-editor-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
    border: 2px dashed #c9cdd4;
    border-radius: 8px;
    gap: 12px;
    padding: 24px;
    box-sizing: border-box;
}

.twb-fb-preview-icon svg {
    display: block;
}

.twb-fb-preview-url {
    font-size: 13px;
    color: #1877f2;
    margin: 0;
    word-break: break-all;
}

.twb-fb-preview-note {
    font-size: 12px;
    color: #65676b;
    margin: 0;
}

/* Responsive iframe from FB plugin */
.twb-fb-embed .fb_iframe_widget {
    width: 100% !important;
}

.twb-fb-embed .fb_iframe_widget span,
.twb-fb-embed .fb_iframe_widget iframe {
    width: 100% !important;
}

/* Loading skeleton trước khi FB SDK init */
.twb-fb-loading {
    height: 500px;
    background: linear-gradient(90deg, #f0f2f5 25%, #e4e6e9 50%, #f0f2f5 75%);
    background-size: 200% 100%;
    animation: twb-skeleton 1.5s infinite;
    border-radius: 4px;
}

@keyframes twb-skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TESTIMONIAL WIDGET
   ───────────────────────────────────────────────────────────────────────────── */

.twb-testi-wrapper {
    position: relative;
    width: 100%;
}

/* ── Grid Layout ─────────────────────────────────────────────── */

.twb-testi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 1024px) {
    .twb-testi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .twb-testi-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Carousel Layout ─────────────────────────────────────────── */

.twb-testi-carousel {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* Ẩn scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px; /* tránh clip shadow */
}

.twb-testi-carousel::-webkit-scrollbar {
    display: none;
}

.twb-testi-carousel .twb-testi-card {
    flex: 0 0 calc((100% - (var(--twb-carousel-view, var(--twb-carousel-fallback-view, 2)) - 1) * var(--twb-carousel-gap, 24px)) / var(--twb-carousel-view, var(--twb-carousel-fallback-view, 2)));
    scroll-snap-align: start;
    min-width: 0;
}
@media (max-width: 1024px) { .twb-testi-carousel { --twb-carousel-fallback-view: 2; } }
@media (max-width: 767px) { .twb-testi-carousel { --twb-carousel-fallback-view: 1; } }
.twb-testi-wrapper [hidden] { display: none; }

/* ── Card Base ───────────────────────────────────────────────── */

.twb-testi-card {
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: #fff;
    border-radius: var(--twb-radius-md, 12px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Card Styles */
.twb-testi-classic {
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.twb-testi-classic:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.twb-testi-bordered {
    border: 2px solid #e5e7eb;
}

.twb-testi-minimal {
    background: transparent;
    border: none;
    box-shadow: none;
    padding-left: 0;
    padding-right: 0;
}

.twb-testi-quote {
    border: none;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    position: relative;
}

.twb-testi-quote::before {
    content: '\201C'; /* " */
    font-size: 80px;
    line-height: 1;
    color: #1877f2;
    position: absolute;
    top: 12px;
    left: 20px;
    font-family: Georgia, serif;
    opacity: 0.25;
    pointer-events: none;
}

.twb-testi-quote .twb-testi-content {
    padding-top: 12px;
}

/* ── Card Content ────────────────────────────────────────────── */

.twb-testi-rating {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    font-size: 18px;
    line-height: 1;
}

.twb-testi-star-filled {
    color: #f59e0b;
}

.twb-testi-star-empty {
    color: #d1d5db;
}

.twb-testi-content {
    font-size: 15px;
    line-height: 1.7;
    color: #4b5563;
    margin: 0 0 20px;
    padding: 0;
    border: none;
    flex-grow: 1;
}

.twb-testi-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.twb-testi-author-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.twb-testi-name {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.twb-testi-position {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.3;
}

/* ── Avatar ──────────────────────────────────────────────────── */

.twb-testi-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #e5e7eb;
}

.twb-testi-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.twb-testi-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: #1877f2;
    border-radius: inherit;
    letter-spacing: 0.5px;
}

/* Avatar top position */
.twb-testi-card > .twb-testi-avatar {
    margin-bottom: 16px;
}

/* ── Carousel Arrows ─────────────────────────────────────────── */

.twb-testi-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    padding: 0;
}

.twb-testi-arrow:hover {
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.16);
}

.twb-testi-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.twb-testi-arrow-prev { left: var(--twb-testi-arrow-inset, 8px); }
.twb-testi-arrow-next { right: var(--twb-testi-arrow-inset, 8px); }

/* ── Dots ────────────────────────────────────────────────────── */

.twb-testi-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.twb-testi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease, width 0.2s ease;
}

.twb-testi-dot.is-active {
    background: #1877f2;
    width: 24px;
    border-radius: 4px;
}


/* Empty state */
.twb-testi-empty {
    color: #9ca3af;
    font-style: italic;
    text-align: center;
    padding: 32px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN WIDGET
   ───────────────────────────────────────────────────────────────────────────── */

.twb-login-wrap {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Logo */
.twb-login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.twb-login-logo img {
    max-width: 160px;
    max-height: 80px;
    object-fit: contain;
    display: inline-block;
}

/* Title */
.twb-login-title {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 24px;
    text-align: center;
}

/* Message */
.twb-login-message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.twb-login-message[hidden] {
    display: none;
}

.twb-login-message.is-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.twb-login-message.is-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Form */
.twb-login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Field */
.twb-login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.twb-login-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

/* Input wrapper (for password toggle) */
.twb-login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.twb-login-input-wrap .twb-login-input {
    flex: 1;
    padding-right: 44px;
}

/* Input */
.twb-login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
    background: #f9fafb;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.twb-login-input:focus {
    border-color: #1877f2;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.12);
}

.twb-login-input::placeholder {
    color: #9ca3af;
}

/* Password toggle */
.twb-login-toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}

.twb-login-toggle-pw:hover {
    color: #1877f2;
}

/* Row: remember + forgot */
.twb-login-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* Checkbox */
.twb-login-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.twb-login-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1877f2;
    flex-shrink: 0;
}

/* Links */
.twb-login-link {
    font-size: 14px;
    color: #1877f2;
    text-decoration: none;
    transition: color 0.15s ease;
}

.twb-login-link:hover {
    color: #1558b0;
    text-decoration: underline;
}

/* Submit */
.twb-login-submit {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: #1877f2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
}

.twb-login-submit:hover {
    background: #1558b0;
}

.twb-login-submit:active {
    transform: scale(0.99);
}

.twb-login-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Submit spinner */
.twb-login-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: twb-spin 0.7s linear infinite;
}

.twb-login-submit.is-loading .twb-login-spinner {
    display: block;
}

.twb-login-submit.is-loading .twb-login-submit-text {
    opacity: 0.7;
}

@keyframes twb-spin {
    to { transform: rotate(360deg); }
}

/* Register */
.twb-login-register {
    text-align: center;
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Logged in state */
.twb-login-logged-in {
    text-align: center;
}

.twb-login-logged-msg {
    color: #374151;
    margin-bottom: 12px;
}

/* Editor: show form always (is-editor flag via PHP) */
.elementor-editor-active .twb-login-wrap {
    /* preview stays always visible in editor */
}

@media(prefers-reduced-motion:reduce){.twb-testi-carousel{scroll-behavior:auto;}}
