/* ============================================================
   Yealink W80B Monitor – Dark Dashboard Theme
   ============================================================ */

:root {
  --bg-0:       #0d1117;
  --bg-1:       #161b22;
  --bg-2:       #21262d;
  --border:     #30363d;
  --text-1:     #e6edf3;
  --text-2:     #8b949e;
  --text-3:     #6e7681;
  --blue:       #2f81f7;
  --blue-light: #58a6ff;
  --green:      #3fb950;
  --yellow:     #d29922;
  --orange:     #f0883e;
  --red:        #f85149;
  --red-dark:   #da3633;
  --purple:     #8957e5;
  --cyan:       #39d353;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ────────────────────────────────────────── */
nav {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.nav-brand svg { flex-shrink: 0; }

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex: 1;
}

.nav-links a {
  color: var(--text-2);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: background .15s, color .15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--bg-2);
  color: var(--text-1);
  text-decoration: none;
}

.nav-badge {
  background: var(--red-dark);
  color: #fff;
  border-radius: 20px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 4px;
  vertical-align: middle;
}

.nav-time {
  font-size: 0.8rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Layout ────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 1.25rem;
}

/* ── Stat Cards Row ─────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-1);
}

.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.blue   { color: var(--blue-light); }

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.3rem;
}

/* ── Base Station Cards ─────────────────────────────────── */
.bases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.base-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  transition: border-color .2s;
  position: relative;
  overflow: hidden;
}

.base-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
}

.base-card.online::before  { background: var(--green); }
.base-card.offline::before { background: var(--red); }
.base-card.warn::before    { background: var(--yellow); }

.base-card:hover { border-color: var(--blue); }

.base-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.base-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.status-dot.warn    { background: var(--yellow); }

.base-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.meta-key   { color: var(--text-2); }
.meta-value { color: var(--text-1); font-weight: 500; }

.signal-bar-wrap {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.signal-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}

.signal-label span { font-weight: 600; }

.signal-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-2);
  overflow: hidden;
}

.signal-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s;
}

.signal-fill.excellent { background: var(--green); }
.signal-fill.good      { background: #6ed56e; }
.signal-fill.medium    { background: var(--yellow); }
.signal-fill.weak      { background: var(--orange); }
.signal-fill.critical  { background: var(--red); }
.signal-fill.none      { background: var(--text-3); width: 0 !important; }

.base-counters {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.65rem;
  font-size: 0.78rem;
}

.counter {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-2);
}

.counter.warn  { color: var(--yellow); }
.counter.crit  { color: var(--red); }

/* ── Charts ─────────────────────────────────────────────── */
.chart-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-1);
}

.section-controls select,
.section-controls input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
}

.chart-wrap { position: relative; height: 260px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.table-section .section-header {
  padding: 1rem 1.25rem 0;
  margin-bottom: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

thead th {
  text-align: left;
  padding: 0.75rem 1.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  font-weight: 600;
}

tbody td {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--bg-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-2); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge-online    { background: #1a3d2a; color: var(--green); }
.badge-offline   { background: #3d1a1a; color: var(--red); }
.badge-info      { background: #1a2a3d; color: var(--blue-light); }
.badge-warning   { background: #3d2e1a; color: var(--yellow); }
.badge-critical  { background: #3d1a1a; color: var(--red); }
.badge-synced    { background: #1a2a1a; color: var(--green); }
.badge-desynced  { background: #3d2e1a; color: var(--orange); }

/* ── Alert Types ─────────────────────────────────────────── */
.alert-type-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

/* ── Problem Bar Chart ───────────────────────────────────── */
.problem-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--bg-2);
}

.problem-row:last-child { border-bottom: none; }

.problem-name {
  min-width: 150px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.problem-bar-outer {
  flex: 1;
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
}

.problem-bar-inner {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--yellow), var(--red));
}

.problem-count {
  min-width: 40px;
  text-align: right;
  font-size: 0.82rem;
  color: var(--text-2);
  font-weight: 600;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding: 1rem;
}

.pagination a {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.82rem;
  transition: background .15s;
}

.pagination a:hover, .pagination a.active {
  background: var(--blue);
  border-color: var(--blue);
  text-decoration: none;
  color: #fff;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #388bfd; text-decoration: none; }

.btn-sm { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); text-decoration: none; }

/* ── Uptime Timeline ─────────────────────────────────────── */
.uptime-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
  flex-wrap: nowrap;
}

.uptime-seg {
  flex: 1;
  min-width: 2px;
}

.uptime-seg.up   { background: var(--green); }
.uptime-seg.down { background: var(--red); }

/* ── Info Box ────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
  font-size: 0.85rem;
}

.info-grid dt {
  color: var(--text-2);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--bg-2);
}

.info-grid dd {
  font-weight: 500;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--bg-2);
}

/* ── Misc ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 3rem 1rem;
  font-size: 0.9rem;
}

.text-muted { color: var(--text-3); }

.loading { color: var(--text-3); font-size: 0.85rem; animation: pulse 1.5s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mt-sm { margin-top: 0.5rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  main { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .bases-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .nav-time { display: none; }
  thead { display: none; }
  tbody td { display: block; padding: 0.4rem 1rem; border: none; }
  tbody td::before {
    content: attr(data-label) ': ';
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.75rem;
  }
  tbody tr { border-bottom: 1px solid var(--border); }
}
