/* ─────────────────────────────────────────────────────────────────────
   Rivera Login & Signup Styles
   Matches rivera-site design system
   ───────────────────────────────────────────────────────────────────── */

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

:root {
    /* Mirrors rivera-site/public/assets/css/marketing-theme.css. The portal
       and marketing site each ship their own copy of these tokens — keep
       them in sync if you change one. */
    --login-page-bg: #ffffff;             /* outer page (body) */
    --login-bg-primary: #f8fafc;          /* inputs, account/type cards (subtle gray) */
    --login-bg-secondary: #f1f5f9;        /* reveal-btn, hover surfaces */
    --login-surface: #ffffff;             /* the login-card itself */
    --login-text-primary: #0f172a;
    --login-text-secondary: #475569;
    --login-text-muted: #64748b;
    /* Brand tokens align with the portal's --primary ramp (primary-600 = #6435E8).
       The wordmark gradient walks the ramp from light (primary-500) to anchor
       (primary-600) to deep (primary-700) instead of the older indigo→magenta
       arc — narrower hue range reads as a single coherent purple rather than
       a rainbow. */
    --login-accent: #6435E8;
    --login-accent-hover: #5524C0;
    --login-accent-glow: rgba(100, 53, 232, 0.18);
    --login-border: #e2e8f0;
    --login-border-strong: #cbd5e1;
    --login-gradient: linear-gradient(135deg, #7C54F2 0%, #6435E8 50%, #5524C0 100%);
    --login-error-bg: rgba(239, 68, 68, 0.08);
    --login-error-border: rgba(239, 68, 68, 0.25);
    --login-error-text: #b91c1c;
    --login-success-bg: rgba(16, 185, 129, 0.08);
    --login-success-border: rgba(16, 185, 129, 0.25);
    --login-success-text: #047857;
    --login-warning: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }

body.login-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--login-text-primary);
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
    /* Mesh gradient — three soft radial blobs in the brand's purple ramp
       (light → anchor → deep). Tighter hue range than the old indigo→
       magenta backdrop so the wordmark gradient on top reads cleanly
       against it instead of fighting the warm-cool clash. */
    background-color: var(--login-page-bg);
    background-image:
        radial-gradient(ellipse 900px 600px at 15% -10%, rgba(100, 53, 232, 0.18), transparent 60%),
        radial-gradient(ellipse 800px 500px at 85% 10%, rgba(150, 120, 247, 0.14), transparent 60%),
        radial-gradient(ellipse 1000px 700px at 50% 110%, rgba(85, 36, 192, 0.16), transparent 65%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

/* Optional secondary glow accent behind the card itself — gives the
   illusion that the card is lit from below. Sits between the body
   gradient and the card, low opacity so it stays subtle. */
body.login-page::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(100, 53, 232, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* Wrapper */
.login-wrapper {
    width: min(94vw, 420px);
    animation: loginFadeInUp 0.5s ease-out;
    position: relative;
    z-index: 1;
    margin-top: -60px;
}

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

/* Logo */
.login-logo {
    display: block;
    height: 140px;
    width: auto;
    margin: 0 auto 12px;
    filter: drop-shadow(0 4px 24px var(--login-accent-glow));
    transition: transform 0.3s ease;
}

.login-logo:hover {
    transform: scale(1.02);
}

/* Brand text */
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand-name {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -1px;
    background: var(--login-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px var(--login-accent-glow));
    margin: 0 0 6px;
}

.login-brand-slogan {
    font-size: 15px;
    font-weight: 500;
    color: var(--login-text-secondary);
    letter-spacing: 0.5px;
    margin: 0 0 4px;
}

.login-brand-powered {
    font-size: 12px;
    font-weight: 500;
    color: var(--login-text-muted);
    letter-spacing: 0.3px;
    margin: 0;
}

/* Card */
.login-card {
    background: var(--login-surface);
    border: 1px solid var(--login-border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow:
        0 10px 25px -5px rgba(15, 23, 42, 0.08),
        0 4px 10px -2px rgba(15, 23, 42, 0.04);
    transition: all 0.3s ease;
}

.login-card:focus-within {
    border-color: var(--login-accent);
    box-shadow:
        0 10px 25px -5px rgba(15, 23, 42, 0.08),
        0 4px 10px -2px rgba(15, 23, 42, 0.04),
        0 0 40px var(--login-accent-glow);
}

/* Headings */
.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.5px;
    color: var(--login-text-primary);
    text-align: center;
}

.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--login-text-secondary);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

/* Labels */
.login-card label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin: 16px 0 8px 2px;
    color: var(--login-text-secondary);
}

/* Inputs */
.login-card input[type=email],
.login-card input[type=password],
.login-card input[type=text] {
    width: 100%;
    height: 48px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--login-border);
    background: var(--login-bg-primary);
    color: var(--login-text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}

.login-card input::placeholder {
    color: var(--login-text-muted);
}

.login-card input:focus {
    border-color: var(--login-accent);
    box-shadow: 0 0 0 3px rgba(100, 53, 232, 0.15);
}

/* Code input (for 2FA) */
.login-card .code-input {
    text-align: center;
    letter-spacing: 8px;
    font-size: 20px;
    font-weight: 600;
}

/* Password reveal field */
.login-field {
    position: relative;
}

.login-field input {
    padding-right: 78px;
}

.login-field .reveal-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--login-border);
    background: var(--login-bg-secondary);
    color: var(--login-text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-field .reveal-btn:hover {
    color: var(--login-text-primary);
    border-color: var(--login-text-muted);
}

/* Cloudflare Turnstile widget */
.cf-turnstile {
    display: flex;
    justify-content: center;
    margin: 24px 0 4px;
    /* When the success callback fires, .is-verified collapses the widget out
       of the way. We don't display:none — the iframe has to stay in the DOM
       so a new challenge can re-render if the token expires or fails. The
       collapse uses opacity + max-height so it animates cleanly. */
    overflow: hidden;
    max-height: 80px; /* Turnstile widget is ~65px tall; leave headroom */
    opacity: 1;
    transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
}

.cf-turnstile.is-verified {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

/* Caption shown while Turnstile is verifying — hidden once the success
   callback fires (turnstile.js handles the [hidden] toggle). The form
   inputs are gated by the same callback so users can't type a stale
   token in before the challenge completes. */
.turnstile-pending-note {
    text-align: center;
    color: var(--login-text-secondary);
    font-size: 13px;
    margin: 8px 0 0;
}

/* Primary button */
.login-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px 20px;
    border: 0;
    border-radius: 10px;
    background: var(--login-gradient);
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 20px var(--login-accent-glow);
    transition: all 0.2s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--login-accent-glow);
}

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

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

/* Secondary / link button */
.login-btn-link {
    background: none;
    border: none;
    color: var(--login-accent-hover);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.login-btn-link:hover {
    color: var(--login-text-primary);
}

/* Error alert */
.login-error {
    background: var(--login-error-bg);
    border: 1px solid var(--login-error-border);
    color: var(--login-error-text);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: loginShake 0.4s ease;
}

.login-error svg { flex-shrink: 0; }

/* Success alert */
.login-success {
    background: var(--login-success-bg);
    border: 1px solid var(--login-success-border);
    color: var(--login-success-text);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-success svg { flex-shrink: 0; color: var(--login-success-text); }

@keyframes loginShake {
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

/* Secret display for TOTP enrollment */
.login-secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    background: var(--login-bg-primary);
    border: 1px dashed var(--login-border);
    padding: 12px 14px;
    border-radius: 10px;
    display: block;
    margin: 8px 0;
    word-break: break-all;
    font-size: 13px;
    color: var(--login-accent-hover);
}

/* QR code enrollment */
.enroll-qr-wrapper {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--login-border);
}

.enroll-qr-wrapper svg {
    width: 200px;
    height: 200px;
}

.enroll-manual-entry {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--login-text-muted);
}

.enroll-manual-entry summary {
    cursor: pointer;
    color: var(--login-accent);
    font-weight: 500;
    padding: 4px 0;
}

.enroll-manual-entry summary:hover {
    color: var(--login-accent-hover);
}

/* Recovery codes display */
.login-recovery {
    margin: 12px 0;
    padding: 16px;
    border-radius: 12px;
    background: var(--login-bg-primary);
    border: 1px solid var(--login-border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 13px;
    color: var(--login-text-secondary);
    line-height: 1.8;
}

/* Checkbox */
.login-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 14px;
    color: var(--login-text-secondary);
    cursor: pointer;
}

.login-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--login-accent);
    cursor: pointer;
}

/* Divider */
.login-divider {
    border: none;
    border-top: 1px solid var(--login-border);
    margin: 24px 0;
}

/* Details/summary */
.login-card details { margin-top: 16px; }

.login-card details summary {
    font-size: 13px;
    color: var(--login-text-muted);
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.2s ease;
}

.login-card details summary:hover { color: var(--login-accent-hover); }
.login-card details[open] summary { color: var(--login-accent-hover); }

/* Note / info box */
.login-note {
    margin-top: 12px;
    padding: 12px;
    background: rgba(100, 53, 232, 0.05);
    border: 1px solid rgba(100, 53, 232, 0.15);
    border-radius: 10px;
    font-size: 13px;
    color: var(--login-text-secondary);
    line-height: 1.5;
}

/* Warning note */
.login-warning {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--login-warning);
}

.login-warning svg {
    vertical-align: middle;
    margin-right: 6px;
}

/* Small text */
.login-small { font-size: 13px; color: var(--login-text-muted); }

/* Links */
.login-card a {
    color: var(--login-accent-hover);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-card a:hover { color: var(--login-text-primary); }

/* Account chooser cards */
.account-chooser {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.account-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--login-bg-primary);
    border: 1px solid var(--login-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.account-card:hover {
    border-color: var(--login-accent);
    transform: translateY(-2px);
}

.account-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.account-card-icon.agency {
    background: var(--login-gradient);
}

.account-card-icon.core {
    background: linear-gradient(135deg, #10b981, #059669);
}

.account-card-icon svg {
    width: 22px;
    height: 22px;
}

.account-card-info { flex: 1; }

.account-card-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--login-text-primary);
    margin-bottom: 2px;
}

.account-card-info span {
    font-size: 12px;
    color: var(--login-text-secondary);
}

/* 2FA icon */
.twofa-icon-box {
    width: 64px;
    height: 64px;
    background: var(--login-gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px var(--login-accent-glow);
}

.twofa-icon-box svg { color: white; }

/* Resend section */
.login-resend {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--login-border);
}

.login-resend p {
    font-size: 14px;
    color: var(--login-text-secondary);
    margin-bottom: 8px;
}

/* Center utility */
.login-center { text-align: center; }

/* Footer */
.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--login-text-muted);
}

.login-footer p {
    margin: 0;
}

.login-footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.login-footer-links a {
    color: var(--login-text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s ease;
}

.login-footer-links a:hover {
    color: var(--login-accent-hover);
}

/* Login links */
.login-links {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--login-border);
}

.login-links p {
    font-size: 14px;
    color: var(--login-text-secondary);
}

/* Signup account type toggle */
.signup-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: 12px;
    margin: 8px 0 8px;
}

.type-option {
    cursor: pointer;
    display: flex;
}

.type-option .type-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.type-option input[type="radio"] {
    display: none;
}

.type-card {
    padding: 14px 12px;
    border-radius: 10px;
    border: 1px solid var(--login-border);
    background: var(--login-bg-primary);
    text-align: center;
    transition: all 0.2s ease;
}

.type-card strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--login-text-primary);
    margin-bottom: 2px;
}

.type-card span {
    font-size: 12px;
    color: var(--login-text-secondary);
}

.type-option.active .type-card,
.type-option input:checked + .type-card {
    border-color: var(--login-accent);
    background: rgba(100, 53, 232, 0.08);
    box-shadow: 0 0 0 3px rgba(100, 53, 232, 0.15);
}

.type-option:hover .type-card {
    border-color: var(--login-text-muted);
}

/* ─────────────────────────────────────────────────────────────────────
   2FA Method Selection Cards
   ───────────────────────────────────────────────────────────────────── */

.twofa-method-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0 4px;
}

.twofa-method-card {
    display: block;
    cursor: pointer;
    border: 1px solid var(--login-border);
    border-radius: 12px;
    background: var(--login-bg-primary);
    transition: all 0.2s ease;
}

.twofa-method-card:hover {
    border-color: var(--login-text-muted);
}

.twofa-method-card.selected {
    border-color: var(--login-accent);
    background: rgba(100, 53, 232, 0.06);
    box-shadow: 0 0 0 3px rgba(100, 53, 232, 0.15);
}

.twofa-method-card input[type="radio"] {
    display: none;
}

.twofa-method-card-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.twofa-method-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--login-bg-primary);
    color: var(--login-text-secondary);
    transition: all 0.2s ease;
}

.twofa-method-card.selected .twofa-method-icon {
    background: var(--login-gradient);
    color: white;
}

.twofa-method-info {
    flex: 1;
    min-width: 0;
}

.twofa-method-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--login-text-primary);
    margin-bottom: 2px;
}

.twofa-method-info span {
    font-size: 12px;
    color: var(--login-text-secondary);
}

/* Security badges */
.security-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.badge-high {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-medium {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-low {
    background: rgba(161, 161, 170, 0.1);
    color: var(--login-text-secondary);
    border: 1px solid rgba(161, 161, 170, 0.2);
}

/* Phone field (shown when SMS selected) */
.phone-field {
    display: none;
    padding: 0 16px 16px;
}

.phone-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--login-text-muted);
    margin: 0 0 6px 2px;
}

.phone-field input[type="tel"] {
    width: 100%;
    height: 44px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--login-border);
    background: var(--login-bg-primary);
    color: var(--login-text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.phone-field input[type="tel"]:focus {
    border-color: var(--login-accent);
    box-shadow: 0 0 0 3px rgba(100, 53, 232, 0.15);
}

.phone-field input[type="tel"]::placeholder {
    color: var(--login-text-muted);
}

/* Mobile */
@media (max-width: 480px) {
    body.login-page {
        padding: 16px 12px;
    }

    body.login-page::before {
        width: 100vw;
    }

    .login-logo {
        height: 100px;
        margin-bottom: 8px;
    }

    .login-wrapper {
        width: 100%;
        max-width: 380px;
        margin-top: -30px;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 14px;
    }

    .login-card h1 {
        font-size: 20px;
    }

    .login-card input[type=email],
    .login-card input[type=password],
    .login-card input[type=text] {
        height: 44px;
        padding: 12px 14px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .login-btn {
        padding: 12px 16px;
    }

    .login-brand-name {
        font-size: 40px;
    }

    .signup-type-toggle {
        gap: 8px;
    }

    .type-card {
        padding: 12px 10px;
    }

    .twofa-method-card-inner {
        gap: 10px;
        padding: 14px;
    }

    .security-badge {
        display: none; /* save horizontal space on small screens */
    }

    .login-footer-links {
        gap: 14px;
    }
}
