/* ============================================================
   Malaysia Web Defacement Observatory — Dashboard Styles
   ============================================================ */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #388bfd;
  --accent-hover: #58a6ff;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 32px 0;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Sections ── */
section {
  margin: 40px 0;
}

section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent-hover);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Chart grid ── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  min-width: 0;       /* prevent grid child overflow */
  overflow: hidden;
}

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

canvas {
  display: block;
  width: 100% !important;
  max-height: 340px;
}

/* ── Monthly Heatmap ── */
#heatmap-container {
  overflow-x: auto;
}

.heatmap-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.78rem;
}

.heatmap-table th,
.heatmap-table td {
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.heatmap-table th {
  color: var(--text-muted);
  background: var(--surface-2);
  font-weight: 600;
}

.heatmap-table td.year-label {
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
}

.heatmap-table td.heat {
  transition: filter 0.15s;
}
.heatmap-table td.heat:hover {
  filter: brightness(1.25);
  cursor: default;
}

/* ── Year Filter ── */
.year-filter {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 10px;
  margin-bottom: 32px;
}

.year-filter-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.year-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.year-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 4px 11px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.year-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.year-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Footer ── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 60px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 2;
}

/* ── Responsive ── */

/* Tablet */
@media (max-width: 900px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .container {
    padding: 0 16px;
  }

  .site-header {
    padding: 20px 0;
  }

  .site-header h1 {
    font-size: 1.2rem;
  }

  .subtitle {
    font-size: 0.82rem;
  }

  section {
    margin: 28px 0;
  }

  section h2 {
    font-size: 1.1rem;
  }

  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 14px 8px;
    min-width: 0;
  }

  .stat-value {
    font-size: 1.35rem;
    word-break: break-all;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .chart-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chart-card {
    padding: 16px;
  }

  .chart-card h3 {
    font-size: 0.82rem;
    margin-bottom: 12px;
  }

  canvas {
    max-height: 260px;
  }

  /* Year filter: single scrollable row instead of wrapping */
  .year-filter {
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 20px;
  }

  .year-filter-label {
    display: none;
  }

  .year-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    /* hide scrollbar visually */
    scrollbar-width: none;
  }

  .year-buttons::-webkit-scrollbar {
    display: none;
  }

  .year-btn {
    flex-shrink: 0;
  }

  .heatmap-table {
    font-size: 0.68rem;
  }

  .heatmap-table th,
  .heatmap-table td {
    padding: 4px 5px;
  }

  .site-footer {
    margin-top: 40px;
    padding: 20px 0;
  }
}
