/* The persistent Scope section's "When" subsection (closed display + inline
   editor) and a token-mapped Flatpickr theme. All color via --ha-* tokens; no
   raw hex. Token definitions live in desk_tokens.css / colors_and_type.css. */

/* Peer Scope section: a top hairline + same-weight eyebrow set it beneath the
   stage work. Separator is a TOP hairline only, never a side stripe. */
.scope-sub { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ha-border-strong); }

/* ---- Scope | Customer | Home tab strip ----
   Mirrors the lane .tab vocabulary, scoped under .scope-tabs so it never
   collides with the lane-level .lanetabs/.tab. */
.scope-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--ha-border); }
.scope-tab {
  font: inherit; font-size: 13px; color: var(--ha-ink-muted);
  background: none; border: 0; cursor: pointer;
  padding: 8px 12px 10px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.scope-tab:hover { color: var(--ha-ink); }
.scope-tab[aria-selected="true"] {
  color: var(--ha-ink); font-weight: var(--ha-weight-medium);
  border-bottom-color: var(--ha-blue-primary);
}
.scope-tab:focus-visible { outline: none; box-shadow: var(--ha-focus-ring); border-radius: var(--ha-radius-sm); }
.scope-panel[hidden] { display: none; }

/* Read-view rows in the Customer/Home tabs. .field-row/.k/.v already exist in the
   Scope content; these add the empty-state and read-only-note treatments. */
.scope-panel .field-row .v.empty { color: var(--ha-ink-muted); font-style: italic; }
.scope-panel .field-row .v .ro { font-size: 11px; color: var(--ha-ink-muted); margin-left: 8px; }

/* Customer/Home edit form: single-column field stack, Save left-justified. */
.ef { display: grid; gap: 12px; }
/* The display:grid above outranks the UA [hidden] rule, so the read/edit toggle's
   hidden attribute needs an explicit collapse (same pattern as .appt-edit[hidden],
   .bpane-date-form[hidden]) or the form stays visible beside the read view. */
.ef[hidden] { display: none; }
.ef label { display: grid; gap: 5px; font-size: 12px; color: var(--ha-ink-muted); }
.ef input {
  height: 38px; border: 1px solid var(--ha-border); border-radius: var(--ha-radius-md);
  padding: 0 12px; font: inherit; font-size: 14px; color: var(--ha-ink); background: var(--ha-surface);
}
.ef input:focus { outline: none; border-color: var(--ha-blue-accent); box-shadow: var(--ha-focus-ring); }
.ef input:disabled { background: var(--ha-surface-subtle); color: var(--ha-ink-muted); }
.ef .ro-hint { font-size: 11px; color: var(--ha-ink-muted); }
.ef .acts { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* ---- When: closed display ---- */
.when-display .when-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.when-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--ha-radius-pill);
  background: var(--ha-border-strong); font-size: 12px; color: var(--ha-ink);
  line-height: 24px; font-variant-numeric: tabular-nums;
}
.when-chip .win { color: var(--ha-ink-muted); font-size: 11px; }
.when-note-read { font-size: 13px; color: var(--ha-ink); margin-top: 8px; }
.when-note-read .lab {
  color: var(--ha-ink-muted); font-size: 11px; display: block; margin-bottom: 2px;
}
.when-empty { font-size: 13px; color: var(--ha-ink-muted); }
.when-edit-link { margin-top: 8px; }

/* ---- When: inline editor ---- */
.when-editor { display: flex; flex-direction: column; gap: 14px; }
.when-row { display: flex; flex-direction: column; gap: 8px; }
.when-row + .when-row { padding-top: 12px; border-top: 1px solid var(--ha-border-strong); }
.when-date-field { position: relative; max-width: 220px; }
.when-date {
  width: 100%; height: 36px; padding: 0 34px 0 12px;
  border: 1px solid var(--ha-border); border-radius: var(--ha-radius-md);
  background: var(--ha-surface); color: var(--ha-ink); font: inherit; font-size: 13px;
}
.when-date::placeholder { color: var(--ha-ink-muted); }
.when-date:focus {
  outline: none; border-color: var(--ha-blue-accent); box-shadow: var(--ha-focus-ring);
}
.when-date-field .cal-ic {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--ha-ink-muted); pointer-events: none;
}

/* Segmented window control: connected radio pills. Selected = blue-text fill +
   white text + revealed check (never hue alone). */
.seg {
  display: inline-flex; border: 1px solid var(--ha-border);
  border-radius: var(--ha-radius-pill); overflow: hidden;
}
.seg .seg-opt { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  height: 30px; padding: 0 14px; font-size: 12px; color: var(--ha-ink);
  border-left: 1px solid var(--ha-border);
}
.seg .seg-opt:first-child label { border-left: 0; }
.seg label:hover { background: var(--ha-row-hover); }
.seg input:checked + label { background: var(--ha-blue-text); color: var(--ha-surface); }
.seg input:focus-visible + label { box-shadow: var(--ha-focus-ring); }
.seg .chk { width: 12px; height: 12px; display: none; }
.seg input:checked + label .chk { display: inline; }

.when-add {
  align-self: flex-start; font-size: 12px; color: var(--ha-blue-text);
  background: none; border: 0; cursor: pointer; padding: 4px 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.when-add svg { width: 13px; height: 13px; }

.when-note-field { display: flex; flex-direction: column; gap: 5px; }
.when-note-field .lab { font-size: 11px; color: var(--ha-ink-muted); }
.when-note {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--ha-border); border-radius: var(--ha-radius-md);
  background: var(--ha-surface); color: var(--ha-ink); font: inherit; font-size: 13px;
}
.when-note:focus {
  outline: none; border-color: var(--ha-blue-accent); box-shadow: var(--ha-focus-ring);
}
.when-note::placeholder { color: var(--ha-ink-muted); }

/* Composer rule: Save left-justified beneath the inputs, Cancel beside it. */
.when-actions { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.when-save {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 18px; border-radius: var(--ha-radius-pill);
  background: var(--ha-blue-primary); color: var(--ha-surface);
  font-size: 13px; font-weight: var(--ha-weight-medium); border: 0; cursor: pointer;
}
.when-cancel {
  font-size: 13px; color: var(--ha-ink-muted);
  background: none; border: 0; cursor: pointer; text-decoration: none;
}

/* ---- Flatpickr theme override: real flatpickr classes, tokens only ---- */
.flatpickr-calendar {
  border-radius: var(--ha-radius-md); box-shadow: var(--ha-shadow-card);
  border: 1px solid var(--ha-border);
}
.flatpickr-day { color: var(--ha-ink); }
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
  background: var(--ha-blue-accent); border-color: var(--ha-blue-accent); color: var(--ha-surface);
}
.flatpickr-day.today { border-color: var(--ha-border); }
.flatpickr-current-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { color: var(--ha-ink); }
span.flatpickr-weekday { color: var(--ha-ink-muted); }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { fill: var(--ha-ink-muted); }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: var(--ha-ink); }
