/*
 * zz-ui — compiled component CSS.
 *
 * Theming contract: every color/geometry value is a semantic `--zz-*` CSS
 * variable with a stock-Tailwind fallback inline in var(). A host maps its own
 * palette to the contract in a theme stylesheet loaded AFTER this file:
 *
 *   :root { --zz-action-primary-background: var(--your-host-brand); … }
 *
 * An unconfigured host gets the fallback values for free (a styled, light UI);
 * a configured host's :root values win at runtime. The gem ships NO :root
 * defaults and NO dark-mode `@media` rule — dark is host opt-in via a `.dark`
 * class on <html>, and the gem ships STOCK .dark overrides (slate-based) so an
 * unconfigured host gets a usable dark UI too; a host .dark block still wins
 * per-role (the host theme loads after this sheet).
 *
 * Size budget: ≤ 10 KB compressed (see bin/audit). Do not over-split into
 * per-component files.
 */

/* ----------------------------------------------------------------- Button */
.zz-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--zz-control-height, 2.5rem);
  padding-inline: var(--zz-control-padding-x, 1rem);
  border-radius: var(--zz-control-radius, 0.5rem);
  font-weight: var(--zz-control-font-weight, 600);
  line-height: 1.25;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
}
.zz-button:focus-visible {
  outline: 2px solid var(--zz-control-focus-ring, var(--zz-action-primary-background, #334155));
  outline-offset: 2px;
}
.zz-button:disabled, .zz-button[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}
.zz-button--size-sm { min-height: 2rem; padding-inline: .625rem; font-size: .8125rem; }
.zz-button--size-md { font-size: .875rem; }
.zz-button--size-lg { min-height: 3rem; padding-inline: 1.25rem; font-size: 1rem; }

/* solid */
.zz-button--primary-solid   { color: var(--zz-action-primary-foreground, #fff);   background: var(--zz-action-primary-background, #334155); }
.zz-button--primary-solid:hover   { background: var(--zz-action-primary-background-hover, #1e293b); }
.zz-button--secondary-solid { color: var(--zz-action-secondary-foreground, #111827); background: var(--zz-action-secondary-background, #f3f4f6); }
.zz-button--secondary-solid:hover { background: var(--zz-action-secondary-background-hover, #e5e7eb); }
.zz-button--success-solid { color: var(--zz-action-success-foreground, #fff);  background: var(--zz-action-success-background, #16a34a); }
.zz-button--success-solid:hover { background: var(--zz-action-success-background-hover, #15803d); }
.zz-button--warning-solid { color: var(--zz-action-warning-foreground, #1f2937); background: var(--zz-action-warning-background, #f59e0b); }
.zz-button--warning-solid:hover { background: var(--zz-action-warning-background-hover, #d97706); }
.zz-button--danger-solid  { color: var(--zz-action-danger-foreground, #fff);   background: var(--zz-action-danger-background, #dc2626); }
.zz-button--danger-solid:hover  { background: var(--zz-action-danger-background-hover, #b91c1c); }
.zz-button--info-solid    { color: var(--zz-action-info-foreground, #fff);    background: var(--zz-action-info-background, #2563eb); }
.zz-button--info-solid:hover    { background: var(--zz-action-info-background-hover, #1d4ed8); }

/* soft */
.zz-button--primary-soft   { color: var(--zz-action-primary-foreground-soft, #1e293b);  background: var(--zz-action-primary-background-soft, #f1f5f9); }
.zz-button--secondary-soft { color: var(--zz-action-secondary-foreground-soft, #374151); background: var(--zz-action-secondary-background-soft, #f9fafb); }
.zz-button--success-soft { color: var(--zz-action-success-foreground-soft, #166534); background: var(--zz-action-success-background-soft, #dcfce7); }
.zz-button--warning-soft { color: var(--zz-action-warning-foreground-soft, #92400e); background: var(--zz-action-warning-background-soft, #fef3c7); }
.zz-button--danger-soft  { color: var(--zz-action-danger-foreground-soft, #991b1b); background: var(--zz-action-danger-background-soft, #fef2f2); }
.zz-button--info-soft    { color: var(--zz-action-info-foreground-soft, #1e40af);  background: var(--zz-action-info-background-soft, #dbeafe); }

/* outline */
.zz-button--primary-outline   { color: var(--zz-action-primary-foreground-soft, #1e293b); border-color: var(--zz-action-primary-outline, #cbd5e1); background: transparent; }
.zz-button--secondary-outline { color: var(--zz-action-secondary-foreground, #111827); border-color: var(--zz-action-secondary-outline, #d1d5db); background: transparent; }
.zz-button--success-outline { color: var(--zz-action-success-foreground-soft, #166534); border-color: var(--zz-action-success-outline, #86efac); background: transparent; }
.zz-button--warning-outline { color: var(--zz-action-warning-foreground-soft, #92400e); border-color: var(--zz-action-warning-outline, #fcd34d); background: transparent; }
.zz-button--danger-outline  { color: var(--zz-action-danger-foreground-soft, #991b1b); border-color: var(--zz-action-danger-outline, #fca5a5); background: transparent; }
.zz-button--info-outline    { color: var(--zz-action-info-foreground-soft, #1e40af); border-color: var(--zz-action-info-outline, #93c5fd); background: transparent; }

/* ghost */
.zz-button--primary-ghost   { color: var(--zz-action-primary-foreground-soft, #1e293b); background: transparent; }
.zz-button--primary-ghost:hover   { background: var(--zz-action-primary-background-soft, #f1f5f9); }
.zz-button--secondary-ghost { color: var(--zz-action-secondary-foreground, #111827); background: transparent; }
.zz-button--secondary-ghost:hover { background: var(--zz-action-secondary-background-soft, #f9fafb); }
.zz-button--success-ghost { color: var(--zz-action-success-foreground-soft, #166534); background: transparent; }
.zz-button--success-ghost:hover { background: var(--zz-action-success-background-soft, #dcfce7); }
.zz-button--warning-ghost { color: var(--zz-action-warning-foreground-soft, #92400e); background: transparent; }
.zz-button--warning-ghost:hover { background: var(--zz-action-warning-background-soft, #fef3c7); }
.zz-button--danger-ghost  { color: var(--zz-action-danger-foreground-soft, #991b1b); background: transparent; }
.zz-button--danger-ghost:hover  { background: var(--zz-action-danger-background-soft, #fef2f2); }
.zz-button--info-ghost    { color: var(--zz-action-info-foreground-soft, #1e40af); background: transparent; }
.zz-button--info-ghost:hover    { background: var(--zz-action-info-background-soft, #dbeafe); }

/* link */
.zz-button--primary-link, .zz-button--secondary-link, .zz-button--success-link,
.zz-button--warning-link, .zz-button--danger-link, .zz-button--info-link {
  min-height: 0;
  padding-inline: 0;
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.zz-button--primary-link   { color: var(--zz-action-primary-foreground-soft, #1e293b); }
.zz-button--secondary-link { color: var(--zz-action-secondary-foreground, #111827); }
.zz-button--success-link { color: var(--zz-action-success-foreground-soft, #166534); }
.zz-button--warning-link { color: var(--zz-action-warning-foreground-soft, #92400e); }
.zz-button--danger-link  { color: var(--zz-action-danger-foreground-soft, #991b1b); }
.zz-button--info-link    { color: var(--zz-action-info-foreground-soft, #1e40af); }

/* ------------------------------------------------------------------ Alert */
.zz-alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1px solid;
  border-radius: var(--zz-control-radius, 0.5rem);
  font-size: .875rem;
}
.zz-alert--primary   { color: var(--zz-alert-primary-foreground, #1e293b); background: var(--zz-alert-primary-background, #f1f5f9); border-color: var(--zz-alert-primary-border, #cbd5e1); }
.zz-alert--secondary { color: var(--zz-alert-secondary-foreground, #111827); background: var(--zz-alert-secondary-background, #f9fafb); border-color: var(--zz-alert-secondary-border, #e5e7eb); }
.zz-alert--info    { color: var(--zz-alert-info-foreground, #1e40af); background: var(--zz-alert-info-background, #dbeafe); border-color: var(--zz-alert-info-border, #93c5fd); }
.zz-alert--success { color: var(--zz-alert-success-foreground, #166534); background: var(--zz-alert-success-background, #dcfce7); border-color: var(--zz-alert-success-border, #86efac); }
.zz-alert--warning { color: var(--zz-alert-warning-foreground, #92400e); background: var(--zz-alert-warning-background, #fef3c7); border-color: var(--zz-alert-warning-border, #fcd34d); }
.zz-alert--danger  { color: var(--zz-alert-danger-foreground, #991b1b); background: var(--zz-alert-danger-background, #fef2f2); border-color: var(--zz-alert-danger-border, #fca5a5); }

/* ------------------------------------------------------------------- Card */
.zz-card {
  background: var(--zz-card-background, #fff);
  color: var(--zz-card-foreground, #111827);
  border: 1px solid var(--zz-card-border, #e5e7eb);
  border-radius: var(--zz-card-radius, 0.75rem);
  overflow: hidden;
}
.zz-card--elevation-flat { box-shadow: none; }
.zz-card--elevation-sm   { box-shadow: var(--zz-elevation-sm, 0 1px 2px 0 rgb(0 0 0 / .05)); }
.zz-card--elevation-md   { box-shadow: var(--zz-elevation-md, 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1)); }
.zz-card--elevation-lg   { box-shadow: var(--zz-elevation-lg, 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1)); }
.zz-card__header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--zz-card-border, #e5e7eb); }
.zz-card__footer { padding: 1rem 1.5rem; border-top: 1px solid var(--zz-card-border, #e5e7eb); background: var(--zz-card-footer-background, #f9fafb); }
.zz-card__body--pad-none { padding: 0; }
.zz-card__body--pad-sm   { padding: var(--zz-card-padding-sm, 1rem); }
.zz-card__body--pad-md   { padding: var(--zz-card-padding-md, 1.5rem); }
.zz-card__body--pad-lg   { padding: var(--zz-card-padding-lg, 2rem); }

/* ------------------------------------------------------------- PageHeader */
.zz-page-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
@media (min-width: 640px) {
  .zz-page-header { flex-direction: row; align-items: center; justify-content: space-between; }
}
.zz-page-header__main { display: flex; flex-direction: column; gap: .25rem; }
.zz-page-header__title { margin: 0; font-weight: var(--zz-page-header-title-weight, 700); color: var(--zz-page-header-title-color, #111827); }
.zz-page-header--hero .zz-page-header__title { font-size: 1.875rem; line-height: 2.25rem; }
.zz-page-header--standard .zz-page-header__title { font-size: 1.5rem; line-height: 2rem; }
.zz-page-header__subtitle { margin: 0; font-size: .875rem; color: var(--zz-page-header-subtitle-color, #6b7280); }
.zz-page-header__actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Badge — tone × variant (soft/solid). Hosts map the --zz-badge-* vars. */
.zz-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-inline: 0.625rem;
  padding-block: 0.125rem;
  border-radius: var(--zz-control-radius, 0.5rem);
  font-size: 0.75rem;
  font-weight: var(--zz-control-font-weight, 600);
  line-height: 1.5;
}
.zz-badge--primary-solid   { color: var(--zz-badge-primary-foreground, #fff);   background: var(--zz-badge-primary-background, #334155); }
.zz-badge--primary-soft    { color: var(--zz-badge-primary-foreground-soft, #334155); background: var(--zz-badge-primary-background-soft, #f1f5f9); }
.zz-badge--secondary-solid { color: var(--zz-badge-secondary-foreground, #fff); background: var(--zz-badge-secondary-background, #64748b); }
.zz-badge--secondary-soft  { color: var(--zz-badge-secondary-foreground-soft, #334155); background: var(--zz-badge-secondary-background-soft, #e2e8f0); }
.zz-badge--success-solid   { color: var(--zz-badge-success-foreground, #fff);   background: var(--zz-badge-success-background, #16a34a); }
.zz-badge--success-soft    { color: var(--zz-badge-success-foreground-soft, #166534); background: var(--zz-badge-success-background-soft, #dcfce7); }
.zz-badge--warning-solid   { color: var(--zz-badge-warning-foreground, #fff);   background: var(--zz-badge-warning-background, #d97706); }
.zz-badge--warning-soft    { color: var(--zz-badge-warning-foreground-soft, #92400e); background: var(--zz-badge-warning-background-soft, #fef3c7); }
.zz-badge--danger-solid    { color: var(--zz-badge-danger-foreground, #fff);    background: var(--zz-badge-danger-background, #dc2626); }
.zz-badge--danger-soft     { color: var(--zz-badge-danger-foreground-soft, #991b1b); background: var(--zz-badge-danger-background-soft, #fee2e2); }
.zz-badge--info-solid      { color: var(--zz-badge-info-foreground, #fff);      background: var(--zz-badge-info-background, #0ea5e9); }
.zz-badge--info-soft       { color: var(--zz-badge-info-foreground-soft, #075985); background: var(--zz-badge-info-background-soft, #e0f2fe); }

/* ErrorSummary — reuses the alert-danger vars. */
.zz-error-summary {
  padding: 0.75rem 1rem;
  border-radius: var(--zz-control-radius, 0.5rem);
  color: var(--zz-alert-danger-foreground, #991b1b);
  background: var(--zz-alert-danger-background, #fef2f2);
  border: 1px solid var(--zz-alert-danger-border, #fecaca);
  font-size: 0.875rem;
}

/* FormField — label/hint/error colors + control geometry. */
.zz-form-field { display: flex; flex-direction: column; gap: 0.375rem; }
.zz-form-field__label {
  font-size: 0.875rem;
  font-weight: var(--zz-control-font-weight, 600);
  color: var(--zz-form-field-label-color, #334155);
}
.zz-form-field__hint { font-size: 0.75rem; color: var(--zz-form-field-hint-color, #64748b); }
.zz-form-field__error { font-size: 0.75rem; color: var(--zz-form-field-error-color, #dc2626); }
/* Generic control surface (inputs, selects, textareas). Geometry only —
   sized off the shared --zz-control-* vars; must NOT set a blanket
   min-height (that would inflate single-line inputs). */
.zz-control {
  width: 100%;
  border-radius: var(--zz-control-radius, 0.5rem);
  border: 1px solid var(--zz-card-border, #e2e8f0);
  padding-inline: var(--zz-control-padding-x, 0.75rem);
  padding-block: 0.5rem;
}
textarea.zz-control { min-height: 8rem; }

/* Dark — stock overrides under the host-opt-in .dark class (Tailwind v4
   convention: html.dark). Values are neutral slate + standard hue scales;
   hosts re-map any role in their theme file, which loads after this sheet. */
.dark {
  /* Actions. */
  --zz-action-primary-background: #e2e8f0;
  --zz-action-primary-background-hover: #cbd5e1;
  --zz-action-primary-foreground: #0f172a;
  --zz-action-primary-foreground-soft: #e2e8f0;
  --zz-action-primary-background-soft: #1e293b;
  --zz-action-primary-outline: #475569;
  --zz-action-secondary-background: #334155;
  --zz-action-secondary-background-hover: #475569;
  --zz-action-secondary-foreground: #f1f5f9;
  --zz-action-secondary-foreground-soft: #94a3b8;
  --zz-action-secondary-background-soft: #1e293b;
  --zz-action-secondary-outline: #475569;
  --zz-action-success-background: #059669;
  --zz-action-success-background-hover: #047857;
  --zz-action-success-foreground: #ffffff;
  --zz-action-success-foreground-soft: #6ee7b7;
  --zz-action-success-background-soft: #064e3b;
  --zz-action-success-outline: #065f46;
  --zz-action-warning-background: #d97706;
  --zz-action-warning-background-hover: #b45309;
  --zz-action-warning-foreground: #ffffff;
  --zz-action-warning-foreground-soft: #fcd34d;
  --zz-action-warning-background-soft: #78350f;
  --zz-action-warning-outline: #92400e;
  --zz-action-danger-background: #dc2626;
  --zz-action-danger-background-hover: #b91c1c;
  --zz-action-danger-foreground: #ffffff;
  --zz-action-danger-foreground-soft: #fca5a5;
  --zz-action-danger-background-soft: #7f1d1d;
  --zz-action-danger-outline: #991b1b;
  --zz-action-info-background: #0284c7;
  --zz-action-info-background-hover: #0369a1;
  --zz-action-info-foreground: #ffffff;
  --zz-action-info-foreground-soft: #7dd3fc;
  --zz-action-info-background-soft: #0c4a6e;
  --zz-action-info-outline: #075985;

  /* Alerts. */
  --zz-alert-primary-background: #1e293b;
  --zz-alert-primary-border: #475569;
  --zz-alert-primary-foreground: #e2e8f0;
  --zz-alert-secondary-background: #1e293b;
  --zz-alert-secondary-border: #475569;
  --zz-alert-secondary-foreground: #cbd5e1;
  --zz-alert-success-background: #064e3b;
  --zz-alert-success-border: #065f46;
  --zz-alert-success-foreground: #6ee7b7;
  --zz-alert-warning-background: #78350f;
  --zz-alert-warning-border: #92400e;
  --zz-alert-warning-foreground: #fcd34d;
  --zz-alert-danger-background: #7f1d1d;
  --zz-alert-danger-border: #991b1b;
  --zz-alert-danger-foreground: #fca5a5;
  --zz-alert-info-background: #0c4a6e;
  --zz-alert-info-border: #075985;
  --zz-alert-info-foreground: #7dd3fc;

  /* Badges (solid bg/fg, then soft bg/fg). */
  --zz-badge-primary-background: #e2e8f0;
  --zz-badge-primary-foreground: #0f172a;
  --zz-badge-primary-background-soft: #1e293b;
  --zz-badge-primary-foreground-soft: #e2e8f0;
  --zz-badge-secondary-background: #334155;
  --zz-badge-secondary-foreground: #f1f5f9;
  --zz-badge-secondary-background-soft: #1e293b;
  --zz-badge-secondary-foreground-soft: #94a3b8;
  --zz-badge-success-background: #059669;
  --zz-badge-success-foreground: #ffffff;
  --zz-badge-success-background-soft: #064e3b;
  --zz-badge-success-foreground-soft: #6ee7b7;
  --zz-badge-warning-background: #d97706;
  --zz-badge-warning-foreground: #ffffff;
  --zz-badge-warning-background-soft: #78350f;
  --zz-badge-warning-foreground-soft: #fcd34d;
  --zz-badge-danger-background: #dc2626;
  --zz-badge-danger-foreground: #ffffff;
  --zz-badge-danger-background-soft: #7f1d1d;
  --zz-badge-danger-foreground-soft: #fca5a5;
  --zz-badge-info-background: #0284c7;
  --zz-badge-info-foreground: #ffffff;
  --zz-badge-info-background-soft: #0c4a6e;
  --zz-badge-info-foreground-soft: #7dd3fc;

  /* Card + controls + elevation + type colors. */
  --zz-card-background: #0f172a;
  --zz-card-border: #334155;
  --zz-card-footer-background: #1e293b;
  --zz-card-foreground: #f1f5f9;
  --zz-control-focus-ring: #94a3b8;
  --zz-elevation-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --zz-elevation-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --zz-elevation-lg: 0 16px 32px rgba(0, 0, 0, 0.55);
  --zz-page-header-title-color: #f1f5f9;
  --zz-page-header-subtitle-color: #94a3b8;
  --zz-form-field-label-color: #e2e8f0;
  --zz-form-field-hint-color: #94a3b8;
  --zz-form-field-error-color: #f87171;
}
