/* VideoLab Auth — Account pages (Login, Register, Consent, Verify, …)
   Nordic Light/Dark theme, purple primary. Mirrors the SPA design tokens
   so a user lands on the same visual language whether they're inside the
   app or on a Razor-rendered auth page. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Surfaces — light */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    /* Borders */
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    /* Text */
    --text: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    /* Brand — purple */
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-fg: #ffffff;
    --primary-bg: rgba(124,58,237,.08);
    /* Semantic */
    --success: #16a34a;
    --success-bg: rgba(34,197,94,.10);
    --warning: #d97706;
    --warning-bg: rgba(245,158,11,.10);
    --danger: #dc2626;
    --danger-bg: rgba(239,68,68,.10);
    /* Radii */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    /* Card elevation (light mode only — dark relies on borders) */
    --card-shadow: 0 1px 2px rgba(15,23,42,.04), 0 0 0 1px rgba(15,23,42,.02);
    /* Motion */
    --ease: cubic-bezier(.4,0,.2,1);
    --duration: 150ms;
}

.dark {
    /* Surfaces — dark */
    --bg: #09090b;
    --surface: #18181b;
    --surface-2: #27272a;
    --surface-3: #3f3f46;
    --border: #27272a;
    --border-hover: #3f3f46;
    --text: #f1f5f9;
    --text-muted: #cbd5e1;
    --text-dim: #94a3b8;
    --primary: #7c3aed;
    --primary-hover: #8b5cf6;
    --primary-fg: #ffffff;
    --primary-bg: rgba(124,58,237,.14);
    --success: #22c55e;
    --success-bg: rgba(34,197,94,.18);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,.18);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,.18);
    /* В тёмной теме хватает border'а, тень убираем чтобы не было «нимба» */
    --card-shadow: none;
}

html { color-scheme: light dark; }

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    width: 100%;
    padding: 1rem;
}

/* === LAYOUT === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80dvh;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--card-shadow);
}

.auth-card h1 {
    font-family: "Sora", "Inter", system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    text-align: center;
    letter-spacing: -.02em;
}

/* === FORM FIELDS === */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .375rem;
    font-weight: 500;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
    width: 100%;
    padding: .5rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .875rem;
    font-family: inherit;
    min-height: 40px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.form-group input::placeholder { color: var(--text-dim); }

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,.18);
}

.form-group input:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.form-row {
    display: flex;
    gap: .75rem;
}
.form-row .form-group { flex: 1; }

/* === CHECKBOX === */
.auth-checkbox {
    display: flex;
    align-items: center;
    gap: .625rem;
    cursor: pointer;
    color: var(--text);
    font-size: .8125rem;
    -webkit-user-select: none;
    user-select: none;
}
.auth-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.auth-checkbox .check {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration) var(--ease);
    background: var(--surface);
}
.auth-checkbox input:focus-visible + .check {
    box-shadow: 0 0 0 3px rgba(124,58,237,.25);
}
.auth-checkbox input:checked + .check {
    background: var(--primary);
    border-color: var(--primary);
}
.auth-checkbox .check svg {
    width: 12px;
    height: 12px;
    stroke: var(--primary-fg);
    stroke-width: 3;
    fill: none;
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}
.auth-checkbox input:checked + .check svg { opacity: 1; }

/* «Запомнить меня» + «Забыли пароль?» */
.auth-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
    margin-top: .25rem;
}
.auth-inline-link {
    color: var(--primary);
    text-decoration: none;
    font-size: .8125rem;
    white-space: nowrap;
    transition: color var(--duration) var(--ease);
}
.auth-inline-link:hover { color: var(--primary-hover); }

/* Войти + иконка Passkey */
.auth-actions {
    display: flex;
    gap: .5rem;
    align-items: stretch;
}
.auth-actions .btn-primary {
    flex: 1;
    width: auto;
    margin-top: 0;
}
.btn-icon {
    flex-shrink: 0;
    width: 44px;
    padding: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 0;
}
.btn-icon:hover { border-color: var(--border-hover); background: var(--surface-2); }
.btn-icon svg {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px;
    max-height: 20px;
    flex-shrink: 0;
}

/* Passkey-кнопка — высокий контраст: чёрная на светлой теме, белая на тёмной.
   Это inverse от обычной .btn-icon, чтобы её было сразу видно как primary
   passwordless-action. */
.btn-passkey {
    background: #000;
    border-color: #000;
    color: #fff;
}
.btn-passkey:hover { background: #000; border-color: #000; filter: brightness(.85); }
html.dark .btn-passkey {
    background: #fff;
    border-color: #fff;
    color: #000;
}
html.dark .btn-passkey:hover { background: #fff; border-color: #fff; filter: brightness(.9); }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease);
    text-decoration: none;
    min-height: 40px;
    line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124,58,237,.30);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
    width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-external {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 100%;
    margin-bottom: .5rem;
    min-height: 40px;
}
.btn-external:hover { border-color: var(--border-hover); background: var(--surface-2); }

/* === DIVIDER === */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border);
}
.auth-divider span {
    padding: 0 1rem;
    color: var(--text-dim);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 500;
}

/* === LINKS === */
.auth-links {
    text-align: center;
    margin-top: 1.25rem;
}
.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: .8125rem;
    transition: color var(--duration) var(--ease);
}
.auth-links a:hover { color: var(--primary-hover); }

/* === ALERTS === */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .8125rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-error {
    background: var(--danger-bg);
    border-color: rgba(220,38,38,.20);
    color: var(--danger);
}
.alert-success {
    background: var(--success-bg);
    border-color: rgba(22,163,74,.20);
    color: var(--success);
}

/* === MISC === */
.external-providers { display: flex; flex-direction: column; gap: .5rem; }
.external-providers form { margin: 0; }

/* Квадратная кнопка-иконка для провайдеров с кастомной SVG.
   Размер и hover-поведение как у .btn-icon — стоит в .auth-actions рядом
   с Войти и Passkey. Цвет фона приходит inline style из ButtonBgColor. */
.btn-external-square {
    flex-shrink: 0;
    width: 44px;
    padding: .5rem;
    margin-top: 0;
}
.btn-external-square:hover { filter: brightness(.9); }
html.dark .btn-external-square:hover { filter: brightness(1.1); }
.btn-external-square svg {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px;
    max-height: 22px;
    flex-shrink: 0;
}

/* === THEME TOGGLE (top-right) === */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
    z-index: 50;
}
.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-hover);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.dark .theme-toggle .icon-sun { display: block; }
.dark .theme-toggle .icon-moon { display: none; }

/* === LOGO BLOCK (опционально для страниц, которым нужен брендинг) === */
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.auth-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
}
.auth-logo-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -.01em;
}
.auth-logo-text span { color: var(--text-dim); font-weight: 400; margin-left: .25rem; }

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem;
        margin: 0 .5rem;
        border-radius: var(--radius);
    }
    .auth-card h1 { font-size: 1.125rem; }
    .form-row { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0s !important;
        animation-duration: 0s !important;
    }
}
