/* =========================================
   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: #2f6f3e33;
    
    --input-bg: #ffffff80;
    --input-border: #ccd6d0;
    
    /* Feedback Colors */
    --status-success-bg: #e8f5e9;
    --status-success-text: #1b5e20;
    --status-error-bg: #ffebee;
    --status-error-text: #c62828;
    
    --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-success-bg: #051b0a;
        --status-success-text: #a5d6a7;
        --status-error-bg: #2c0b0e;
        --status-error-text: #ef9a9a;
        
        --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;
    
    /* Ambient 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;
    
    /* Layout: Center Everything */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-sm);
}

/* Utility: Visually Hidden (Accessible) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================
   3. Auth Wrapper & Glass Card
   ========================================= */
.auth-wrapper {
    width: 100%;
    max-width: 480px;
    container-type: inline-size;
    container-name: card;
    perspective: 1000px;
}

.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);
    
    /* Animation */
    animation: fadeUp 0.5s var(--ease-smooth) forwards;
    opacity: 0;
    transform: translateY(20px);
}

/* =========================================
   4. Header
   ========================================= */
.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%;
}

.auth-header h1 {
    font-family: var(--font-sans);
    font-size: var(--space-lg);
    color: var(--accent-primary);
    line-height: 1.1;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* =========================================
   5. 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"] {
    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-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-glass);
}

.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;
    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;
}

/* =========================================
   6. Dynamic Flash Message
   ========================================= */
.flash-container {
    margin-bottom: var(--space-md);
}

.flash-message {
    /* Reset dialog defaults */
    position: static;
    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 */
    animation: slideUp 0.3s var(--ease-smooth);
}

.flash-success {
    background: var(--status-success-bg);
    color: var(--status-success-text);
    border-left: 4px solid currentColor;
}

.flash-error {
    background: var(--status-error-bg);
    color: var(--status-error-text);
    border-left: 4px solid currentColor;
}

/* Close Button in Flash Message */
.flash-message button {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    margin-left: 0.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.flash-message button:hover {
    opacity: 1;
}

/* =========================================
   7. Footer
   ========================================= */
.auth-footer {
    margin-top: var(--space-xs);
    text-align: center;
    border-top: 1px solid var(--bg-glass-border);
    padding-top: var(--space-md);
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: lighter;
    font-size: 0.9rem;
}

.auth-footer a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
    font-weight: bold;
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =========================================
   8. Animations & Queries
   ========================================= */
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Desktop App Shell */
@media (min-width: 768px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
}

/* Mobile adjustments */
@container card (max-width: 350px) {
    .auth-card { padding: var(--space-md); }
    .auth-header h1 { font-size: 2.5rem; }
}