/* ============================================================
   NETSCRAPPER — Tier 3 Power Features styles
   Command palette, global search, theme toggle, session replay.
   Purely additive. Loaded after the base theme sheets.
   ============================================================ */

/* ---------- Header additions (global search + theme toggle) ---------- */
.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.global-search-wrap {
  position: relative;
}

.global-search {
  background: var(--surface-01);
  border: 1px solid var(--ghost-dim);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 7px 12px 7px 32px;
  width: 260px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.global-search:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
.global-search::placeholder { color: var(--ghost); }

.gs-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ghost);
  pointer-events: none;
  width: 14px; height: 14px;
}

.gs-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ghost);
  border: 1px solid var(--ghost-dim);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}

.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface-02);
  border: 1px solid var(--ghost-dim);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 4000;
  display: none;
  padding: 8px;
}
.gs-section-title {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ghost);
  padding: 8px 8px 4px;
  border-top: 1px solid var(--ghost-dim);
}
.gs-section-title:first-child { border-top: none; }
.gs-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.gs-item:hover { background: var(--surface-3); }
.gs-key { color: var(--text-primary); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-key.mono { font-family: var(--font-mono); }
.gs-meta { color: var(--ghost); font-size: 0.72rem; font-family: var(--font-mono); white-space: nowrap; }
.gs-empty { color: var(--ghost); font-size: 0.75rem; padding: 6px 10px; font-family: var(--font-mono); }

/* Theme toggle button */
.theme-toggle {
  background: var(--surface-01);
  border: 1px solid var(--ghost-dim);
  color: var(--text-primary);
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  transition: border-color 0.15s, transform 0.1s;
}
.theme-toggle:hover { border-color: var(--red); transform: translateY(-1px); }

.cp-launcher {
  background: var(--surface-01);
  border: 1px solid var(--ghost-dim);
  color: var(--ghost);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s, color 0.15s;
}
.cp-launcher:hover { border-color: var(--red); color: var(--text-primary); }
.cp-launcher kbd {
  background: var(--surface-3);
  border: 1px solid var(--ghost-dim);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.66rem;
  color: var(--red-bright);
}

/* ---------- Command palette ---------- */
.cp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 3, 4, 0.72);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}
.cp-box {
  width: 100%;
  max-width: 620px;
  background: var(--surface-02);
  border: 1px solid var(--red-dim);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgba(0,0,0,0.6);
  overflow: hidden;
  font-family: var(--font-mono);
}
.cp-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ghost-dim);
}
.cp-prompt {
  color: var(--red);
  font-size: 1.15rem;
}
.cp-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.02rem;
}
.cp-input::placeholder { color: var(--ghost); }
.cp-kbd {
  background: var(--surface-3);
  border: 1px solid var(--ghost-dim);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.66rem;
  color: var(--ghost);
}
.cp-list {
  max-height: 48vh;
  overflow-y: auto;
  padding: 8px;
}
.cp-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.cp-item.active {
  background: var(--surface-4);
  border-left: 2px solid var(--red);
}
.cp-group {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ghost);
  min-width: 92px;
}
.cp-label { color: var(--text-primary); font-size: 0.9rem; }
.cp-item.active .cp-label { color: var(--red-bright); }
.cp-empty { color: var(--ghost); text-align: center; padding: 28px; }
.cp-footer {
  display: flex;
  gap: 18px;
  padding: 12px 18px;
  border-top: 1px solid var(--ghost-dim);
  color: var(--ghost);
  font-size: 0.72rem;
}
.cp-footer kbd {
  background: var(--surface-3);
  border: 1px solid var(--ghost-dim);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.64rem;
  margin-right: 4px;
  color: var(--red-bright);
}

/* ---------- Session replay ---------- */
.replay-box {
  width: 100%;
  max-width: 720px;
  background: var(--surface-02);
  border: 1px solid var(--red-dim);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-family: var(--font-mono);
}
.replay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ghost-dim);
}
.replay-title { color: var(--red-bright); font-size: 0.95rem; letter-spacing: 0.04em; }
.replay-stage { padding: 28px 20px; }
.replay-frame {
  display: flex;
  justify-content: space-around;
  gap: 12px;
  flex-wrap: wrap;
}
.replay-metric { text-align: center; }
.replay-num { font-size: 2.4rem; color: var(--text-primary); font-weight: 700; }
.replay-lbl { font-size: 0.62rem; letter-spacing: 0.16em; color: var(--ghost); margin-top: 6px; }
.replay-spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 70px;
  margin: 24px 0 10px;
}
.replay-bar {
  flex: 1;
  background: var(--red-dim);
  border-radius: 2px 2px 0 0;
  opacity: 0.55;
}
.replay-bar.active { background: var(--red-bright); opacity: 1; }
.replay-time { text-align: center; color: var(--ghost); font-size: 0.74rem; }
.replay-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--ghost-dim);
}
.replay-progress {
  margin-left: auto;
  color: var(--ghost);
  font-size: 0.78rem;
}

/* ============================================================
   LIGHT THEME — remaps the design-token variables only.
   Everything else inherits, so no component styles change.
   ============================================================ */
html[data-theme="light"] {
  --void: #f4f2ee;
  --void-light: #fbfaf8;
  --void-deep: #e9e6e0;
  --bone: #24211c;
  --ghost: #6b6761;
  --ghost-dim: #d8d3ca;
  --red: #c81e1e;
  --red-bright: #e02424;
  --red-dim: #f0b4b4;
  --red-glow: rgba(200, 30, 30, 0.22);
  --surface-01: rgba(255, 255, 255, 0.72);
  --surface-02: rgba(255, 255, 255, 0.92);
  --surface-3: rgba(236, 232, 225, 0.95);
  --surface-4: rgba(200, 30, 30, 0.12);
  --text-primary: var(--bone);
  --text-secondary: var(--ghost);
  color-scheme: light;
}
html[data-theme="light"] body {
  background: var(--void);
  color: var(--bone);
}
/* Soften the dark WebGL veil in light mode */
html[data-theme="light"] .veil {
  opacity: 0.28;
}
html[data-theme="light"] .cp-overlay {
  background: rgba(244, 242, 238, 0.72);
}
html[data-theme="light"] .cp-box,
html[data-theme="light"] .replay-box,
html[data-theme="light"] .global-search-results {
  box-shadow: 0 24px 70px rgba(60, 50, 40, 0.22);
}
