/* ============================================================
   PARROT-BRAIN DASHBOARD — Tiki / Rum / Voodoo Theme
   Warm torchlight. Aged wood. No space stations.
   ============================================================ */

:root {
  --bg:          #120a04;
  --surface:     #1e1008;
  --surface-2:   #2a1a0c;
  --surface-3:   #382212;
  --border:      #4a2e14;
  --border-warm: #6a4020;

  --text:        #e8c870;
  --text-dim:    #9a7a3a;
  --text-faint:  #5a4020;
  --text-mono:   #c8a850;

  --accent:      #c87810;   /* torch amber */
  --accent-hot:  #e8500a;   /* hot ember */
  --accent-cool: #6a9a3a;   /* jungle green — healthy */

  --online:   #c87810;
  --offline:  #6a3020;
  --unknown:  #4a3a20;
  --warn:     #c84010;

  --bar-bg:   #2a1a0c;
  --bar-fill: #c87810;
  --bar-warn: #c84010;

  --font-title: 'Pirata One', serif;
  --font-body:  'IM Fell English', serif;
  --font-mono:  'Courier Prime', monospace;

  --radius: 4px;
  --gap: 1rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  padding-bottom: 3rem;
}

/* ---- HEADER ---- */
.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-icon {
  background: #d4b882;
  border-radius: 50%;
  padding: 4px;
  border: 1px solid var(--border-warm);
  flex-shrink: 0;
}

.parrot-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  filter: sepia(0.2) brightness(0.85);
}

.header-text { flex: 1; }

.site-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  line-height: 1;
}

.site-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.2rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-refresh {
  background: none;
  border: 1px solid var(--border-warm);
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: color 0.2s, border-color 0.2s;
}
.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }

.auto-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- STATUS BANNER ---- */
.status-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.status-flame {
  font-size: 2rem;
  line-height: 1;
  animation: flicker 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes flicker {
  0%,100% { opacity: 1;   transform: scale(1);    }
  25%      { opacity: 0.85; transform: scale(0.97) rotate(-1deg); }
  50%      { opacity: 1;   transform: scale(1.03) rotate(1deg);  }
  75%      { opacity: 0.9; transform: scale(0.98);  }
}

.status-banner.offline .status-flame { animation: none; opacity: 0.4; }
.status-banner.unknown .status-flame { animation: none; opacity: 0.3; }

.status-info { flex: 1; }

.status-label {
  font-family: var(--font-title);
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.status-banner.offline .status-label { color: var(--offline); }
.status-banner.unknown .status-label { color: var(--unknown); }

.status-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.2rem;
}

.status-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.meta-item {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.source-badge {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  color: var(--text-dim);
}
.source-badge.local  { border-color: var(--accent-cool); color: var(--accent-cool); }
.source-badge.cloud  { border-color: var(--accent); color: var(--accent); }
.source-badge.stale  { border-color: var(--warn); color: var(--warn); }

/* ---- STATS ROW ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-card {
  background: var(--surface);
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

/* ---- MAIN GRID ---- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 1px;
  background: var(--border);
  margin-top: 1px;
}

/* ---- PANELS ---- */
.panel {
  background: var(--surface);
  padding: 1.25rem 1.5rem;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

.panel-sub {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-style: italic;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

/* Leaderboard spans full width on first row */
.panel-leaderboard { grid-column: 1; grid-row: 1; }
.panel-health      { grid-column: 2; grid-row: 1; }
.panel-network     { grid-column: 1; grid-row: 2; }
.panel-audio       { grid-column: 2; grid-row: 2; }

/* ---- LEADERBOARD ---- */
.leaderboard-list { display: flex; flex-direction: column; gap: 0.4rem; }

.leaderboard-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border-left: 2px solid var(--border);
  transition: border-color 0.2s;
}
.leaderboard-item:nth-child(1) { border-left-color: var(--accent-hot); }
.leaderboard-item:nth-child(2) { border-left-color: var(--accent); }
.leaderboard-item:nth-child(3) { border-left-color: var(--text-dim); }

.lb-rank {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  text-align: right;
}

.lb-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-bar-wrap {
  width: 60px;
  height: 6px;
  background: var(--bar-bg);
  border-radius: 3px;
  overflow: hidden;
}
.lb-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.lb-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  text-align: right;
  min-width: 2rem;
}

.placeholder-text {
  font-style: italic;
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* ---- HEALTH BARS ---- */
.health-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}
.health-row:last-child { margin-bottom: 0; grid-template-columns: 80px 1fr; }

.health-label {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.health-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  text-align: right;
}
.health-bar-wrap {
  height: 8px;
  background: var(--bar-bg);
  border-radius: 4px;
  overflow: hidden;
  grid-column: span 1;
}
.health-bar {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease, background 0.3s;
}
.health-bar.warn  { background: var(--warn); }
.health-bar.crit  { background: var(--accent-hot); }

/* ---- INFO TABLE ---- */
.info-table {
  width: 100%;
  border-collapse: collapse;
}
.info-table tr + tr td { border-top: 1px solid var(--surface-3); }
.info-key {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 0.45rem 0.5rem 0.45rem 0;
  width: 40%;
  vertical-align: top;
}
.info-val {
  font-size: 0.82rem;
  color: var(--text);
  padding: 0.45rem 0;
}
.info-val.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-mono);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.dot.green  { background: var(--accent-cool); }
.dot.red    { background: var(--warn); }
.dot.amber  { background: var(--accent); }

/* ---- FOOTER ---- */
.site-footer {
  margin-top: 2rem;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-style: italic;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .main-grid { grid-template-columns: 1fr; }
  .panel-leaderboard,
  .panel-health,
  .panel-network,
  .panel-audio { grid-column: 1; grid-row: auto; }
  .status-meta { display: none; }
}
