/* ========================================
   AUTH MODAL - Compact iOS Design
   ======================================== */

/* Overlay */
.auth-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: linear-gradient(135deg, #292c327d 0%, #292c324f 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.auth-modal-overlay.active {
    display: flex;
    animation: authOverlayIn 0.3s ease-out;
}

@keyframes authOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Container - compact with safe areas */
.auth-modal-container {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    padding-top: max(env(safe-area-inset-top, 20px), 40px);
    padding-bottom: max(env(safe-area-inset-bottom, 20px), 30px);
    box-sizing: border-box;
}

/* Background effects - subtle */
.auth-bg-grid,
.auth-bg-gradient {
    display: none;
}

/* Form wrapper — overflow visible so language dropdown is not clipped (scroll lives on .auth-modal-overlay) */
.auth-form-wrapper {
    width: 100%;
    max-width: 360px;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--kb-padding, 0px);
    animation: authFormIn 0.4s ease-out 0.1s backwards;
}

@keyframes authFormIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form container - card style */
.auth-form-container {
    padding: 24px 20px;
}

/* Trigger stays transparent (global); menu panel is styled in styles.css + below */
#authLanguageSelector .language-dropdown-menu:not([hidden]) {
    background: rgba(30, 41, 59, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

body.light-theme #authLanguageSelector .language-dropdown-menu:not([hidden]) {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
}

.auth-form-title {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 4px 0;
    text-align: center;
}

.auth-form-subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin: 0 0 20px 0;
    text-align: center;
}

/* Error */
.auth-error {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 14px;
    animation: authErrorIn 0.35s ease-out;
}

@keyframes authErrorIn {
    0% { opacity: 0; transform: translateY(-6px); }
    60% { opacity: 1; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Inputs */
.auth-input-group {
    margin-bottom: 14px;
}

.auth-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.auth-label i {
    color: var(--accent-green);
    font-size: 12px;
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--card-radius);
    color: #f8fafc;
    font-size: var(--font-size-tertiary);
    font-weight: 500;
    box-sizing: border-box;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.auth-input::placeholder {
    color: #64748b;
}

.auth-input:focus {
    border-color: var(--accent-green);
    outline: none;
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-green) 12%, transparent);
}

/* Submit button */
.auth-submit-btn {
    width: 100%;
    height: 44px;
    padding: 0 0.5rem;
    background: var(--accent-green);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: var(--font-size-tertiary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.auth-submit-btn:active {
    opacity: 0.92;
    transform: scale(0.98);
}

.auth-submit-btn:disabled {
    opacity: 0.5;
}

/* Divider */
.auth-divider {
    position: relative;
    text-align: center;
    margin: 20px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(148, 163, 184, 0.15);
}

.auth-divider span {
    position: relative;
    background: rgba(30, 41, 59, 0.8);
    padding: 0 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

/* Toggle buttons */
.auth-toggle-btn {
    width: 100%;
    height: 44px;
    padding: 0 0.5rem;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--card-radius);
    color: #cbd5e1;
    font-size: var(--font-size-tertiary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#showSignInFormBtn {
    margin-bottom: 12px;
}

/* Leading icon (Sign in / Create account) */
.auth-toggle-btn > i:first-child {
    margin-right: 10px;
    color: var(--accent-green);
}

.auth-toggle-btn:active {
    background: rgba(255, 255, 255, 0.04);
    transform: scale(0.99);
}

.auth-toggle-btn strong {
    color: var(--accent-green);
}

/* Forgot button */
.auth-forgot-btn {
    width: 100%;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: var(--font-size-tertiary);
    margin-top: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Back button */
.auth-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: var(--font-size-tertiary);
    cursor: pointer;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.auth-back-btn:active {
    opacity: 0.8;
}

/* Footer */
.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer p {
    color: #475569;
    font-size: 11px;
    margin: 0;
}

/* View transitions (main ↔ form) */
#authMainView,
#authForm {
    animation: authViewIn 0.3s ease-out;
}

@keyframes authViewIn {
    from { opacity: 0; transform: translateX(8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   OAUTH BUTTONS
   ======================================== */

.auth-oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    padding: 0 0.5rem;
    border-radius: var(--card-radius);
    font-size: var(--font-size-tertiary);
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-oauth-btn:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.auth-oauth-btn i,
.auth-oauth-btn svg {
    font-size: 18px;
}

.apple-btn {
    background: #000;
    border: none;
    color: #fff;
}

.google-btn {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #1f2937;
}

/* ========================================
   LIGHT THEME
   ======================================== */

body.light-theme .auth-modal-overlay {
    background: linear-gradient(to bottom right, rgba(241, 245, 249, 0.98), rgba(226, 232, 240, 0.98), rgba(241, 245, 249, 0.98));
}

body.light-theme .auth-form-title {
    color: #1e293b;
}

body.light-theme .auth-form-subtitle {
    color: #64748b;
}

body.light-theme .auth-label {
    color: #475569;
}

body.light-theme .auth-input {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
    color: #1e293b;
}

body.light-theme .auth-input:focus {
    background: #fff;
}

body.light-theme .auth-divider span {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .auth-toggle-btn {
    border-color: rgba(148, 163, 184, 0.2);
    color: #475569;
}

body.light-theme .auth-forgot-btn,
body.light-theme .auth-back-btn {
    color: #94a3b8;
}

body.light-theme .auth-footer p {
    color: #94a3b8;
}

/* ========================================
   REDUCE MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .auth-modal-overlay.active,
    .auth-form-wrapper,
    .auth-error,
    #authMainView,
    #authForm {
        animation: none;
    }
    .auth-input,
    .auth-submit-btn,
    .auth-toggle-btn,
    .auth-oauth-btn,
    .auth-back-btn {
        transition: none;
    }
}

/* ========================================
   LOADING
   ======================================== */

.auth-loading {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ========================================
   WEB DESKTOP — split auth (left) + hero (right)
   ======================================== */

.auth-modal-split {
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.auth-form-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.auth-hero-panel {
    display: none;
}

@media (min-width: 900px) {
    .auth-modal-overlay {
        align-items: stretch;
        justify-content: stretch;
        background: #0f172a;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    body.light-theme .auth-modal-overlay {
        background: #f1f5f9;
    }

    .auth-modal-container {
        min-height: 100%;
        padding: 0;
        justify-content: stretch;
    }

    .auth-modal-split {
        flex-direction: row;
        align-items: stretch;
        justify-content: stretch;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .auth-form-panel {
        flex: 0 0 44%;
        max-width: 520px;
        min-width: 380px;
        padding: 40px 32px;
        padding-top: max(env(safe-area-inset-top, 24px), 40px);
        padding-bottom: max(env(safe-area-inset-bottom, 24px), 32px);
        box-sizing: border-box;
        background-color: var(--glass-bg-dark);
        border-right: 1px solid rgba(148, 163, 184, 0.12);
        overflow-y: auto;
    }

    body.light-theme .auth-form-panel {
        background-color: var(--glass-bg-light);
        border-right-color: rgba(148, 163, 184, 0.2);
    }

    .auth-form-wrapper {
        max-width: 400px;
        width: 100%;
    }

    .auth-hero-panel {
        display: flex;
        flex: 1 1 auto;
        position: relative;
        min-height: 320px;
        overflow: hidden;
        align-items: flex-end;
    }

    .auth-hero-video {
        position: absolute;
        inset: 0;
        z-index: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center 42%;
        transform: scale(1);
        transform-origin: center 38%;
    }

    .auth-hero-scrim {
        position: absolute;
        inset: 0;
        z-index: 1;
        background: linear-gradient(
            180deg,
            transparent 0%,
            transparent 50%,
            rgba(15, 23, 42, 0.4) 100%
        );
        pointer-events: none;
    }

    .auth-hero-content {
        position: relative;
        z-index: 2;
        display: flex;
        align-items: flex-end;
        justify-content: flex-start;
        width: 100%;
        box-sizing: border-box;
        padding: 48px clamp(40px, 5vw, 72px) clamp(44px, 5vh, 56px);
        color: #f8fafc;
        background: linear-gradient(
            to top,
            rgba(15, 23, 42, 0.88) 0%,
            rgba(15, 23, 42, 0.55) 42%,
            transparent 100%
        );
    }

    .auth-hero-inner {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        max-width: 520px;
    }

    .auth-hero-title {
        margin: 0 0 22px;
        font-size: clamp(1.65rem, 2.8vw, 2.35rem);
        font-weight: 700;
        line-height: 1.35;
        color: #f1f5f9 !important;
        text-wrap: balance;
        text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
    }

    .auth-hero-bullets {
        margin: 0 0 24px;
        padding: 0;
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .auth-hero-bullets li {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        font-size: 15px;
        font-weight: 500;
        line-height: 1.45;
        color: #e2e8f0 !important;
    }

    .auth-hero-bullets li::before {
        content: '';
        flex-shrink: 0;
        width: 7px;
        height: 7px;
        margin-top: 0.5em;
        border-radius: 50%;
        background: var(--accent-green);
        box-shadow: 0 0 8px color-mix(in srgb, var(--accent-green) 45%, transparent);
    }

    .auth-hero-actions {
        display: flex;
        align-items: center;
        width: 100%;
        margin-top: 4px;
        padding-top: 20px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .auth-hero-learn-more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        padding: 0 22px;
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        color: #0f172a;
        border: none;
        border-radius: 10px;
        background: var(--accent-green);
        box-shadow: 0 2px 12px color-mix(in srgb, var(--accent-green) 35%, transparent);
        transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }

    .auth-hero-learn-more:hover {
        background: color-mix(in srgb, var(--accent-green) 88%, #ffffff);
        color: #0f172a;
        box-shadow: 0 4px 16px color-mix(in srgb, var(--accent-green) 40%, transparent);
    }

    .auth-hero-learn-more:active {
        transform: scale(0.98);
    }

    .auth-footer {
        width: 100%;
        max-width: 400px;
    }

    /* Hero panel — light theme */
    body.light-theme .auth-hero-panel {
        background: transparent;
    }

    body.light-theme .auth-hero-scrim {
        background: linear-gradient(
            180deg,
            transparent 0%,
            transparent 50%,
            rgba(255, 255, 255, 0.35) 100%
        );
    }

    body.light-theme .auth-hero-content {
        color: #1e293b;
        background: linear-gradient(
            to top,
            rgba(255, 255, 255, 0.94) 0%,
            rgba(255, 255, 255, 0.65) 42%,
            transparent 100%
        );
    }

    body.light-theme .auth-hero-title {
        color: #0f172a !important;
        text-shadow: none;
    }

    body.light-theme .auth-hero-bullets li {
        color: #475569 !important;
    }

    body.light-theme .auth-hero-actions {
        border-top-color: rgba(15, 23, 42, 0.08);
    }

    body.light-theme .auth-hero-learn-more {
        color: #ffffff;
    }

    body.light-theme .auth-hero-learn-more:hover {
        color: #ffffff;
    }
}

@media (min-width: 900px) and (prefers-reduced-motion: reduce) {
    .auth-hero-video {
        display: none;
    }

    .auth-hero-panel {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #14532d 100%);
    }
}
