/* Auth Pages - Modern Mobile Design */
:root {
    /* Design system tokens */
    --auth-gold: var(--theme-accent, #DCAE49);
    --auth-gold-dark: var(--theme-accent-dark, #A66D19);
    --auth-bg: var(--theme-page-bg, #070807);
    --auth-card: var(--theme-surface, #18212B);
    --auth-card-hover: var(--theme-surface-raised, #202B36);
    --auth-border: var(--theme-border-soft, rgba(255, 229, 154, 0.15));
    --auth-border-focus: var(--theme-accent, #DCAE49);
    --auth-text: var(--theme-text, #FFF8E6);
    --auth-text-secondary: var(--theme-text-muted, #8FA0B2);
    --auth-text-muted: var(--text-muted, #8FA0B2);
    --auth-error: var(--color-danger, #E34B5F);
    --auth-success: var(--color-positive, #32D583);
    --auth-radius: var(--radius-md, 18px);
    --auth-radius-sm: var(--radius-sm, 12px);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

html body.public-route-auth {
    height: 100%;
    margin: 0;
    padding: 0;
    color: var(--auth-text);
    background: var(--auth-bg) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

html body.public-route-auth #app {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--auth-bg) !important;
}

/* Page */
.auth-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
    background: var(--auth-bg);
}

/* Header */
.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.auth-header__nav { display: flex; gap: 10px; }

.auth-header__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: var(--auth-text) !important;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    font-size: 16px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.auth-header__btn:active { transform: scale(0.96); background: var(--auth-card-hover); }

.auth-header__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--auth-gold) !important;
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    min-height: 44px;
}

.auth-header__logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--auth-gold), var(--auth-gold-dark));
    border-radius: 10px;
    font-size: 16px;
    color: #0a0a0f;
}

/* Hero */
.auth-hero { text-align: center; padding: 24px 0; }

.auth-hero__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 16px;
    font-size: 28px;
    color: var(--auth-gold);
}

.auth-hero__title {
    margin: 0 0 6px;
    font-size: 26px;
    font-weight: 800;
    color: var(--auth-text);
    line-height: 1.2;
}

.auth-hero__subtitle { margin: 0; font-size: 14px; color: var(--auth-text-secondary); }

/* Form Card */
.auth-form-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 16px;
}

/* Form */
.auth-form { display: flex; flex-direction: column; gap: 16px; }

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

.auth-field__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--auth-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-field__label--optional { color: var(--auth-text-muted); font-weight: 400; text-transform: none; }

/* Input Wrap */
.auth-field__wrap {
    position: relative;
    display: flex;
    align-items: center;
    height: 50px;
    background: var(--auth-bg);
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field__wrap:focus-within {
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.1);
}

.auth-field.is-error .auth-field__wrap { border-color: var(--auth-error); }

/* Prefix */
.auth-field__prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 48px;
    padding: 0 12px;
    color: var(--auth-text-secondary);
    background: var(--auth-card);
    border-right: 1px solid var(--auth-border);
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Input */
.auth-field__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 14px;
    color: var(--auth-text);
    background: transparent;
    border: none;
    font-size: 16px;
    outline: none;
}

.auth-field__input::placeholder { color: var(--auth-text-muted); }

/* Icon */
.auth-field__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 100%;
    color: var(--auth-text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

.auth-field__wrap:focus-within .auth-field__icon { color: var(--auth-gold); }

/* Toggle Password */
.auth-field__toggle,
.auth-toggle-pw {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 52px;
    color: var(--auth-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--auth-radius-sm);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s;
}

.auth-field__toggle:active,
.auth-toggle-pw:active { transform: scale(0.92); }
.auth-field__wrap:focus-within .auth-field__toggle,
.auth-field__wrap:focus-within .auth-toggle-pw { color: var(--auth-gold); }

/* OTP Button */
.auth-field__otp-btn {
    flex-shrink: 0;
    height: 44px;
    margin: 2px;
    padding: 0 10px;
    color: var(--auth-gold);
    background: transparent;
    border: 1.5px solid var(--auth-gold);
    border-radius: var(--auth-radius-sm);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.auth-field__otp-btn:active { transform: scale(0.96); }
.auth-field__otp-btn:disabled { opacity: 0.5; }
.auth-field__otp-btn.is-counting { color: #0a0a0f; background: var(--auth-gold); }

/* Error Text */
.auth-field__error {
    font-size: 11px;
    color: var(--auth-error);
    margin-top: 4px;
}
.auth-field.is-error .auth-field__error { display: block; }
.auth-field:not(.is-error) .auth-field__error { display: none; }

/* OTP Info */
.auth-otp-info { font-size: 11px; color: var(--auth-text-muted); margin-top: 4px; }
.auth-change-number {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 6px 0;
    color: var(--auth-text-secondary);
    background: transparent;
    border: none;
    font-size: 12px;
    cursor: pointer;
}

.auth-change-number[hidden],
[hidden] {
    display: none !important;
}

/* Checkbox */
.auth-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    cursor: pointer;
}

.auth-checkbox__input {
    position: absolute;
    inset-inline-start: -11px;
    top: 50%;
    width: 44px;
    height: 44px;
    margin: 0;
    opacity: 0;
    transform: translateY(-50%);
    cursor: pointer;
}

.auth-checkbox__box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--auth-bg);
    border: 2px solid var(--auth-border);
    border-radius: 6px;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s ease;
}

.auth-checkbox__input:checked + .auth-checkbox__box {
    background: var(--auth-gold);
    border-color: var(--auth-gold);
    color: #0a0a0f;
}

.auth-checkbox__input:focus-visible + .auth-checkbox__box {
    outline: 3px solid var(--focus-ring, var(--auth-border-focus));
    outline-offset: 3px;
}

.auth-checkbox__text { font-size: 13px; color: var(--auth-text-secondary); }
.auth-checkbox__text a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--auth-gold);
    font-weight: 600;
    text-decoration: none;
}

/* Submit */
.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 52px;
    color: #0a0a0f;
    background: linear-gradient(135deg, var(--auth-gold), var(--auth-gold-dark));
    border: none;
    border-radius: var(--auth-radius);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.auth-submit:active { transform: translateY(1px); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* Account Link */
.auth-account-link {
    text-align: center;
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--auth-text-secondary);
}

.auth-account-link a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 4px;
    color: var(--auth-gold);
    font-weight: 600;
    text-decoration: none;
}

/* Help */
.auth-help {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--auth-border);
}

.auth-help__link {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 4px;
    color: var(--auth-text-secondary);
    font-size: 12px;
    text-decoration: none;
}

.auth-help__link:active { color: var(--auth-gold); }

/* Support */
.auth-support {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 16px;
    color: var(--auth-text-secondary);
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    font-size: 13px;
    text-decoration: none;
}

.auth-support:active { background: var(--auth-card-hover); }
.auth-support i:first-child { font-size: 18px; color: var(--auth-gold); }
.auth-support i:last-child { font-size: 11px; color: var(--auth-gold); }

/* Toast */
.auth-toast { position: fixed; right: 20px; left: 20px; bottom: 20px; z-index: 2010; pointer-events: none; }

.auth-toast__message {
    position: fixed;
    right: 20px;
    left: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    padding: 14px 18px;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 14px;
    color: var(--auth-text);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.auth-toast__message.is-visible { opacity: 1; transform: translateY(0); }
.auth-toast__message.is-error { border-color: var(--auth-error); color: #ff9999; }
.auth-toast__message.is-success { border-color: var(--auth-success); color: #99ff99; }

/* Loading */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.9);
}

.auth-overlay.is-visible { display: flex; }

.auth-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2001;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    font-size: 14px;
    color: var(--auth-text);
}

.auth-loading.is-visible { display: flex; }
.auth-loading i { color: var(--auth-gold); }

/* Focus */
.auth-header__btn:focus-visible,
.auth-header__logo:focus-visible,
.auth-field__toggle:focus-visible,
.auth-field__otp-btn:focus-visible,
.auth-account-link a:focus-visible,
.auth-help__link:focus-visible,
.auth-submit:focus-visible { outline: 2px solid var(--auth-gold); outline-offset: 2px; }

body.public-route-auth .auth-field input::placeholder {
    color: #aebdce !important;
    opacity: 1;
}

/* ============================================
   SHARED AUTH LAYOUT (login.ejs & forgot.ejs)
   Uses auth.css instead of inline <style>
   ============================================ */

/* Main wrapper */
.auth-main {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 var(--space-4) var(--space-6);
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

/* Card variant */
.auth-card {
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 18px;
    padding: var(--space-6);
}

/* Fields in card */
.auth-card .auth-field {
    margin-bottom: var(--space-4);
}

/* Hero icon 72px variant (for login/forgot, vs 64px for register) */
.auth-main .auth-hero__icon {
    width: 72px;
    height: 72px;
}

/* Submit 54px variant (for login/forgot, vs 52px for register) */
.auth-main .auth-submit {
    height: 54px;
}

/* Focus visible */
.auth-main .auth-header__btn:focus-visible,
.auth-main .auth-submit:focus-visible {
    outline: 2px solid var(--auth-gold);
    outline-offset: 2px;
}

/* Atmospheric background */
body.public-route-auth::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(245, 197, 24, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(245, 197, 24, 0.02) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Header sticky variant */
.auth-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    padding-top: calc(var(--space-3) + env(safe-area-inset-top));
    background: linear-gradient(to bottom, var(--auth-bg) 60%, transparent);
    backdrop-filter: blur(8px);
}

/* Toast fixed position for login/forgot */
.auth-toast-container {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: 20px;
    right: 20px;
    z-index: 2010;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.auth-toast {
    max-width: 340px;
    width: 100%;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    pointer-events: auto;
}

.auth-toast.is-visible { transform: none; opacity: 1; }
.auth-toast.is-error { border-color: var(--auth-error); }
.auth-toast.is-success { border-color: var(--auth-success); }
.auth-toast__icon { font-size: 18px; flex-shrink: 0; }
.auth-toast.is-error .auth-toast__icon { color: var(--auth-error); }
.auth-toast.is-success .auth-toast__icon { color: var(--auth-success); }
.auth-toast:not(.is-error):not(.is-success) .auth-toast__icon { color: var(--auth-text); }
.auth-toast__msg { flex: 1; word-break: break-word; }

/* Loading overlay */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 13, 0.85);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.auth-overlay.is-visible { opacity: 1; visibility: visible; }

/* Loading spinner */
.auth-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--auth-text);
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.auth-loading.is-visible { opacity: 1; visibility: visible; }
.auth-loading i { color: var(--auth-gold); font-size: 24px; animation: spin 1s linear infinite; }

/* OTP Warning (register.ejs inline JS) */
.auth-otp-warning { color: var(--auth-error); }

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

@media (max-width: 360px) {
    .auth-page {
        padding-right: 14px;
        padding-left: 14px;
    }

    .auth-main {
        padding-right: 12px;
        padding-left: 12px;
    }

    .auth-page .auth-hero,
    .auth-main .auth-hero {
        padding: 14px 0;
    }

    .auth-page .auth-hero__icon,
    .auth-main .auth-hero__icon {
        width: 60px;
        height: 60px;
        margin-bottom: 10px;
        font-size: 24px;
    }

    .auth-card,
    .auth-form-card {
        padding: 16px;
    }

    .auth-hero__title {
        font-size: 24px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .auth-submit__spinner,
    .auth-loading i { animation: none; }
    .auth-toast,
    .auth-overlay,
    .auth-loading { transition: none; }
}

/* Logo styles for auth pages */
.auth-hero__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.auth-hero__logo img {
    display: block;
    width: 100%;
    max-width: 96px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(245, 196, 81, 0.15));
}

/* WhatsApp OTP Button */
.auth-field__otp-btn--wa {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    background: rgba(37, 211, 102, 0.1);
    border-color: #25D366;
    color: #25D366;
}

.auth-field__otp-btn--wa i {
    font-size: 14px;
}

.auth-field__otp-btn--wa.is-counting {
    background: #25D366;
    color: #fff;
    border-color: #25D366;
}
