/* ==========================================================================
   iSix — Login

   Layout and components for this page. Colour, type, spacing, radius and
   motion all resolve through the shared tokens; compat.css maps this page's
   legacy variable names onto them.

   Load order: tokens.css -> base.css -> compat.css -> this file
   ========================================================================== */

/* ── Design tokens (from theme.css) ── */




/* ── Base (from login.html) ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'ss02';
    -webkit-font-smoothing: antialiased;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: hidden;
}

.mono, .num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input, select { font-family: inherit; }

/* ── Auth shell (from login.html) ── */
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    isolation: isolate;
}

/* Dot-grid backdrop — same effect in light and dark */
.auth-shell::before {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(var(--dot) 1.4px, transparent 1.4px);
    background-size: 24px 24px;
    opacity: var(--dot-opacity);
    mask-image: radial-gradient(ellipse 65% 65% at center, black 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse 65% 65% at center, black 0%, transparent 78%);
    z-index: -2;
    pointer-events: none;
}

/* Soft accent glow */
.auth-shell::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, 92vw);
    height: min(760px, 92vw);
    background: radial-gradient(circle at center, var(--accent-soft), transparent 62%);
    z-index: -1;
    pointer-events: none;
}

.auth-shell > main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Top bar (theme toggle only — the logo now sits inside the card) ── */
.auth-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 14px 18px;
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
}

/* ── Card logo — centred, no plate ───────────────────────────
   The <img> is wrapped in <picture>, so the flex ITEM here is <picture>, not
   the image. The old `height:100%` resolved against a <picture> of indefinite
   height (which itself sizes to its content) — a circular dependency engines
   resolve by falling back to the intrinsic 288x180, which then bleeds out of
   this box. Everything below is absolute px with a relative cap, so nothing
   depends on percentage resolution. */
.card-logo {
    --auth-logo-h: 48px;                 /* rendered height of the mark       */
    --auth-logo-w: 77px;                 /* 48 x (288/180) = 76.8, rounded up */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--auth-logo-h);      /* never a fixed height */
    margin: 0 auto 22px;
}

/* <picture> is the actual flex item. Give it a real block box so the image has
   a definite containing block and no baseline descender gap. */
.card-logo picture {
    display: block;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    line-height: 0;
    font-size: 0;
}

/* Absolute size on BOTH axes (no aspect-ratio — iOS Safari < 15), plus a
   relative cap. object-fit:contain keeps the 1.6:1 artwork undistorted and
   inside the box if max-width ever engages on a very narrow phone. */
.card-logo img {
    display: block;
    width: var(--auth-logo-w);
    height: var(--auth-logo-h);
    max-width: 100%;
    max-height: var(--auth-logo-h);
    object-fit: contain;
    object-position: center;
}

/* The PNG is dark artwork on transparency; with the white plate gone it would
   sit at ~1.9:1 against dark --surface. Flip it to white so the mark stays
   legible in dark mode. Light mode is untouched. */
[data-theme="dark"] .card-logo img { filter: brightness(0) invert(1); }

/* ── Main centered area ── */
.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 84px 18px 24px;
}

/* ── Auth card (from login.html) ── */
.auth-card {
    --auth-card-max: 470px;
    width: 100%;
    max-width: var(--auth-card-max);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 34px 28px 28px;
    box-shadow: var(--shadow-md);
}

/* ── Eyebrow (from login.html) ── */
.auth-eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}
.auth-eyebrow .dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--paid);
}

.auth-title {
    font-size: 22px; font-weight: 800; letter-spacing: -0.025em;
    line-height: 1.1;
}
.auth-sub {
    color: var(--muted); font-size: 13px; margin-top: 4px;
}

/* ── Alerts (from login.html) ── */
.alert {
    display: flex; gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12.5px;
    margin-top: 14px;
    margin-bottom: 0;
}
.alert.err { background: var(--due-strong-soft); color: var(--due-strong); }
.alert.ok  { background: var(--paid-soft);       color: var(--paid); }

/* ── Form (from login.html) ── */
.form { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-size: 11.5px; font-weight: 600;
    color: var(--ink-2);
    letter-spacing: 0.01em;
    display: flex; align-items: center; justify-content: space-between;
}
.field label .hint { color: var(--muted); font-weight: 500; font-size: 11px; }

/* ── Input container (from login.html) ── */
.input {
    height: 48px;
    display: flex; align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 12px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.input:focus-within {
    border-color: var(--ink);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--surface-3);
}

.input .prefix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--muted);
    padding-right: 8px;
    margin-right: 8px;
    border-right: 1px solid var(--border);
    flex: 0 0 auto;
    line-height: 1;
}

/* Override Bootstrap's .form-control inside our .input */
.input input,
.input input.form-control {
    flex: 1; min-width: 0;
    height: 100%;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--ink) !important;
    font-size: 15px;
    font-family: inherit;
    letter-spacing: -0.005em;
    padding: 0 !important;
    border-radius: 0 !important;
}
.input input::placeholder { color: var(--muted-2) !important; }
.input input.mono { font-family: 'JetBrains Mono', monospace; font-size: 14px; }

/* Password reveal (eye icon — kept as FA i.reveal) */
.input .reveal {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    flex: 0 0 auto;
}
.input .reveal:hover { background: var(--surface-3); color: var(--ink-2); }

/* ── Row between (from login.html) ── */
.row-between {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 2px;
}

/* ── Custom checkbox (from login.html) ── */
.check {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12.5px;
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
}
/* Hide the real checkbox (JS still reads it by id="rememberMe") */
.check input[type="checkbox"] { display: none; }
.check .box {
    width: 18px; height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--border-strong);
    background: var(--surface);
    display: grid; place-items: center;
    transition: background .12s, border-color .12s;
    flex: 0 0 auto;
}
.check .box svg { opacity: 0; transition: opacity .12s; color: var(--surface); }
.check input[type="checkbox"]:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input[type="checkbox"]:checked + .box svg { opacity: 1; }

.link {
    color: var(--ink); font-size: 12.5px; font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dashed var(--border-strong);
    padding-bottom: 1px;
}
.link:hover { border-bottom-style: solid; }

/* ── Primary button (from login.html) ── */
.btn-primary {
    margin-top: 4px;
    height: 50px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--surface);
    font-weight: 700; font-size: 14.5px;
    letter-spacing: -0.005em;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%;
    transition: transform .08s ease, box-shadow .15s, opacity .15s;
    border: 0;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; pointer-events: none; }
.btn-primary .arrow { transition: transform .15s; }
.btn-primary:hover .arrow { transform: translateX(3px); }

/* Spinner inside btn-primary */
.spinner-border {
    width: 16px;
    height: 16px;
    border-width: 2px;
    display: none;
    color: var(--surface);
}

/* ── Or divider (from login.html) ── */
.or {
    display: flex; align-items: center; gap: 10px;
    color: var(--muted-2); font-size: 11px;
    margin: 16px 0 12px;
    text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}
.or::before, .or::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Install CTA (from login.html) ── */
.install-cta {
    display: none;
    align-items: center; gap: 10px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    font-size: 12.5px;
    color: var(--ink-2);
}
.install-cta .ic {
    width: 32px; height: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid; place-items: center;
    color: var(--ink-2);
    flex: 0 0 auto;
}
.install-cta b { color: var(--ink); font-weight: 700; }
.install-cta .install-btn {
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--ink); color: var(--surface);
    font-size: 11.5px; font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* ── Auth footer (from login.html) ── */
.auth-foot {
    text-align: center;
    margin-top: 18px;
    font-size: 12.5px;
    color: var(--muted);
}
.auth-foot a { color: var(--ink); font-weight: 700; }

/* ── Theme toggle pill (from login.html) ── */
.theme-toggle {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
}
.theme-toggle button {
    width: 30px; height: 26px;
    border-radius: 999px;
    color: var(--muted);
    display: grid; place-items: center;
}
.theme-toggle button[data-on="true"] {
    background: var(--ink);
    color: var(--surface);
}

/* ── Desktop polish (from login.html) ── */
@media (min-width: 900px) {
    .auth-main { padding: 92px 40px 40px; }
    .auth-card { --auth-card-max: 520px; padding: 38px 34px 32px; }
    .card-logo { --auth-logo-h: 52px; --auth-logo-w: 84px; margin-bottom: 24px; }
}

/* ── Mobile ── */
@media (max-width: 576px) {
    .input input,
    .input input.form-control { font-size: 16px; } /* prevent iOS zoom */

    /* Larger tap targets */
    .theme-toggle button { width: 36px; height: 32px; }
}

@media (max-width: 420px) {
    .auth-top { padding-top: 12px; padding-bottom: 12px; }
    .card-logo { --auth-logo-h: 44px; --auth-logo-w: 71px; margin-bottom: 18px; }

    .auth-main { padding: 78px 10px 20px; }
    .auth-card { padding: 26px 20px 22px; border-radius: 16px; }
    .auth-title { font-size: 19px; }

    .install-cta { flex-wrap: wrap; }
    .install-cta .install-btn { margin-left: auto; }
}
