/* ═══════════════════════════════════════════════════════════════
   WISOBOOKS — AUTHENTICATION PAGES

   Covers sign-in (two-step), forgot / reset password, two-factor,
   recovery, invitation accept and registration confirmation.

   Structure of the sign-in page — one centred column, nothing either
   side of it:

     body.auth-body.auth-body--center
       .auth-shell                   max-width column
         .auth-brandmark             the WisoBooks lockup, on top
         .auth-card                  stepper + the two-step form
         .auth-trust                 three security badges
         .auth-legal                 Security / Privacy / Terms + ©

   Every other auth page uses body.auth-body + .auth-card on its own,
   which still centres the card the way it always did.
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Brand */
    --wb-blue: #0B5FA5;
    --wb-blue-bright: #1478C8;
    --wb-blue-soft: #8ECAF5;
    --wb-ink: #0B1F33;
    --wb-font: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Page tokens */
    --auth-bg: #F4F7FA;
    --auth-surface: #ffffff;
    --auth-primary: var(--sm-primary-bg, #0B5FA5);
    --auth-primary-hover: var(--sm-primary-text, #094B83);
    --auth-primary-light: var(--sm-primary-soft, #E8F1F9);
    --auth-text: #101828;
    --auth-text-muted: #667085;
    --auth-border: #E4E7EC;
    --auth-danger: #A5231F;
    --auth-success: #16704A;
    --auth-radius: 16px;
    --auth-button-radius: var(--sm-button-radius, 9px);
    --auth-dropdown-radius: var(--sm-dropdown-radius, 12px);
    --auth-shadow: 0 1px 2px rgba(16,24,40,.04), 0 12px 32px rgba(16,24,40,.08);
    --auth-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body.auth-body {
    font-family: var(--auth-font);
    background: var(--auth-bg);
    color: var(--auth-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    -webkit-font-smoothing: antialiased;
}

/* Sign-in: one centred column — lockup, card, legal row. Nothing either side of
   it, so the eye lands on the single field it has to fill in. */
body.auth-body.auth-body--center {
    justify-content: center;
    padding: 40px 16px 28px;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    /* Optical centre reads better than true centre on a tall viewport. */
    margin-block: auto;
}

.auth-shell-brand {
    align-self: center;
    margin-bottom: 26px;
}

/* ═══════════════ BRAND LOCKUP ═══════════════ */

.auth-brandmark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    line-height: 1;
    /* The lockup is Latin: never mirrored, never reordered on RTL pages. */
    direction: ltr;
    unicode-bidi: isolate;
}

.auth-brandmark img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: block;
    flex: 0 0 auto;
}

.auth-brandmark .wb-wordmark {
    font-family: var(--wb-font);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.025em;
    color: var(--wb-ink);
    white-space: nowrap;
}

.auth-brandmark .wb-wordmark > span { color: var(--wb-blue); }

.auth-brandmark--on-dark .wb-wordmark { color: #fff; }
.auth-brandmark--on-dark .wb-wordmark > span { color: var(--wb-blue-soft); }
.auth-brandmark--on-dark img { background: rgba(255,255,255,.12); }

.auth-brandmark--lg img { width: 42px; height: 42px; border-radius: 12px; }
.auth-brandmark--lg .wb-wordmark { font-size: 29px; }

/* Legacy centred lockup used by the non-login auth pages. */
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* ═══════════════ TRUST BADGES ═══════════════
   Small, grey, factual. On a sign-in page this is reassurance, not marketing —
   the moment it is coloured or oversized it starts to look like a sales pitch on
   a screen where the person just wants to get in. */

.auth-trust {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
    list-style: none;
    padding: 0;
}

.auth-trust li {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--auth-border);
    border-radius: 999px;
    background: #fff;
    font-size: 11.5px;
    font-weight: 600;
    color: #667085;
    white-space: nowrap;
}

.auth-trust li svg { flex: 0 0 auto; color: var(--auth-success); }

/* ═══════════════ LEGAL / TRUST ROW ═══════════════ */

.auth-legal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 14px;
    margin-top: 20px;
    font-size: 12px;
    color: var(--auth-text-muted);
}

.auth-legal a {
    color: var(--auth-text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: 4px;
}

.auth-legal a:hover { color: var(--auth-text); text-decoration: underline; }

/* The security item leads with a shield so the guarantee reads at a glance. */
.auth-legal .al-secure {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.auth-legal .al-secure svg { flex: 0 0 auto; color: var(--auth-success); }

/* Copyright is a statement, not a link, so it gets its own line under the three
   links rather than sitting in the row with a separator that orphans on wrap. */
.auth-legal .al-copy {
    flex-basis: 100%;
    text-align: center;
    color: #98A2B3;
    margin-top: 4px;
}

/* ═══════════════ CARD ═══════════════ */

.auth-card {
    background: var(--auth-surface);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    border: 1px solid var(--auth-border);
    width: 100%;
    max-width: 420px;
    padding: 30px 28px 24px;
    position: relative;
}

.auth-card h1 {
    font-family: var(--wb-font);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: 6px;
    color: var(--auth-text);
    text-align: center;
}

.auth-card .auth-subtitle {
    font-size: 13.5px;
    color: var(--auth-text-muted);
    margin-bottom: 22px;
    line-height: 1.55;
    text-align: center;
}

/* ═══════════════ TWO-STEP MACHINERY ═══════════════ */

/* Both steps live in one form. Step 2 is hidden only once JS has taken over
   (it adds .auth-steps--js); with scripting off both steps stay visible and
   the page degrades to the single-screen form it used to be. */
.auth-steps .auth-step { display: block; }

.auth-steps--js .auth-step { display: none; }
.auth-steps--js .auth-step.active { display: block; animation: auth-step-in .26s cubic-bezier(.22,.9,.3,1) both; }

@keyframes auth-step-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Step counter */
.auth-stepper {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

/* Only meaningful once JS is driving the steps. */
.auth-card.is-two-step .auth-stepper { display: flex; }

.auth-stepper .sp-dot {
    width: 22px;
    height: 4px;
    border-radius: 999px;
    background: var(--auth-border);
    transition: background .25s ease, width .25s ease;
}

.auth-stepper .sp-dot.on { background: var(--auth-primary); width: 32px; }

.auth-stepper .sp-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--auth-text-muted);
    margin-inline-start: 4px;
}

/* The identifier chip shown on step 2 */
.auth-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 12px;
    border: 1px solid var(--auth-border);
    border-radius: 999px;
    background: #F9FAFB;
    margin-bottom: 18px;
}

.auth-identity .id-avatar {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--auth-primary-light);
    color: var(--auth-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.auth-identity .id-value {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--auth-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Emails and E.164 numbers read left-to-right on RTL pages too. */
    direction: ltr;
    unicode-bidi: plaintext;
    text-align: start;
}

.auth-identity .id-change {
    flex: 0 0 auto;
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--auth-font);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--auth-primary);
    padding: 5px 10px;
    border-radius: 999px;
    transition: background .15s;
}

.auth-identity .id-change:hover { background: var(--auth-primary-light); }

/* ═══════════════ TABS ═══════════════ */

.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #F2F4F7;
    border-radius: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--auth-text-muted);
    background: none;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: color .15s, background .15s, box-shadow .15s;
    font-family: var(--auth-font);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auth-tab:hover { color: var(--auth-text); }

.auth-tab.active {
    color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 1px 2px rgba(16,24,40,.06);
}

.auth-tab-panel { display: none; }
.auth-tab-panel.active { display: block; }

/* ═══════════════ ALERTS ═══════════════ */

.auth-alert {
    background: #FEF3F2;
    border: 1px solid #FECDCA;
    color: var(--auth-danger);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.auth-alert-icon { flex-shrink: 0; margin-top: 1px; }

.auth-alert-success {
    background: #ECFDF3;
    border-color: #ABEFC6;
    color: var(--auth-success);
}

/* ═══════════════ FIELDS ═══════════════ */

.auth-field { margin-bottom: 16px; }

.auth-field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--auth-text);
    margin-bottom: 6px;
}

.auth-field .field-input-wrap { position: relative; }

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="tel"] {
    width: 100%;
    height: 44px;
    padding: 0 38px 0 13px;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-button-radius);
    font-size: 14.5px;
    font-family: var(--auth-font);
    color: var(--auth-text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.auth-field input:focus {
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px var(--auth-primary-light);
}

.auth-field input.input-error { border-color: var(--auth-danger); }
.auth-field input.input-error:focus { box-shadow: 0 0 0 4px rgba(165,35,31,.10); }

.auth-field .field-error {
    font-size: 11.5px;
    color: var(--auth-danger);
    margin-top: 5px;
    min-height: 14px;
}

.auth-field .field-hint {
    font-size: 11.5px;
    color: var(--auth-text-muted);
    margin-top: 5px;
}

/* ═══════════════ PHONE COMBO ═══════════════ */

.auth-phone-combo {
    display: flex;
    gap: 0;
    position: relative;
}

.auth-phone-combo .auth-cc-btn {
    flex: 0 0 86px;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 1.5px solid var(--auth-border);
    border-right: none;
    border-radius: var(--auth-button-radius) 0 0 var(--auth-button-radius);
    background: #F9FAFB;
    font-size: 12.5px;
    font-family: var(--auth-font);
    color: var(--auth-text);
    cursor: pointer;
    position: relative;
}

.auth-phone-combo .auth-cc-btn:focus { border-color: var(--auth-primary); outline: none; }

.auth-phone-combo .auth-cc-btn .cc-flag-img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.auth-phone-combo .auth-cc-btn .cc-arrow {
    margin-left: auto;
    flex-shrink: 0;
}

.auth-phone-combo input[type="tel"] {
    flex: 1;
    border-radius: 0 var(--auth-button-radius) var(--auth-button-radius) 0;
}

/* ═══════════════ COUNTRY DROPDOWN ═══════════════ */

.auth-cc-dropdown {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    width: 280px;
    max-height: 260px;
    background: #fff;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-dropdown-radius);
    box-shadow: var(--sm-dropdown-shadow, 0 14px 34px rgba(16,24,40,.14), 0 4px 12px rgba(16,24,40,.08));
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
}

.auth-cc-dropdown.open { display: flex; }

.auth-cc-dropdown .ccd-search {
    padding: 8px;
    border-bottom: 1px solid #F2F4F7;
}

.auth-cc-dropdown .ccd-search input {
    width: 100%;
    height: 34px;
    padding: 0 9px;
    border: 1.5px solid var(--auth-border);
    border-radius: 7px;
    font-size: 12.5px;
    font-family: var(--auth-font);
    outline: none;
    background: #F9FAFB;
}

.auth-cc-dropdown .ccd-search input:focus { border-color: var(--auth-primary); }

.auth-cc-dropdown .ccd-list { overflow-y: auto; max-height: 210px; padding: 2px 0; }

.auth-cc-dropdown .ccd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--auth-text);
    transition: background .1s;
}

.auth-cc-dropdown .ccd-item:hover { background: var(--auth-primary-light); color: var(--auth-primary-hover); }
.auth-cc-dropdown .ccd-item.selected { background: var(--auth-primary-light); color: var(--auth-primary-hover); font-weight: 600; }
.auth-cc-dropdown .ccd-item .cc-flag-img { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; }
.auth-cc-dropdown .ccd-item .ccd-dial { color: var(--auth-text-muted); font-size: 11.5px; min-width: 38px; }
.auth-cc-dropdown .ccd-empty { padding: 14px; text-align: center; color: #98A2B3; font-size: 12.5px; }

/* ═══════════════ CONTROLS ═══════════════ */

.auth-toggle-pw {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--auth-text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
}

.auth-toggle-pw:hover { color: var(--auth-text); }

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    font-size: 12.5px;
}

.auth-options label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: var(--auth-text);
    font-weight: 500;
}

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

.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 12.5px;
    transition: color .15s;
}

.auth-link:hover {
    color: var(--auth-primary-hover);
    text-decoration: underline;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    border: none;
    border-radius: var(--auth-button-radius);
    background: var(--auth-primary);
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    font-family: var(--auth-font);
    cursor: pointer;
    transition: background .2s, box-shadow .2s, transform .1s;
    gap: 8px;
    text-decoration: none;
}

.auth-btn:hover {
    background: var(--auth-primary-hover);
    box-shadow: 0 8px 18px rgba(11,95,165,.22);
}

.auth-btn:active { transform: scale(0.99); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin .6s linear infinite;
    display: none;
}

/* The label stays put and changes to "Checking…" / "Signing in…" — a button that
   goes blank except for a spinner reads as broken. */
.auth-btn.loading .spinner { display: block; }
.auth-btn.loading .btn-arrow { display: none; }
.auth-btn.loading { background: var(--auth-primary-hover); box-shadow: none; }
.auth-btn:disabled { opacity: 1; }
.auth-btn:disabled:not(.loading) { opacity: .6; }

.auth-btn .btn-arrow { flex: 0 0 auto; opacity: .85; }

/* While a step is in flight the whole form is inert. */
.auth-form.is-busy { cursor: progress; }
.auth-form.is-busy input:disabled,
.auth-form.is-busy button:disabled { opacity: .7; }

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

.auth-divider {
    display: flex;
    align-items: center;
    margin: 18px 0;
    gap: 10px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

.auth-divider span {
    font-size: 11px;
    color: var(--auth-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}

.auth-btn-ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-button-radius);
    background: #fff;
    color: var(--auth-text);
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--auth-font);
    cursor: pointer;
    transition: background .15s, border-color .15s;
    gap: 7px;
    text-decoration: none;
}

.auth-btn-ghost:hover {
    background: #F9FAFB;
    border-color: #D0D5DD;
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--auth-text-muted);
}

.auth-footer a {
    color: var(--auth-text-muted);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover { text-decoration: underline; }

.auth-footer .af-sep { margin: 0 7px; opacity: .5; }

/* ═══════════════ SHARED PAGE PIECES ═══════════════ */

.auth-recaptcha-notice {
    font-size: 10.5px;
    color: #98A2B3;
    text-align: center;
    margin-top: 16px;
    line-height: 1.6;
}

.auth-recaptcha-notice a { color: #98A2B3; text-decoration: underline; }

.auth-recovery-options { margin-bottom: 20px; }

.auth-recovery-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--auth-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
}

.auth-recovery-card:hover {
    border-color: var(--auth-primary);
    background: var(--auth-primary-light);
}

.auth-recovery-card .rc-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--auth-primary-light);
    color: var(--auth-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.auth-recovery-card .rc-body { flex: 1; min-width: 0; }
.auth-recovery-card .rc-title { font-size: 13.5px; font-weight: 600; color: var(--auth-text); }
.auth-recovery-card .rc-desc { font-size: 12px; color: var(--auth-text-muted); margin-top: 1px; }
.auth-recovery-card .rc-arrow { flex-shrink: 0; color: #D0D5DD; }

.auth-confirm { text-align: center; padding: 40px 28px; }

.auth-confirm .confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ECFDF3;
    color: var(--auth-success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.auth-confirm h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

.auth-confirm p {
    font-size: 13.5px;
    color: var(--auth-text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ═══════════════ PASSWORD STRENGTH ═══════════════ */

.pw-strength { margin-top: 8px; }

.pw-strength-bar {
    height: 3px;
    border-radius: 2px;
    background: var(--auth-border);
    overflow: hidden;
    margin-bottom: 6px;
}

.pw-strength-bar .fill {
    height: 100%;
    border-radius: 2px;
    transition: width .3s, background .3s;
    width: 0;
}

.pw-strength-reqs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 11.5px;
    color: var(--auth-text-muted);
}

.pw-strength-reqs .req { display: flex; align-items: center; gap: 4px; }
.pw-strength-reqs .req.met { color: var(--auth-success); }

.pw-strength-reqs .req .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--auth-border);
    flex-shrink: 0;
}

.pw-strength-reqs .req.met .dot { background: var(--auth-success); }

/* ═══════════════ RESPONSIVE ═══════════════ */

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px 20px; }
    .auth-card h1 { font-size: 21px; }
    .auth-options { flex-direction: column; gap: 10px; align-items: flex-start; }
    .auth-cc-dropdown { width: 260px; }
    .auth-brandmark img { width: 30px; height: 30px; }
    .auth-brandmark .wb-wordmark { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-steps.js .auth-step.active { animation: none; }
}
