/* ============================================
   TERRABOOKS — Auth (minimal login)
   Brand: blue #108cf8 + green #7ec918
   ============================================ */


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

body.auth {
    min-height: 100vh;
    font-family: var(--font-primary);
    font-size: 16px;
    line-height: 1.6;
    background: var(--gray-6);
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(16, 140, 248, 0.25); }

/* ── Theme toggle ─────────────────────────────────────────────────── */

.auth-theme-corner {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 50;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-5);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
    color: var(--gray-1);
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(16, 140, 248, 0.35);
    outline-offset: 2px;
}

/* ── Shell ────────────────────────────────────────────────────────── */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: clamp(2rem, 4vw, 4rem);
    background:
        radial-gradient(ellipse 90% 55% at 12% -10%, rgba(16, 140, 248, 0.28), transparent 58%),
        radial-gradient(ellipse 70% 45% at 92% 8%, rgba(126, 201, 24, 0.22), transparent 52%),
        radial-gradient(ellipse 60% 40% at 70% 100%, rgba(16, 140, 248, 0.12), transparent 55%),
        linear-gradient(180deg, #f8faff 0%, #f0f5ff 42%, #f7faf3 100%);
}

.auth-panel-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.auth-form-shell {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
}

/* ── Brand (far-left top, like landing nav) ───────────────────────── */

.auth-brand {
    position: fixed;
    top: 1.1rem;
    left: clamp(1.25rem, 4vw, 3rem);
    z-index: 50;
    display: flex;
}

.auth-logo {
    height: 36px;
    width: auto;
}

/* ── Form header ─────────────────────────────────────────────────── */

.auth-form-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.auth-form-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--dark);
    line-height: 1.2;
}

.auth-form-header p {
    margin: 0.4rem 0 0;
    font-size: 0.95rem;
    color: var(--gray-2);
}

/* ── SSO button ──────────────────────────────────────────────────── */

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 28px;
    border-radius: var(--radius);
    background: var(--primary-dark);
    color: var(--white);
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
    filter: brightness(1.10);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary[disabled], .btn-primary.disabled {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.btn-primary .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }

.btn-primary:focus-visible {
    outline: 3px solid rgba(16, 140, 248, 0.35);
    outline-offset: 2px;
}

/* ── Flash banner ───────────────────────────────────────────────── */

.flash {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid;
}

.flash-error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.35);
    color: #b91c1c;
}

.flash-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.4);
    color: #047857;
}

/* ── Divider + secure note ──────────────────────────────────────── */

.divider {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--gray-4);
}

.divider span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gray-3);
    white-space: nowrap;
}

.secure-note {
    font-size: 0.83rem;
    line-height: 1.6;
    text-align: center;
    color: var(--gray-2);
}

.secure-note strong { color: var(--gray-1); }

/* ── Legal footer ────────────────────────────────────────────────── */

.legal {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--gray-2);
}

.legal nav {
    display: flex;
    gap: 18px;
}

.legal a {
    color: var(--gray-1);
    text-decoration: none;
    transition: var(--transition);
}

.legal a:hover { color: var(--primary); }

/* ── Dark theme ──────────────────────────────────────────────────── */

html.dark body.auth {
    background: #121110;
    color: #e2ddd2;
}

html.dark .theme-toggle {
    background: rgba(28, 26, 23, 0.85);
    border-color: var(--dark-3);
    color: var(--gray-3);
}

html.dark .theme-toggle:hover {
    color: var(--primary-light);
    border-color: var(--primary);
}

html.dark .auth-page {
    background:
        radial-gradient(ellipse 90% 55% at 12% -10%, rgba(16, 140, 248, 0.28), transparent 58%),
        radial-gradient(ellipse 70% 45% at 92% 8%, rgba(126, 201, 24, 0.18), transparent 52%),
        radial-gradient(ellipse 60% 40% at 70% 100%, rgba(16, 140, 248, 0.12), transparent 55%),
        linear-gradient(180deg, #141310 0%, #161412 50%, #1a1917 100%);
}

html.dark .auth-form-title { color: #e9e4da; }

html.dark .auth-form-header p { color: #ffffff; }

html.dark .divider::before,
html.dark .divider::after { background: var(--dark-3); }

html.dark .divider span { color: #ffffff; }

html.dark .secure-note { color: #ffffff; }

html.dark .secure-note strong { color: #ffffff; }

html.dark .flash-error {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

html.dark .flash-success {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
}

html.dark .legal { color: #ffffff; }

html.dark .legal a { color: #ffffff; }

html.dark .legal a:hover { color: var(--primary-light); }

/* ── Responsive ──────────────────────────────────────────────────── */

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