/* ============================================================
   AvatarMapper v2 — dashboard dark theme
   Tom: ferramenta de tracking. Denso, mono, sem firulas.
   ============================================================ */

:root {
  --bg: #0b0d10;
  --bg-elev: #11141a;
  --bg-card: #141821;
  --bg-card-hover: #1a1f2a;
  --border: #1e242f;
  --border-strong: #2a3140;
  --text: #e6e8eb;
  --text-muted: #7a8290;
  --text-dim: #4f5662;
  --accent: #2dd4a4;
  --accent-dark: #129869;
  --amber: #f5a623;
  --blue: #4ea3ff;
  --red: #ef4654;
  --pos: #2dd4a4;
  --neg: #ef4654;
  --gray-pill: #2a3140;

  --radius: 6px;
  --radius-lg: 10px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   Layout
============================================================ */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.brand-mark {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand-name span { color: var(--accent); }
.brand-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover {
  background: var(--bg-card);
  color: var(--text);
}
.nav-link.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-icon {
  font-size: 14px;
  color: var(--text-dim);
  width: 18px;
  display: inline-block;
}
.nav-link.active .nav-icon { color: var(--accent); }

.sidebar-footer { padding: 20px 24px 0; border-top: 1px solid var(--border); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
}
.status-pill.online .status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-pill.offline .status-dot { background: var(--red); }

.content {
  padding: 32px 40px;
  overflow-x: auto;
}

/* ============================================================
   Headers & typography
============================================================ */
h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
h2 { font-size: 18px; font-weight: 600; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
h4 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin: 14px 0 8px; }

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 24px;
  flex-wrap: wrap;
}
.header-actions {
  display: flex;
  gap: 8px;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.small { font-size: 12px; }
.mt { margin-top: 12px; }

/* ============================================================
   Buttons
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--text-dim); }
.btn-primary {
  background: var(--accent);
  color: #07150f;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-tiny { padding: 4px 9px; font-size: 11.5px; }
.btn-danger { color: var(--red); border-color: rgba(239,70,84,0.3); }
.btn-danger:hover { background: rgba(239,70,84,0.08); }

/* ============================================================
   Stats grid
============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  position: relative;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.stat.accent-green .stat-value { color: var(--accent); }
.stat.accent-amber .stat-value { color: var(--amber); }
.stat.accent-red .stat-value { color: var(--red); }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Toolbar
============================================================ */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.toolbar input { min-width: 240px; flex: 1; }
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--accent);
}

/* ============================================================
   Tables
============================================================ */
.video-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table.t {
  width: 100%;
  border-collapse: collapse;
}
table.t thead {
  background: var(--bg-elev);
}
table.t th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
table.t td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
table.t tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
table.t tbody tr:hover { background: var(--bg-card-hover); }
table.t tbody tr:last-child td { border-bottom: 0; }

.thumb {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.thumb-empty {
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

.cell-name { font-weight: 500; font-size: 13.5px; }
.cell-parsed { color: var(--text-muted); margin-top: 2px; }
.cell-avatar b { display: block; font-size: 13px; }
.cell-scene b { font-weight: 500; }
.cell-perf { font-family: var(--font-mono); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.cell-perf.pos > span:first-child { color: var(--pos); font-weight: 700; }
.cell-perf.neg > span:first-child { color: var(--neg); }

/* ============================================================
   Tags / badges
============================================================ */
.tag {
  display: inline-block;
  background: var(--gray-pill);
  color: var(--text);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 3px;
}
.tag-shot { background: rgba(78,163,255,0.15); color: var(--blue); }
.tag-obj  { background: rgba(245,166,35,0.15); color: var(--amber); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.badge-gray  { background: var(--gray-pill); color: var(--text-muted); }
.badge-green { background: rgba(45,212,164,0.15); color: var(--accent); }
.badge-amber { background: rgba(245,166,35,0.15); color: var(--amber); }
.badge-blue  { background: rgba(78,163,255,0.15); color: var(--blue); }
.badge-red   { background: rgba(239,70,84,0.15); color: var(--red); }

/* ============================================================
   Cards
============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.card-head h3 { margin: 0; }
.card-wide { grid-column: 1 / -1; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.codes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1200px) { .codes-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .codes-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Detail page
============================================================ */
.detail-page { max-width: 1100px; }
.back-row { margin-bottom: 16px; }
.back-link { color: var(--text-muted); font-size: 13px; }
.back-link:hover { color: var(--text); }

.detail-header {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
  align-items: flex-start;
}
.detail-thumb {
  width: 220px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.detail-header h1 {
  font-family: var(--font-mono);
  font-size: 18px;
  word-break: break-all;
  font-weight: 500;
}
.detail-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-avatar {
  display: flex;
  gap: 14px;
  align-items: center;
}
.avatar-ref, .avatar-ref-empty {
  width: 70px; height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
}
.avatar-ref-empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev); color: var(--text-dim); font-size: 22px;
}
.kv-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.kv-value { font-size: 16px; font-weight: 600; margin-top: 2px; }
.kv-sub { color: var(--text-muted); }

.kv {
  width: 100%;
  border-collapse: collapse;
}
.kv td {
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.kv td:first-child {
  width: 32%;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.taglist {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.taglist li {
  display: flex; align-items: center; gap: 10px;
}

.ocr-list {
  list-style: none;
  margin: 0; padding: 0;
}
.ocr-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ocr-list li:last-child { border-bottom: none; }

.audio-block {
  background: var(--bg-elev);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-style: italic;
  border-left: 2px solid var(--accent);
}

.error-block {
  background: rgba(239,70,84,0.08);
  border: 1px solid rgba(239,70,84,0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--red);
}

/* ============================================================
   Avatar cards
============================================================ */
.avatar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.avatar-card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-elev);
}
.avatar-card-img.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: var(--text-dim);
}
.avatar-card-body { padding: 14px 16px; }
.avatar-card-actions {
  display: flex; gap: 6px; margin-top: 12px;
}

/* ============================================================
   Dialog
============================================================ */
.dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--text);
  max-width: 420px;
}
.dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog h2 { margin-bottom: 16px; }
.dialog label {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dialog input, .dialog textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  margin-top: 4px;
  outline: none;
}
.dialog input:focus, .dialog textarea:focus { border-color: var(--accent); }
.dlg-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ============================================================
   Toast
============================================================ */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { border-color: var(--red); color: var(--red); }
#toast.ok { border-color: var(--accent); }

/* ============================================================
   Empty state
============================================================ */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
