/* Shared styles for LLM Inference Explorer demos */

:root {
  --bg: #ffffff;
  --panel: #f5f6f8;
  --surface: #e8ecf0;
  --accent: #d63a52;
  --text: #2d3748;
  --text-dim: #6b7c93;
  --blue: #3b7dd8;
  --green: #2d9a2d;
  --orange: #d4690a;
  --purple: #7b4fa2;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── View Transitions ─────────────────────────────────────── */
.page-nav { view-transition-name: nav; }
.controls { view-transition-name: sidebar; }
.bottom-panel { view-transition-name: bottom; }

/* ── Page Nav Bar ─────────────────────────────────────────── */
.page-nav {
  display: flex; flex-direction: column;
  padding: 6px 16px;
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0; gap: 2px;
}
.page-nav .nav-header {
  display: flex; align-items: center;
}
.page-nav .nav-title {
  font-size: 14px; font-weight: 700;
  color: var(--accent); text-decoration: none;
}
.page-nav .nav-title:hover { opacity: 0.8; }
.page-nav .nav-row {
  display: flex; align-items: center;
}
.page-nav .nav-row-label {
  font-size: 9px; letter-spacing: 0.3px;
  color: #aab4c2; white-space: nowrap; margin-right: 8px; min-width: 80px;
  font-style: italic;
}
.page-nav .nav-row nav {
  display: flex; gap: 3px; flex-wrap: wrap;
}
.page-nav nav a {
  color: var(--text-dim); text-decoration: none;
  font-size: 12px; padding: 2px 7px; border-radius: 3px;
  font-weight: 500; transition: background 0.15s, color 0.15s;
}
.page-nav nav a:hover { background: var(--surface); color: var(--text); }
.page-nav nav a.active { color: #fff; background: var(--accent); }

/* ── Layout ───────────────────────────────────────────────── */
.page-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Controls Panel ───────────────────────────────────────── */
.controls {
  width: 320px; min-width: 320px; background: var(--panel);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--surface);
}
.controls-scroll {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
/* Backward compat: if page hasn't been updated to use controls-scroll yet */
.controls > .control-group,
.controls > h1,
.controls > details { padding-left: 16px; padding-right: 16px; }
.controls > .control-group:first-child,
.controls > h1:first-child { padding-top: 16px; }
.controls h1 { font-size: 15px; font-weight: 600; letter-spacing: 0.5px; color: var(--accent); }
.controls h2 { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 2px; }
.control-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 11px; color: var(--text-dim); display: flex; justify-content: space-between; align-items: center; }
label .val { color: var(--text); font-weight: 600; }
select, input[type="range"] {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid #bfc5cf; border-radius: 4px; padding: 5px 7px;
  font-family: inherit; font-size: 11px;
}
select { cursor: pointer; }
input[type="range"] { -webkit-appearance: none; height: 5px; border-radius: 3px; padding: 0; border: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); cursor: pointer; }

/* ── Preset Pills ──────────────────────────────────────────── */
.preset-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.preset-pill {
  background: var(--surface); border: 1px solid #ccd0d8; border-radius: 12px;
  padding: 3px 10px; font-size: 11px; color: var(--accent); cursor: pointer;
  font-family: inherit; transition: background 0.1s, color 0.1s;
}
.preset-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Option Pills (replace small <select> dropdowns) ─────── */
.option-pills { display: flex; gap: 3px; flex-wrap: wrap; }
.option-pill {
  background: var(--bg); border: 1px solid #ccd0d8; border-radius: 3px;
  padding: 3px 8px; font-size: 11px; color: var(--text-dim); cursor: pointer;
  font-family: inherit; transition: all 0.1s;
}
.option-pill:hover { border-color: var(--accent); color: var(--text); }
.option-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Bottom Panel (Explore / Questions tabs) ───────────────── */
.bottom-panel {
  border-top: 2px solid var(--surface); flex-shrink: 0;
  background: var(--panel);
}
.bottom-panel.collapsed .tab-content { display: none !important; }
.bottom-panel .tab-strip {
  display: flex; align-items: center;
}
.bottom-panel .tab-btn {
  padding: 7px 14px; text-align: center; font-size: 11px;
  font-weight: 600; cursor: pointer; background: none; border: none;
  color: var(--text-dim); font-family: inherit; border-bottom: 2px solid transparent;
  transition: color 0.1s;
}
.bottom-panel .tab-btn:hover { color: var(--text); }
.bottom-panel .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.bottom-panel .collapse-btn {
  margin-left: auto; padding: 4px 10px; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 14px; font-family: inherit;
  transition: color 0.1s;
}
.bottom-panel .collapse-btn:hover { color: var(--text); }
.bottom-panel .tab-content {
  padding: 8px 24px; overflow-y: auto; height: 100px;
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
}
.bottom-panel .tab-content .preset-pills {
  padding: 0; gap: 6px;
}
.bottom-panel .tab-content ul {
  padding-left: 18px; margin: 0;
}
.bottom-panel .tab-content li {
  margin-bottom: 4px;
}
.bottom-panel .tab-content a {
  color: var(--accent); text-decoration: none;
}
.bottom-panel .tab-content a:hover { text-decoration: underline; }
.checkbox-row input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ── Coachmarks ──────────────────────────────────────────── */
.coachmark { cursor: default; }
.coachmark-content {
  background: #2d3748; color: #fff; border-radius: 8px;
  padding: 12px 16px; max-width: 250px; font-size: 12px;
  line-height: 1.5; box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  animation: coachmark-in 0.2s ease-out;
}
@keyframes coachmark-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.coachmark-text { margin-bottom: 4px; }
.coachmark-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
}
.coachmark-step { font-size: 10px; color: #9ca3af; }
.coachmark-nav div { display: flex; gap: 6px; }
.coachmark-next, .coachmark-back {
  background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 4px 12px; font-size: 11px; cursor: pointer; font-family: inherit;
}
.coachmark-back { background: #4a5568; }
.coachmark-dismiss {
  background: none; color: #9ca3af; border: none; border-radius: 4px;
  padding: 4px 8px; font-size: 10px; cursor: pointer; font-family: inherit;
}
.coachmark-dismiss:hover { color: #fff; text-decoration: underline; }
.coachmark-next:hover { filter: brightness(1.1); }
.coachmark-back:hover { background: #5a6578; }

.reset-tips { font-size: 10px; color: var(--text-dim); text-decoration: none; cursor: pointer; }
.reset-tips:hover { color: var(--accent); text-decoration: underline; }

/* ── Summary Cards ────────────────────────────────────────── */
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.summary-card { background: var(--surface); border-radius: 5px; padding: 8px 10px; }
.summary-card .card-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin-bottom: 2px; }
.summary-card .card-value { font-size: 15px; font-weight: 700; }
.summary-card .card-value.compute-bound { color: var(--green); }
.summary-card .card-value.memory-bound { color: var(--orange); }

/* ── Main Visualization ───────────────────────────────────── */
.visualization {
  flex: 1; display: flex; flex-direction: column; padding: 14px; gap: 14px;
  overflow-y: auto;
}
.viz-section {
  background: var(--panel); border: 1px solid var(--surface);
  border-radius: 6px; padding: 12px; flex-shrink: 0;
}
.viz-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin-bottom: 10px;
}

/* ── Matrix Diagram ───────────────────────────────────────── */
.matrix-diagram { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; }
.matrix-box {
  border: 2px solid; border-radius: 4px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 8px 12px; position: relative;
  min-width: 60px; min-height: 40px;
}
.matrix-box .dim-label { font-size: 10px; color: var(--text-dim); }
.matrix-box .dim-value { font-size: 13px; font-weight: 700; }
.matrix-box .matrix-name { font-size: 9px; position: absolute; top: -8px; left: 6px; background: var(--panel); padding: 0 3px; }
.op-symbol { font-size: 18px; font-weight: 700; color: var(--text-dim); }

/* ── Memory Bars ──────────────────────────────────────────── */
.mem-bars { display: flex; flex-direction: column; gap: 10px; }
.mem-bar-row { display: flex; flex-direction: column; gap: 3px; }
.mem-bar-label { font-size: 11px; display: flex; justify-content: space-between; }
.mem-bar-label .name { font-weight: 600; }
.mem-bar-label .stats { color: var(--text-dim); font-size: 10px; }
.mem-bar-outer {
  height: 24px; background: #e2e6eb; border-radius: 4px;
  position: relative; overflow: hidden; border: 1px solid #ccd0d8;
}
.mem-bar-fill { height: 100%; border-radius: 3px; transition: width 0.2s ease-out; }
.mem-bar-annotation { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* ── Layer Table ──────────────────────────────────────────── */
.layer-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.layer-table th {
  text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--surface);
  color: var(--text-dim); font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px;
}
.layer-table td { padding: 5px 8px; border-bottom: 1px solid #d5dae2; }
.layer-table tr { cursor: pointer; transition: background 0.1s; }
.layer-table tr:hover { background: var(--surface); }
.layer-table tr.selected { background: #d0ddf0; }
.layer-table tr.summary-row { font-weight: 700; border-top: 2px solid var(--surface); cursor: default; }
.layer-table tr.summary-row:hover { background: transparent; }
.bound-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.bound-dot.compute { background: var(--green); }
.bound-dot.memory { background: var(--orange); }

/* ── Canvas Containers ────────────────────────────────────── */
.canvas-container { position: relative; width: 100%; }
.canvas-container canvas { width: 100%; height: 100%; display: block; }
