/* widgets.css — In-app updater, collapsible sidebar groups, API tokens panel, spinner, tablet breakpoint, sweep utility classes. Split out of utilities.css; load order: utilities.css → polish.css → widgets.css → sweep.css. */

/* ─── In-app updater (docs/UPDATES.md) ────────────────────────────────
   Topbar badge that links into Settings → Updates, plus the two cards
   that live inside the Updates tab itself. */
.update-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: filter 120ms ease;
}
.update-badge:hover { filter: brightness(0.95); }
.update-badge i { font-size: 10px; }

.updates-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 14px;
}
.updates-card {
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--rule, #e6e2d8);
  border-radius: var(--radius, 8px);
  padding: 20px 22px;
}
.updates-card__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3, #666);
  margin: 0 0 12px;
}
.updates-version {
  margin-left: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 14px;
  color: var(--ink-3, #666);
}
.updates-card--accent {
  border-color: var(--success);
  background: var(--success-bg);
}

/* Public poll: radio-option block (one row per choice). */
.pf-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--rule, #d8d4cc);
  border-radius: 8px;
  margin: 0 0 8px;
  cursor: pointer;
  background: var(--bg-elevated, #fff);
  transition: border-color 120ms ease, background 120ms ease;
}
.pf-radio:hover { border-color: var(--accent, #8B7C68); }
.pf-radio input[type=radio] { margin: 0; accent-color: var(--accent, #8B7C68); }


/* ─── Sidebar: collapsible groups (Integrations) ─────────────────────────
   The group lives inside .nav-group so it inherits the existing label/padding;
   the toggle row uses .nav-item visuals but with a chevron + rollup badge. */
.nav-group--collapsible { padding-top: 0; }
.nav-group__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  border-radius: var(--radius-sm, 6px);
}
.nav-group__toggle:hover { background: var(--bg-hover, rgba(0,0,0,0.04)); }
.nav-group__toggle-label { flex: 1; }
.nav-group__toggle-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-group__chevron {
  transition: transform 180ms ease;
  font-size: 11px;
  color: var(--ink-3, #888);
}
.nav-group--collapsible.is-open .nav-group__chevron { transform: rotate(180deg); }

/* Subgroup uses display: none when collapsed — the grid-template-rows
   animation trick is brittle in some browsers and the toggle visibly
   didn't track state. A hard show/hide is rock-solid. */
.nav-subgroup { display: none; }
.nav-group--collapsible.is-open .nav-subgroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
/* Indent the nested nav items so the hierarchy reads visually. */
.nav-subgroup .nav-item { padding-left: 28px; }

/* The rollup badge (e.g. unread forms-data count) hides when the group is
   open because the child item shows its own badge in the natural position. */
.nav-group--collapsible.is-open .nav-group__rollup-count { display: none; }

/* ─── API tokens panel ─────────────────────────────────────────────────
   `pre.copyable` flashes briefly when clicked to copy. Reveal block
   only appears once after token creation (server side flash). */
pre.copyable {
  cursor: copy;
  user-select: all;
  font-family: var(--mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 13px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius, 6px);
  padding: 12px 14px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  transition: background 0.2s ease, border-color 0.2s ease;
}
pre.copyable:hover { background: var(--paper-3); border-color: var(--rule-2); }
pre.copyable.copyable--flash {
  background: var(--brand-3, #FCE4D6);
  border-color: var(--brand, #C2410C);
}
.api-tokens-reveal {
  border-color: var(--brand, #C2410C);
  background: linear-gradient(0deg, var(--paper-2), var(--paper-2)) padding-box;
}
.api-tokens-reveal__code { margin-top: var(--space-6); }

/* aria-busy spinner for buttons — paired with utils.js withButtonBusy().
   Hides the label (color: transparent) and overlays a spinner so the
   layout doesn't shift when an async action is in flight. */
.btn[aria-busy="true"] {
  position: relative;
  color: transparent;
  cursor: progress;
}
.btn[aria-busy="true"]::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin .8s linear infinite;
  /* Inherit color from a non-transparent ancestor — currentColor at
     this scope is `transparent` from the rule above. */
  color: var(--ink, #2A2118);
}
@keyframes btn-spin { to { transform: rotate(1turn); } }

/* Tablet/small-laptop breakpoint — bridges the gap between the desktop
   layout and the 600px phone breakpoint above. Collapses task / project /
   compass tabs gracefully so they don't bleed off the right edge. */
@media (max-width: 720px) {
  /* Collapse the project overview + task detail sidebars earlier — at the
     desktop breakpoint, the 280px sidebar squeezes the main column too
     much for comfortable reading. */
  .project-overview,
  .task-detail { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
  .project-sidebar { margin-top: var(--space-6); }

  /* Project & compass tabs row — stack vertically with full-width tap
     targets instead of horizontally overflowing. */
  .project-tabs {
    flex-direction: column;
    gap: var(--space-2);
    align-items: stretch;
  }
  .project-tab {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }
}

/* ─── §20 CSS-5 sweep utility classes (added in Wave 9.1d) ───────
   Lifted from the top-30 inline-style patterns across views/. Naming
   stays terse / Tailwind-ish for one-off swaps; semantic component
   styles live in cards-panels.css / forms.css. */

/* Margins (px-named — additional to the existing .mt-8/16/24/32 set) */
.m-0       { margin: 0; }
.mt-4      { margin-top: 4px; }
.mt-6      { margin-top: 6px; }
.mt-14     { margin-top: 14px; }
.mt-18     { margin-top: 18px; }
.mt-22     { margin-top: 22px; }
.mt-28     { margin-top: 28px; }
.mb-7      { margin-bottom: 7px; }
.mb-16     { margin-bottom: 16px; }
.mr-space-2 { margin-right: var(--space-2); }

/* Font-sizes */
.fz-10  { font-size: 10px; }
.fz-11  { font-size: 11px; }
.fz-12  { font-size: 12px; }
.fz-13  { font-size: 13px; }
.fz-14  { font-size: 14px; }
.fz-15  { font-size: 15px; }
.fz-16  { font-size: 16px; }
.fz-20  { font-size: 20px; }
.fz-24  { font-size: 24px; }
.fz-32  { font-size: 32px; }

/* Font-weights */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* Colors (token-bound — re-use the existing palette) */
.text-accent { color: var(--accent); }
.text-brand  { color: var(--brand); }
.text-paper  { color: var(--paper); }
.text-ink-2  { color: var(--ink-2); }
.text-ink-3  { color: var(--ink-3); }
.text-text-2 { color: var(--text-2); }
.text-muted-strong { color: var(--text-muted); }

/* Text utilities */
.no-underline           { text-decoration: none; }
.no-underline-inherit   { text-decoration: none; color: inherit; }
.text-center            { text-align: center; }
.uppercase-label        { text-transform: uppercase; letter-spacing: .1em; }

/* Display / layout */
.d-none           { display: none; }
.d-inline         { display: inline; }
.d-inline-block   { display: inline-block; }
.flex-1-min       { flex: 1; min-width: 0; }

/* Composed hints / labels — these patterns repeated ≥8× in views. */
.field-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin: 0 0 16px;
}
.field-hint--tight  { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
.field-hint--tight2 { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }
.field-hint--top    { margin: 0 0 18px; font-size: 12px; color: var(--ink-3); }

.section-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* Big numeric display (hero metric / counters) */
.metric-display {
  font-family: var(--font-mono);
  font-size: 96px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.04em;
  line-height: 1;
}

/* Empty-state placeholder (was .empty-state pattern with 60px padding) */
.empty-state--simple { text-align: center; padding: 60px 20px; }

/* CTA underline link (used on empty-state pages) */
.cta-underline {
  display: inline-block;
  margin-top: 24px;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Small inline icon-text pair (e.g. role badge) */
.inline-icon-text {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Pass-2 add-ons */
.u-mb-space-2     { margin-bottom: var(--space-2); }
.u-mb-space-8     { margin-bottom: var(--space-8); }
.u-mt-space-6     { margin-top: var(--space-6); }
.whitespace-pre-line { white-space: pre-line; }
.bg-accent        { background: var(--accent); }
.page-section-title {
  /* Was inlined as `font-size:24px;font-weight:600;margin:16px 0 8px;` on
     section headers inside compass / admin pages. */
  margin: 16px 0 8px;
}

/* Pass-3 additions */
.flex-row-gap-6     { display: flex; gap: 6px; }
.flex-row-gap-8     { display: flex; gap: 8px; }
.flex-row-gap-8-mt-8 { display: flex; gap: 8px; margin-top: 8px; }
.table-cell         { padding: var(--space-3) var(--space-4); }
.table-cell--strong { padding: var(--space-3) var(--space-4); font-weight: 600; color: var(--text-2); }
.table-cell--strong-right { padding: var(--space-3) var(--space-4); font-weight: 600; color: var(--text-2); text-align: right; }
.table-head-row     { text-align: left; border-bottom: 1px solid var(--rule); }
.w-full             { width: 100%; }
.w-200              { width: 200px; }
.w-140              { width: 140px; }
.w-full-mt-8        { width: 100%; margin-top: 8px; }
.data-table         { width: 100%; border-collapse: collapse; font-size: 13px; }
.text-ink           { color: var(--ink); }
.text-brand-underline { color: var(--brand); text-decoration: underline; }
.text-accent-mb-12  { color: var(--accent); margin: 0 0 12px; }
.head-with-actions  {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--space-8);
}
.split-head         {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.section-strong-label {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.section-strong-label--alt {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.page-section-title-lg {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 24px;
}
.text-hint-tight    { margin: -8px 0 16px; color: var(--ink-3); font-size: 13px; }
.text-13-mb-10      { font-size: 13px; margin: 0 0 10px; }
.text-13-ink-2-mt-18 { margin-top: 18px; font-size: 13px; color: var(--ink-2); }
.callout-card       {
  border: 1px solid var(--rule);
  padding: 18px;
  background: var(--paper);
  border-radius: 4px;
}
.border-rule-bottom { border-bottom: 1px solid var(--rule); }

