/* ============================================================================
   Primitives — reusable token-driven utility classes
   Extracted from patterns that recur across app.css (5+ modals, 5+ lists,
   15+ button variants, 8+ badge sites, 3+ chip sites).
   These are defined for incremental adoption during Part 2 modularization.
   Existing component-specific styles in app.css are NOT changed — modules
   opt into these primitives one at a time as they're extracted.
   All values are token-only; no hardcoded hex/rgba.
   ============================================================================ */

/* ===== BUTTONS ===== */
/* Mirrors the button system in shared.css but as composable utility classes
   instead of element selectors. The shared.css button.primary/ghost/danger/
   icon-btn classes stay for backward compat; these are the class-based
   equivalents for use on non-<button> elements or when mixing variants. */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  cursor: pointer; transition: all .2s var(--ease);
  outline: none;
}
.btn:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-primary {
  background: transparent; border: 1.5px solid var(--accent); color: var(--accent);
  font-weight: 500; border-radius: var(--radius-pill); padding: 9px 20px;
  transition: all .25s var(--ease-out);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent); color: var(--text-on-fill);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px var(--accent-glow); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  border-radius: var(--radius-sm); transition: all .2s var(--ease);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-bg);
  box-shadow: var(--ring);
}

.btn-danger {
  background: transparent; border: 1.5px solid var(--red); color: var(--red);
  border-radius: var(--radius-sm); transition: all .25s var(--ease-out);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red); color: var(--text-on-fill);
  box-shadow: 0 4px 16px var(--red-glow);
  transform: translateY(-1px);
}

.btn-icon {
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 0; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all .2s var(--ease);
}
.btn-icon:hover:not(:disabled) {
  background: var(--panel-2); border-color: var(--border);
  box-shadow: var(--shadow-sm); transform: scale(1.05);
}
.btn-icon:active:not(:disabled) { transform: scale(0.95); }
.btn-icon svg { width: 18px; height: 18px; }

/* ===== MODAL / OVERLAY ===== */
/* The .overlay and .modal classes in shared.css already cover the base
   modal pattern. These extend them with the variants used across app.css:
   full-screen (stats, terminal, file-viewer) and bottom-sheet (mobile cp). */

.modal-fullscreen {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  display: flex; flex-direction: column;
}
.modal-fullscreen[hidden] { display: none; }

.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h2 { font-size: 15px; font-weight: 600; flex: 1; letter-spacing: -0.2px; }
.modal-close {
  background: transparent; border: none; color: var(--muted); font-size: 20px;
  width: 32px; height: 32px; border-radius: var(--radius-pill); cursor: pointer; padding: 0; line-height: 1;
  flex-shrink: 0; transition: all .2s var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); box-shadow: var(--shadow-sm); }

.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}
.modal-foot .spacer { flex: 1; }

/* ===== LIST ITEM ===== */
/* Pattern used by .sb-item, .picker-item, .fv-item, .mpd-item, .cmd-item,
   .mode-menu-item, .session-row — all share hover-fill, active-accent,
   and optional delete/action button on hover. */

.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; font-size: 14px;
  border-radius: var(--radius-sm); transition: all .15s var(--ease);
  position: relative; overflow: hidden;
}
.list-item:hover { background: var(--panel-2); }
.list-item.active { background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.list-item .li-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); flex-shrink: 0; }

/* ===== BADGE ===== */
/* Pattern used by .si-live-dot, .dir-badge, .mode-badge, diff +N -M badges,
   .sb-badge, .mpd-tier. All are pill-shaped, token-driven color variants. */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; font-family: var(--mono);
  padding: 2px 8px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }

/* Status dot — the live-session indicator used in sidebar, sessions modal */
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 6px var(--green-bright-glow);
  flex-shrink: 0;
}
.badge-dot.dead { background: var(--red); box-shadow: none; }

/* ===== CHIP ===== */
/* Pattern used by .recent-dirs .chip, .picker-recent-chip, .picker-roots
   .root-chip, model-family chips. Pill-shaped, token borders, hover-accent. */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 12px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--panel-2); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-2);
  transition: all .2s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); transform: translateY(-1px); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.chip.live { border-color: var(--green); color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.chip-removable { padding-right: 4px; }
.chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: none; background: transparent;
  color: var(--muted); font-size: 15px; line-height: 1;
  border-radius: 50%; cursor: pointer; flex-shrink: 0; padding: 0;
}
.chip-remove:hover { background: var(--red); color: var(--text-on-fill); }

/* ===== SEGMENTED TOGGLE ===== */
/* Pattern used by .fv-view-toggle, .cp-segmented — identical structure. */
.segmented {
  display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-2);
}
.segmented-btn {
  flex: 1; padding: 8px 12px; font-size: 13px; font-weight: 500; color: var(--text-2);
  background: transparent; border: none; cursor: pointer; transition: all .15s var(--ease);
}
.segmented-btn + .segmented-btn { border-left: 1px solid var(--border); }
.segmented-btn:hover { color: var(--text); background: var(--panel-2); }
.segmented-btn.active { color: var(--accent); background: var(--accent-bg); }
