/* esp32/xiaozhi.css */
* { box-sizing: border-box; margin: 0; padding: 0; }

body { background: #0a0a0a; color: #e2e8f0; font-family: system-ui, sans-serif; min-height: 100vh; }

/* ── Nav ──────────────────────────────────────────────────────────── */
nav {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-bottom: 1px solid #111;
  font-size: 0.82rem; color: #555; position: sticky; top: 0;
  background: rgba(10,10,10,0.92); backdrop-filter: blur(8px); z-index: 100;
}
nav a { color: #555; text-decoration: none; }
nav a:hover { color: #aaa; }
nav .sep { color: #333; }
nav .current { color: #999; }
nav .spacer { flex: 1; }
#nav-auth { position: relative; }
#nav-auth-btn {
  background: none; border: 1px solid #252525; border-radius: 6px;
  color: #444; font-size: 0.75rem; padding: 4px 10px; cursor: pointer;
  font-family: inherit; transition: color 0.2s, border-color 0.2s;
  text-decoration: none; display: inline-block; line-height: 1.6;
}
#nav-auth-btn:hover { color: #888; border-color: #333; }
#nav-auth-btn.authed { color: #4ade80; border-color: rgba(74,222,128,0.25); }
#nav-auth-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: #0e0e0e; border: 1px solid #1e1e1e; border-radius: 8px;
  min-width: 160px; z-index: 200; overflow: hidden;
}
#nav-auth-dropdown.open { display: block; }
.nav-dd-item {
  display: block; padding: 9px 14px; font-size: 0.8rem; color: #888;
  text-decoration: none; cursor: pointer; background: none; border: none;
  font-family: inherit; width: 100%; text-align: left; transition: background .15s, color .15s;
}
.nav-dd-item:hover { background: #161616; color: #ccc; }
.nav-dd-item.danger:hover { color: #f87171; }

main { padding: 32px 24px; max-width: 1200px; margin: 0 auto; }
h1   { font-size: 1.4rem; font-weight: 600; margin-bottom: 4px; }
.subtitle { color: #64748b; font-size: 0.85rem; margin-bottom: 28px; }

/* ── Status bar ─────────────────────────────────────────────────── */
.status-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.online-dot.offline { background: #f87171; }
.online-dot.stale   { background: #fbbf24; }
#status-text { font-size: 0.82rem; color: #94a3b8; }
.refresh-btn { background: #1e2230; color: #94a3b8; border: 1px solid #2d3748; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; font-family: inherit; }
.refresh-btn:hover { background: #2d3748; }

/* ── Metric cards ───────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }
.card { background: #141720; border: 1px solid #1e2230; border-radius: 10px; padding: 16px; }
.card .label { font-size: 0.7rem; color: #64748b; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.card .value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.card .unit  { font-size: 0.78rem; color: #94a3b8; margin-left: 2px; }
.card-note { margin-top: 8px; font-size: 0.72rem; color: #64748b; }

.good { color: #34d399; }
.warn { color: #fbbf24; }
.bad  { color: #f87171; }
.dim  { color: #64748b; }

/* ── Table ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 10px; background: #0d1015; border: 1px solid #1e2230; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.table-wrap thead th { text-align: left; padding: 9px 10px; background: #141720; color: #94a3b8; font-weight: 500; border-bottom: 1px solid #1e2230; position: sticky; top: 0; white-space: nowrap; }
.table-wrap tbody td { padding: 7px 10px; border-bottom: 1px solid #0f1117; white-space: nowrap; }
.table-wrap tbody tr:hover td { background: #141720; }

/* ── Event badges ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 0.7rem; font-weight: 600; }
.ev-boot               { background: #1e3a5f; color: #60a5fa; }
.ev-heartbeat          { background: #1a2e1a; color: #4ade80; }
.ev-conversation_start { background: #2e1a3a; color: #c084fc; }
.ev-conversation_end   { background: #2a2a1a; color: #facc15; }
.ev-wake_word          { background: #3a1a1a; color: #f87171; }
.ev-video_playback_progress { background: #10263d; color: #7dd3fc; }
.ev-video_playback_end      { background: #1a2f24; color: #86efac; }

.details-cell {
  min-width: 360px;
  white-space: normal !important;
  line-height: 1.45;
}
.details-main {
  color: #e2e8f0;
  font-weight: 600;
  margin-bottom: 3px;
}
.details-sub {
  color: #94a3b8;
  font-size: 0.74rem;
}
.detail-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ── New-row flash ──────────────────────────────────────────────── */
@keyframes rowflash { from { background: #1a2e1a; } to { background: transparent; } }
tr.new-row td { animation: rowflash 1.2s ease-out forwards; }

/* ── Tab bar ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 24px;
  border-bottom: 1px solid #1e2230; padding-bottom: 0;
}
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: #64748b; font-size: 0.85rem; font-family: inherit;
  padding: 8px 16px; cursor: pointer; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: #94a3b8; }
.tab-btn.active { color: #e2e8f0; border-bottom-color: #4ade80; }

.tab-sub { color: #64748b; font-size: 0.8rem; margin-bottom: 20px; }
.hidden  { display: none !important; }

/* ── Info grid (shared by Hardware / Architecture / Firmware tabs) ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 20px;
}
.info-section {
  background: #141720; border: 1px solid #1e2230; border-radius: 10px; padding: 20px;
  min-width: 0; overflow: hidden;
}
.info-section--wide { grid-column: 1 / -1; }
.info-section h2 {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: #94a3b8; margin-bottom: 14px;
}
.info-sub-h {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: #64748b; margin: 14px 0 8px;
}

/* ── Info tables ─────────────────────────────────────────────────── */
.info-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; table-layout: fixed; }
.info-table th {
  text-align: left; padding: 6px 10px 6px 0;
  color: #64748b; font-weight: 500; border-bottom: 1px solid #1e2230;
  overflow-wrap: break-word;
}
.info-table td {
  padding: 6px 10px 6px 0; border-bottom: 1px solid #0f1117; vertical-align: top;
  overflow-wrap: break-word; word-break: break-word;
}
.info-table tr:last-child td { border-bottom: none; }
.info-key { color: #64748b; white-space: nowrap; padding-right: 16px; width: 30%; }
.pin { color: #60a5fa; font-family: monospace; font-size: 0.8rem; }
.info-table code { font-family: monospace; font-size: 0.78rem; color: #a5b4fc; word-break: break-all; }

/* ── Pin table: 4-column layout ─────────────────────────────────── */
.pin-table { table-layout: auto; }
.pin-table td { padding: 5px 12px 5px 0; white-space: nowrap; }

/* ── Prose / notes ───────────────────────────────────────────────── */
.info-prose { font-size: 0.82rem; color: #94a3b8; line-height: 1.6; margin-bottom: 10px; }
.info-note  { font-size: 0.75rem; color: #64748b; margin-top: 10px; line-height: 1.5; }
.info-note.critical { color: #f87171; }
.info-prose.info-warn { color: #fbbf24; background: #1c1200; border-left: 3px solid #78350f; padding: 8px 12px; border-radius: 4px; }

/* ── Steps list ──────────────────────────────────────────────────── */
.info-steps { font-size: 0.82rem; color: #94a3b8; line-height: 1.8; padding-left: 20px; }
.info-steps code { font-family: monospace; font-size: 0.78rem; color: #a5b4fc; }

/* ── Code block ──────────────────────────────────────────────────── */
.info-code {
  background: #0d1015; border: 1px solid #1e2230; border-radius: 6px;
  padding: 12px 14px; font-size: 0.78rem; color: #94a3b8;
  font-family: monospace; white-space: pre; overflow-x: auto; margin-top: 10px;
  display: block; max-width: 100%;
}

/* ── State machine ───────────────────────────────────────────────── */
.state-list { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.state-item {
  background: #1e2230; border-radius: 6px; padding: 7px 14px;
  font-size: 0.82rem; font-weight: 600; min-width: 140px; text-align: center;
}
.state-idle   { color: #4ade80; border: 1px solid rgba(74,222,128,.25); }
.state-conn   { color: #60a5fa; border: 1px solid rgba(96,165,250,.25); }
.state-listen { color: #c084fc; border: 1px solid rgba(192,132,252,.25); }
.state-speak  { color: #facc15; border: 1px solid rgba(250,204,21,.25); }
.state-arrow  { font-size: 0.72rem; color: #475569; padding: 3px 14px; }

/* ── Audio pipeline ──────────────────────────────────────────────── */
.pipeline { display: flex; flex-direction: column; gap: 0; }
.pipe-step {
  background: #1e2230; border-radius: 6px; padding: 8px 14px;
  font-size: 0.82rem; display: flex; flex-direction: column; gap: 2px;
}
.pipe-step--highlight { background: #1a2e1a; border: 1px solid rgba(74,222,128,.2); }
.pipe-sub { font-size: 0.7rem; color: #64748b; }
.pipe-arrow { font-size: 0.8rem; color: #475569; padding: 2px 14px; }

/* ── How-it-works flow steps ─────────────────────────────────────── */
.flow-row {
  display: flex; gap: 0; align-items: flex-start; flex-wrap: wrap;
}
.flow-step {
  display: flex; gap: 12px; flex: 1; min-width: 180px;
  background: #0d1015; border: 1px solid #1e2230; border-radius: 8px;
  padding: 14px; margin: 4px;
}
.flow-step-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: #1e2230; border: 1px solid #4ade8033;
  color: #4ade80; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.flow-step-body { flex: 1; min-width: 0; overflow-wrap: break-word; }
.flow-step-title { font-size: 0.82rem; font-weight: 600; color: #e2e8f0; margin-bottom: 5px; }
.flow-step-desc  { font-size: 0.75rem; color: #64748b; line-height: 1.55; }
.flow-step-desc code { font-family: monospace; font-size: 0.72rem; color: #a5b4fc; word-break: break-all; }
.flow-connector {
  font-size: 1.1rem; color: #334155; padding: 18px 2px 0; flex-shrink: 0;
  align-self: flex-start;
}
@media (max-width: 800px) {
  .flow-connector { display: none; }
}

/* ── Hyperlinks inside info sections ─────────────────────────────── */
.info-section a { color: #60a5fa; text-decoration: none; }
.info-section a:hover { text-decoration: underline; }

/* ── Issue cards ─────────────────────────────────────────────────── */
.issue-card {
  background: #0d1015; border: 1px solid #1e2230; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 12px;
}
.issue-card:last-child { margin-bottom: 0; }
.issue-card p { font-size: 0.8rem; color: #64748b; line-height: 1.6; margin-top: 8px; }
.issue-card code { font-family: monospace; font-size: 0.75rem; color: #a5b4fc; }
.issue-title { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.issue-badge { font-size: 0.65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }
.issue-badge--open    { background: #3a1a1a; color: #f87171; }
.issue-badge--cosmetic { background: #2a2a1a; color: #facc15; }
.issue-badge--by-design { background: #1a2030; color: #94a3b8; }

/* ── Version history / known-issues inline badges ───────────────── */
.badge-tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.65rem; font-weight: 600; background: #1e293b; color: #94a3b8; white-space: nowrap; }
.badge-tag.good { background: #14532d; color: #4ade80; }
.badge-tag.bad  { background: #450a0a; color: #f87171; }
.badge-tag.warn { background: #422006; color: #fbbf24; }
.info-row-highlight td { background: #1a2a1a !important; }
