/* ============================================================================
   SCRIPT: modern-v3.css
   Created: 2026-08-13
   Purpose: Presentation layer for index3.cfm — the single-page ("one screen,
            progressive disclosure") rebuild of the patient scheduler.
            Unlike modern-v2.css, this does NOT restyle the classic modal
            markup: index3.cfm consumes the existing requestOnly/ endpoints as
            a DATA source and renders its own layout, so the class names here
            are ours.
   Theming: index3.cfm sets the --c-* custom properties from the client's
            appearanceJSON (identical config source as the classic scheduler).
   ========================================================================== */

:root {
    --c-primary: #2563eb;
    --c-secondary: #7c3aed;
    --c-body-bg: #f6f7fb;
    --c-body-text: #16202e;
    --c-primary-text: #ffffff;   /* text on primary fills; set by index3.cfm */
    --c-secondary-text: #ffffff; /* text on the secondary masthead bar */
    --c-alert-bg: var(--v3-accent-soft);
    --c-alert-text: var(--v3-ink);

    --v3-canvas: color-mix(in srgb, var(--c-body-bg) 8%, #f6f7f9);
    --v3-surface: #ffffff;
    --v3-ink: var(--c-body-text);
    --v3-ink-soft: #64748b;
    --v3-ink-faint: #94a3b8;
    --v3-line: #e6e9ef;
    --v3-line-strong: #d3d9e3;
    --v3-radius: 16px;
    --v3-radius-sm: 10px;
    --v3-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --v3-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 10px 30px rgba(16, 24, 40, 0.06);
    --c-primary-ink: var(--c-primary); /* overridden per-client by index3.cfm */
    --v3-accent-soft: color-mix(in srgb, var(--c-primary) 8%, white);
    --v3-accent-line: color-mix(in srgb, var(--c-primary) 30%, white);
}

* { box-sizing: border-box; }

body.v3 {
    margin: 0;

    /* Same page background as the classic scheduler (index.cfm): the shared
       images/bg2.jpg medical abstract over the client's configured bodyColor,
       fixed so it does not scroll with the content, plus a soft brand-tinted
       wash so the client's primary color still reads through. The art is
       light, so dark page-head text over it stays legible.

       The background-image itself is emitted per client by index3.cfm because
       it depends on the dashboard's bodyImage setting. These single-value
       properties apply to every layer, so they hold for either case. */
    background-color: var(--v3-canvas);
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;

    color: var(--v3-ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------------
   Masthead
--------------------------------------------------------------------------- */
.v3-masthead {
    /* The classic scheduler paints its nav bar with secondaryColor and writes
       on it in secondaryTextColor; this keeps that contract. */
    background: var(--c-secondary);
    color: var(--c-secondary-text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.v3-masthead-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.v3-brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.v3-brand img { max-height: 42px; max-width: 190px; object-fit: contain; }

.v3-brand-text { min-width: 0; }
.v3-brand-name {
    font-weight: 650;
    font-size: 0.98rem;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
.v3-brand-sub { font-size: 0.78rem; color: var(--c-secondary-text); opacity: 0.75; }

.v3-masthead-meta {
    font-size: 0.8rem;
    color: var(--c-secondary-text);
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-align: right;
}

/* ---------------------------------------------------------------------------
   Page shell
--------------------------------------------------------------------------- */
.v3-wrap {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 4rem;
}

.v3-pagehead { margin-bottom: 1.5rem; }

.v3-pagehead h1 {
    margin: 0 0 0.3rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 680;
    letter-spacing: -0.025em;
}

.v3-pagehead p { margin: 0; color: var(--v3-ink-soft); max-width: 60ch; }

/* Practice-authored preview message (settingsJSON.previewMessage). Given its
   own voice so it does not read as part of the page's own instructions. */
.v3-notice {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    margin-top: 0.9rem;
    padding: 0.7rem 0.9rem;
    max-width: 66ch;
    border: 1px solid color-mix(in srgb, var(--c-primary) 20%, white);
    border-left: 4px solid var(--c-primary);
    border-radius: var(--v3-radius-sm);
    background: var(--c-alert-bg);
    font-size: 0.86rem;
    color: var(--c-alert-text);
}

.v3-notice i { color: var(--c-primary-ink); line-height: 1.4; flex: none; }

.v3-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 900px) {
    .v3-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------------------
   Step cards
--------------------------------------------------------------------------- */
.v3-step {
    background: var(--v3-surface);
    border: 1px solid var(--v3-line);
    border-radius: var(--v3-radius);
    box-shadow: var(--v3-shadow-sm);
    padding: 1.15rem 1.25rem 1.25rem;
    margin-bottom: 1rem;
    transition: opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* A step the patient cannot act on yet: visible (so the whole journey is
   legible up front) but muted and non-interactive. */
.v3-step.is-locked {
    opacity: 0.5;
    pointer-events: none;
    filter: saturate(0.5);
}

.v3-step.is-active {
    border-color: var(--v3-accent-line);
    box-shadow: var(--v3-shadow);
}

.v3-step-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.15rem;
}

.v3-step-num {
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--v3-accent-soft);
    color: var(--c-primary-ink);
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.v3-step.is-done .v3-step-num { background: var(--c-primary); color: var(--c-primary-text); }

.v3-step h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.v3-step-hint {
    margin: 0.1rem 0 0.9rem 2.2rem;
    font-size: 0.83rem;
    color: var(--v3-ink-soft);
}

.v3-step-body { margin-left: 2.2rem; }

@media (max-width: 560px) {
    .v3-step-body, .v3-step-hint { margin-left: 0; }
}

/* ---------------------------------------------------------------------------
   Option chips (locations, providers, reasons)
--------------------------------------------------------------------------- */
.v3-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.v3-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    border: 1.5px solid var(--v3-line-strong);
    border-radius: 999px;
    background: var(--v3-surface);
    color: var(--v3-ink);
    font: inherit;
    font-weight: 550;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.v3-chip:hover { border-color: var(--c-primary); transform: translateY(-1px); }

.v3-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 25%, transparent);
}

.v3-chip.is-selected {
    border-color: var(--c-primary);
    background: var(--v3-accent-soft);
    box-shadow: inset 0 0 0 1px var(--c-primary);
}

/* provider chips carry an avatar */
.v3-chip .v3-avatar {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    background: var(--v3-accent-soft);
    margin-left: -0.35rem;
}

.v3-chip-label { display: block; }
.v3-chip-sub {
    display: block;
    font-size: 0.74rem;
    font-weight: 450;
    color: var(--v3-ink-soft);
}

/* wider tap targets for location chips, which carry addresses */
.v3-chip.v3-chip-block {
    border-radius: var(--v3-radius-sm);
    align-items: flex-start;
    padding: 0.7rem 0.95rem;
}

/* ---------------------------------------------------------------------------
   Provider cards

   Providers get cards rather than chips because many carry a real bio
   (practitionerJSON.BIO) that is several sentences long. The bio is clamped to
   three lines so a long write-up cannot push the rest of the page down; the
   full text is available on hover/focus via the title attribute and expands
   when the card is selected.
--------------------------------------------------------------------------- */
.v3-providers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.65rem;
}

.v3-provider {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    text-align: left;
    padding: 0.85rem 0.95rem;
    border: 1.5px solid var(--v3-line-strong);
    border-radius: var(--v3-radius-sm);
    background: var(--v3-surface);
    color: var(--v3-ink);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.v3-provider:hover {
    border-color: var(--c-primary);
    transform: translateY(-1px);
    box-shadow: var(--v3-shadow-sm);
}

.v3-provider:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 25%, transparent);
}

.v3-provider.is-selected {
    border-color: var(--c-primary);
    background: var(--v3-accent-soft);
    box-shadow: inset 0 0 0 1px var(--c-primary);
}

.v3-provider-media { flex: none; }

.v3-provider-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    background: var(--v3-accent-soft);
    display: block;
}

.v3-provider-icon {
    font-size: 2.3rem;
    line-height: 1;
    color: var(--v3-ink-faint);
    display: block;
}

.v3-provider-text { min-width: 0; }

.v3-provider-name {
    font-weight: 620;
    font-size: 0.92rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.v3-provider-bio {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--v3-ink-soft);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Selecting a provider reveals their full bio — by then it is the only one
   on screen the patient still cares about. */
.v3-provider.is-selected .v3-provider-bio {
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Provider filter, shown only for practices with a long provider list */
.v3-search {
    position: relative;
    margin-bottom: 0.75rem;
    max-width: 340px;
}

.v3-search i {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--v3-ink-faint);
    font-size: 0.9rem;
    pointer-events: none;
}

.v3-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.1rem;
    border: 1.5px solid var(--v3-line-strong);
    border-radius: 999px;
    font: inherit;
    font-size: 0.88rem;
    color: var(--v3-ink);
    background: var(--v3-surface);
}

.v3-search input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 16%, transparent);
}

.v3-search-empty { margin-top: 0.6rem; }

/* ---------------------------------------------------------------------------
   Date strip
--------------------------------------------------------------------------- */
.v3-datebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.v3-daterange { font-size: 0.86rem; font-weight: 600; color: var(--v3-ink); }

.v3-navbtns { display: flex; gap: 0.35rem; }

.v3-navbtn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid var(--v3-line-strong);
    background: var(--v3-surface);
    color: var(--v3-ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.v3-navbtn:hover:not(:disabled) { border-color: var(--c-primary); background: var(--v3-accent-soft); }
.v3-navbtn:disabled { opacity: 0.4; cursor: not-allowed; }

.v3-days {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84px, 1fr);
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
}

.v3-day {
    border: 1.5px solid var(--v3-line);
    border-radius: var(--v3-radius-sm);
    background: var(--v3-surface);
    padding: 0.6rem 0.4rem;
    text-align: center;
    cursor: pointer;
    font: inherit;
    color: var(--v3-ink);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.v3-day:hover:not(:disabled) { border-color: var(--c-primary); transform: translateY(-1px); }

.v3-day-dow {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--v3-ink-soft);
}

.v3-day-num { font-size: 1.15rem; font-weight: 650; line-height: 1.25; }

.v3-day-count { font-size: 0.68rem; color: var(--v3-ink-soft); }

.v3-day.is-selected {
    border-color: var(--c-primary);
    background: var(--c-primary);
}
.v3-day.is-selected .v3-day-dow,
.v3-day.is-selected .v3-day-num,
.v3-day.is-selected .v3-day-count { color: var(--c-primary-text); }

.v3-day:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: transparent;
}
.v3-day:disabled .v3-day-count { color: var(--v3-ink-faint); }

/* ---------------------------------------------------------------------------
   Time chips, grouped by part of day
--------------------------------------------------------------------------- */
.v3-timegroup { margin-top: 1.1rem; }

.v3-timegroup-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--v3-ink-soft);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.v3-times {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.5rem;
}

.v3-time {
    padding: 0.55rem 0.4rem;
    border: 1.5px solid var(--v3-line-strong);
    border-radius: var(--v3-radius-sm);
    background: var(--v3-surface);
    color: var(--c-primary-ink);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.13s ease;
}

.v3-time:hover:not(:disabled) {
    border-color: var(--c-primary);
    background: var(--v3-accent-soft);
    transform: translateY(-1px);
}

.v3-time.is-selected {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: var(--c-primary-text);
}

.v3-time:disabled {
    color: var(--v3-ink-faint);
    border-color: var(--v3-line);
    border-style: dashed;
    background: transparent;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* ---------------------------------------------------------------------------
   Details form
--------------------------------------------------------------------------- */
.v3-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

@media (max-width: 620px) { .v3-fields { grid-template-columns: minmax(0, 1fr); } }

.v3-field.v3-field-full { grid-column: 1 / -1; }

.v3-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--v3-ink);
    margin-bottom: 0.3rem;
}

.v3-field input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--v3-line-strong);
    border-radius: var(--v3-radius-sm);
    font: inherit;
    font-size: 0.92rem;
    color: var(--v3-ink);
    background: var(--v3-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.v3-field input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 18%, transparent);
}

/* Only flag a field AFTER the patient has interacted with it. :invalid alone
   would paint every empty required field red on first paint — and date inputs
   have no placeholder, so the :placeholder-shown guard does not cover them. */
.v3-field input:user-invalid { border-color: #e11d48; }

.v3-field-note { font-size: 0.75rem; color: var(--v3-ink-soft); margin-top: 0.2rem; }

/* ---------------------------------------------------------------------------
   Summary rail
--------------------------------------------------------------------------- */
.v3-rail { position: sticky; top: 1.25rem; }

.v3-summary {
    background: var(--v3-surface);
    border: 1px solid var(--v3-line);
    border-radius: var(--v3-radius);
    box-shadow: var(--v3-shadow);
    overflow: hidden;
}

.v3-summary-head {
    padding: 0.95rem 1.15rem;
    background: linear-gradient(135deg,
        var(--c-primary) 0%,
        color-mix(in srgb, var(--c-primary) 60%, var(--c-secondary)) 100%);
    color: var(--c-primary-text);
}

.v3-summary-head .v3-summary-kicker {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
}

.v3-summary-head h3 { margin: 0.1rem 0 0; font-size: 1.05rem; font-weight: 650; }

.v3-summary-body { padding: 1rem 1.15rem 1.15rem; }

.v3-sumrow {
    display: flex;
    gap: 0.7rem;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--v3-line);
}
.v3-sumrow:last-of-type { border-bottom: none; }

.v3-sumrow i { color: var(--c-primary-ink); font-size: 0.95rem; line-height: 1.45; flex: none; }

.v3-sumrow-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--v3-ink-soft);
}

.v3-sumrow-value { font-size: 0.9rem; font-weight: 550; }
.v3-sumrow-value.is-empty { color: var(--v3-ink-faint); font-weight: 400; }

.v3-confirm {
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--v3-radius-sm);
    background: var(--c-primary);
    color: var(--c-primary-text);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.12s ease;
}

.v3-confirm:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }

/* The disabled button is no longer a brand surface, so it must not inherit the
   brand's text color — a light primaryTextColor on grey is unreadable. */
.v3-confirm:disabled {
    background: var(--v3-line);
    color: var(--v3-ink-soft);
    cursor: not-allowed;
    transform: none;
}

.v3-confirm-note {
    margin-top: 0.6rem;
    font-size: 0.74rem;
    color: var(--v3-ink-soft);
    text-align: center;
}

.v3-startover {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--v3-ink-soft);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Feedback: loading, empty, error
--------------------------------------------------------------------------- */
.v3-loading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--v3-ink-soft);
    font-size: 0.88rem;
    padding: 0.6rem 0;
}

.v3-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--v3-line-strong);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: v3spin 0.7s linear infinite;
}

@keyframes v3spin { to { transform: rotate(360deg); } }

.v3-empty {
    border: 1px dashed var(--v3-line-strong);
    border-radius: var(--v3-radius-sm);
    padding: 1.1rem;
    text-align: center;
    color: var(--v3-ink-soft);
    font-size: 0.88rem;
    background: color-mix(in srgb, var(--c-primary) 2%, white);
}

.v3-empty strong { color: var(--v3-ink); display: block; margin-bottom: 0.2rem; }

.v3-alert {
    border-radius: var(--v3-radius-sm);
    padding: 0.75rem 0.95rem;
    font-size: 0.88rem;
    border: 1px solid #fecdd3;
    background: #fff1f2;
    color: #9f1239;
    margin-top: 0.75rem;
}

.v3-alert.is-hidden { display: none; }

.v3-footer {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
    color: var(--v3-ink-faint);
    font-size: 0.76rem;
    text-align: center;
}

.v3-linkbtn {
    background: none;
    border: none;
    padding: 0;
    color: var(--c-primary-ink);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
