/* SkyCanvass Design System — Component Styles
 * All components are token-driven; tweak tokens.css to retheme the system.
 */

/* === BUTTON ============================================================== */
.sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  outline: none;
}
.sc-btn:focus-visible { box-shadow: var(--shadow-focus); }
.sc-btn[disabled], .sc-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.sc-btn .lucide { width: 16px; height: 16px; }

/* sizes */
.sc-btn-xs { height: 24px; padding: 0 8px;  font-size: var(--text-xs); border-radius: var(--radius-sm); gap: 4px; }
.sc-btn-sm { height: 30px; padding: 0 10px; font-size: var(--text-sm); }
.sc-btn-lg { height: 44px; padding: 0 18px; font-size: var(--text-md); }
.sc-btn-xs .lucide { width: 12px; height: 12px; }
.sc-btn-sm .lucide { width: 14px; height: 14px; }

/* variants */
.sc-btn-primary { background: var(--primary); color: var(--primary-fg); }
.sc-btn-primary:hover { background: var(--primary-hover); }
.sc-btn-primary:active { background: var(--primary-active); }

.sc-btn-secondary {
  background: var(--bg-subtle);
  color: var(--fg);
  border-color: var(--border);
}
.sc-btn-secondary:hover { background: var(--bg-muted); border-color: var(--border-strong); }

.sc-btn-outline {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.sc-btn-outline:hover { background: var(--bg-subtle); }

.sc-btn-ghost {
  background: transparent;
  color: var(--fg-muted);
}
.sc-btn-ghost:hover { background: var(--bg-subtle); color: var(--fg); }

.sc-btn-link {
  background: transparent;
  color: var(--primary);
  height: auto;
  padding: 0;
  border-radius: 0;
}
.sc-btn-link:hover { text-decoration: underline; }

.sc-btn-danger { background: var(--danger-500); color: white; }
.sc-btn-danger:hover { background: var(--danger-700); }

.sc-btn-icon { width: 36px; padding: 0; }
.sc-btn-icon.sc-btn-sm { width: 30px; }
.sc-btn-icon.sc-btn-xs { width: 24px; }

/* === METADATA CHIP (Tier 1) ============================================= */
/* Neutral chip + small colored dot. For type/role/category — describes, doesn't decide. */
.sc-meta {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}
.sc-meta .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #94a3b8; flex-shrink: 0;
}
.sc-meta-neutral .dot { background: #64748b; }
.sc-meta-primary .dot { background: #0284c7; }
.sc-meta-success .dot { background: #059669; }
.sc-meta-warning .dot { background: #d97706; }
.sc-meta-danger  .dot { background: #dc2626; }
.sc-meta-info    .dot { background: #2563eb; }
.sc-meta-purple  .dot { background: #7c3aed; }

/* Backwards compat — old .sc-badge classes route to metadata chips */
.sc-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: var(--weight-semibold); line-height: 1; height: 22px; padding: 0 9px; border-radius: 6px; background: #f8fafc; color: #334155; border: 1px solid #e2e8f0; white-space: nowrap; }
.sc-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
.sc-badge-neutral::before { background: #64748b; }
.sc-badge-primary::before { background: #0284c7; }
.sc-badge-success::before { background: #059669; }
.sc-badge-warning::before { background: #d97706; }
.sc-badge-danger::before  { background: #dc2626; }
.sc-badge-info::before    { background: #2563eb; }
.sc-badge-outline { background: transparent; border-color: var(--border-strong); }
.sc-badge-outline::before { display: none; }

/* === STATE INDICATOR (Tier 2) ========================================== */
/* No chip — just a 7px square dot + text inline. Lightest possible touch.
   For lifecycle/severity/activity that lives inside table cells. */
.sc-state {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: #0f172a;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.sc-state::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 1.5px;
  background: #64748b;
  flex-shrink: 0;
}
.sc-state-neutral::before { background: #64748b; }
.sc-state-primary::before { background: #0284c7; }
.sc-state-success::before { background: #059669; }
.sc-state-warning::before { background: #d97706; }
.sc-state-danger::before  { background: #dc2626; }
.sc-state-info::before    { background: #2563eb; }

/* Compact variant for very dense tables */
.sc-state-sm { font-size: 11.5px; gap: 6px; }
.sc-state-sm::before { width: 6px; height: 6px; }

/* === DECISION CHIP (Tier 3) ============================================= */
/* Confident filled chip with leading icon. Reserved for terminal outcomes. */
.sc-decision {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  height: 24px;
  padding: 0 10px 0 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.sc-decision .icon {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; line-height: 1;
  flex-shrink: 0;
}
.sc-decision-approved { background: #047857; color: #fff; border-color: #047857; }
.sc-decision-pending  { background: #b45309; color: #fff; border-color: #b45309; }
.sc-decision-denied   { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.sc-decision-archived { background: var(--slate-700); color: #fff; border-color: var(--slate-700); }

/* Quieter outline variant of decision — for lighter contexts */
.sc-decision-outline.sc-decision-approved { background: #fff; color: #047857; border-color: #047857; }
.sc-decision-outline.sc-decision-pending  { background: #fff; color: #b45309; border-color: #b45309; }
.sc-decision-outline.sc-decision-denied   { background: #fff; color: #b91c1c; border-color: #b91c1c; }
.sc-decision-outline.sc-decision-archived { background: #fff; color: var(--slate-700); border-color: var(--slate-400); }

/* Backwards compat — old .sc-status classes route to decision chips */
.sc-status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-sans); font-size: 12px; font-weight: var(--weight-semibold); line-height: 1; height: 24px; padding: 0 10px 0 8px; border-radius: 6px; border: 1px solid transparent; white-space: nowrap; letter-spacing: -0.005em; }
.sc-status .dot { display: none; }
.sc-status::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: rgba(255,255,255,0.25); flex-shrink: 0;
}
.sc-status-active   { background: #047857; color: #fff; border-color: #047857; }
.sc-status-pending  { background: #b45309; color: #fff; border-color: #b45309; }
.sc-status-rejected { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.sc-status-archived { background: var(--slate-700); color: #fff; border-color: var(--slate-700); }

/* === INPUT =============================================================== */
.sc-field { display: flex; flex-direction: column; gap: 6px; }
.sc-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg);
}
.sc-help { font-size: var(--text-xs); color: var(--fg-subtle); }
.sc-error { font-size: var(--text-xs); color: var(--danger-700); }

.sc-input,
.sc-textarea,
.sc-select {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.sc-input::placeholder, .sc-textarea::placeholder { color: var(--fg-subtle); }
.sc-input:hover, .sc-select:hover, .sc-textarea:hover { border-color: var(--slate-400); }
.sc-input:focus, .sc-select:focus, .sc-textarea:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.sc-input[aria-invalid="true"] { border-color: var(--danger-500); }
.sc-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgb(239 68 68 / 0.18); }
.sc-textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; line-height: var(--leading-normal); }

/* input with icon */
.sc-input-group { position: relative; }
.sc-input-group .sc-input { padding-left: 36px; }
.sc-input-group > .lucide {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--fg-subtle); pointer-events: none;
}

/* select native chevron */
.sc-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='4,6 8,10 12,6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* checkbox / radio */
.sc-check, .sc-radio {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--text-base);
  color: var(--fg);
  cursor: pointer;
  user-select: none;
}
.sc-check input, .sc-radio input {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.sc-check input { border-radius: var(--radius-xs); }
.sc-radio input { border-radius: 50%; }
.sc-check input:hover, .sc-radio input:hover { border-color: var(--slate-400); }
.sc-check input:checked, .sc-radio input:checked { background: var(--primary); border-color: var(--primary); }
.sc-check input:checked::after {
  content: ""; width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='2.5,6.5 5,9 9.5,3.5'/></svg>") center/contain no-repeat;
}
.sc-radio input:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: white; }
.sc-check input:focus-visible, .sc-radio input:focus-visible { box-shadow: var(--shadow-focus); }

/* toggle */
.sc-toggle { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.sc-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sc-toggle-track {
  width: 32px; height: 18px;
  background: var(--slate-300);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--duration-fast);
}
.sc-toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-out);
}
.sc-toggle input:checked + .sc-toggle-track { background: var(--primary); }
.sc-toggle input:checked + .sc-toggle-track::after { transform: translateX(14px); }

/* === CARD ================================================================ */
.sc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.sc-card-pad { padding: 20px; }
.sc-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.sc-card-title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin: 0; }
.sc-card-body { padding: 20px; }
.sc-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* === TABLE =============================================================== */
.sc-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.sc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.sc-table th, .sc-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.sc-table thead th {
  background: var(--bg-muted);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--fg-subtle);
}
.sc-table tbody tr:last-child td { border-bottom: none; }
.sc-table tbody tr:hover { background: var(--bg-muted); }
.sc-table td.num, .sc-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* === NAVIGATION ========================================================== */
.sc-topnav {
  display: flex; align-items: center; gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.sc-topnav-brand { display: flex; align-items: center; gap: 8px; font-weight: var(--weight-semibold); font-size: 0.9375rem; }
.sc-topnav-links { display: flex; gap: 4px; margin-left: 24px; }
.sc-topnav-link {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}
.sc-topnav-link:hover { background: var(--bg-subtle); color: var(--fg); }
.sc-topnav-link.active { color: var(--primary); }
.sc-topnav-spacer { flex: 1; }

.sc-sidenav {
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  width: 240px;
  padding: 16px 12px;
}
.sc-sidenav-section { margin-bottom: 12px; }
.sc-sidenav-label { font-size: 10px; font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-wider); color: var(--fg-subtle); padding: 4px 8px; }
.sc-sidenav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}
.sc-sidenav a:hover { background: var(--bg-subtle); color: var(--fg); }
.sc-sidenav a.active { background: var(--primary-soft); color: var(--primary-soft-fg); }
.sc-sidenav .lucide { width: 16px; height: 16px; }

.sc-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--text-base); color: var(--fg-subtle); }
.sc-breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.sc-breadcrumb a:hover { color: var(--fg); }
.sc-breadcrumb .sep { color: var(--slate-400); }
.sc-breadcrumb .current { color: var(--fg); font-weight: var(--weight-medium); }

/* === MODAL =============================================================== */
.sc-modal-backdrop {
  position: fixed; inset: 0; background: rgb(15 23 42 / 0.5);
  display: grid; place-items: center;
  z-index: var(--z-modal);
  padding: 24px;
}
.sc-modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px;
  overflow: hidden;
}
.sc-modal-header { padding: 20px 24px 8px; }
.sc-modal-title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin: 0 0 4px; }
.sc-modal-desc { font-size: var(--text-base); color: var(--fg-muted); margin: 0; }
.sc-modal-body { padding: 16px 24px; }
.sc-modal-footer { padding: 16px 24px; background: var(--bg-muted); display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }

/* === TOOLTIP ============================================================= */
.sc-tooltip {
  display: inline-block;
  background: var(--slate-900);
  color: var(--slate-50);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  position: relative;
}
.sc-tooltip::after {
  content: "";
  position: absolute; top: 100%; left: 50%;
  border: 5px solid transparent;
  border-top-color: var(--slate-900);
  transform: translateX(-50%);
}

/* === COMBOBOX ============================================================ */
.sc-combobox {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  width: 320px;
}
.sc-combobox-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sc-combobox-search input {
  flex: 1; border: none; outline: none; font-size: var(--text-base);
  background: transparent; color: var(--fg);
}
.sc-combobox-search .lucide { width: 16px; height: 16px; color: var(--fg-subtle); }
.sc-combobox-list { max-height: 280px; overflow-y: auto; padding: 4px; }
.sc-combobox-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-base);
}
.sc-combobox-item:hover, .sc-combobox-item[aria-selected="true"] { background: var(--bg-subtle); }
.sc-combobox-item .check { margin-left: auto; color: var(--primary); width: 14px; height: 14px; }
.sc-combobox-empty { padding: 20px; text-align: center; color: var(--fg-subtle); font-size: var(--text-base); }

/* === SKELETON ============================================================ */
.sc-skel {
  background: linear-gradient(90deg, var(--slate-100) 0%, var(--slate-200) 50%, var(--slate-100) 100%);
  background-size: 200% 100%;
  animation: sc-shimmer 1.5s infinite var(--ease-in-out);
  border-radius: var(--radius-sm);
}
@keyframes sc-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sc-skel-line { height: 12px; }
.sc-skel-circle { border-radius: 50%; }

/* === CODE BLOCK ========================================================== */
.sc-code {
  background: var(--slate-900);
  color: var(--slate-100);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  position: relative;
}
.sc-code-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--slate-800);
  color: var(--slate-300);
  padding: 8px 16px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.sc-code-header + .sc-code { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* === CODE CITATION ======================================================= */
.sc-citation {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
}
.sc-citation-meta {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: 8px;
}
.sc-citation-section { color: var(--primary); font-weight: var(--weight-semibold); }
.sc-citation-quote {
  font-size: var(--text-md);
  color: var(--fg);
  line-height: var(--leading-relaxed);
  margin: 0;
}
.sc-citation-source {
  display: flex; gap: 12px; align-items: center;
  margin-top: 8px;
  font-size: var(--text-xs);
  color: var(--fg-subtle);
}
.sc-citation-source a { color: var(--primary); text-decoration: none; }

/* === DATE PICKER ========================================================= */
.sc-datepicker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 12px;
  width: 280px;
}
.sc-dp-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; }
.sc-dp-month { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.sc-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.sc-dp-dow { font-size: 10px; font-weight: var(--weight-semibold); color: var(--fg-subtle); text-align: center; padding: 6px 0; text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.sc-dp-day {
  height: 32px; display: grid; place-items: center;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.sc-dp-day:hover { background: var(--bg-subtle); }
.sc-dp-day.muted { color: var(--fg-subtle); }
.sc-dp-day.today { box-shadow: inset 0 0 0 1px var(--primary); }
.sc-dp-day.selected { background: var(--primary); color: var(--primary-fg); }
.sc-dp-day.in-range { background: var(--primary-soft); color: var(--primary-soft-fg); border-radius: 0; }

/* === TIMELINE ============================================================ */
.sc-timeline { position: relative; padding-left: 24px; }
.sc-timeline::before {
  content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px; background: var(--border);
}
.sc-timeline-item { position: relative; padding-bottom: 20px; }
.sc-timeline-item::before {
  content: ""; position: absolute; left: -21px; top: 4px;
  width: 12px; height: 12px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 50%;
}
.sc-timeline-item.past::before { background: var(--primary); }
.sc-timeline-time { font-family: var(--font-mono); font-size: 11px; color: var(--fg-subtle); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.sc-timeline-title { font-size: var(--text-base); font-weight: var(--weight-semibold); margin: 2px 0 4px; }
.sc-timeline-body { font-size: var(--text-sm); color: var(--fg-muted); }

/* === HAIL LEGEND ========================================================= */
.sc-hail-legend {
  display: flex; align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
}
.sc-hail-step {
  flex: 1;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
  color: var(--slate-900);
}
.sc-hail-step .sz { font-weight: var(--weight-semibold); }
.sc-hail-step .lb { opacity: 0.75; font-size: 10px; }
