/*
 * #3739 shared suggestion card: the parts js/appointment-card.js added for the booking card
 * (date / time editor, open-time chips, notices, Review, disabled buttons). Design-system
 * tokens only, so light and dark follow the theme (docs/ui/3739-suggestion-card-spec.md s5).
 * The card's older parts keep their inline TONES for now (the style migration moves them).
 */

/* A disabled button looks disabled, on every card (spec s5). */
.appt-card button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* #4008: the page's dark theme paints a disabled .btn-primary gray-800 (!important), which is the card's own
 * dark background now that the card is not blue: a disabled Confirm vanished. On the card it keeps its color,
 * dimmed, so it reads as "not yet" rather than missing. */
.appt-card .appt-card-actions button.btn-primary:disabled {
    background: var(--btn-bg) !important;
    color: var(--btn-text) !important;
}

/* ---- the date / time editor ---- */
.appt-card-when-edit {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin: 0.25rem 0 0.375rem;
}
.appt-card-times {
    display: flex;
    align-items: flex-end;
    gap: 0.375rem;
}
.appt-card-times .appt-card-field { flex: 1 1 0; min-width: 0; }
.appt-card-times-to {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-bottom: 0.55rem;
}
.appt-card-field {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin: 0;
}
.appt-card-field-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}
/* Native date / time pickers follow the theme (their icons are black on a dark card otherwise).
 * #4008: iOS ignores width on a native date / time input and lets it overflow the card; appearance: none
 * plus an explicit block width keeps it inside (Michael's iPhone, 2026-10-07). */
.appt-card-input {
    color-scheme: light dark;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
}
.appt-card-input::-webkit-date-and-time-value { text-align: left; }
/* #4008 (Michael 2026-10-07): an empty time box shows "Start" / "End" inside it, faint; iOS has no placeholder
 * for type=time, so a label overlays the box (taps go through) and the native empty value is hidden under it. */
.appt-card-input-wrap { position: relative; display: block; min-width: 0; }
.appt-card-input-hint {
    display: none;
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    opacity: 0.7;
    pointer-events: none;
    font-size: 0.85rem;
}
.appt-card-input-wrap[data-empty="true"] .appt-card-input-hint { display: block; }
.appt-card-input-wrap[data-empty="true"] .appt-card-input::-webkit-datetime-edit { color: transparent; }

/* #4008: the three selects fill the card's width (two share a line), not 150px islands */
.appt-card--booking .appt-card-controls select {
    max-width: none !important;
    flex: 1 1 calc(50% - 0.375rem) !important;
}

/* #4008 (Michael 2026-10-07: "sizing of everything seems off"): ONE control height on the booking card for the
 * date and time boxes, the three selects and the time chips: 32px on a desktop, 36px on a phone. */
.appt-card--booking { --appt-ctl-h: 32px; }
.appt-card--booking .appt-card-input,
.appt-card--booking .appt-card-controls select,
.appt-card--booking .appt-card-slot {
    height: var(--appt-ctl-h);
    min-height: 0;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
}

/* ---- open-time chips (#4008: the standard secondary-button look, not a dark pill) ---- */
.appt-card-slots { margin: 0 0 0.375rem; }
.appt-card-slots-heading {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.appt-card-slot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.appt-card-slot {
    border: 1px solid var(--border-strong);
    background: var(--bg-nested);
    color: var(--text);
    border-radius: 0.375rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
}
.appt-card-slot:hover { background: var(--bg-hover); }
.appt-card-slot.is-selected {
    background: var(--btn-bg);
    border-color: var(--btn-bg);
    color: var(--btn-text);
}
/* #4008 (Michael 2026-10-07): on the booking card the times sit in rows of four, at most two rows a page; with
 * more than one page an up / down pair at the right pages through them, and the block stays two rows tall so the
 * links under it (Next open day, Show calendar) never move. */
.appt-card--booking .appt-card-slot-chips {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.appt-card--booking .appt-card-slot {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.appt-card-slot-paged {
    display: flex;
    gap: 0.375rem;
    align-items: flex-start;
}
.appt-card-slot-paged .appt-card-slot-chips {
    flex: 1 1 auto;
    min-width: 0;
    grid-template-rows: repeat(2, var(--appt-ctl-h, 32px));
}
.appt-card-slot-pager {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.appt-card-slot-page {
    height: var(--appt-ctl-h, 32px);
    width: var(--appt-ctl-h, 32px);
    border: 1px solid var(--border-strong);
    background: var(--bg-nested);
    color: var(--text);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.appt-card-slot-page:hover:not(:disabled) { background: var(--bg-hover); }

.appt-card-slots-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.appt-card-slot-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

/* #4008: a chip that opens its record (#TK / #INQ) says it can be tapped */
.appt-card-chip--link:hover,
.appt-card-chip--link:focus-visible { text-decoration: underline; }

/* A quiet text link (Next open day, Show calendar, Book a second appointment anyway). */
.appt-card-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.8rem;
    color: var(--info-text);
    text-decoration: underline;
    cursor: pointer;
}

/* ---- notices (busy, not scheduled, already booked, errors) ---- */
.appt-card-notice {
    margin: 0.375rem 0 0;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
}

/* ---- the Review ---- */
.appt-card-review { margin: 0.25rem 0 0; }
.appt-card-review-rows {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}
.appt-card-review-rows li {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text);
}
.appt-card-review-rows li span:first-child {
    flex: 0 0 4.5rem;
    color: var(--text-muted);
}
.appt-card-review-rows li span:last-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.appt-card-text-heading {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin: 0.5rem 0 0.25rem;
}
/* The EXACT customer text, verbatim (line breaks kept). */
.appt-card-quote {
    margin: 0;
    padding: 0.5rem 0.625rem;
    border-left: 3px solid var(--info-border);
    background: var(--bg-nested);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text);
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.appt-card-review-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---- the text toggle as the row above the actions (the booking card) ---- */
.appt-card-toggle-row--footer {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* #4016: a box that cannot be ticked (the customer cannot be texted) reads as off: its label is muted too */
.appt-card-toggle-row:has(input[data-toggle]:disabled) .appt-card-toggle-label {
    color: var(--text-muted) !important;
    cursor: default !important;
}

/* ---- the text toggle's hint (an external booking already confirmed) ---- */
.appt-card-toggle-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: -0.125rem 0 0.25rem 1.75rem;
}

/* ---- the booking card on a phone: 44px targets (spec s5) ---- */
@media (max-width: 768px), (pointer: coarse) {
    .appt-card--booking { --appt-ctl-h: 36px; }
    /* #4008 margins (Michael 2026-10-07): the card's own padding is 12px on a phone, and the Schedule
     * Appointment modal is full width, so the card sits 16px from the screen there too, as in the sheet
     * (the modal's 20px margin + 32px content padding + 16px body padding stacked to ~68px). */
    .appt-card--booking { padding: 0.625rem 0.75rem !important; }
    #appointment-modal .modal-content {
        width: 100vw;
        max-width: 100vw !important;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
        border-radius: 0;
    }
    .appt-card--booking .appt-card-actions button {
        min-height: 44px;
    }
    .appt-card--booking .appt-card-actions button { flex: 1 1 auto; }
    .appt-card--booking .appt-card-link { min-height: 44px; }
    /* 16px so iOS does not zoom on focus; the height is the one control height above */
    .appt-card--booking select { font-size: 16px !important; }
    .appt-card--booking .appt-card-input { font-size: 16px; }
}

/* ---- the ticket badge's booking popover (#3739 spec s1) ----
 * Positioned by the page through custom properties only (--popover-top / --popover-left, and
 * --popover-width on a phone). Desktop: 360px under the badge. Phone (the page adds
 * .appt-booking-popover--phone from screen.width / visualViewport, never innerWidth, which this
 * page inflates): the visible width minus the 16px gutters, never a fixed box past the edge. */
.appt-booking-popover {
    position: fixed;
    top: var(--popover-top, 16px);
    left: var(--popover-left, 16px);
    z-index: 10000;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - var(--popover-top, 16px) - 16px);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 0.375rem;
}
.appt-booking-popover .appt-card { margin-bottom: 0; }
/* #4076: placement 'center' (desktop only): a modal over a scrim, in the middle of the window, at most 90% of its height */
.appt-booking-scrim--center { z-index: 9999; }
.appt-booking-popover--center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100vw - 32px));
    max-height: 90vh;
    max-height: 90dvh;
    z-index: 10000;
}
.appt-booking-popover--center:focus { outline: none; }
/* #4008: the popover's top bar, as the phone sheet's: "Suggested appointment", [Open ticket], x */
.appt-booking-popover-head {
    gap: 0.375rem;
    padding: 0.125rem 0.125rem 0.375rem 0.375rem;
    font-size: 0.9rem;
}
.appt-booking-popover-head .appt-booking-sheet-close { min-width: 32px; min-height: 32px; font-size: 1.25rem; }
/* ---- on a phone the badge opens a BOTTOM SHEET instead (loop326, Michael's native-patterns rule) ----
 * As the #3928 Call Log sheet: the page picks it from screen.width / visualViewport (never a width
 * query: this page inflates the layout width); z-index just under the modal band (every modal on
 * admin_tickets is >= 1000), so the scheduler opened by Modify stacks above it; the bottom tab bar
 * is hidden while it is open (body.appt-sheet-open). */
.appt-booking-scrim {
    position: fixed;
    inset: 0;
    z-index: 955;
    background: rgba(0, 0, 0, 0.45);
}
.appt-booking-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 960;
    display: flex;
    flex-direction: column;
    max-height: var(--sheet-max-height, 90vh);
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow);
}
body.appt-sheet-open #mobile-panel-tabs { display: none; }
.appt-booking-sheet-head {
    flex: 0 0 auto;
    padding: 0.375rem 0.75rem 0.25rem;
    border-bottom: 1px solid var(--border);
}
.appt-booking-sheet-handle {
    width: 2.5rem;
    height: 0.3rem;
    margin: 0.125rem auto 0.375rem;
    border-radius: 999px;
    background: var(--border-strong);
}
.appt-booking-sheet-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}
.appt-booking-sheet-open {
    margin-left: auto;
    margin-right: 0.25rem;
    font-size: 0.85rem;
}
.appt-booking-sheet-close {
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}
.appt-booking-sheet-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 16px 0; /* #4008: ONE 16px edge from the screen to the card */
}
.appt-booking-sheet-body .appt-card { margin-bottom: 0; }
/* The action row stays on screen while the card scrolls; bottom room clears the page's floating
   buttons (feedback, toast history: they float over everything, as on the Call Log sheet). */
.appt-booking-sheet .appt-card-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--bg-card); /* #4008: the card's own color, not the old info blue */
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px) + var(--floating-widget-clearance, 78px));
}

/* ---- #4007: the Action Items "Suggested appointments" group: ONE line per suggestion ----
 * name | [Past / No text slot] | when | Book...   (a ticketless one: Open... = the pop-out with Create ticket + Dismiss). Two show, then a
 * quiet "Show all (N)". Book opens the SAME floating card as the ticket badge (SuggestionBooking.openFloating). */
.suggestion-items-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0.25rem 0 0.375rem;
}
.suggestion-items-list {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.4rem;
    /* #4015: ONE container with the standard card look; a 1px separator between the lines (no per-row dashes). */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    overflow: hidden;
}
.sugg-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name end" "meta end";
    column-gap: 0.5rem;
    row-gap: 0.05rem;
    align-items: center;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
}
.sugg-row + .sugg-row { border-top: 1px solid var(--border); }
.sugg-row[data-done] { cursor: default; }
.sugg-row[data-has-reason] { grid-template-areas: "name end" "meta end" "reason end"; }
.sugg-reason {
    grid-area: reason;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sugg-name {
    grid-area: name;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.sugg-meta {
    grid-area: meta;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}
.sugg-name--link {
    background: none;
    border: 0;
    padding: 0;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}
.sugg-warn {
    flex: none;
    padding: 0 0.4rem;
    border: 1px solid var(--warning-border);
    border-radius: 999px;
    background: var(--warning-bg);
    color: var(--warning-text);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}
.sugg-when {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sugg-end {
    grid-area: end;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    min-width: 4.2rem;
}
.sugg-end .sugg-btn { min-width: 4.2rem; justify-content: center; text-align: center; }   /* Book... and Open... are the same size */
/* the ticketless pop-out body (inside the shared floating box / bottom sheet) */
.sugg-pop { padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px)); }
.appt-booking-sheet .sugg-pop { padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px) + var(--floating-widget-clearance, 78px)); }
.sugg-pop-name { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.sugg-pop-when { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.1rem; }
.sugg-pop-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.4rem; }
.sugg-pop-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.sugg-btn { min-width: 4.2rem; justify-content: center; text-align: center; }   /* Book... and Open... are the same size */
.sugg-btn {
    min-height: 1.75rem;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
}
.suggestion-action-items--phone .sugg-btn { min-height: 36px; }
.sugg-btn--danger {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}
.sugg-chip {
    flex: none;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.sugg-chip--info { background: var(--info-bg); color: var(--info-text); }
.sugg-chip--success { background: var(--success-bg); color: var(--success-text); }
.sugg-chip--error { background: var(--error-bg); color: var(--error-text); }
.sugg-more {
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    color: var(--info-text);
    font-size: 0.8rem;
    cursor: pointer;
}
