/* --- 1. CSS Custom Properties (Design Tokens) --- */
:root {
    /* Light Theme (Default) */
    --bg-base: #fcfaf8;
    --bg-surface: #ffffff;
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --accent-main: #b48545;
    --accent-hover: #9c7138;
    --border-color: #e7e5e4;
    --error-color: #dc2626;
    --focus-ring: rgba(180, 133, 69, 0.3);
    
    /* Dynamic Background Blobs */
    --blob-1: rgba(180, 133, 69, 0.15);
    --blob-2: rgba(120, 113, 108, 0.1);
    
    /* Typography */
    --font-sans: 'Inter', system-ui, sans-serif;
    --transition-snappy: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme Override */
    --bg-base: #12100e;
    --bg-surface: #1c1917;
    --text-primary: #fafaf9;
    --text-secondary: #a8a29e;
    --border-color: #292524;
    --blob-1: rgba(180, 133, 69, 0.08);
    --blob-2: rgba(41, 37, 36, 0.4);
}

/* --- 2. Reset & Base Styles --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-snappy), color var(--transition-snappy);
    overflow-x: hidden;
}

/* --- 3. Dynamic Background --- */
.dynamic-bg {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1; overflow: hidden; pointer-events: none;
}
.blob {
    position: absolute; border-radius: 50%; filter: blur(80px);
    will-change: transform; /* Hardware acceleration hint */
}
.blob-1 {
    top: -10%; left: -10%; width: 50vw; height: 50vw;
    background: var(--blob-1);
    animation: float 24s infinite alternate ease-in-out;
}
.blob-2 {
    bottom: -20%; right: -10%; width: 60vw; height: 60vw;
    background: var(--blob-2);
    animation: float 28s infinite alternate-reverse ease-in-out;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* --- 4. Layout Architecture --- */
.top-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2rem 5%; width: 100%; position: fixed; top: 0; z-index: 10;
}
.brand { font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: opacity var(--transition-snappy); }
.brand span { color: var(--accent-main); }

.top-nav a{
    color: white;
    text-decoration: none;
}
.top-nav a:hover{
    color: white;
    text-decoration: none;
    opacity: 0.7;

}

.icon-btn {
    background: transparent; border: none; color: var(--text-primary);
    cursor: pointer; padding: 0.5rem; border-radius: 50%; transition: var(--transition-snappy);
}
.icon-btn:hover { background: var(--border-color); }

.auth-container {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 6rem 1.5rem 2rem;
}
.auth-card {
    background: var(--bg-surface); width: 100%; max-width: 440px;
    padding: 3rem 2.5rem; border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

/* Typography Hierarchy */
.auth-header h1 { font-size: clamp(1.5rem, 4vw, 1.75rem); margin-bottom: 0.5rem; font-weight: 600; }
.auth-header p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 2rem; line-height: 1.5; }

/* --- 5. Form & Micro-interactions --- */
.form-group { position: relative; margin-bottom: 1.5rem; }
.input-wrapper { position: relative; }

/* Floating Labels System */
.form-group input {
    width: 100%; padding: 1.25rem 1rem 0.5rem;
    background: transparent; border: 1px solid var(--border-color);
    border-radius: 8px; color: var(--text-primary); font-size: 1rem;
    transition: border-color var(--transition-snappy), box-shadow var(--transition-snappy);
    /* Ensures the input background doesn't default to white on autocomplete/type change */
    color-scheme: dark light; 
}
input:focus { outline: none; border-color: var(--accent-main); box-shadow: 0 0 0 3px var(--focus-ring); }
input.invalid { border-color: var(--error-color); }

.form-group label {
    position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
    color: var(--text-secondary); font-size: 1rem; pointer-events: none;
    transition: all 0.2s ease-out;
}
/* Trigger floating label on focus or when input is populated */
input:focus ~ label, input:not(:placeholder-shown) ~ label {
    top: 0.6rem; font-size: 0.75rem; transform: translateY(0); color: var(--accent-main);
}
input.invalid ~ label { color: var(--error-color); }

.pwd-toggle {
    position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; font-size: 0.85rem; color: var(--text-secondary);
    cursor: pointer; font-weight: 500;
}
.pwd-toggle:hover { color: var(--text-primary); }

.error-msg {
    display: block; color: var(--error-color); font-size: 0.8rem;
    margin-top: 0.4rem; height: 1rem; /* Reserves space to prevent layout shift */
}

/* Utilities (Checkbox & Link) */
.form-utilities {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem; font-size: 0.9rem;
}
.custom-checkbox { display: flex; align-items: center; cursor: pointer; gap: 0.5rem; color: var(--text-secondary); }
.custom-checkbox input { appearance: none; }
.checkmark {
    width: 16px; height: 16px; border: 1.5px solid var(--border-color);
    border-radius: 4px; display: flex; align-items: center; justify-content: center;
    transition: var(--transition-snappy);
}
.custom-checkbox input:checked + .checkmark { background: var(--accent-main); border-color: var(--accent-main); }
.custom-checkbox input:checked + .checkmark::after {
    content: "✓"; color: white; font-size: 12px;
}
.custom-checkbox input:focus-visible + .checkmark { box-shadow: 0 0 0 3px var(--focus-ring); }

a { color: var(--accent-main); text-decoration: none; transition: var(--transition-snappy); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* --- 6. Button & Loading State --- */
.btn-primary {
    width: 100%; padding: 1rem; background: var(--accent-main);
    color: #fff; border: none; border-radius: 8px; font-size: 1rem; font-weight: 500;
    cursor: pointer; position: relative; overflow: hidden;
    transition: transform 0.1s, background var(--transition-snappy);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.8; cursor: not-allowed; }

.spinner {
    display: none; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 1.25rem; height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
.btn-primary.loading .btn-text { opacity: 0; }
.btn-primary.loading .spinner { display: block; }

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-secondary); }

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .auth-card { padding: 2rem 1.5rem; border-radius: 0; border: none; border-top: 1px solid var(--border-color); box-shadow: none; }
    .auth-container { padding: 5rem 0 0; }
}