/*
 * components.css — reusable primitives composed by every screen:
 * buttons, pills, dots, ID chips, cards, KPI cards, toolbars, pagination,
 * the right-hand detail drawer, forms, tabs.
 */

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff; color: var(--text);
  font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--row-hover); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #4338CA; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--row-hover); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn .icon { width: 15px; height: 15px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ---- amber mirror badge ---- */
.mirror-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--amber);
  color: var(--amber-text);
  background: var(--amber-bg);
  border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---- pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
  white-space: nowrap;
}
.pill--teal { background: var(--teal-bg); color: var(--teal-text); }
.pill--amber { background: var(--amber-bg); color: var(--amber-text); }
.pill--red { background: var(--red-bg); color: var(--red-text); }
.pill--slate { background: var(--slate-bg); color: var(--slate-text); }
.pill--indigo { background: var(--indigo-bg); color: var(--indigo-text); }

/* ---- status dots ---- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot--on { background: var(--teal); }
.dot--off { background: transparent; border: 1.5px solid var(--muted); }
.dot--amber { background: var(--amber); }
.dot--red { background: var(--red); }
.dot-label { display: inline-flex; align-items: center; gap: 7px; }

/* ---- ID / ISO chips ---- */
.chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-secondary);
  background: var(--slate-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.chip--iso { text-transform: uppercase; letter-spacing: 0.03em; }
.chip--copy { cursor: pointer; }
.chip--copy:hover { background: #E2E8F0; }

/* ---- callout banners ---- */
.callout { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 14px 18px; }
.callout--teal { background: #F0FDFA; border-left-color: var(--teal); color: #0F766E; }
.callout--indigo { background: #EEF2FF; border-left-color: var(--accent-2); color: #3730A3; }
.callout--amber { background: #FFFBEB; border-left-color: var(--amber); color: #92400E; }
.callout h3 { color: inherit; font-size: 14px; margin-bottom: 4px; }

/* ---- cards ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: 14px; font-weight: 600; }
.card__head .card__meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.card__body { padding: 18px; }
.card--accent-top { border-top: 2px solid var(--accent-2); }
.card--accent-top-teal { border-top: 2px solid var(--teal); }

/* ---- KPI stat cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi--accent { border-top: 2px solid var(--accent-2); }
.kpi__label { font-size: var(--fs-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi__value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi__caption { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- definition list (detail cards) ---- */
.dl { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 10px 18px; align-items: baseline; }
.dl dt { font-size: var(--fs-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-size: 13px; color: var(--text); word-break: break-word; }
.dl dd.mono { font-variant-numeric: tabular-nums; }

/* ---- two-column detail layout ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail-rail { display: flex; flex-direction: column; gap: 20px; }
.dual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* detail page header */
.detail-head { margin-bottom: 20px; }
.detail-head__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head__row h1 { font-size: 24px; letter-spacing: -0.02em; }
.detail-head__actions { margin-left: auto; display: flex; gap: 10px; }
.detail-head .subtitle { color: var(--muted); margin-top: 6px; font-size: 13px; }

/* ---- results toolbar (above tables) ---- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar__count { font-size: 13px; color: var(--text-secondary); }
.toolbar__count strong { color: var(--text); font-variant-numeric: tabular-nums; }
.toolbar__spacer { margin-left: auto; }
.toolbar .chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* filter chips / removable */
.fchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: #fff; font-size: 12px; color: var(--text-secondary); }
.fchip button { border: none; background: none; color: var(--muted); padding: 0; line-height: 1; font-size: 14px; }

/* ---- filter bar / inputs ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: var(--fs-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.input, .select {
  height: 34px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 10px; font-size: 13px; background: #fff; color: var(--text); min-width: 150px;
}
.input:focus, .select:focus { border-color: var(--accent-2); outline: none; }

/* ---- pagination ---- */
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager button { width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; }
.pager button:hover:not([disabled]) { background: var(--row-hover); }
.pager button[disabled] { opacity: 0.4; cursor: default; }
.pager .page-size { height: 30px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 6px; font-size: 12px; background: #fff; }

/* ---- horizontal bar list (dashboard largest tables) ---- */
.barlist { display: flex; flex-direction: column; gap: 12px; }
.barlist__row { display: grid; grid-template-columns: 190px 1fr auto; gap: 12px; align-items: center; }
.barlist__name { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.barlist__track { height: 8px; background: var(--slate-bg); border-radius: 4px; overflow: hidden; }
.barlist__fill { height: 100%; background: var(--accent-2); border-radius: 4px; }
.barlist__val { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; text-align: right; }

/* ---- clearance matrix ---- */
.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.matrix th.terr, .matrix td.terr { text-align: left; white-space: nowrap; }
.matrix thead th { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }

/* ---- tabs / segmented control ---- */
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.tabs button { height: 32px; padding: 0 14px; border: none; background: #fff; color: var(--text-secondary); font-size: 13px; font-weight: 500; border-right: 1px solid var(--border); }
.tabs button:last-child { border-right: none; }
.tabs button.active { background: var(--accent); color: #fff; }

/* ---- right-hand drawer ---- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 420px; background: #fff; border-left: 1px solid var(--border); z-index: 41; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(15,23,42,0.08); }
.drawer__head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer__body { padding: 20px; overflow-y: auto; }

/* ---- JSON viewer ---- */
.json-view { font-family: var(--font-mono); font-size: 12px; line-height: 1.6; white-space: pre; overflow: auto; background: #0F172A; color: #E2E8F0; border-radius: var(--radius); padding: 16px; max-height: 70vh; }
.json-view .k { color: #93C5FD; }
.json-view .s { color: #86EFAC; }
.json-view .n { color: #FCA5A5; }
.json-view .b { color: #FCD34D; }

/* ---- misc ---- */
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.section-label { font-size: var(--fs-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.hairline-note { color: var(--amber-text); font-size: 12px; margin-top: 12px; }
.cover { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); background: var(--slate-bg); }
.cover-thumb { width: 56px; height: 56px; border-radius: var(--radius); border: 1px solid var(--border); background: linear-gradient(135deg, #1E293B, #4338CA); color: #C7D2FE; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.lookup { max-width: 460px; }
.lookup .input { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stat-inline { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-inline .s-val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-inline .s-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ---- utility classes (CSP style-src 'self' forbids inline style=) ---- */
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.p-0 { padding: 0; }
.pad-16 { padding: 16px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-15 { font-size: 15px; }
.text-secondary { color: var(--text-secondary); }
.teal { color: var(--teal); }
.big-stat { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--teal); }
.capitalize { text-transform: capitalize; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.wrap-gap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; }
.full { width: 100%; }
.pager__info { font-size: 12px; padding: 0 8px; font-variant-numeric: tabular-nums; }
