/* Fantasy Football Nerds - Unified Authentication System */
/* Shared shell for FFN account flows and FantasyGPT handoffs */

@import url('/css/brand-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Montserrat:wght@600;700;800&display=swap');

:root {
    --gray-50: #fafafa;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --gray-950: #020617;

    --primary: var(--brand-navy);
    --primary-hover: var(--brand-navy-light);
    --secondary: var(--brand-slate);
    --secondary-hover: var(--brand-text-heading);
    --accent: var(--brand-green);
    --accent-secondary: var(--brand-blue);

    --bg-page: #eff4fb;
    --bg-page-alt: #f8fbff;
    --bg-card: rgba(255, 255, 255, 0.86);
    --bg-input: rgba(255, 255, 255, 0.92);
    --bg-hover: rgba(255, 255, 255, 0.72);
    --surface-strong: rgba(14, 34, 64, 0.05);

    --text-primary: var(--brand-text-heading);
    --text-secondary: #334155;
    --text-muted: var(--brand-text-muted);
    --text-placeholder: #94a3b8;
    --text-inverse: #ffffff;

    --border-light: rgba(15, 23, 42, 0.09);
    --border-medium: rgba(15, 23, 42, 0.16);
    --border-strong: rgba(15, 23, 42, 0.24);
    --border-focus: var(--brand-blue-dark);

    --input-border: rgba(148, 163, 184, 0.4);
    --input-border-focus: var(--brand-blue-dark);
    --input-border-error: #dc2626;
    --input-border-success: var(--brand-green-light);

    --success: var(--brand-green);
    --success-bg: rgba(5, 150, 105, 0.08);
    --success-border: rgba(5, 150, 105, 0.22);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.08);
    --error-border: rgba(220, 38, 38, 0.22);
    --warning: #b45309;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --warning-border: rgba(217, 119, 6, 0.22);

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.16);
}

/* === DARK THEME === */
[data-theme="dark"] {
    --gray-50: #020617;
    --gray-100: #08101a;
    --gray-200: #0f172a;
    --gray-300: #1e293b;
    --gray-400: #334155;
    --gray-500: #475569;
    --gray-600: #64748b;
    --gray-700: #94a3b8;
    --gray-800: #cbd5e1;
    --gray-900: #e2e8f0;
    --gray-950: #f8fafc;

    --primary: var(--brand-green-light);
    --primary-hover: var(--brand-blue);
    --secondary: #cbd5e1;
    --secondary-hover: #ffffff;
    --accent: var(--brand-blue);
    --accent-secondary: var(--brand-purple);

    --bg-page: #06111b;
    --bg-page-alt: #0a1422;
    --bg-card: rgba(7, 18, 31, 0.78);
    --bg-input: rgba(15, 23, 42, 0.8);
    --bg-hover: rgba(30, 41, 59, 0.55);
    --surface-strong: rgba(56, 182, 255, 0.1);

    --text-primary: #f8fafc;
    --text-secondary: #dbeafe;
    --text-muted: #94a3b8;
    --text-placeholder: #64748b;
    --text-inverse: #ffffff;

    --border-light: rgba(148, 163, 184, 0.18);
    --border-medium: rgba(148, 163, 184, 0.3);
    --border-strong: rgba(148, 163, 184, 0.42);
    --border-focus: var(--brand-blue);

    --input-border: rgba(148, 163, 184, 0.28);
    --input-border-focus: var(--brand-blue);

    --success-bg: rgba(5, 150, 105, 0.14);
    --success-border: rgba(5, 150, 105, 0.32);
    --error-bg: rgba(220, 38, 38, 0.14);
    --error-border: rgba(220, 38, 38, 0.32);
    --warning-bg: rgba(217, 119, 6, 0.14);
    --warning-border: rgba(217, 119, 6, 0.32);

    --shadow-xs: 0 1px 2px rgba(2, 6, 23, 0.2);
    --shadow-sm: 0 12px 30px rgba(2, 6, 23, 0.24);
    --shadow-md: 0 20px 60px rgba(2, 6, 23, 0.34);
    --shadow-lg: 0 36px 120px rgba(2, 6, 23, 0.5);
}

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top left, rgba(56, 182, 255, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(5, 150, 105, 0.14), transparent 24%),
        linear-gradient(180deg, var(--bg-page) 0%, var(--bg-page-alt) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    position: relative;
    overflow-x: hidden;
    transition: background 0.25s ease, color 0.25s ease;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(255,255,255,0.02), rgba(255,255,255,0.02)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Ccircle cx='60' cy='60' r='1.5' fill='%23047857' opacity='0.15'/%3E%3C/svg%3E");
    background-size: auto, 72px 72px;
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    width: 420px;
    height: 420px;
    right: -140px;
    bottom: -180px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.18) 0%, transparent 68%);
    filter: blur(12px);
    pointer-events: none;
    z-index: 0;
}

/* === FLOATING NAVIGATION === */
.floating-nav-left {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    display: flex;
    gap: 12px;
}

.floating-nav-right {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
    transform: translateY(-1px) scale(1.01);
    box-shadow: var(--shadow-md);
}

.nav-btn.primary {
    background: var(--brand-gradient-editorial);
    color: #ffffff;
    border-color: transparent;
}

.nav-btn.primary:hover {
    filter: brightness(1.05);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--border-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.theme-toggle .icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover .icon {
    color: var(--text-primary);
}

/* === MAIN CONTENT === */
.auth-main {
    width: 100%;
    max-width: 468px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* === AUTH CONTAINER === */
.auth-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 42px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
    animation: slideUp 0.4s ease-out;
}

.auth-container::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--brand-gradient-product);
}

.auth-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(56, 182, 255, 0.1), transparent 30%),
        radial-gradient(circle at bottom left, rgba(5, 150, 105, 0.09), transparent 28%);
    pointer-events: none;
}

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

/* === LOGO SECTION === */
.auth-logo-section {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 10px 18px rgba(37, 99, 235, 0.16));
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.55;
    max-width: 32ch;
    margin: 0 auto;
}

.auth-context-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    margin-top: 18px;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255,255,255,0.55), var(--surface-strong));
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}

.auth-context-pill {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--brand-gradient-product);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-context-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.auth-context-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-context-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* === FORM STYLES === */
.auth-form {
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--input-border);
    border-radius: 14px;
    font-size: 15px;
    font-weight: 400;
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.form-input::placeholder {
    color: var(--text-placeholder);
    font-weight: 400;
}

.form-input:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
    transform: translateY(-1px);
}

[data-theme="dark"] .form-input:focus {
    box-shadow: 0 0 0 4px rgba(56, 182, 255, 0.16);
}

.form-input.valid {
    border-color: var(--input-border-success);
}

.form-input.invalid {
    border-color: var(--input-border-error);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    transition: color 0.15s ease;
}

.form-hint.success {
    color: var(--success);
}

.form-hint.error {
    color: var(--error);
}

/* === BUTTONS === */
.auth-btn {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    outline: none;
    letter-spacing: 0.01em;
}

.auth-btn.primary {
    background: var(--brand-gradient-product);
    color: #ffffff;
    box-shadow: 0 16px 36px rgba(5, 150, 105, 0.2);
}

.auth-btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 20px 44px rgba(5, 150, 105, 0.26);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Loading State */
.auth-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === ALERTS === */
.auth-alert {
    padding: 13px 15px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
    animation: slideDown 0.2s ease-out;
    backdrop-filter: blur(8px);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-alert.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}

.auth-alert.error {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error-border);
}

.auth-alert.warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}

/* === LOADING SPINNER === */
.auth-loading {
    display: none;
    text-align: center;
    margin: 16px 0;
    color: var(--text-secondary);
    font-weight: 500;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.auth-loading.show {
    display: flex;
}

.auth-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--text-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* === LINKS === */
.auth-links {
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.auth-links a:hover {
    color: var(--primary-hover);
    opacity: 0.92;
}

/* === FOOTER === */
.auth-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.auth-footer p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
}

.auth-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.auth-footer a:hover {
    color: var(--text-primary);
}

/* === SUCCESS STATE === */
.auth-success-state {
    text-align: center;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.auth-success-state.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.auth-success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--brand-gradient-product);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
    box-shadow: 0 20px 44px rgba(5, 150, 105, 0.24);
}

.auth-success-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-success-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .auth-logo {
        width: 80px;
        height: 80px;
        max-width: 80px;
        max-height: 80px;
    }
    
    .form-input {
        min-height: 48px;
        font-size: 16px;
    }
    
    .auth-btn {
        min-height: 48px;
        font-size: 1rem;
    }
    
    .nav-btn {
        min-height: 44px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 16px;
    }
    
    .floating-nav-left {
        top: 16px;
        left: 16px;
        gap: 8px;
    }
    
    .floating-nav-right {
        top: 16px;
        right: 16px;
    }
    
    .nav-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
    
    .auth-container {
        padding: 32px 24px;
        border-radius: 12px;
    }
    
    .auth-title {
        font-size: 22px;
    }
    
    .auth-logo {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .floating-nav-left {
        flex-direction: column;
        gap: 6px;
    }
    
    .floating-nav-right {
        top: 12px;
        right: 12px;
    }
    
    .nav-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .auth-container {
        padding: 28px 20px;
    }
    
    .auth-title {
        font-size: 20px;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
.nav-btn:focus-visible,
.theme-toggle:focus-visible,
.form-input:focus-visible,
.auth-btn:focus-visible,
.auth-links a:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-light: #000000;
        --border-medium: #000000;
    }
    
    [data-theme="dark"] {
        --border-light: #ffffff;
        --border-medium: #ffffff;
    }
}
