/* ─ src/public/css/history.css (v16.4.0) ───────────────────────────────
   Wave 1.0d additions on top of v16.3.1:
   - Search input
   - Hover-revealed action buttons (pin / archive)
   - Pinned + archived row visual states
   - Pinned group gets a subtle accent
   ──────────────────────────────────────────────────────────────────── */

/* ─ Drawer — matches existing .drawer pattern ────────────────────── */
.jrv-history-drawer {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 320px;
  max-width: 92vw;
  z-index: 310;
  background: var(--surface);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.jrv-history-drawer.open { transform: translateX(0); }

.jrv-history-overlay {
  position: fixed;
  inset: 0;
  z-index: 309;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.jrv-history-overlay.open { display: block; opacity: 1; }

/* ─ Header ───────────────────────────────────────────────────────── */
.jrv-history-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex-shrink: 0;
}
.jrv-history-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.jrv-history-title {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
}
.jrv-history-close {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  width: 26px; height: 26px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.jrv-history-close:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.jrv-history-newchat {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), rgba(0, 100, 200, 0.8));
  color: #000;
  border: none;
  padding: 8px 12px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  clip-path: polygon(4% 0%, 100% 0%, 96% 100%, 0% 100%);
  transition: all 0.15s;
}
.jrv-history-newchat:hover {
  background: linear-gradient(135deg, var(--cyan2), var(--cyan));
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.4);
}

/* Search — matches existing .input-wrap aesthetic */
.jrv-history-search {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 7px 10px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.jrv-history-search::placeholder {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.jrv-history-search:focus {
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.08);
}

/* ─ Filter chips ─ matches .hint pattern ───────────────────────── */
.jrv-history-filters {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.jrv-history-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 2px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s;
}
.jrv-history-chip:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.jrv-history-chip.active {
  background: var(--cyan-dim);
  border-color: rgba(0, 212, 255, 0.25);
  color: var(--cyan);
}

/* ─ List ─ ───────────────────────────────────────────────────────── */
.jrv-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 12px;
}
.jrv-history-list::-webkit-scrollbar { width: 6px; }
.jrv-history-list::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}
.jrv-history-list::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

.jrv-history-group {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 12px 14px 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.jrv-history-group::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Conversation row */
.jrv-history-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  color: var(--text2);
  font-family: 'Rajdhani', sans-serif;
  padding: 7px 10px 7px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  margin: 0 6px 1px;
  border-radius: 3px;
}
.jrv-history-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.15s;
}
.jrv-history-item:hover {
  background: var(--cyan-glow);
  border-color: var(--border2);
  color: var(--text);
}
.jrv-history-item:hover::before { background: var(--cyan); }
.jrv-history-item.active {
  background: var(--cyan-dim);
  border-color: rgba(0, 212, 255, 0.2);
  color: var(--cyan);
}
.jrv-history-item.active::before { background: var(--cyan); }

/* Pinned: subtle gold accent */
.jrv-history-item.pinned::before { background: var(--gold); }
.jrv-history-item.pinned:hover::before { background: var(--gold2); }

/* Archived: dimmed */
.jrv-history-item.archived { opacity: 0.55; }
.jrv-history-item.archived:hover { opacity: 0.85; }

.jrv-history-icon {
  flex-shrink: 0;
  font-size: 11px;
  margin-top: 1px;
  width: 14px;
  text-align: center;
  opacity: 0.85;
}
.jrv-history-body {
  flex: 1;
  min-width: 0;
}
.jrv-history-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.jrv-history-pin {
  font-size: 9px;
  color: var(--gold);
  margin-right: 2px;
  flex-shrink: 0;
}
.jrv-history-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7.5px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.jrv-history-meta-dot {
  width: 2px; height: 2px;
  background: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─ Hover actions on each row ─────────────────────────────────── */
.jrv-history-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: 4px;
}
.jrv-history-item:hover .jrv-history-actions { opacity: 1; }
/* Always show actions when something is "on" so user can toggle off */
.jrv-history-item.pinned .jrv-history-actions,
.jrv-history-item.archived .jrv-history-actions { opacity: 0.6; }
.jrv-history-item.pinned:hover .jrv-history-actions,
.jrv-history-item.archived:hover .jrv-history-actions { opacity: 1; }

.jrv-history-action {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 11px;
  width: 22px; height: 22px;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0;
}
.jrv-history-action:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-dim);
}
.jrv-history-action.on {
  color: var(--gold);
  border-color: rgba(255, 170, 0, 0.3);
}
.jrv-history-action.on:hover {
  color: var(--gold2);
  border-color: var(--gold);
  background: var(--gold-dim);
}

/* ─ State / empty / loading ──────────────────────────────────── */
.jrv-history-state {
  padding: 36px 20px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
  line-height: 1.7;
}

/* ─ Detail pane ──────────────────────────────────────────────── */
.jrv-history-detail {
  position: absolute;
  inset: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 1;
}
.jrv-history-detail.open { transform: translateX(0); }

.jrv-history-detail-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.jrv-history-back {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  width: 28px; height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.jrv-history-back:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.jrv-history-detail-title {
  flex: 1;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jrv-history-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jrv-history-msgs::-webkit-scrollbar { width: 6px; }
.jrv-history-msgs::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

.jrv-history-msg {
  padding: 8px 10px;
  border-radius: 3px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
  border: 1px solid var(--border);
}
.jrv-history-msg.user {
  background: var(--cyan-dim);
  border-color: rgba(0, 212, 255, 0.2);
  color: var(--text);
  align-self: flex-end;
  max-width: 88%;
}
.jrv-history-msg.assistant {
  background: var(--card);
  color: var(--text2);
  align-self: flex-start;
  max-width: 95%;
}
.jrv-history-msg-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 4px;
}

.jrv-history-detail-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.jrv-history-resume {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), rgba(0, 100, 200, 0.8));
  color: #000;
  border: none;
  padding: 9px 12px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  clip-path: polygon(4% 0%, 100% 0%, 96% 100%, 0% 100%);
  transition: all 0.15s;
}
.jrv-history-resume:hover {
  background: linear-gradient(135deg, var(--cyan2), var(--cyan));
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.4);
}

/* ─ Desktop sidebar entry ────────────────────────────────────── */
.jrv-history-entry {
  width: 100%;
  background: none;
  border: 1px solid transparent;
  color: var(--text2);
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
  margin-bottom: 1px;
  position: relative;
  overflow: hidden;
}
.jrv-history-entry::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.15s;
}
.jrv-history-entry:hover {
  background: var(--cyan-glow);
  border-color: var(--border2);
  color: var(--text);
}
.jrv-history-entry:hover::before { background: var(--cyan); }
.jrv-history-entry-icon { font-size: 12px; flex-shrink: 0; }

/* ─ Mobile ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .jrv-history-drawer { width: 100vw; max-width: 100vw; }
  .jrv-history-actions { opacity: 1; }  /* always visible on touch */
}
