/* components.css — canonical CSS for shared UI primitives.
 *
 * LOADED globally via public/index.html (<link> in <head>). These classes are
 * live canon — edits here affect every module already using them.
 *
 * Rules:
 *   - Tokens come from styles.css :root (--bg, --ink, --border, --accent, ...).
 *     Never hard-code a hex.
 *   - These classes are namespace-free on purpose. They are the canon.
 *     Module-prefixed classes (.tpl-*, .ov-*, .seq-*, .events-*) are legacy
 *     and migrate to these over time. See docs/COMPONENTS.md.
 *   - The following primitives reuse classes already in styles.css and are
 *     NOT redefined here: .btn / .btn-primary / .btn-secondary / .btn-ghost
 *     (styles.css:168), .field / .field-input / .field-textarea / .field-select
 *     (styles.css:427), .drawer family (styles.css:371), .toast (706),
 *     .spinner (694), .stat-card / .stat-label / .stat-value (224),
 *     .pill family (245), .status-pill (1838).
 */

/* ── PILLBAR (canonical: events two-tier nav) ─────────────────── */

.pillbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 9999px;
  flex-wrap: wrap;
}
.pillbar > .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9999px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.pillbar > .pill:hover { color: var(--ink); background: color-mix(in srgb, var(--card-bg) 62%, transparent); }
.pillbar > .pill.is-active {
  border-color: var(--border);
  background: var(--card-bg);
  color: var(--ink);
  box-shadow: 0 1px 1px rgba(26, 23, 18, 0.04), 0 8px 20px rgba(26, 23, 18, 0.08);
  transform: translateY(-1px);
}
.pillbar > .pill > i { font-size: 18px; line-height: 1; }
.pillbar > .pill .pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  margin-left: 2px;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
}

/* sub-pillbar: tighter, sits underneath a main pillbar */
.pillbar.pillbar-sub {
  padding: 2px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  gap: 2px;
}
.pillbar.pillbar-sub > .pill {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 6px;
}
.pillbar.pillbar-sub > .pill.is-active {
  background: var(--bg);
  box-shadow: inset 0 -2px 0 var(--ink);
  border-radius: 6px 6px 0 0;
}

@media (max-width: 767px) {
  .pillbar {
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 10px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .pillbar::-webkit-scrollbar {
    display: none;
  }

  .pillbar > .pill {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 9px 15px;
    scroll-snap-align: start;
    touch-action: manipulation;
  }
}

/* ── DISCLOSURE (canonical: sequences chevron expand) ─────────── */

.disclosure {
  border-top: 1px solid var(--border-light);
}
.disclosure-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  background: transparent;
  border: 0;
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  text-align: left;
}
.disclosure-toggle:hover { color: var(--ink); }
.disclosure-toggle > i {
  font-size: 14px;
  transition: transform 0.18s ease;
}
.disclosure.is-open .disclosure-toggle > i { transform: rotate(180deg); }
.disclosure.is-open .disclosure-toggle { color: var(--ink); }
.disclosure-body {
  display: none;
  padding: 4px 0 14px 22px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.55;
}
.disclosure.is-open .disclosure-body { display: block; }

/* disclosure-card: list-friendly variant using <details> */
.disclosure-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.disclosure-card > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.disclosure-card > summary::-webkit-details-marker { display: none; }
.disclosure-card > summary > i {
  font-size: 14px;
  transition: transform 0.18s ease;
}
.disclosure-card[open] > summary > i { transform: rotate(180deg); }
.disclosure-card-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-muted);
}

/* ── DATE INPUT (.flatpickr — paired with comp.enhanceDates) ──── */

input.flatpickr {
  font-variant-numeric: tabular-nums;
}
input.flatpickr.form-control[readonly] { background: var(--bg); }
.flatpickr-calendar {
  font-family: 'Poppins', sans-serif;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(26, 23, 18, 0.08);
}

/* ── HEADINGS ─────────────────────────────────────────────────── */

.heading-page {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-title);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.heading-section {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-subheading);
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 12px;
}
.heading-eyebrow {
  font-family: 'Poppins', sans-serif;
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 8px;
}

/* SURFACE — the module body wrapper. The page TITLE / subtitle / primary
   action are NOT here: they come from the global header (.header / #pageTitle /
   #pageSub / #headerPrimaryBtn, driven by moduleHeaders[mod] in app.js). The
   surface layer standardizes the BODY below that header: nav + regions.
   See docs/SPEC_SURFACE_ARCHITECTURE.md. */
.surface { display: block; }
.surface-body { display: block; }
.surface-nav { margin: 4px 0 20px; }

/* Sub-surface toolbar — the row between the nav and the content.
   Convention: context (count/title/filters) on the LEFT, actions pinned to
   the RIGHT edge (aligned with the global header's primary action). */
.surface-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0 4px;
  flex-wrap: wrap;
}
.surface-toolbar-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink-muted);
  font-size: var(--text-small);
}
.surface-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
@media (max-width: 767px) {
  .surface-toolbar-actions { width: 100%; }
}

.surface-intro { margin: 0 0 24px; }
.surface-intro-kicker {
  font-family: 'Poppins', sans-serif;
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.surface-intro-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-heading);
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 6px;
}
.surface-intro-copy {
  font-size: var(--text-small);
  color: var(--ink-muted);
  line-height: 1.6;
  max-width: 60ch;
  margin: 0;
}

/* ── BUTTON variants not in styles.css ────────────────────────── */

.btn-danger {
  background: #b04444;
  color: #fff;
  border: 1px solid #b04444;
}
.btn-danger:hover { background: #9a3838; border-color: #9a3838; }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.btn-icon > i { font-size: 16px; }

.btn-sm { padding: 6px 12px; font-size: 11px; }

/* ── FIELD additions ──────────────────────────────────────────── */

.field-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-muted);
}

/* ── MODAL (canonical) ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
  animation: modal-fade-in 0.16s ease;
}
@keyframes modal-fade-in { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(26, 23, 18, 0.2);
}
.modal.modal-sm { width: 380px; }
.modal.modal-lg { width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-heading);
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}
.modal-close {
  width: 32px; height: 32px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}
.modal-close:hover { background: var(--bg-subtle); color: var(--ink); }
.modal-close > i { font-size: 18px; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
}

/* ── EMPTY STATE ──────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-muted);
}
.empty-state-icon {
  font-size: 32px;
  color: var(--ink-light);
  margin-bottom: 12px;
}
.empty-state-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-heading);
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 6px;
}
.empty-state-text {
  font-size: 12px;
  line-height: 1.55;
  margin: 0 auto;
  max-width: 44ch;
}
.empty-state-action { margin-top: 16px; }

/* ── METRIC STRIP ─────────────────────────────────────────────── */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.metric-value {
  font-family: 'Poppins', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 6px;
}
.metric-label {
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.metric-sub { font-size: 10px; color: var(--ink-muted); margin-top: 4px; }

/* ── CAPACITY BAR ─────────────────────────────────────────────── */

.capacity-bar { margin: 12px 0; }
.capacity-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--ink-muted);
}
.capacity-bar-label { font-weight: 500; }
.capacity-bar-count { font-variant-numeric: tabular-nums; }
.capacity-track {
  height: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.capacity-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.24s ease;
}

/* ── CARD ─────────────────────────────────────────────────────── */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.14s, transform 0.14s;
}
.card[onclick] { cursor: pointer; }
.card[onclick]:hover {
  box-shadow: 0 4px 14px rgba(26, 23, 18, 0.08);
  transform: translateY(-1px);
}
.card-cover {
  aspect-ratio: 16 / 9;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-body { padding: 14px 16px; flex: 1; }
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-heading);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.2;
}
.card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
}
.card-add {
  background: transparent;
  border: 1.5px dashed var(--border);
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  cursor: pointer;
  min-height: 140px;
}
.card-add:hover { color: var(--ink); border-color: var(--ink-muted); }

/* ── LIST / LIST ROW ──────────────────────────────────────────── */

.list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
.list-row:last-child { border-bottom: 0; }
.list-row[onclick] { cursor: pointer; transition: background 0.1s; }
.list-row[onclick]:hover { background: var(--bg-subtle); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-meta { color: var(--ink-muted); font-size: 11px; white-space: nowrap; }
.list-row-actions { display: flex; gap: 4px; }
