/* ==========================================================================
   AUTH MODAL (Right-side slide-in)
   ========================================================================== */
.required {
    color: var(--error);
}

body.body-scroll-locked {
    overflow: hidden !important;
}

#login-modal {
    position: fixed;
    top: var(--nav-height);
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(100vh - var(--nav-height));
    z-index: 3000;
    display: flex;
    justify-content: flex-end;
}

#login-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 26, 62, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auth-sidebar-active #login-modal-overlay {
    opacity: 1;
}

#login-modal-content {
    position: relative;
    width: 100%;
    max-width: 35%;
    height: 100%;
    background: var(--surface);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#login-modal-content .btn-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    background: var(--surface-container-low);
    color: var(--on-surface-variant);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-full);
    padding: 4px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

#login-modal-content .btn-modal-close:hover {
    background: var(--surface-container-high);
    color: var(--on-surface);
}

@media (max-width: 1023px) {
    #login-modal-content {
        max-width: 100%;
        width: 100%;
    }
}

.auth-sidebar-active #login-modal-content {
    transform: translateX(0);
}

.auth-wrapper {
    padding: 32px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

@media (max-width: 1023px) {
    .auth-wrapper {
        padding: 20px;
    }
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--outline-variant);
    margin-bottom: 32px;
}

.auth-tab {
    flex: 1;
    padding-bottom: 16px;
    text-align: center;
    color: var(--on-surface-variant);
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: none;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    font-weight: 700;
}

#auth-modal-form, .auth-form-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* Prevents container from stretching */
}

.auth-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 8px;
    justify-content: flex-start;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.input-group.email-btn .btn-submit {
    margin-top: 0px;
}

.form-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface-container);
    border-radius: 8px;
    border: 1px solid var(--outline-variant);
}

.phone-row {
    display: flex;
    gap: 8px;
}

.phone-prefix {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: 8px;
    font-weight: 500;
}

.auth-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terms-box {
    padding: 16px;
    background: var(--surface-container-low);
    border-radius: 12px;
    border: 1px solid rgba(195, 198, 214, 0.3);
}

.btn-submit {
    width: 100%;
    padding: 14px 0;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 12px;
    margin-top: 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast) ease;
}

.btn-submit:hover {
    background: var(--primary-container);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.auth-divider .line {
    flex: 1;
    height: 1px;
    background: rgba(195, 198, 214, 0.3);
}

.social-btns {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: auto;
    align-self: center;
    margin-inline: auto;
    gap: 16px;
}

.social-btn, .btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 10px; /* Uniform rounded rectangle mask */
    border: 1px solid #E0E2E7;
    background: #ffffff;
    color: #1f1f1f;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    outline: none;
    position: relative;
    overflow: hidden;
}

.social-btn:hover, .btn-social:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.social-btn:focus-visible, .btn-social:focus-visible {
    outline: 2px solid #0068FF;
    outline-offset: 2px;
}

.social-btn:active, .btn-social:active {
    transform: translateY(0);
    box-shadow: none;
}

.social-btn__icon, .social-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    pointer-events: none;
    flex: 0 0 20px;
}

.social-btn__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.social-btn__icon svg, .social-brand-icon svg {
    display: block;
    width: 24px;
    height: 24px;
}

/* Individual Provider Borders/Backgrounds */
.social-btn--google {
    background: #ffffff;
    border-color: #dadce0;
}

.social-btn--apple {
    background: #000000;
    border-color: #000000;
}

.social-btn--apple .social-btn__icon,
.social-btn--apple .social-btn__img {
    width: 100%;
    height: 100%;
    flex-basis: 100%;
    border-radius: inherit;
}

.social-btn--facebook {
    background: #ffffff;
    border-color: #E0E2E7;
}

.social-btn--zalo {
    background: #ffffff;
    border-color: #E0E2E7;
}

/* 32px mark + 8px outer clear space satisfies Facebook's 1/4 x rule. */
.social-btn--facebook .social-btn__icon,
.social-btn--zalo .social-btn__icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

.social-btn--google .social-btn__icon {
    position: relative;
    z-index: 1;
}

.social-brand-icon--apple svg {
    width: 18px;
    height: 20px;
}

.social-brand-icon--apple {
    justify-content: center;
}

.btn-close-modal {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Auth Modal inner helpers */
#register-fields.flex-col,
#seller-only-fields.flex-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.phone-row .form-input-flex {
    flex: 1;
}

.auth-helpers-forgot-btn {
    color: var(--primary);
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.auth-alert-message {
    color: var(--error);
}

.auth-helpers-forgot-btn:hover {
    text-decoration: underline;
}

.auth-signup-prompt {
    display: block;
    text-align: center;
    width: 100%;
    margin-top: 12px;
}

.terms-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.terms-desc {
    font-size: 12px;
    color: var(--on-surface-variant);
    margin-bottom: 12px;
}

.terms-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.terms-agree-all {
    font-weight: 700;
}

.terms-divider {
    height: 1px;
    background: rgba(195, 198, 214, 0.3);
    margin: 4px 0;
}

.terms-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terms-view-btn {
    color: var(--primary);
    font-size: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.apple-icon {
    font-size: 20px;
}

/* Register User Type Selector (Regular User vs Seller) */
.register-type-selector {
    display: flex;
    gap: 8px;
    background: var(--surface-container-low);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 8px;
}

.register-type-selector .type-btn {
    flex: 1;
    padding: 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-xs);
    color: var(--on-surface-variant);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.register-type-selector .type-btn.active {
    background: var(--primary);
    color: var(--on-primary);
}

/* Seller Identity Verification Button */
.btn-verify-identity {
    padding: 10px 16px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.btn-verify-identity:hover {
    background: var(--primary-container);
}

/* Terms Accordion Content Box */
.terms-item-wrapper {
    display: flex;
    flex-direction: column;
}

.terms-accordion-content {
    background: var(--surface-container-low);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s ease,
        border-color 0.3s ease;
    padding: 0 12px;
    font-size: 12px;
    color: var(--on-surface-variant);
    line-height: 1.5;
}

.terms-accordion-content.active {
    border-color: var(--outline-variant);
    padding: 12px;
    overflow-y: auto;
    margin-top: 8px;
}

.terms-accordion-content .accordion-inner strong {
    display: block;
    margin-bottom: 6px;
    color: var(--on-surface);
}

.terms-accordion-content .accordion-inner p {
    margin-bottom: 8px;
}

.terms-accordion-content .accordion-inner p:last-child {
    margin-bottom: 0;
}

/* --- Social Agreement Legal Modal Overlay --- */
.auth-legal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 26, 62, 0.4);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-legal-modal-overlay.hidden {
    display: none !important;
}

.auth-legal-modal-content {
    background: var(--surface);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.auth-legal-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--outline-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-legal-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--on-surface);
    margin: 0;
}

.auth-legal-modal-header .btn-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-legal-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-legal-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--outline-variant);
    display: flex;
    justify-content: flex-end;
}

.auth-legal-modal-footer .btn-submit {
    margin-top: 0 !important;
    padding: 12px 24px;
    width: auto !important;
}

/* --- Top Navbar Auth & Avatar Toggles --- */
body.guest-state .nav-signout-btn {
    display: none !important;
}

body.guest-state .top-navbar .user-avatar {
    display: none !important;
}

body:not(.guest-state) .nav-signin-btn {
    display: none !important;
}

/* --- Mobile Drawer Profile Toggles --- */
body.guest-state .drawer-logged-in-profile {
    display: none !important;
}

body.guest-state .drawer-logged-out-profile {
    display: flex !important;
}

body:not(.guest-state) .drawer-logged-in-profile {
    display: flex !important;
}

body:not(.guest-state) .drawer-logged-out-profile {
    display: none !important;
}

/* --- Mobile Drawer Menu Role Toggles --- */
body.guest-state .agent-only,
body.guest-state .user-only {
    display: none !important;
}

body.role-agent .agent-only {
    display: block !important;
}

body:not(.role-agent) .agent-only {
    display: none !important;
}

body.role-user .user-only {
    display: block !important;
}

body:not(.role-user) .user-only {
    display: none !important;
}

body.role-agent .agent-only-inline {
    display: inline-block !important;
}

body:not(.role-agent) .agent-only-inline {
    display: none !important;
}

.btn-social.btn-apple {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #000000;
}

.btn-social.btn-apple:hover {
    background-color: #1a1a1a;
}

/* --- Mobile Stacked Phone Input --- */
@media (max-width: 767px) {
    .phone-row {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .phone-prefix {
        width: 100% !important;
        box-sizing: border-box;
        justify-content: space-between;
    }

    .phone-row .form-input-flex {
        width: 100% !important;
    }
}

/* --- Validation Error Highlight --- */
.form-input.is-invalid {
    border-color: var(--error) !important;
    background-color: rgba(186, 26, 26, 0.04) !important;
}

.auth-alert-box.error,
.auth-error-msg {
    color: var(--error);
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
    display: block;
}

.auth-alert-box.success {
    color: var(--success);
}

.forgot-instruction {
    margin-bottom: 10px;
}
