/* components.css — Studio Copilot component library (PRD-003, T-007).
 *
 * Styles for the ui.* macros defined in
 * frontend/templates/components/_macros_v2.html. Nothing in this file is
 * consumed by any page yet (that starts at T-008/T-009) — it is additive
 * and does not touch style.css or any existing selector.
 *
 * Token-pure: every color is var(--…) from tokens.css. No raw hex (G1).
 * Tone system: components take a `data-tone="blue|orange|green|purple|
 * danger|neutral"` attribute; tone -> token mapping lives entirely below.
 *   blue    -> var(--industrial)
 *   orange  -> var(--altgeld) for text/icon, var(--orange) for solid fills
 *   green   -> var(--prairie)
 *   purple  -> var(--berry)
 *   danger  -> var(--danger) (T-017, PRD-006) — semantically-negative states
 *              (denied, FERPA/PHI, suspended/grounded, error) that used to
 *              overload `purple`; `purple` is kept for non-negative uses.
 *   neutral -> var(--muted) / var(--line)
 * Tinted backgrounds use color-mix() against --panel so no new hex/rgba
 * literals are needed.
 */

/* Icon ------------------------------------------------------------------ */

.ui-icon {
  display: inline-flex;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
}
svg.ui-icon {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Page header ------------------------------------------------------------ */

.ui-page-header {
  /* Owns the page's horizontal gutter + top rhythm so every page that uses
     ui.page_header() lands its title on the same left edge — regardless of
     whether the page wraps the header (catalog/learn) or drops it straight
     into <main> (chat/keys/hangar/community/admin). Wrappers that used to
     supply this padding are deduped to 0 (T-UX-2). */
  margin: 0 0 24px;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 32px) 0;
}
.ui-page-header__eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--altgeld);
}
.ui-page-header__title {
  margin: 0 0 8px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: -.01em;
  line-height: 1.15;
  color: var(--blue);
}
.ui-page-header__sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 60ch;
}

/* Card -------------------------------------------------------------------- */

.ui-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.ui-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}
.ui-card__icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
}
.ui-card[data-tone="blue"] .ui-card__icon { color: var(--industrial); }
.ui-card[data-tone="orange"] .ui-card__icon { color: var(--altgeld); }
.ui-card[data-tone="green"] .ui-card__icon { color: var(--prairie); }
.ui-card[data-tone="purple"] .ui-card__icon { color: var(--berry); }
.ui-card__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--blue);
}
.ui-card__body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
.ui-card__footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

/* Chip --------------------------------------------------------------------- */

.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: color-mix(in srgb, var(--panel) 100%, transparent);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue);
}
.ui-chip__icon {
  width: 14px;
  height: 14px;
  color: var(--altgeld);
}
.ui-chip[data-tone="blue"] { color: var(--industrial); }
.ui-chip[data-tone="blue"] .ui-chip__icon { color: var(--industrial); }
.ui-chip[data-tone="orange"] { color: var(--altgeld); }
.ui-chip[data-tone="orange"] .ui-chip__icon { color: var(--altgeld); }
.ui-chip[data-tone="green"] { color: var(--prairie); }
.ui-chip[data-tone="green"] .ui-chip__icon { color: var(--prairie); }
.ui-chip[data-tone="purple"] { color: var(--berry); }
.ui-chip[data-tone="purple"] .ui-chip__icon { color: var(--berry); }
.ui-chip[data-tone="neutral"] { color: var(--muted); }
.ui-chip[data-tone="neutral"] .ui-chip__icon { color: var(--muted); }
.ui-chip[data-tone="danger"] { color: var(--danger); }
.ui-chip[data-tone="danger"] .ui-chip__icon { color: var(--danger); }

/* Badge ---------------------------------------------------------------------- */

.ui-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, var(--panel));
}
.ui-badge[data-tone="blue"] {
  color: var(--industrial);
  background: color-mix(in srgb, var(--industrial) 14%, var(--panel));
}
.ui-badge[data-tone="orange"] {
  color: var(--altgeld);
  background: color-mix(in srgb, var(--orange) 16%, var(--panel));
}
.ui-badge[data-tone="green"] {
  color: var(--prairie);
  background: color-mix(in srgb, var(--prairie) 14%, var(--panel));
}
.ui-badge[data-tone="purple"] {
  color: var(--berry);
  background: color-mix(in srgb, var(--berry) 14%, var(--panel));
}
.ui-badge[data-tone="danger"] {
  color: var(--danger);
  background: var(--danger-tint);
}

/* Button --------------------------------------------------------------------- */

.ui-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 14px;
  border-radius: 12px;
  padding: 11px 18px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.ui-btn__icon {
  width: 16px;
  height: 16px;
}
.ui-btn--primary {
  background: var(--orange);
  color: var(--blue);
}
.ui-btn--primary:hover {
  background: color-mix(in srgb, var(--orange) 88%, white);
}
.ui-btn--quiet {
  background: var(--panel);
  border-color: var(--line);
  color: var(--blue);
}
.ui-btn--quiet:hover {
  border-color: color-mix(in srgb, var(--ink) 24%, var(--line));
}
/* Branded secondary: navy outline that inverts to a navy fill on hover.
   Pairs with --primary (orange) to give two equal-weight, on-brand CTAs
   with a clear primary/secondary hierarchy. */
.ui-btn--secondary {
  background: var(--panel);
  border-color: var(--blue);
  color: var(--blue);
}
.ui-btn--secondary:hover {
  background: var(--blue);
  color: var(--panel);
}
.ui-btn--ghost {
  background: transparent;
  color: var(--muted);
}
.ui-btn--ghost:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--blue);
}

/* Field ---------------------------------------------------------------------- */

.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.ui-field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}
.ui-field__control :is(input, select, textarea) {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.ui-field__control :is(input, select, textarea):focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 1px;
}
.ui-field__help {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.ui-field__error {
  margin: 0;
  font-size: 12.5px;
  color: var(--berry);
  font-weight: 600;
}
.ui-field--error .ui-field__control :is(input, select, textarea) {
  border-color: var(--berry);
}

/* Notice (T-017, PRD-006) ------------------------------------------------------
 * ui.notice(tone, title=None) call-block macro — info/warn/danger banner.
 * Same tone-mix pattern as the badge/chip backgrounds above.
 */

.ui-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: color-mix(in srgb, var(--muted) 6%, var(--panel));
}
.ui-notice__icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--muted);
}
.ui-notice__body {
  flex: 1 1 auto;
  min-width: 0;
}
.ui-notice__title {
  margin: 0 0 4px;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--blue);
}
.ui-notice__text {
  margin: 0;
}
.ui-notice[data-tone="info"] {
  border-left-color: var(--industrial);
  background: color-mix(in srgb, var(--industrial) 6%, var(--panel));
}
.ui-notice[data-tone="info"] .ui-notice__icon { color: var(--industrial); }
.ui-notice[data-tone="warn"] {
  border-left-color: var(--altgeld);
  background: color-mix(in srgb, var(--orange) 8%, var(--panel));
}
.ui-notice[data-tone="warn"] .ui-notice__icon { color: var(--altgeld); }
.ui-notice[data-tone="danger"] {
  border-left-color: var(--danger);
  background: var(--danger-tint);
}
.ui-notice[data-tone="danger"] .ui-notice__icon { color: var(--danger); }

/* Table ---------------------------------------------------------------------- */

.ui-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.ui-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 4%, var(--panel));
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.ui-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.ui-table tbody tr:last-child td {
  border-bottom: 0;
}
.ui-table tbody tr:hover {
  background: color-mix(in srgb, var(--ink) 3%, var(--panel));
}

/* Progress ------------------------------------------------------------------- */

.ui-progress__label {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue);
}
.ui-progress__track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.ui-progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--orange);
}

/* Empty state ------------------------------------------------------------------ */

.ui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 40px 20px;
  color: var(--muted);
}
.ui-empty__icon {
  width: 32px;
  height: 32px;
  margin-bottom: 6px;
  color: var(--muted);
}
.ui-empty__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--blue);
}
.ui-empty__hint {
  margin: 0;
  font-size: 13.5px;
  max-width: 42ch;
}

/* Stat link ---------------------------------------------------------------------- */

.ui-stat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  text-decoration: none;
}
.ui-stat-link:hover {
  border-color: color-mix(in srgb, var(--ink) 20%, var(--line));
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 7%, transparent);
}
.ui-stat-link__label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--blue);
}
.ui-stat-link__value {
  font-size: 12.5px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .ui-btn,
  .ui-chip,
  .ui-stat-link,
  .ui-table tbody tr {
    transition: none !important;
  }
}
