/* =========================================
   1. Design Tokens & Theme Setup
   ========================================= */
:root {
    /* Typography */
    --font-sans: 'Roboto', system-ui, -apple-system, sans-serif;
    --font-script: 'Dancing Script', cursive;

    /* Spacing (Fluid) */
    --space-xs: clamp(0.5rem, 1vw, 0.75rem);
    --space-sm: clamp(0.75rem, 1.5vw, 1rem);
    --space-md: clamp(1.25rem, 2.5vw, 1.5rem);
    --space-lg: clamp(2rem, 4vw, 3rem);

    /* Animation */
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;
}

/* Light Mode (Warm Paper & Forest Green) */
:root {
    --bg-body: #fdfaf6;
    --bg-glass: #ffffffcc; /* 80% Opacity */
    --bg-glass-border: #ffffff;
    
    --text-primary: #1a2e1f;
    --text-secondary: #4a5d50;
    --text-muted: #6e7a72;
    --text-on-accent: #ffffff;
    
    --accent-primary: #2f6f3e;
    --accent-hover: #1e4a29;
    --accent-glow: #2f6f3e40;
    
    --input-bg: #ffffff80;
    --input-border: #ccd6d0;
    --status-error: #d32f2f;
    --status-warning-bg: #fff3e0;
    --status-warning-text: #e65100;
    
    --shadow-card: 0 8px 32px 0 #1f268726; 
}

/* Dark Mode (Midnight Navy & Luxe Gold) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #020c1b;
        --bg-glass: #020c1bbf; /* 75% Opacity */
        --bg-glass-border: #ffffff1a;
        
        --text-primary: #e6f1ff;
        --text-secondary: #8892b0;
        --text-muted: #606a80;
        --text-on-accent: #020c1b;
        
        --accent-primary: #ffd700;
        --accent-hover: #d4b200;
        --accent-glow: #ffd70040;
        
        --input-bg: #0a192f80;
        --input-border: #233554;
        --status-error: #ff8a80;
        --status-warning-bg: #3e2723;
        --status-warning-text: #ffab91;
        
        --shadow-card: 0 8px 32px 0 #00000080;
    }
}

/* =========================================
   2. Global Reset
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    
    /* Dynamic Background */
    background-image: 
        radial-gradient(circle at 5% 5%, var(--accent-glow) 0%, transparent 40%),
        radial-gradient(circle at 95% 95%, var(--accent-glow) 0%, transparent 40%);
    background-attachment: fixed;
    
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-sm);
}

/* =========================================
   3. App Shell / Auth Wrapper
   ========================================= */
.auth-wrapper {
    width: 100%;
    max-width: 480px;
    
    /* Container Query Context */
    container-type: inline-size;
    container-name: card;
    
    perspective: 1000px;
}

/* =========================================
   4. Glassmorphism Card
   ========================================= */
.auth-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-glass-border);
    border-radius: clamp(1rem, 2vw, 1.5rem);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg) var(--space-md);
    
    /* Entrance Animation */
    animation: fadeUp 0.5s var(--ease-smooth) forwards;
    opacity: 0;
    transform: translateY(20px);
}

/* =========================================
   5. Header & Logo
   ========================================= */
.auth-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.brand-logo {
    margin-bottom: var(--space-xs);
    display: inline-block;
    filter: drop-shadow(0 4px 6px var(--accent-glow));
}

.brand-logo img {
    display: block;
    height: auto;
    width: 64px;
    border-radius: 50%; /* Full rounding for circular logo */
}

.auth-header h1 {
    font-family: var(--font-script);
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    color: var(--accent-primary);
    line-height: 1.1;
}

.hidden { display: none !important; }
#verification-container {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
}

/* =========================================
   6. Form Elements
   ========================================= */
.form-group {
    margin-bottom: var(--space-md);
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-left: 0.25rem;
}

input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    transition: all var(--duration) var(--ease-smooth);
}

/* Input Focus State */
input:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-glass);
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* if password btn is toggled and password is now visible */
.password-wrapper input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    transition: all var(--duration) var(--ease-smooth);
}


.btn-toggle-password {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: color var(--duration);
}

.btn-toggle-password:hover {
    color: var(--accent-primary);
}

.btn-toggle-password svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Icons Logic */
.hidden {
    display: none;
}

/* =========================================
   7. Buttons
   ========================================= */
.btn-primary {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-on-accent);
    background: var(--accent-primary);
    border: none;
    border-radius: 50px; /* Pill shape */
    cursor: pointer;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: transform var(--duration) var(--ease-elastic), 
                box-shadow var(--duration) var(--ease-smooth);
    margin-top: var(--space-xs);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   8. Feedback & verification
   ========================================= */
#verification-container {
    display: none; /* Controlled by JS */
    margin-top: var(--space-md);
    padding: var(--space-sm);
    background: var(--status-warning-bg);
    color: var(--status-warning-text);
    border-radius: 0.75rem;
    text-align: center;
    border: 1px solid currentColor;
}

#verification-container p {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

#resend-btn {
    background: transparent;
    border: 1px solid currentColor;
    color: inherit;
    font-size: 0.8rem;
    padding: 0.4em 1em;
    border-radius: 4px;
    cursor: pointer;
}

#resend-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Flash Messages */
.flash-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: var(--space-md);
}

.flash-message {
    position: static; /* Override default dialog fixed/absolute */
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s var(--ease-smooth);
}

/* Success/Error Variants */
.flash-success {
    background: #e6f4ea;
    color: #1e4620;
    border-left: 4px solid #1e4620;
}

.flash-error {
    background: #fdecea;
    color: #611a15;
    border-left: 4px solid #611a15;
}

/* Dark mode overrides for flash */
@media (prefers-color-scheme: dark) {
    .flash-success { background: #0c1b0f; color: #a5d6a7; border-color: #a5d6a7; }
    .flash-error { background: #240b0b; color: #ef9a9a; border-color: #ef9a9a; }
}

.flash-message button {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    margin-left: 0.5rem;
}

/* =========================================
   9. Footer Links
   ========================================= */
.auth-footer {
    margin-top: var(--space-xs);
    text-align: center;
    border-top: 1px solid var(--bg-glass-border);
    padding-top: var(--space-md);
}

.links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.links a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: lighter;
}

.links a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    font-weight: bold;
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =========================================
   10. Animations & Utilities
   ========================================= */
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Desktop App Shell Logic */
@media (min-width: 768px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
}

/* Small Container Adjustments */
@container card (max-width: 350px) {
    .auth-card {
        padding: var(--space-md);
    }
    
    .auth-header h1 {
        font-size: 2.5rem;
    }
    
    .links {
        flex-direction: column;
        gap: 0.25rem;
        align-items: center;
    }
    
    .links span {
        display: none; /* Hide the separator pipe */
    }
}