/* ═══════════════════════════════════════════════════════════════════════════
   SERVICES ADD-ONS — Label Tagging (slt-1) + Auto Save (sas-1) · 2026-08-09
   ───────────────────────────────────────────────────────────────────────────
   Loads LAST among the Services stylesheets (additive layer — same cascade
   rule as services-command.css). Everything rides the --sc-* token ramp;
   light mode overrides live under :root[data-svc-theme="light"].

   §1  Label Tag chip (.svc-lt-chip) — visual clone of My Quickbase's
       .qb-services-badge: flat, hairline border, zero radius, 8.5px/800
       uppercase. Colour = whitelist class svc-lt-c-<key>; ink + border share
       currentColor so one custom property (--lt) recolours the whole chip.
   §2  Cell + header context-menu additions (.svc-lt-menu, swatches, preview)
   §3  Auto Save toolbar switch (.svc-as-*) + Save-button attention pulse

   RULES (asserted by tests/unit/services_labels.test.js):
   - No `font:` shorthand with a CSS-wide keyword family (§2b trap) — longhands.
   - Label colours: every ink ≥ 4.5:1 against its cell surface in BOTH themes.
   - Gold is never a label colour (brand/action only).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ══ §1 · THE CHIP ══════════════════════════════════════════════════════ */

.svc-lt-chip {
  display: block;
  width: fit-content;
  max-width: calc(100% - 20px);
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 0;               /* Signal Desk: flat, hairline, zero radius */
  padding: 1px 5px;
  color: var(--lt, var(--sc-text-dim, #B7BCC6));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;           /* the cell input owns every pointer gesture */
  animation: svc-lt-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes svc-lt-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* In-grid placement: value on top, chip pinned under it — the exact
   My Quickbase stacking, fitted into the grid's fixed row height. */
.svc-grid tbody td.svc-lt-on { position: relative; }
.svc-grid tbody td.svc-lt-on > .svc-lt-chip {
  position: absolute;
  left: 14px;                     /* shares the input's text start (8px 14px padding) */
  bottom: 3px;
  z-index: 1;
}
.svc-grid tbody td.svc-lt-on > input.cell,
.svc-grid tbody td.svc-lt-on .svc-qb-case-cell-wrap input.cell {
  padding-top: 4px;
  padding-bottom: 18px;           /* lifts the value line clear of the chip */
}

/* Colour whitelist — DARK ink values (≥4.5:1 on the #0C0C0E…panel canvas). */
.svc-lt-c-neutral { --lt: #B7BCC6; }
.svc-lt-c-blue    { --lt: #7DB1F7; }
.svc-lt-c-cyan    { --lt: #67D3E0; }
.svc-lt-c-teal    { --lt: #5ED4B9; }
.svc-lt-c-green   { --lt: #7BD88F; }
.svc-lt-c-yellow  { --lt: #E0C566; }
.svc-lt-c-orange  { --lt: #F0A868; }
.svc-lt-c-pink    { --lt: #F291C7; }
.svc-lt-c-violet  { --lt: #B49DF5; }
.svc-lt-c-red     { --lt: #F08A8A; }

/* LIGHT ink values — darker cuts of the same hues (≥4.5:1 on white). */
:root[data-svc-theme="light"] .svc-lt-c-neutral { --lt: #4B5563; }
:root[data-svc-theme="light"] .svc-lt-c-blue    { --lt: #1D4ED8; }
:root[data-svc-theme="light"] .svc-lt-c-cyan    { --lt: #0E7490; }
:root[data-svc-theme="light"] .svc-lt-c-teal    { --lt: #0F766E; }
:root[data-svc-theme="light"] .svc-lt-c-green   { --lt: #15803D; }
:root[data-svc-theme="light"] .svc-lt-c-yellow  { --lt: #8A6D08; }
:root[data-svc-theme="light"] .svc-lt-c-orange  { --lt: #C2410C; }
:root[data-svc-theme="light"] .svc-lt-c-pink    { --lt: #BE185D; }
:root[data-svc-theme="light"] .svc-lt-c-violet  { --lt: #6D28D9; }
:root[data-svc-theme="light"] .svc-lt-c-red     { --lt: #B91C1C; }

/* ══ §2 · MENUS ═════════════════════════════════════════════════════════ */

/* The cell menu reuses .svc-col-ctx-menu chrome (premium skin applies).
   These rules only add the label-specific inner pieces. */
.svc-lt-menu { min-width: 232px; }

.svc-lt-menu-col {
  padding: 2px 14px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sc-text-dim, #9AA1AC);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-lt-preview {
  display: flex;
  align-items: center;
  min-height: 24px;
  margin: 0 12px 6px;
  padding: 4px 8px;
  background: var(--sc-bg2, #101012);
  border: 1px dashed var(--sc-border2, #26262A);
}
.svc-lt-preview .svc-lt-chip { animation: none; }
.svc-lt-chip.svc-lt-ghost { opacity: 0.45; }

.svc-lt-input-row { cursor: default; }
.svc-lt-input.ctx-rename-input { width: 100%; }
.svc-lt-input-err { border-color: #F08A8A !important; }

.svc-lt-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 8px;
}
.svc-lt-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--lt, #B7BCC6);
  background: transparent;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease;
}
.svc-lt-swatch::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--lt, #B7BCC6);
  opacity: 0.85;
}
.svc-lt-swatch:hover { transform: translateY(-1px); }
.svc-lt-swatch.active {
  outline: 2px solid var(--sc-text-bright, #ECEDEF);
  outline-offset: 1px;
}
:root[data-svc-theme="light"] .svc-lt-swatch.active { outline-color: #1F2430; }

/* ══ §3 · AUTO SAVE SWITCH ══════════════════════════════════════════════ */

.svc-as-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  padding: 3px 9px 3px 4px;
  border: 1px solid var(--sc-elev, #2A2A31);
  background: var(--sc-panel, #131316);
  user-select: none;
}

.svc-as-switch {
  position: relative;
  width: 30px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--sc-elev2, #33333B);
  border-radius: 999px;
  background: #2E7D46;            /* ON track — settled green, not brand gold */
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
}
.svc-as-knob {
  position: absolute;
  top: 1px;
  left: 15px;                     /* ON: knob right */
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: left 0.18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.svc-as-off .svc-as-switch { background: var(--sc-panel3, #1D1D21); }
.svc-as-off .svc-as-knob { left: 1px; background: var(--sc-text-dim, #9AA1AC); }

.svc-as-lbl {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--sc-text-bright, #ECEDEF);
  cursor: pointer;
  line-height: 1;
}
.svc-as-off .svc-as-lbl { color: var(--sc-text-dim, #9AA1AC); }

.svc-as-state {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: var(--sc-text-dim, #9AA1AC);
  white-space: nowrap;
}
.svc-as-state.ok   { color: #7BD88F; }
.svc-as-state.busy { color: #E0C566; }
.svc-as-state.warn { color: #F0A868; }
.svc-as-state.err  { color: #F08A8A; }

:root[data-svc-theme="light"] .svc-as-wrap { background: #FFFFFF; border-color: #D7DAE0; }
:root[data-svc-theme="light"] .svc-as-state { color: #4B5563; }
:root[data-svc-theme="light"] .svc-as-state.ok   { color: #15803D; }
:root[data-svc-theme="light"] .svc-as-state.busy { color: #8A6D08; }
:root[data-svc-theme="light"] .svc-as-state.warn { color: #C2410C; }
:root[data-svc-theme="light"] .svc-as-state.err  { color: #B91C1C; }

/* Manual mode with pending edits: the Save button asks for attention. */
@keyframes svc-as-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 168, 104, 0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(240, 168, 104, 0); }
}
.svc-btn.svc-as-attn { animation: svc-as-pulse 1.6s ease-in-out infinite; }

/* Tight toolbars: drop the status text first, then the wordmark. */
@media (max-width: 1460px) { .svc-as-state { display: none; } }
@media (max-width: 1290px) { .svc-as-lbl { display: none; } .svc-as-wrap { padding-right: 4px; } }
