/*
 * mojo-auth reference login page styles
 * Copy and customise freely — this is yours.
 *
 * Theming: override the CSS variables below on :root or any parent element.
 */

:root {
    --ma-primary: #3b82f6;
    --ma-primary-dark: #2563eb;
    --ma-bg: #f0f4ff;
    --ma-surface: #ffffff;
    --ma-text: #111827;
    --ma-muted: #6b7280;
    --ma-border: #e2e8f0;
    --ma-danger-bg: #fef2f2;
    --ma-danger-border: #fecaca;
    --ma-danger-text: #991b1b;
    --ma-success-bg: #f0fdf4;
    --ma-success-border: #bbf7d0;
    --ma-success-text: #166534;
    --ma-info-bg: #eff6ff;
    --ma-info-border: #bfdbfe;
    --ma-info-text: #1e40af;
    --ma-radius: 20px;
    --ma-field-radius: 12px;
    --ma-shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 12px 40px -4px rgba(59,130,246,.12);
}

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

html {
    margin: 0;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    width: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    font-size: 16px;
    background: var(--ma-bg);
    color: var(--ma-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Page wrapper ── */
.ma-page {
    width: 100%;
    max-width: 440px;
    padding: 1.5rem 1rem;
}

/* ── Card ── */
.ma-card {
    background: var(--ma-surface);
    border-radius: var(--ma-radius);
    box-shadow: var(--ma-shadow);
    padding: 2.25rem 2rem 2rem;
}

/* ── Header ── */
.ma-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 2rem;
}

/* Default brand icon — shown when no logo URL is provided */
.ma-brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}
.ma-brand-icon svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

.ma-logo {
    max-height: 48px;
    flex-shrink: 0;
}
.ma-header-text {
    text-align: left;
}
.ma-title {
    margin: 0 0 0.15rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ma-primary);
    line-height: 1.2;
    letter-spacing: -0.3px;
}
.ma-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ma-muted);
}

/* ── Status message ── */
.ma-message {
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
    display: none;
}
.ma-message.is-visible {
    display: block;
}
.ma-message.is-error {
    background: var(--ma-danger-bg);
    border-color: var(--ma-danger-border);
    color: var(--ma-danger-text);
}
.ma-message.is-success {
    background: var(--ma-success-bg);
    border-color: var(--ma-success-border);
    color: var(--ma-success-text);
}
.ma-message.is-info {
    background: var(--ma-info-bg);
    border-color: var(--ma-info-border);
    color: var(--ma-info-text);
}

/* ── Views ── */
.ma-view {
    display: none;
}
.ma-view.is-active {
    display: block;
}

/* ── Form fields ── */
.ma-field {
    margin-bottom: 1.125rem;
}
.ma-label {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    color: #374151;
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

/* ── Input wrapper (icon + eye support) ── */
.ma-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

/* Leading icon inside input */
.ma-input-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    width: 17px;
    height: 17px;
    pointer-events: none;
    flex-shrink: 0;
}

.ma-input {
    width: 100%;
    padding: 0.7rem 0.875rem;
    font-size: 0.9375rem;
    border: 1.5px solid var(--ma-border);
    border-radius: var(--ma-field-radius);
    background: #f8fafc;
    color: var(--ma-text);
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
/* Add left padding when there is a leading icon */
.ma-input-wrap .ma-input {
    padding-left: 2.5rem;
}
/* Add right padding when there is an eye button */
.ma-input-wrap .ma-input.has-eye {
    padding-right: 2.75rem;
}
.ma-input::placeholder {
    color: #9ca3af;
}
.ma-input:focus {
    border-color: var(--ma-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.13);
}

/* ── Password eye toggle ── */
.ma-eye {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--ma-muted);
    display: flex;
    align-items: center;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s;
}
.ma-eye:hover {
    color: var(--ma-primary);
}
.ma-eye:focus-visible {
    outline: 2px solid var(--ma-primary);
}

/* ── Radio tiles ── */
.ma-radio-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}
.ma-radio-tile {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    border: 1.5px solid var(--ma-border);
    border-radius: var(--ma-field-radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.ma-radio-tile:has(input:checked) {
    border-color: var(--ma-primary);
    background: var(--ma-info-bg);
}
.ma-radio-tile input[type="radio"] {
    display: none;
}
.ma-radio-dot {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
.ma-radio-tile:has(input:checked) .ma-radio-dot {
    border-color: var(--ma-primary);
}
.ma-radio-dot::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ma-primary);
    display: none;
}
.ma-radio-tile:has(input:checked) .ma-radio-dot::after {
    display: block;
}
.ma-radio-tile-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.3;
}
.ma-radio-tile-sub {
    font-size: 0.75rem;
    color: var(--ma-muted);
}

/* ── Buttons ── */
.ma-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 0.9375rem;
    font-weight: 700;
    border: 1.5px solid transparent;
    border-radius: var(--ma-field-radius);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s, opacity 0.15s;
    text-decoration: none;
    user-select: none;
    letter-spacing: 0.01em;
}
.ma-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}
.ma-btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.ma-btn-primary {
    background: linear-gradient(135deg, var(--ma-primary-dark), var(--ma-primary));
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}
.ma-btn-primary:not(:disabled):hover {
    opacity: 0.93;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.ma-btn-outline {
    background: #fff;
    color: #334155;
    border-color: var(--ma-border);
}
.ma-btn-outline:not(:disabled):hover {
    border-color: #93c5fd;
    background: var(--ma-info-bg);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.ma-btn-ghost {
    background: #fff;
    border-color: var(--ma-border);
    color: #374151;
}
.ma-btn-ghost:not(:disabled):hover {
    border-color: #93c5fd;
    background: var(--ma-info-bg);
}

.ma-btn + .ma-btn {
    margin-top: 0.6rem;
}

/* ── OAuth row — side by side ── */
.ma-oauth-row {
    display: flex;
    align-items: stretch;
    gap: 0.625rem;
}
.ma-oauth-row .ma-btn {
    flex: 1;
    width: auto;
    font-size: 0.875rem;
    padding: 0;
    height: 44px;
    margin-top: 0;
}

.ma-btn-passkey {
    background: #171717;
    color: #fff;
    border-color: #171717;
}
.ma-btn-passkey svg {
    stroke: #fff;
}
.ma-btn-passkey:not(:disabled):hover {
    background: #2a2a2a;
    border-color: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ── OAuth row — icon-only mode ── */
.ma-oauth-row.ma-oauth-icons .ma-btn {
    flex: 0;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
}
.ma-oauth-row.ma-oauth-icons {
    justify-content: center;
    gap: 1rem;
}
.ma-oauth-row.ma-oauth-icons .ma-btn-text {
    display: none;
}
.ma-oauth-row.ma-oauth-icons .ma-btn svg {
    flex-shrink: 0;
}

/* ── Spinner inside button ── */
@keyframes ma-spin {
    to { transform: rotate(360deg); }
}
.ma-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-right-color: #fff;
    border-radius: 50%;
    animation: ma-spin 0.6s linear infinite;
    flex-shrink: 0;
}
.ma-btn.is-loading .ma-spinner {
    display: inline-block;
}
.ma-btn.is-loading .ma-btn-text {
    opacity: 0.7;
}

/* ── Divider ── */
.ma-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--ma-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.ma-divider::before,
.ma-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--ma-border);
}

/* ── Back link ── */
.ma-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    color: var(--ma-primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 1.25rem;
    text-decoration: none;
    transition: color 0.15s;
}
.ma-back:hover {
    color: var(--ma-primary-dark);
    text-decoration: underline;
}

/* ── Section heading inside sub-views ── */
.ma-view-title {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}
.ma-view-sub {
    font-size: 0.8125rem;
    color: var(--ma-muted);
    margin: 0 0 1.25rem;
}

/* ── Footer links row ── */
.ma-footer-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1.25rem;
}
.ma-footer-link {
    font-size: 0.8125rem;
}
.ma-footer-link a,
.ma-footer-link button {
    background: none;
    border: none;
    color: var(--ma-primary);
    font-size: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.ma-footer-link a:hover,
.ma-footer-link button:hover {
    color: var(--ma-primary-dark);
    text-decoration: underline;
}

/* ── Legal links ── */
.ma-legal-links {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ma-border);
    font-size: 0.75rem;
}
.ma-legal-links a {
    color: var(--ma-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.ma-legal-links a:hover {
    color: var(--ma-primary);
    text-decoration: underline;
}
.ma-legal-sep {
    color: var(--ma-border);
    margin: 0 0.375rem;
}

/* ── Hint text ── */
.ma-hint {
    font-size: 0.8125rem;
    color: var(--ma-muted);
    margin: -0.25rem 0 1.125rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    body {
        align-items: stretch;
        background: var(--ma-surface);
    }
    .ma-page {
        max-width: none;
        padding: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    .ma-card {
        flex: 1;
        border-radius: 0;
        box-shadow: none;
        padding: 2rem 1.5rem;
        display: flex;
        flex-direction: column;
    }
    /* Push legal links to bottom of screen */
    .ma-legal-links {
        margin-top: auto;
        padding-top: 2rem;
        border-top: none;
    }
    .ma-title {
        font-size: 1.25rem;
    }
    .ma-oauth-row {
        flex-direction: column;
    }
    .ma-oauth-row .ma-btn {
        width: 100%;
    }
}

/* =============================================================================
   THEMES
   Apply by adding a class to <body>: <body class="theme-dark">
   ============================================================================= */

/* ── Dark ── */
body.theme-dark {
    --ma-primary: #60a5fa;
    --ma-primary-dark: #93c5fd;
    --ma-bg: #0f172a;
    --ma-surface: #1e293b;
    --ma-text: #f1f5f9;
    --ma-muted: #94a3b8;
    --ma-border: #334155;
    --ma-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --ma-danger-bg: rgba(239, 68, 68, 0.15);
    --ma-danger-border: rgba(239, 68, 68, 0.3);
    --ma-danger-text: #fca5a5;
    --ma-success-bg: rgba(34, 197, 94, 0.12);
    --ma-success-border: rgba(34, 197, 94, 0.25);
    --ma-success-text: #86efac;
    --ma-info-bg: rgba(96, 165, 250, 0.12);
    --ma-info-border: rgba(96, 165, 250, 0.25);
    --ma-info-text: #93c5fd;
}
body.theme-dark .ma-input {
    background: #0f172a;
    color: #f1f5f9;
    border-color: #334155;
}
body.theme-dark .ma-input:focus {
    background: #1e293b;
}
body.theme-dark .ma-input::placeholder {
    color: #475569;
}
body.theme-dark .ma-label {
    color: #cbd5e1;
}
body.theme-dark .ma-radio-tile-label {
    color: #cbd5e1;
}
body.theme-dark .ma-radio-tile {
    background: #0f172a;
}
body.theme-dark .ma-btn-outline,
body.theme-dark .ma-btn-ghost {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}
body.theme-dark .ma-btn-outline:not(:disabled):hover,
body.theme-dark .ma-btn-ghost:not(:disabled):hover {
    background: #334155;
    border-color: #60a5fa;
}

/* ── Modern (deep purple gradient bg, white card) ── */
body.theme-modern {
    --ma-primary: #7c3aed;
    --ma-primary-dark: #6d28d9;
    --ma-bg: #1a0533;
    --ma-surface: #ffffff;
    --ma-text: #111827;
    --ma-muted: #6b7280;
    --ma-border: #e5e7eb;
    --ma-shadow: 0 20px 60px rgba(124, 58, 237, 0.25);
    --ma-radius: 20px;
    --ma-field-radius: 12px;
    --ma-info-bg: #f5f3ff;
    --ma-info-border: #ddd6fe;
    --ma-info-text: #5b21b6;
}
body.theme-modern {
    background: linear-gradient(135deg, #1a0533 0%, #2d1054 50%, #0f0820 100%);
    background-attachment: fixed;
}
body.theme-modern .ma-brand-icon {
    background: linear-gradient(135deg, #5b21b6, #7c3aed);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
body.theme-modern .ma-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
body.theme-modern .ma-btn-primary:not(:disabled):hover {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}
body.theme-modern .ma-radio-dot::after {
    background: #7c3aed;
}

/* ── Corporate (clean blue, no-nonsense) ── */
body.theme-corporate {
    --ma-primary: #1d4ed8;
    --ma-primary-dark: #1e40af;
    --ma-bg: #f8fafc;
    --ma-surface: #ffffff;
    --ma-text: #0f172a;
    --ma-muted: #64748b;
    --ma-border: #e2e8f0;
    --ma-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
    --ma-radius: 8px;
    --ma-field-radius: 6px;
}
body.theme-corporate .ma-btn:not(:disabled):hover {
    transform: none;
}
body.theme-corporate .ma-btn-primary {
    background: var(--ma-primary);
    box-shadow: none;
}

/* =============================================================================
   AUTH OVERLAY
   Full-screen overlay shown during session check and post-login redirect.
   ============================================================================= */

.ma-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.ma-overlay.is-visible {
    display: flex;
}

.ma-overlay-card {
    background: var(--ma-surface);
    border-radius: var(--ma-radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    padding: 2.5rem 3rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 240px;
    animation: ma-overlay-in 0.2s ease;
}

@keyframes ma-overlay-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

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

.ma-overlay-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--ma-border);
    border-top-color: var(--ma-primary);
    border-radius: 50%;
    animation: ma-overlay-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.ma-overlay-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ma-text);
}

.ma-overlay-sub {
    margin: 0;
    font-size: 0.875rem;
    color: var(--ma-muted);
}
