/* ==========================================================================
   Modern auth layout — shared across TellWilma, AskWilma, and PracticeOS
   auth pages (login, register, verify, reset, invite, pending, etc.)
   ========================================================================== */

body.light-bg { background: #f4f6f2; }

/* Prevent double vertical scrollbar on auth pages.
   portal-global.css applies `html, body { overflow-x: hidden; max-width: 100vw; }`
   which turns html AND body into independently sized layout boxes — on narrow
   viewports (where auth content is much taller than the viewport) the browser
   renders a scrollbar on EACH. Constrain scrolling to the browser's viewport
   (html) only; body stays visible. !important defeats portal-global.css which
   uses the same selector specificity. */
html:has(.auth-page) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    max-width: 100% !important;
    height: auto !important;
}
body:has(.auth-page) {
    overflow-x: hidden !important;
    overflow-y: visible !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
}

.footer { display: none !important; }

/* Apply border-box to every auth descendant so padding never blows past the container width */
.auth-page, .auth-page *, .auth-page *::before, .auth-page *::after { box-sizing: border-box; }

.auth-page {
    min-height: 100dvh; /* dynamic viewport — respects iOS address bar */
    padding: 32px 20px;
    display: flex;
    /* `safe center` falls back to `flex-start` when content is taller than the
       flex container — prevents the top of the card from being pushed above
       the visible area on mobile, which is what was creating the second
       scrollbar (browser was rendering scroll on both html and body). */
    align-items: safe center;
    justify-content: center;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1a2b1a;
}

.auth-shell {
    width: 100%;
    max-width: 100%;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px -20px rgba(45, 90, 20, 0.25), 0 4px 12px rgba(0,0,0,0.04);
    overflow: hidden;
}

/* Compact: centered single-column card (login, verify, reset, pending, etc.) */
.auth-shell--compact {
    max-width: 460px;
    padding: 40px 40px 32px;
}
.auth-shell--compact .auth-card__brand {
    display: block;
    text-align: center;
    margin-bottom: 24px;
}
.auth-shell--compact .auth-card__brand img {
    width: 120px;
}

/* Wide: for long content like terms */
.auth-shell--wide {
    max-width: 820px;
    padding: 48px 56px;
}

/* Split: two-column with hero (register) */
.auth-shell--split {
    max-width: 980px;
    display: grid;
    grid-template-columns: 1fr 1.2fr;
}

/* Hero panel (left side of split) */
.auth-hero {
    background: linear-gradient(155deg, #1f4d1a 0%, #2d8a00 60%, #58b42f 100%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    align-items: stretch;
}
.auth-hero__inner { display: flex; flex-direction: column; width: 100%; }
.auth-hero__brand { display: inline-block; margin-bottom: 40px; }
.auth-hero__brand img { width: 140px; filter: brightness(0) invert(1); }
.auth-hero__title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px;
    letter-spacing: -0.5px;
}
.auth-hero__tagline {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255,255,255,0.88);
    margin: 0 0 28px;
}
.auth-hero__bullets { list-style: none; padding: 0; margin: 0 0 auto; font-size: 13.5px; }
.auth-hero__bullets li {
    padding: 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: rgba(255,255,255,0.92);
    line-height: 1.5;
}
.auth-hero__check {
    background: rgba(255,255,255,0.18);
    color: #fff;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    margin-top: 1px;
}
.auth-hero__foot {
    margin: 32px 0 0;
    font-size: 11px;
    color: rgba(255,255,255,0.65);
}

/* Card (right side of split, or primary content in compact).
   No overflow:auto — otherwise inputs appearing/disappearing trigger a blinking scrollbar on desktop. */
.auth-card { padding: 44px 48px; background: #fff; }
.auth-shell--compact .auth-card { padding: 0; }
.auth-shell--wide .auth-card { padding: 0; }

.auth-card__head { text-align: left; margin-bottom: 24px; }
.auth-shell--compact .auth-card__head { text-align: center; }
.auth-card__head h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px;
    color: #1a2b1a;
}
.auth-card__head p {
    font-size: 13.5px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}
.auth-card__icon {
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: rgba(45, 138, 0, 0.1);
    color: #2d8a00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.auth-shell--compact .auth-card__icon { display: flex; }

/* Flash messages */
.auth-flash {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.auth-flash--ok { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.auth-flash--err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.auth-flash--warn { background: #fef7ec; color: #854d0e; border: 1px solid #fde68a; }

/* Forms */
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field__labelrow { display: flex; align-items: center; justify-content: space-between; }
.auth-field label {
    font-size: 12.5px;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.auth-field__hint { font-size: 11.5px; color: #9ca3af; font-weight: 400; }
.auth-req { color: #dc2626; font-weight: 600; }

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="tel"],
.auth-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    /* 16px, not 13.5px: iOS Safari zooms the whole page on focus when a text
       input is under 16px, which throws the login form off-screen mid-typing.
       Every seasonal theme partial already forces 16px !important, and the
       theme calendar now covers every day of the year, so 16px is what users
       actually see -- this only ever applied on the bare shell reached via
       ?login_theme=none or the LOGIN_THEMES_ENABLED kill switch (which exists
       for sales demos, frequently on mobile). Aligning the base removes the
       discrepancy rather than leaving two different rendered sizes. */
    font-size: 16px;
    color: #1f2937;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    height: auto;
    box-shadow: none;
}
.auth-form input:focus {
    outline: none;
    border-color: #2d8a00;
    box-shadow: 0 0 0 3px rgba(45, 138, 0, 0.15);
}
.auth-form input.has-error,
.auth-form input.is-invalid { border-color: #dc2626; }
.auth-form input[readonly] { background: #f5f5f5; color: #6b7280; }

.auth-error { font-size: 12px; color: #dc2626; margin: 2px 0 0; }
.auth-linkbtn {
    background: none;
    border: 0;
    padding: 0;
    font-size: 12px;
    color: #2d8a00;
    font-weight: 500;
    cursor: pointer;
}
.auth-linkbtn:hover { text-decoration: underline; }

/* OTP / code input */
.auth-form input.auth-otp {
    text-align: center;
    font-size: 22px;
    letter-spacing: 8px;
    font-weight: 600;
    font-family: 'Roboto Mono', 'SF Mono', Consolas, monospace;
    padding: 14px 12px;
}

/* Strength meter */
.auth-strength { margin-top: 6px; }
.auth-strength__bars { display: flex; gap: 4px; margin-bottom: 6px; }
.auth-strength__bars span {
    flex: 1; height: 3px; background: #e5e7eb; border-radius: 2px;
    transition: background 0.2s;
}
.auth-strength__reqs {
    display: flex; flex-wrap: wrap; gap: 4px 10px;
    font-size: 11px; color: #6b7280;
}
.auth-strength__reqs span.ok { color: #2d8a00; }
.auth-match { font-size: 12px; margin: 2px 0 0; color: #dc2626; }
.auth-match.ok { color: #2d8a00; }

/* Password requirements checklist (used in reset/invite flows) */
.auth-reqs { list-style: none; padding: 0; margin: 4px 0 0; font-size: 12px; color: #6b7280; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.auth-reqs li { padding-left: 18px; position: relative; line-height: 1.5; }
.auth-reqs li::before { content: '✗'; position: absolute; left: 0; color: #d1d5db; font-weight: 600; }
.auth-reqs li.ok { color: #2d8a00; }
.auth-reqs li.ok::before { content: '✓'; color: #2d8a00; }

/* SMS consent box */
.auth-consent {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
    background: #f8faf6;
    border: 1px solid #e3ead9;
    border-radius: 10px;
    margin: 4px 0 0;
    cursor: pointer;
}
.auth-consent input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
    pointer-events: none;
}
.auth-consent__box {
    width: 16px; height: 16px;
    border: 1.5px solid #9ca3af;
    border-radius: 4px;
    background: #fff;
    position: relative;
    margin-top: 2px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.auth-consent:hover .auth-consent__box { border-color: #2d8a00; }
.auth-consent input:checked ~ .auth-consent__box {
    background: #2d8a00;
    border-color: #2d8a00;
}
.auth-consent input:checked ~ .auth-consent__box::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 4px; height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.auth-consent input:focus-visible ~ .auth-consent__box {
    box-shadow: 0 0 0 3px rgba(45, 138, 0, 0.2);
}
.auth-consent__text { font-size: 12px; line-height: 1.55; color: #4b5563; }
.auth-consent__links { display: block; margin-top: 4px; font-size: 11.5px; color: #9ca3af; }
.auth-consent__links a { color: #2d8a00; text-decoration: none; font-weight: 500; }
.auth-consent__links a:hover { text-decoration: underline; }

/* Submit + secondary buttons */
.auth-submit {
    margin-top: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #2d8a00;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    width: 100%;
}
.auth-submit:hover:not(:disabled) { background: #256e00; }
.auth-submit:active:not(:disabled) { transform: translateY(1px); }
.auth-submit:disabled {
    background: #cbd6d2;
    color: #fff;
    cursor: not-allowed;
}

.auth-btn-ghost {
    display: inline-block;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 500;
    color: #2d8a00;
    background: transparent;
    border: 1px solid #2d8a00;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.auth-btn-ghost:hover { background: #f0f7eb; color: #2d8a00; text-decoration: none; }

/* Fine print / helper links below form */
.auth-fineprint {
    font-size: 11.5px;
    color: #9ca3af;
    text-align: center;
    line-height: 1.6;
    margin: 4px 0 0;
}
.auth-fineprint a { color: #2d8a00; text-decoration: none; font-weight: 500; }
.auth-fineprint a:hover { text-decoration: underline; }

.auth-altlink {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin: 12px 0 0;
}
.auth-altlink a { color: #2d8a00; font-weight: 500; text-decoration: none; position: relative; }
/* The link is drawn 16px tall ("Back to sign in", "Forgot password?"). Its hit area is 24px
   (WCAG 2.5.8) through an invisible layer centred on the text; the drawn link is unchanged. */
.auth-altlink a::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 24px; transform: translateY(-50%); }
.auth-altlink a:hover { text-decoration: underline; }

/* Content page body (sms-terms, etc.) */
.auth-prose { font-size: 14.5px; line-height: 1.7; color: #374151; }
.auth-prose h1 { font-size: 26px; font-weight: 700; color: #1a2b1a; margin: 0 0 8px; }
.auth-prose h2 { font-size: 17px; font-weight: 600; color: #1a2b1a; margin: 28px 0 8px; }
.auth-prose p { margin: 0 0 12px; }
.auth-prose ul { padding-left: 22px; margin: 0 0 12px; }
.auth-prose a { color: #2d8a00; text-decoration: none; font-weight: 500; }
.auth-prose a:hover { text-decoration: underline; }
.auth-prose__meta { color: #6b7280; font-size: 13px; margin-bottom: 24px; }

/* Tenant-branded (Stripe-Connect style) invite/registration shell.
   Left hero carries the tenant's logo + name; right card shows the
   dual-brand connector dots and a "Powered by Wilma" badge to make
   it unambiguous that the end user is registering on the Wilma
   platform on behalf of the host tenant. */
.auth-shell--tenant { max-width: 1040px; }
.auth-hero--tenant {
    background: linear-gradient(155deg, #13331a 0%, #1f4d1a 55%, #2d8a00 100%);
}

.auth-tenant__brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.18);
}
/* Logo-only variant: full wordmark shown without a text label.
   Block layout so the logo occupies its natural width without being squeezed
   by a sibling text node. */
.auth-tenant__brand--logo-only {
    display: block;
}

.auth-tenant__logo {
    display: block;
    max-height: 64px;
    max-width: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
}
/* White/monochrome logo: reads directly on the dark hero gradient, no plate. */
.auth-tenant__logo--white {
    background: transparent;
    padding: 0;
}
/* Color logo: drop into a subtle white plate so dark logos stay legible on
   the green gradient. Sized to fit the logo with generous breathing room. */
.auth-tenant__logo--plated {
    background: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    max-height: 72px;   /* slightly taller to compensate for plate padding */
}

.auth-tenant__monogram {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: #fff;
    color: #1f4d1a;
    font-weight: 700;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.auth-tenant__name {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.2px;
}

.auth-tenant__powered {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.18);
}
.auth-tenant__powered-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.auth-tenant__powered-brand { display: inline-flex; }
.auth-tenant__powered-brand img {
    height: 18px;
    filter: brightness(0) invert(1);
    opacity: 0.92;
}

.auth-tenant__footnote {
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px dashed #e5e7eb;
    font-size: 11.5px;
    line-height: 1.6;
    color: #9ca3af;
    text-align: center;
}
.auth-tenant__footnote a {
    color: #2d8a00;
    text-decoration: none;
    font-weight: 500;
}
.auth-tenant__footnote a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 860px) {
    .auth-page { padding: 16px; }
    .auth-shell--split { grid-template-columns: 1fr; max-width: 520px; }
    .auth-hero { padding: 32px 28px; }
    .auth-hero__brand { margin-bottom: 20px; }
    .auth-hero__title { font-size: 22px; }
    .auth-hero__bullets,
    .auth-hero__foot { display: none; }
    .auth-card { padding: 28px 24px; }
    .auth-shell--wide { padding: 32px 28px; }

    .auth-shell--tenant { max-width: 520px; }
    .auth-tenant__brand { margin-bottom: 18px; padding-bottom: 14px; }
    .auth-tenant__powered { display: none; }
}
@media (max-width: 480px) {
    .auth-field-row { grid-template-columns: 1fr; }
    .auth-reqs { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 20px; }
    .auth-shell--compact { padding: 28px 24px; }
}
