/* ============================================================
   Light Theme — Spam Detection Interactive UI
   ============================================================ */
:root {
  --bg:       #f0f4f8;
  --panel:    #ffffff;
  --panel2:   #f8fafc;
  --text:     #1e293b;
  --muted:    #64748b;
  --line:     rgba(15, 23, 42, 0.10);
  --shadow:   0 2px 10px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.05);

  --ham:    #16a34a;
  --spam:   #dc2626;
  --accent: #2563eb;
  --warn:   #d97706;

  --lr:  #1d4ed8;
  --knn: #7c3aed;
  --nb:  #be185d;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% 0%,  rgba(37,99,235,.07),  transparent 60%),
    radial-gradient(700px 400px at 90% 10%, rgba(124,58,237,.05), transparent 55%),
    radial-gradient(800px 500px at 60% 90%, rgba(22,163,74,.06),  transparent 55%),
    #eef2f9;
  min-height: 100vh;
}

.app { max-width: 1200px; margin: 20px auto; padding: 0 16px 28px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: #ffffff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
}
.brand__title { font-weight: 800; letter-spacing: .2px; font-size: 18px; color: var(--text); }
.brand__sub   { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.status       { display: flex; align-items: center; gap: 10px; }
.pill {
  padding: 6px 12px; border-radius: 999px;
  background: #f1f5f9; border: 1px solid var(--line);
  color: var(--text); font-size: 12px; white-space: nowrap;
}
.pill--muted { color: var(--muted); }

/* Tabs */
.tabs {
  display: flex; gap: 8px; margin: 14px 0 10px; padding: 6px;
  border-radius: 14px; border: 1px solid var(--line);
  background: #ffffff; box-shadow: var(--shadow);
}
.tab {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-weight: 700;
  font-size: 13.5px; letter-spacing: .2px; transition: background .15s, color .15s;
}
.tab:hover { background: #f1f5f9; color: var(--text); }
.tab.is-active {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border-color: rgba(37,99,235,.25); color: var(--accent);
  box-shadow: 0 1px 4px rgba(37,99,235,.12);
}
.panels { display: block; }
.panel  { display: none; }
.panel.is-active { display: block; }

/* Panel header */
.panelHeader { padding: 10px 6px 2px; }
.panelHeader h2 {
  margin: 6px 0 6px; font-size: 19px; font-weight: 800;
  letter-spacing: .2px; color: var(--text);
}
.panelHeader p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* Cards */
.card {
  background: #ffffff; border: 1px solid var(--line);
  border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.cardTitle { font-weight: 800; color: var(--text); margin-bottom: 10px; font-size: 13.5px; }

/* Formula Box */
.formulaBox {
  background: linear-gradient(135deg, #f8faff 0%, #f0fdf4 100%);
  border: 1px solid rgba(37,99,235,.18);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 14px 20px 12px; margin: 12px 0;
}
.formulaBox__label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px;
  color: var(--accent); margin-bottom: 8px;
}
.formulaBox__eq {
  text-align: center; font-size: 15px; color: var(--text);
  margin: 4px 0; overflow-x: auto;
}
.formulaBox__note {
  text-align: center; font-size: 12px;
  color: var(--muted); margin-top: 8px;
}
.fml {
  display: inline-block; background: #eff6ff;
  border: 1px solid rgba(37,99,235,.18); border-radius: 6px;
  padding: 1px 7px; font-size: 12.5px; color: #1d4ed8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Algo formula bar inside c3 panel cards */
.algoFormula {
  background: rgba(0,0,0,.03); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 10px; text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--text); border: 1px solid rgba(0,0,0,.06);
}

/* Controls */
.controlsRow { display: flex; gap: 16px; align-items: flex-end; }
.controlsRow--wrap { flex-wrap: wrap; }
.control        { min-width: 240px; flex: 1; }
.control--wide  { flex: 2; min-width: 320px; }
.control--btn   { flex: 0 0 auto; min-width: auto; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
select, textarea {
  width: 100%; background: #f8fafc;
  border: 1px solid rgba(15,23,42,.14); color: var(--text);
  border-radius: 10px; padding: 10px 12px; outline: none;
  font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
textarea:disabled { opacity: .55; background: #f1f5f9; }
.sliderRow { display: flex; align-items: center; gap: 10px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.readout {
  min-width: 44px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text);
}

/* Buttons */
.btn {
  border-radius: 10px; border: 1px solid var(--line); padding: 10px 16px;
  color: var(--text); background: #f8fafc; cursor: pointer;
  font-weight: 700; font-size: 13.5px; letter-spacing: .2px;
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: #f1f5f9; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.btn--ghost   { background: transparent; }
.btn--info    { background: #eff6ff; border-color: rgba(37,99,235,.3); color: #1d4ed8; }
.btn--info:hover    { background: #dbeafe; }
.btn--success { background: #f0fdf4; border-color: rgba(22,163,74,.3); color: #15803d; }
.btn--success:hover { background: #dcfce7; }
.btn--primary { background: #eff6ff; border-color: rgba(29,78,216,.3); color: #1d4ed8; }
.btn--primary:hover { background: #dbeafe; }
.btn--warning { background: #fffbeb; border-color: rgba(217,119,6,.3); color: #b45309; }
.btn--warning:hover { background: #fef3c7; }

/* Grids */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 6px; }
.grid3--wideLeft { grid-template-columns: 2fr 1fr; }
.span2 { grid-column: span 1; }
.chartWrap      { height: 260px; position: relative; }
.chartWrap--tall{ height: 340px; }
canvas { width: 100% !important; height: 100% !important; }

/* Summary */
.summary { display: flex; flex-direction: column; gap: 8px; padding: 6px 4px 2px; }
.summaryLine {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 13px;
}
.summary .k { color: var(--muted); font-weight: 500; }
.summary .v { font-weight: 900; font-variant-numeric: tabular-nums; }
.v--ham    { color: var(--ham); }
.v--spam   { color: var(--spam); }
.v--accent { color: var(--accent); }
.v--pred   { color: var(--text); }
.divider   { height: 1px; background: var(--line); margin: 4px 0; }
.hint      { color: var(--muted); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }
.miniSummary { margin-top: 8px; }

/* Metrics Table */
.tableWrap { overflow: auto; }
table.metrics {
  width: 100%; border-collapse: collapse; margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
table.metrics th, table.metrics td {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  text-align: center; font-size: 13px;
}
table.metrics th { color: var(--text); background: #f8fafc; font-weight: 700; }
td.cls { text-align: left; font-weight: 900; }
.best { background: rgba(22,163,74,.09); }

/* Triple Panels */
.triplePanels { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 10px; }
.panelCard {
  border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); background: #ffffff; box-shadow: var(--shadow);
}
.panelCard__head {
  padding: 12px 16px; font-weight: 900; font-size: 13.5px;
  border-bottom: none;
}
.panelCard__bar { height: 5px; width: 100%; }
.panelCard__body { padding: 14px; min-height: 260px; }

.panelCard--lr  .panelCard__head { background: #eff6ff; color: var(--lr); }
.panelCard--knn .panelCard__head { background: #f5f3ff; color: var(--knn); }
.panelCard--nb  .panelCard__head { background: #fdf2f8; color: var(--nb); }
.panelCard--lr  .panelCard__bar  { background: var(--lr); }
.panelCard--knn .panelCard__bar  { background: var(--knn); }
.panelCard--nb  .panelCard__bar  { background: var(--nb); }

/* Comparison banner */
.c3CompBanner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px 8px;
  margin-top: 10px;
}
.c3CompBanner__title {
  font-weight: 700; font-size: 15px; color: var(--text);
}
.c3CompBanner__legend {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.legendDot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 4px; vertical-align: middle;
}
.legendDot--ham  { background: var(--ham); }
.legendDot--spam { background: var(--spam); }

/* Panel content components (c3 panels) */
.cpTitle {
  text-align: center; font-size: 16px; font-weight: 800;
  margin: 8px 0 2px;
}
.cpSubtitle {
  text-align: center; font-size: 13px; font-weight: 700;
  color: var(--muted); margin-bottom: 10px;
}
.cpTable {
  width: 100%; border-collapse: collapse;
  font-variant-numeric: tabular-nums; margin: 6px 0;
}
.cpTable th {
  color: var(--muted); font-weight: 600; font-size: 12.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.cpTable th.cpNum { text-align: right; }
.cpTable td {
  padding: 7px 8px; font-size: 13px;
  border-bottom: 1px solid rgba(15,23,42,.05);
}
.cpWord { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cpNum  { text-align: right; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cpDivider  { height: 1px; background: var(--line); margin: 12px 0 8px; }
.cpVotes    { text-align: center; font-weight: 700; font-size: 13px; color: var(--text); margin: 8px 0 4px; }
.cpPosterior{ text-align: center; font-weight: 700; font-size: 13px; color: var(--text); margin: 8px 0 4px; }
.cpPredBox {
  border-radius: 10px; border: 1.5px solid;
  padding: 14px 16px; text-align: center; font-weight: 800; font-size: 14px;
  margin: 8px 0; display: flex; justify-content: center; align-items: center;
  gap: 20px; flex-wrap: wrap;
}
.cpPredBox--ham  { background: #f0fdf4; border-color: rgba(22,163,74,.4);  color: var(--ham); }
.cpPredBox--spam { background: #fef2f2; border-color: rgba(220,38,38,.35); color: var(--spam); }
.cpHint {
  color: var(--muted); font-size: 12px; font-style: italic;
  text-align: center; margin-top: 12px;
}

/* KV pairs */
.kv {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px dashed rgba(15,23,42,.10); font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); font-weight: 500; }
.kv .v { font-weight: 900; color: var(--text); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 900; font-size: 12.5px; }
.badge--ham  { background: #f0fdf4; border: 1px solid rgba(22,163,74,.4);  color: var(--ham); }
.badge--spam { background: #fef2f2; border: 1px solid rgba(220,38,38,.4); color: var(--spam); }

ol.neighbors { margin: 6px 0 0 18px; padding: 0; color: var(--text); }
ol.neighbors li { margin-bottom: 8px; }
.nbrLine { display: flex; justify-content: space-between; gap: 10px; }
.nbrTxt  { color: var(--text); font-size: 12.5px; }
.nbrLbl  { font-weight: 900; font-size: 12.5px; }
.nbrLbl--ham  { color: var(--ham); }
.nbrLbl--spam { color: var(--spam); }

table.words {
  width: 100%; border-collapse: collapse; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
table.words th, table.words td {
  border-bottom: 1px solid var(--line); padding: 8px 8px;
  text-align: left; font-size: 12.5px;
}
table.words th { color: var(--text); background: #f8fafc; font-weight: 700; }
table.words td.num { text-align: right; }

/* Footer */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; color: var(--muted); font-size: 12px;
  margin-top: 14px; padding: 10px 4px 0; border-top: 1px solid var(--line);
}
.footer code {
  color: var(--accent); background: #eff6ff;
  padding: 3px 8px; border-radius: 6px;
  border: 1px solid rgba(37,99,235,.15); font-size: 11.5px;
}

/* Responsive */
@media (max-width: 980px) {
  .grid3           { grid-template-columns: 1fr; }
  .grid3--wideLeft { grid-template-columns: 1fr; }
  .triplePanels    { grid-template-columns: 1fr; }
  .control         { min-width: 220px; }
}
