/**
 * Unified login hub (/login) — light + dark, mobile-first
 */

/* ── Tokens ────────────────────────────────────────────────────── */

html {
    --lh-bg: #fafafa;
    --lh-bg-subtle: #f4f4f5;
    --lh-surface: #ffffff;
    --lh-surface-hover: #f4f4f5;
    --lh-border: rgba(0, 0, 0, 0.1);
    --lh-border-strong: rgba(0, 0, 0, 0.16);
    --lh-text: #09090b;
    --lh-text-secondary: #52525b;
    --lh-text-muted: #71717a;
    --lh-accent: #4f46e5;
    --lh-accent-hover: #4338ca;
    --lh-accent-subtle: rgba(79, 70, 229, 0.1);
    --lh-accent-glow: rgba(79, 70, 229, 0.22);
    --lh-success: #059669;
    --lh-warning: #d97706;
    --lh-danger: #dc2626;
    --lh-staff: #4f46e5;
    --lh-customer: #059669;
    --lh-reseller: #d97706;
    --lh-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    --lh-orb-1: rgba(99, 102, 241, 0.07);
    --lh-orb-2: rgba(34, 211, 238, 0.05);
    --lh-orb-3: rgba(129, 140, 248, 0.04);
    color-scheme: light;
}

html.portal-dark {
    --lh-bg: #09090b;
    --lh-bg-subtle: #18181b;
    --lh-surface: #18181b;
    --lh-surface-hover: #27272a;
    --lh-border: rgba(255, 255, 255, 0.1);
    --lh-border-strong: rgba(255, 255, 255, 0.16);
    --lh-text: #fafafa;
    --lh-text-secondary: #a1a1aa;
    --lh-text-muted: #71717a;
    --lh-accent: #818cf8;
    --lh-accent-hover: #a5b4fc;
    --lh-accent-subtle: rgba(129, 140, 248, 0.14);
    --lh-accent-glow: rgba(99, 102, 241, 0.35);
    --lh-success: #34d399;
    --lh-warning: #fbbf24;
    --lh-danger: #f87171;
    --lh-staff: #818cf8;
    --lh-customer: #34d399;
    --lh-reseller: #fbbf24;
    --lh-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --lh-orb-1: rgba(99, 102, 241, 0.18);
    --lh-orb-2: rgba(34, 211, 238, 0.1);
    --lh-orb-3: rgba(129, 140, 248, 0.08);
    color-scheme: dark;
}

/* ── Base ──────────────────────────────────────────────────────── */

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

body.isp-login-hub-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: Outfit, ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--lh-text);
    background: var(--lh-bg);
    -webkit-font-smoothing: antialiased;
}

/* Decorative orbs disabled — caused layout issues when CSS cache stale */
.lh-orbs,
.isp-premium-orbs,
.portal-premium-orbs { display: none !important; }

/* ── Shell & card ─────────────────────────────────────────────── */

.lh-shell {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}

.lh-card {
    width: min(26rem, 100%);
    background: var(--lh-surface);
    border: 1px solid var(--lh-border);
    border-radius: 1.125rem;
    box-shadow: var(--lh-shadow);
    padding: 1.25rem 1.25rem 1.5rem;
    animation: lh-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lh-card--customer { border-top: 3px solid var(--lh-customer); }
.lh-card--staff { border-top: 3px solid var(--lh-staff); }
.lh-card--reseller { border-top: 3px solid var(--lh-reseller); }

@media (min-width: 480px) {
    .lh-card {
        width: min(28rem, 100%);
        padding: 1.5rem 1.75rem 1.75rem;
        border-radius: 1.25rem;
    }
}

@keyframes lh-in {
    from { opacity: 0; transform: translateY(10px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.lh-card__top {
    display: flex;
    justify-content: flex-end;
    margin: -0.25rem 0 0.25rem;
}

.lh-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--lh-border);
    border-radius: 0.5rem;
    background: var(--lh-bg-subtle);
    color: var(--lh-text-secondary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.lh-theme-btn:hover {
    background: var(--lh-surface-hover);
    color: var(--lh-text);
}

.lh-theme-btn svg { width: 1rem; height: 1rem; }
html.portal-dark .lh-theme-btn__sun { display: none; }
html:not(.portal-dark) .lh-theme-btn__moon { display: none; }

/* ── Header ────────────────────────────────────────────────────── */

.lh-head { text-align: center; margin-bottom: 1.25rem; }

.lh-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.lh-brand__logo {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.875rem;
    object-fit: contain;
    background: var(--lh-bg-subtle);
    padding: 0.25rem;
    border: 1px solid var(--lh-border);
}

.lh-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.875rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.lh-head__eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lh-accent);
}

.lh-head__title {
    margin: 0;
    font-size: clamp(1.25rem, 4vw, 1.625rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.lh-head__lead {
    margin: 0.5rem auto 0;
    max-width: 22rem;
    font-size: 0.875rem;
    color: var(--lh-text-secondary);
    line-height: 1.5;
}

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

.lh-form { display: flex; flex-direction: column; gap: 0.875rem; }

.lh-field label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--lh-text);
}

.lh-field input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--lh-border-strong);
    border-radius: 0.625rem;
    background: var(--lh-bg-subtle);
    color: var(--lh-text);
    font: inherit;
    font-size: 0.9375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.lh-field input::placeholder { color: var(--lh-text-muted); }

.lh-field input:focus {
    outline: none;
    border-color: var(--lh-accent);
    box-shadow: 0 0 0 3px var(--lh-accent-subtle);
    background: var(--lh-surface);
}

.lh-password-wrap { position: relative; }

.lh-password-wrap input { padding-right: 2.75rem; }

.lh-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--lh-text-muted);
    cursor: pointer;
}

.lh-password-toggle:hover { color: var(--lh-text); }
.lh-password-toggle svg { width: 1.125rem; height: 1.125rem; }

/* Role hint removed from UI */
.lh-role {
    display: none !important;
}

/* legacy */
.lh-role--legacy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--lh-border);
    background: var(--lh-bg-subtle);
    font-size: 0.8125rem;
    color: var(--lh-text-secondary);
    min-height: 2.5rem;
}

.lh-role__dot {
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--lh-text-muted);
}

.lh-role--email .lh-role__dot { background: var(--lh-accent); }
.lh-role--staff .lh-role__dot { background: var(--lh-staff); }
.lh-role--customer .lh-role__dot { background: var(--lh-customer); }
.lh-role--reseller .lh-role__dot { background: var(--lh-reseller); }

.lh-role--email { border-color: rgba(79, 70, 229, 0.25); background: var(--lh-accent-subtle); color: var(--lh-text); }
.lh-role--staff { border-color: rgba(79, 70, 229, 0.25); }
.lh-role--customer { border-color: rgba(5, 150, 105, 0.25); }
.lh-role--reseller { border-color: rgba(217, 119, 6, 0.25); }

.lh-remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--lh-text-secondary);
    cursor: pointer;
    user-select: none;
}

.lh-remember input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--lh-accent);
}

.lh-submit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.875rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 2px var(--lh-accent-glow), 0 6px 16px var(--lh-accent-glow);
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.lh-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.lh-submit:disabled { opacity: 0.75; cursor: wait; }

.lh-submit__spinner {
    display: none;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lh-spin 0.7s linear infinite;
}

.lh-submit.is-loading .lh-submit__label { opacity: 0; }
.lh-submit.is-loading .lh-submit__spinner { display: block; position: absolute; }

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

/* Alert */
.lh-alert {
    margin-bottom: 0.875rem;
    padding: 0.75rem 0.875rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.lh-alert--error {
    border: 1px solid rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.08);
    color: var(--lh-danger);
}

html.portal-dark .lh-alert--error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.3);
}

/* ── Manual portals ────────────────────────────────────────────── */

.lh-portals {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--lh-border);
}

.lh-portals__label {
    margin: 0 0 0.625rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--lh-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.lh-portals__grid {
    display: grid;
    gap: 0.5rem;
}

@media (min-width: 400px) {
    .lh-portals__grid { grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); }
}

.lh-portal {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 0.875rem;
    border-radius: 0.625rem;
    border: 1px solid var(--lh-border);
    background: var(--lh-bg-subtle);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.lh-portal:hover {
    border-color: var(--lh-border-strong);
    background: var(--lh-surface-hover);
    transform: translateY(-1px);
    color: inherit;
}

.lh-portal--customer { border-top: 2px solid var(--lh-customer); }
.lh-portal--staff { border-top: 2px solid var(--lh-staff); }
.lh-portal--reseller { border-top: 2px solid var(--lh-reseller); }

.lh-portal--current {
    border-color: var(--lh-accent);
    background: var(--lh-accent-subtle);
    pointer-events: none;
    opacity: 0.85;
}

.lh-portal__badge {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lh-text-muted);
}

.lh-portal__title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--lh-text);
    line-height: 1.3;
}

/* ── Footer chips ──────────────────────────────────────────────── */

.lh-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.lh-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--lh-accent);
    background: var(--lh-accent-subtle);
    border: 1px solid var(--lh-border);
    transition: background 0.15s ease, transform 0.15s ease;
}

.lh-chip svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.lh-chip:hover { background: var(--lh-accent-subtle); transform: translateY(-1px); color: var(--lh-accent-hover); }

.lh-chip--muted {
    color: var(--lh-text-secondary);
    background: var(--lh-bg-subtle);
}

.lh-chip--muted:hover { color: var(--lh-text); }

/* Notes & extra links */
.lh-note {
    margin-bottom: 0.875rem;
    padding: 0.75rem 0.875rem;
    border-radius: 0.625rem;
    border: 1px solid var(--lh-border);
    background: var(--lh-bg-subtle);
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--lh-text-secondary);
}

.lh-extra {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--lh-text-secondary);
}

.lh-link {
    color: var(--lh-accent);
    font-weight: 600;
    text-decoration: none;
}

.lh-link:hover {
    color: var(--lh-accent-hover);
    text-decoration: underline;
}

/* Demo hint inside card */
body.isp-login-hub-page .isp-demo-credentials {
    margin: 0 0 1rem !important;
    border-color: var(--lh-border) !important;
    background: var(--lh-accent-subtle) !important;
    font-size: 0.78rem !important;
}

/* ── A11y & motion ─────────────────────────────────────────────── */

:focus-visible {
    outline: 2px solid var(--lh-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .lh-card, .lh-submit__spinner, .lh-overlay, .lh-signing__ring, .lh-signing__bar-fill { animation: none !important; }
    .lh-submit:hover:not(:disabled), .lh-portal:hover { transform: none; }
}

/* ── Login submit overlay ──────────────────────────────────────── */

.lh-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(9, 9, 11, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

html.portal-dark .lh-overlay {
    background: rgba(0, 0, 0, 0.72);
}

.lh-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.lh-overlay__panel {
    width: min(20rem, 100%);
    padding: 1.75rem 1.5rem;
    text-align: center;
    background: var(--lh-surface);
    border: 1px solid var(--lh-border);
    border-radius: 1.125rem;
    box-shadow: var(--lh-shadow);
    animation: lh-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lh-overlay__spinner {
    position: relative;
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1.125rem;
}

.lh-overlay__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--lh-accent-subtle);
    border-top-color: var(--lh-accent);
    animation: lh-spin 0.85s cubic-bezier(0.5, 0.1, 0.3, 0.9) infinite;
}

.lh-overlay__ring--delay {
    inset: 0.45rem;
    border-width: 2px;
    border-top-color: var(--lh-accent-hover);
    animation-duration: 1.1s;
    animation-direction: reverse;
    opacity: 0.85;
}

.lh-overlay__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--lh-text);
}

.lh-overlay__text {
    margin: 0.45rem 0 0;
    font-size: 0.875rem;
    color: var(--lh-text-muted);
}

.lh-overlay__dots::after {
    content: '';
    animation: lh-dots 1.4s steps(4, end) infinite;
}

@keyframes lh-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ── Post-login signing page (/admin/login/complete) ───────────── */

body.lh-signing-page {
    overflow: hidden;
}

.lh-signing {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}

.lh-signing__glow {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, var(--lh-orb-1), transparent 70%),
        radial-gradient(ellipse 50% 40% at 80% 100%, var(--lh-orb-2), transparent 65%),
        radial-gradient(ellipse 40% 35% at 10% 80%, var(--lh-orb-3), transparent 60%);
    pointer-events: none;
}

.lh-signing__card {
    position: relative;
    z-index: 1;
    width: min(22rem, 100%);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
    background: var(--lh-surface);
    border: 1px solid var(--lh-border);
    border-radius: 1.25rem;
    box-shadow: var(--lh-shadow);
    animation: lh-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lh-signing__brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.lh-signing__mark {
    width: 4rem;
    height: 4rem;
    font-size: 1.75rem;
}

.lh-signing__spinner {
    position: relative;
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.25rem;
}

.lh-signing__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--lh-accent-subtle);
    border-top-color: var(--lh-accent);
    animation: lh-spin 0.9s cubic-bezier(0.5, 0.1, 0.3, 0.9) infinite;
}

.lh-signing__ring--delay {
    inset: 0.55rem;
    border-width: 2px;
    border-top-color: var(--lh-accent-hover);
    animation-duration: 1.25s;
    animation-direction: reverse;
    opacity: 0.8;
}

.lh-signing__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--lh-text);
}

.lh-signing__lead {
    margin: 0.5rem 0 0;
    font-size: 0.9375rem;
    color: var(--lh-text-muted);
}

.lh-signing__bar {
    height: 4px;
    margin: 1.35rem 0 0.75rem;
    overflow: hidden;
    background: var(--lh-accent-subtle);
    border-radius: 999px;
}

.lh-signing__bar-fill {
    display: block;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, var(--lh-accent), var(--lh-accent-hover));
    border-radius: inherit;
    animation: lh-bar-slide 1.2s ease-in-out infinite;
}

@keyframes lh-bar-slide {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

.lh-signing__hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--lh-text-muted);
}
