/*
 * components-core.css — foundational UI: drop zone, loaders, before/after
 * report, reset button, action bar, stat cards, site filter, tables, charts.
 */

/*
 * components.css — reusable UI components: drop zone, buttons, stat cards,
 * tables, badges, mini bars, chart wrappers, country list, unknown agents panel,
 * and the AI-warning banner.
 * Edit here when restyling individual UI elements.
 */

/* ── Drop zone ── */
.drop-zone {
  width: 100%;
  max-width: 520px;
  border: 1.5px dashed var(--border2);
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--accent); background: rgba(79,156,249,.05); }

.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.drop-icon {
  width: 48px; height: 48px;
  margin: 0 auto 1.25rem;
  border-radius: 12px;
  background: rgba(79,156,249,.12);
  display: flex; align-items: center; justify-content: center;
}

.drop-icon svg { width: 24px; height: 24px; stroke: var(--accent); fill: none; stroke-width: 1.5; }

.drop-title  { font-size: 18px; font-weight: 500; margin-bottom: .4rem; }
.drop-sub    { font-size: 13px; color: var(--muted); }
.drop-hint   { margin-top: 2.5rem; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }

#error-msg { margin-top: 1rem; color: #f48fb1; font-size: 13px; display: none; }

/* ── Before / after loader ── */
.compare-loader {
  width: 100%;
  max-width: 720px;
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.compare-loader-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}

.compare-loader-head span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.compare-loader-head small {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.compare-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compare-upload {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px dashed var(--border2);
  border-radius: 10px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  min-width: 0;
}

.compare-upload:hover {
  border-color: var(--accent);
  background: rgba(79,156,249,.06);
}

.compare-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.compare-upload-title {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
}

.compare-upload-summary {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-status {
  margin-top: .75rem;
  color: var(--muted);
  font-size: 12px;
}

.compare-status.compare-error { color: var(--block); }

/* ── Before / after report ── */
.before-after-panel {
  overflow: visible;
}

.ba-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, max-content);
  gap: 1rem;
  align-items: start;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,.025);
  margin-bottom: 1rem;
}

.ba-good { border-left-color: var(--allow); }
.ba-bad { border-left-color: var(--block); }
.ba-mixed { border-left-color: var(--challenge); }

.ba-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 4px;
}

.ba-head h2 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 500;
  margin-bottom: 5px;
}

.ba-head p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ba-files {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.ba-files span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ba-files strong {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 11px;
}

.ba-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.ba-narrative {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.ba-narrative > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  background: rgba(255,255,255,.018);
}

.ba-narrative strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.ba-narrative ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ba-narrative li + li {
  margin-top: 4px;
}

.ba-notice {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 1rem;
  font-size: 13px;
  line-height: 1.5;
}

.ba-notice-info {
  background: rgba(79,156,249,.06);
  border-color: rgba(79,156,249,.2);
  color: #9ecbff;
}

.ba-notice-warn {
  background: rgba(255,183,77,.07);
  border-color: rgba(255,183,77,.25);
  color: #ffcc80;
}

.ba-notice-danger {
  background: rgba(239,154,154,.07);
  border-color: rgba(239,154,154,.25);
  color: #ef9a9a;
}

.ba-summary-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.ba-summary-card span {
  display: block;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.2;
}

.ba-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.ba-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.ba-table th {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0 8px 10px;
}

.ba-table th.r,
.ba-table td.r {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.ba-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 8px;
  vertical-align: top;
}

.ba-table td strong {
  display: block;
  font-weight: 500;
}

.ba-table td span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.ba-row-good td:last-child { color: var(--allow); }
.ba-row-bad td:last-child { color: var(--block); }
.ba-row-neutral td:last-child { color: var(--muted); }

.ba-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.ba-detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: rgba(255,255,255,.018);
  min-width: 0;
}

.ba-detail-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .75rem;
}

.ba-path-list {
  display: grid;
  gap: 7px;
}

.ba-path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.ba-path-row code {
  color: var(--text);
  overflow-wrap: anywhere;
}

.ba-path-row span {
  white-space: nowrap;
}

.ba-investigation {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.ba-investigation-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ba-investigation-head span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.ba-investigation-head small {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.ba-investigation-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.ba-investigation-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: rgba(255,255,255,.018);
  min-width: 0;
}

.ba-investigation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.ba-investigation-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ba-investigation-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ba-investigation-main strong {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ba-investigation-main span {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.ba-investigation-main code {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.ba-investigation-rate {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

/* ── Reset button ── */
.reset-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  white-space: nowrap;
}

.reset-btn:hover { border-color: var(--accent); color: var(--accent); }

.print-btn {
  background: rgba(255,255,255,.035);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  white-space: nowrap;
}

.print-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79,156,249,.08);
}

/* ── Action summary bar ── */
.action-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  animation: fadeUp .3s ease both;
}

.action-bar-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 1rem;
}

.action-track {
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  width: 100%;
  margin-bottom: .85rem;
}

.action-seg {
  height: 100%;
  transition: width .6s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  cursor: default;
}

.action-seg:first-child { border-radius: 6px 0 0 6px; }
.action-seg:last-child  { border-radius: 0 6px 6px 0; }

.action-pills { display: flex; flex-wrap: wrap; gap: 10px; }

.action-pill { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.action-pill-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.action-pill-label  { color: var(--muted); font-size: 12px; }
.action-pill-count  { font-family: var(--font-mono); font-weight: 500; }

/* ── Stat cards ── */
.stat-card {
  appearance: none;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  animation: fadeUp .4s ease both;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}

.stat-card:hover {
  border-color: var(--border2);
  background: rgba(255,255,255,.035);
  transform: translateY(-1px);
}

.stat-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-family: var(--font-mono); margin-bottom: 5px; }
.stat-value { font-size: 24px; font-weight: 300; letter-spacing: -.5px; }

/* ── Site / subdomain filter ── */
.site-filter {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  animation: fadeUp .35s ease both;
}

.site-filter-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.site-filter-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.site-filter-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.site-pill {
  appearance: none;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,.025);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 9px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  cursor: pointer;
}

.site-pill span {
  color: var(--muted);
  flex-shrink: 0;
}

.site-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.site-pill.active {
  border-color: rgba(79,156,249,.55);
  background: rgba(79,156,249,.12);
  color: var(--accent);
}

/* ── Scrollable table wrapper ── */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* thin scrollbar on desktop */
  scrollbar-color: #3a424d var(--surface);
  scrollbar-width: thin;
}

.table-scroll::-webkit-scrollbar        { height: 6px; }
.table-scroll::-webkit-scrollbar-track  { background: var(--surface); }
.table-scroll::-webkit-scrollbar-thumb  { background: #3a424d; border-radius: 999px; }

/* ── Chart wrapper and legends ── */
.chart-wrap { position: relative; width: 100%; overflow: hidden; }

/* Canvas must never exceed its wrapper — prevents bar/donut charts from blowing out panels */
canvas { max-width: 100%; display: block; }

.legend        { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1rem; font-size: 12px; color: var(--muted); }
.legend-item   { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ── Enforcement table ── */
.enf-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }

.enf-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  text-align: left;
}

.enf-table th.r { text-align: right; }

.enf-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.enf-table tr:last-child td { border-bottom: none; }
.enf-table tr:hover td      { background: rgba(255,255,255,.02); }

.enf-table .table-summary-row td {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
  line-height: 1.45;
  background: rgba(255,255,255,.025);
}

.rules-scroll {
  max-height: 370px;
  overflow-y: auto;
  overflow-x: auto;
  padding-right: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #3a424d var(--surface);
  scrollbar-width: thin;
}

.rules-scroll::-webkit-scrollbar { width: 8px; }
.rules-scroll::-webkit-scrollbar-track { background: var(--surface); }
.rules-scroll::-webkit-scrollbar-thumb {
  background: #3a424d;
  border: 2px solid var(--surface);
  border-radius: 999px;
}

.rules-scroll .enf-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

/* ── Full bot breakdown table ── */
.bot-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }

.bot-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.bot-table th.r { text-align: right; }

.bot-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-table tr:last-child td { border-bottom: none; }
.bot-table tr:hover td      { background: rgba(255,255,255,.02); }

.col-bot    { width: 20%; }
.col-vendor { width: 12%; }
.col-cat    { width: 16%; }
.col-hits   { width: 7%; }
.col-pct    { width: 6%; }
.col-ips    { width: 6%; }
.col-action { width: 22%; }
.col-bar    { width: 11%; }

/* ── Table cell helpers ── */
.bot-name   { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.color-pip  { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.cat-badge  { font-size: 11px; font-family: var(--font-mono); padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.action-badge { font-size: 11px; font-family: var(--font-mono); padding: 2px 7px; border-radius: 4px; white-space: nowrap; display: inline-block; }
.td-num   { text-align: right; font-family: var(--font-mono); }
.td-muted { text-align: right; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }

.bar-track { height: 4px; background: var(--border2); border-radius: 2px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 2px; }

/* ── Mini action bars (inside enforcement table) ── */
.mini-actions { display: flex; gap: 3px; align-items: center; }
.mini-seg     { height: 6px; border-radius: 2px; min-width: 3px; }

/* ── CSV export button (panel title corner) ── */
.csv-btn {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.csv-btn:hover { border-color: var(--accent); color: var(--accent); }

