/* ── History page ─────────────────────────────────────────────────────────── */

.history-page {
  background: var(--bg);
  min-height: 100vh;
}

.history-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

.hist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 0 1.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.1rem;
}

.hist-stat {
  font-size: .82rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ── Search ──────────────────────────────────────────────────────────────── */

.hist-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.hist-search-icon {
  position: absolute;
  left: .65rem;
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
}

.hist-search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .8rem;
  padding: .38rem 2rem .38rem 2.1rem;
  width: 200px;
  outline: none;
  transition: border-color .2s, width .25s;
}

.hist-search-input::placeholder { color: var(--text-dim); }

.hist-search-input:focus {
  border-color: var(--border-focus);
  width: 240px;
}

.hist-search-clear {
  position: absolute;
  right: .45rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 .15rem;
}

.hist-search-clear:hover { color: var(--text); }

.hist-no-results {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-dim);
  font-size: .9rem;
}

/* ── Live indicator ──────────────────────────────────────────────────────── */

.hist-live-indicator {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .2rem .7rem;
  border-radius: 99px;
  border: 1px solid transparent;
  margin-left: auto;
  margin-right: 1rem;
}

.hist-live-indicator[data-state="live"] {
  color: #34d399;
  border-color: rgba(52,211,153,.3);
  background: rgba(52,211,153,.07);
}

.hist-live-indicator[data-state="live"] .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-dot 2s ease-in-out infinite;
}

.hist-live-indicator[data-state="idle"] {
  color: var(--text-dim);
  border-color: var(--border);
}

.hist-live-indicator[data-state="idle"] .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 4rem 2rem;
  color: var(--text-dim);
  text-align: center;
}

.hist-empty p {
  font-size: .9rem;
  line-height: 1.6;
  margin: 0;
}

/* ── Entry cards ─────────────────────────────────────────────────────────── */

.history-wrap {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.hist-card {
  border: 1px solid rgba(99,102,241,.15);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color .2s;
  animation: hist-in .2s ease;
}

@keyframes hist-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hist-card:hover {
  border-color: rgba(99,102,241,.35);
}

.hist-card--open {
  border-color: rgba(99,102,241,.5);
}

.hist-card-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .75rem 1rem;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}

.hist-card-header:hover {
  background: rgba(99,102,241,.04);
}

.hist-col-time {
  font-family: var(--font-mono);
  font-size: .73rem;
  color: var(--text-dim);
  min-width: 110px;
  white-space: nowrap;
}

.hist-col-mission {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: #818cf8;
  font-weight: 600;
  min-width: 80px;
}

.hist-col-driver {
  flex: 1;
  min-width: 140px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
}

.hist-col-candidates {
  font-size: .75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.hist-col-confidence {
  display: flex;
  align-items: center;
}

.hist-col-elapsed {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.hist-human-tag {
  font-size: .72rem;
  color: #f59e0b;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 99px;
  padding: .1rem .5rem;
  white-space: nowrap;
}

.hist-toggle {
  margin-left: auto;
  font-size: .78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  flex-shrink: 0;
  transition: transform .2s;
}

.hist-card--open .hist-toggle {
  transform: rotate(180deg);
}

/* ── Expanded detail ─────────────────────────────────────────────────────── */

.hist-detail {
  display: none;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.hist-card--open .hist-detail {
  display: block;
}

/* Nested cards inside the detail view get a slightly reduced shadow */
.hist-detail .card {
  box-shadow: none;
  border-color: rgba(255,255,255,.07);
}
