/* ═══════════════════════════════════════════════════════════════════
   SystemFlow - ribbon.css
   Bottom ribbon panel redesign (all 9 tabs): consistent "group card"
   anatomy - labeled clusters, aligned 26-28px control rhythm, stat
   chips, tile grids, framed timeline.
   · Uses ONLY existing Clay Violet v3 tokens (no new colors/fonts).
   · Everything namespaced under .bottom-panel / .rib- so nothing leaks.
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────── Tab bar ─────────────────────────── */
.bottom-panel .rib-tabbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.bottom-panel .rib-tabbar::-webkit-scrollbar { display: none; }

.bottom-panel .rib-tab {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.03em;
  color: var(--text-sec);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.bottom-panel .rib-tab:hover { background: var(--surface2); color: var(--text); }
.bottom-panel .rib-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

/* Sim state chip on the right of the tab bar */
.bottom-panel .rib-state {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font: 500 9.5px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bottom-panel .rib-state.running { color: var(--green); border-color: var(--green); background: var(--green-dim, rgba(52,211,153,0.1)); }
.bottom-panel .rib-state.paused  { color: var(--amber); border-color: var(--amber); background: var(--amber-dim); }
.bottom-panel .rib-state-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  animation: ribPulse 1.2s ease-in-out infinite;
}

/* ─────────────────────────── Body ─────────────────────────── */
.bottom-panel .ribbon-body {
  padding: 10px 12px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}
.bottom-panel .ribbon-body::-webkit-scrollbar { height: 6px; width: 6px; }
.bottom-panel .ribbon-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
.bottom-panel .ribbon-body::-webkit-scrollbar-track { background: transparent; }

/* ─────────────────────── Group card anatomy ─────────────────────── */
.rib-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: max-content;   /* lets the body scroll horizontally when cramped */
  width: 100%;
}
.bottom-panel .rib-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
  min-width: 0;
}
.bottom-panel .rib-group.rib-grow { flex: 1; min-width: 220px; }

.bottom-panel .rib-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 9px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  user-select: none;
  min-height: 12px;
}
/* small action button living inside a group label */
.bottom-panel .rib-label-btn {
  margin-left: auto;
  padding: 1px 7px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  font: 600 8.5px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.bottom-panel .rib-label-btn:hover { background: var(--surface3); color: var(--text); }
.bottom-panel .rib-label-btn.danger { color: var(--red); border-color: var(--red); background: var(--red-dim, rgba(248,113,113,0.1)); }
.bottom-panel .rib-label-btn.danger:hover { background: var(--red-dim, rgba(248,113,113,0.18)); }

/* generic controls row - 26-28px rhythm */
.bottom-panel .rib-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
}

/* ─────────────────────────── Stats ─────────────────────────── */
.bottom-panel .rib-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}
.bottom-panel .rib-stat { display: flex; flex-direction: column; gap: 3px; min-width: 52px; }
.bottom-panel .rib-stat-label {
  font: 600 8.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.bottom-panel .rib-stat-value {
  font: 700 15px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ─────────────────────── Buttons & segments ─────────────────────── */
.bottom-panel .rib-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  height: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.bottom-panel .rib-seg button {
  height: 20px;
  padding: 0 7px;
  border: none;
  border-radius: 5px;
  background: transparent;
  font: 500 10px/1 var(--mono);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.bottom-panel .rib-seg button:hover { color: var(--text); background: var(--surface3); }
.bottom-panel .rib-seg button.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

/* small mono chip (elapsed time, counts) */
.bottom-panel .rib-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: 500 10.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-sec);
  white-space: nowrap;
}
.bottom-panel .rib-chip.live { color: var(--green); border-color: var(--green); }
.bottom-panel .rib-chip-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  font: 600 10px/1 var(--mono);
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.bottom-panel .rib-chip-btn:hover { background: var(--surface3); color: var(--text); }
.bottom-panel .rib-chip-btn.live {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-dim, rgba(52,211,153,0.12));
}

/* number inputs */
.bottom-panel .rib-input {
  height: 26px;
  width: 76px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font: 600 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
.bottom-panel .rib-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.bottom-panel .rib-unit { font: 500 10px/1 var(--mono); color: var(--text-muted); white-space: nowrap; }

/* labelled field (SLO targets) */
.bottom-panel .rib-field { display: flex; flex-direction: column; gap: 5px; }
.bottom-panel .rib-field-label {
  font: 600 8.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

/* slider tick labels */
.bottom-panel .rib-scale-labels {
  display: flex;
  justify-content: space-between;
  font: 500 9px/1 var(--mono);
  color: var(--text-muted);
}

/* ─────────────────────────── Tiles ─────────────────────────── */
.bottom-panel .rib-tile {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-sec);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s var(--ease-out), border-color 0.15s var(--ease-out),
              color 0.15s var(--ease-out), transform 0.15s var(--ease-out),
              box-shadow 0.15s var(--ease-out);
}
.bottom-panel .rib-tile:hover {
  background: var(--surface3);
  border-color: var(--border2);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--clay-shadow-sm);
}

/* Traffic pattern tiles */
.bottom-panel .rib-pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(56px, 1fr));
  gap: 5px;
  flex: 1;
}
.bottom-panel .rib-pattern-tile {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  font: 500 9.5px/1 var(--mono);
}
.bottom-panel .rib-pattern-tile svg { opacity: 0.8; }
.bottom-panel .rib-pattern-tile.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

/* Chaos scenario tiles */
.bottom-panel .rib-scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 6px;
  flex: 1;
}
.bottom-panel .rib-scenario-tile {
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--sc-color, var(--red));
}
.bottom-panel .rib-scenario-tile.active {
  background: var(--surface3);
  border-color: var(--sc-color, var(--red));
  box-shadow: 0 0 0 1px var(--sc-color, var(--red));
}
.bottom-panel .rib-scenario-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--sc-color, var(--red));
  flex-shrink: 0;
}
.bottom-panel .rib-scenario-icon svg { width: 14px; height: 14px; }
.bottom-panel .rib-scenario-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bottom-panel .rib-scenario-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 600 11px/1.2 var(--sans);
  color: var(--text);
}
.bottom-panel .rib-scenario-tile.active .rib-scenario-name { color: var(--sc-color, var(--red)); }
.bottom-panel .rib-scenario-desc {
  font: 500 9.5px/1.3 var(--sans);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bottom-panel .rib-live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: ribPulse 1.2s ease-in-out infinite;
}

/* Interview challenge tiles */
.bottom-panel .rib-challenge-tile {
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  min-width: 168px;
  max-width: 200px;
}
.bottom-panel .rib-challenge-tile:hover { border-color: var(--gold); }
.bottom-panel .rib-challenge-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.bottom-panel .rib-challenge-icon {
  display: flex;
  align-items: center;
  color: var(--gold);
}
.bottom-panel .rib-challenge-icon svg { width: 15px; height: 15px; }
.bottom-panel .rib-challenge-time {
  font: 600 9px/1 var(--mono);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.bottom-panel .rib-challenge-name { font: 600 11.5px/1.2 var(--sans); color: var(--text); }
.bottom-panel .rib-challenge-desc {
  font: 500 10px/1.35 var(--sans);
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bottom-panel .rib-challenge-meta { font: 500 9px/1 var(--mono); color: var(--text-dim); margin-top: auto; }

/* ─────────────────────────── Timeline ─────────────────────────── */
.bottom-panel .rib-timeline-group { min-width: 300px; }
.bottom-panel .rib-timeline-track {
  position: relative;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  /* tick marks */
  background-image: repeating-linear-gradient(
    to right,
    var(--border) 0 1px,
    transparent 1px calc(100% / 12)
  );
  background-size: 100% 5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
}
.bottom-panel .rib-timeline-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 500 10px/1 var(--mono);
  color: var(--text-dim);
  pointer-events: none;
}
.bottom-panel .rib-timeline-axis {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font: 500 9px/1 var(--mono);
  color: var(--text-muted);
}
.bottom-panel .rib-scrub-row { min-height: 0; }
.bottom-panel .rib-scrub-row .slider { flex: 1; }

/* ─────────────────────── Hints / shortcuts ─────────────────────── */
.bottom-panel .rib-hints { justify-content: flex-start; }
.bottom-panel .rib-hint-line {
  font: 500 10px/1.5 var(--mono);
  color: var(--text-muted);
  white-space: nowrap;
}
.bottom-panel .rib-kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: 600 9px/1.2 var(--mono);
  color: var(--accent);
}

/* ─────────────────────── Chaos switches / knobs ─────────────────────── */
.bottom-panel .rib-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}
.bottom-panel .rib-switch-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.bottom-panel .rib-switch-title { font: 600 11.5px/1.2 var(--sans); }
.bottom-panel .rib-switch-desc {
  font: 500 10px/1.25 var(--sans);
  color: var(--text-muted);
  white-space: nowrap;
}
.bottom-panel .rib-knob { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.bottom-panel .rib-knob-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bottom-panel .rib-knob-name {
  font: 600 8.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.bottom-panel .rib-knob-value {
  font: 600 10px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--red);
  background: var(--red-dim, rgba(248,113,113,0.12));
  border: 1px solid var(--red-dim, rgba(248,113,113,0.2));
}

/* ─────────────────── Scroll helpers inside groups ─────────────────── */
.bottom-panel .rib-hscroll {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}
.bottom-panel .rib-hscroll::-webkit-scrollbar { height: 5px; }
.bottom-panel .rib-hscroll::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
.bottom-panel .rib-hscroll::-webkit-scrollbar-track { background: transparent; }

.bottom-panel .rib-wrap-scroll {
  overflow-y: auto;
  max-height: 108px;
  align-content: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}
.bottom-panel .rib-wrap-scroll::-webkit-scrollbar { width: 5px; }
.bottom-panel .rib-wrap-scroll::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* empty-state message inside a group */
.bottom-panel .rib-empty-msg {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 26px;
  font: 500 11px/1.4 var(--mono);
  color: var(--text-muted);
}

/* ───────────────── Legacy card fit inside group cards ───────────────── */
/* cards now live inside .rib-group (surface2) - step them down a level */
.bottom-panel .rib-group .whatif-card,
.bottom-panel .rib-group .profile-card,
.bottom-panel .rib-group .testcard,
.bottom-panel .rib-group .criteria-item,
.bottom-panel .rib-group .incident-node-btn {
  background: var(--surface);
}
.bottom-panel .rib-group .testcard { min-height: 116px; width: 164px; min-width: 164px; padding: 8px 10px; }
.bottom-panel .rib-group .profile-card { min-width: 124px; padding: 9px 10px; }
.bottom-panel .rib-group .whatif-card { min-width: 168px; max-width: 200px; flex-shrink: 0; }
.bottom-panel .rib-group .profile-row,
.bottom-panel .rib-group .testlab-row,
.bottom-panel .rib-group .whatif-row { padding-bottom: 3px; }
.bottom-panel .rib-slo-checks { display: flex; flex-direction: column; gap: 4px; }
.bottom-panel .rib-suggestions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: 500 10.5px/1.35 var(--sans);
  color: var(--text-sec);
}
.bottom-panel .rib-row > .warning-chip { align-self: center; flex-shrink: 0; }
.bottom-panel .rib-group .warning-chip { margin-left: 0; align-self: flex-start; }
.bottom-panel .rib-group .btn { height: 26px; padding: 0 12px; font-size: 11px; display: inline-flex; align-items: center; }

/* ─────────────────────── Focus & motion ─────────────────────── */
.bottom-panel .rib-tab:focus-visible,
.bottom-panel .rib-tile:focus-visible,
.bottom-panel .rib-seg button:focus-visible,
.bottom-panel .rib-chip-btn:focus-visible,
.bottom-panel .rib-label-btn:focus-visible,
.bottom-panel .rib-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@keyframes ribPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .bottom-panel .rib-state-dot,
  .bottom-panel .rib-live-dot { animation: none; }
  .bottom-panel .rib-tile,
  .bottom-panel .rib-tile:hover { transform: none; transition: none; }
  .bottom-panel .rib-tab,
  .bottom-panel .rib-seg button,
  .bottom-panel .rib-chip-btn,
  .bottom-panel .rib-label-btn { transition: none; }
}
