/* ====================================================
   stats.css — Statistics page styles
   ==================================================== */

/* ── Stats toolbar ─────────────────────────────────── */
.stats-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.stats-toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.stats-toolbar-right {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
}

/* ── Time range pills ────────────────────────────────── */
.time-filter-group,
.granularity-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(20, 34, 52, 0.05);
}

.time-btn,
.gran-btn {
  min-width: 42px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.time-btn:hover,
.gran-btn:hover {
  background: var(--panel-strong);
  color: var(--ink);
}

.time-btn.active,
.gran-btn.active {
  background: var(--proof);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
}

/* ── Network toggle pills ────────────────────────────── */
.network-toggles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.net-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  transition: opacity 0.15s, box-shadow 0.15s, border-color 0.15s;
  background: var(--panel);
  color: var(--muted);
}

.net-toggle.active {
  opacity: 1;
  border-color: currentColor;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.net-toggle:not(.active) {
  opacity: 0.45;
  border-color: var(--line);
}

.net-toggle .net-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* ── Load state ─────────────────────────────────────── */
.stats-load-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 0;
  color: var(--muted);
  font-size: 0.95rem;
  justify-content: center;
}

.stats-load-state[hidden] {
  display: none;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--proof);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Skeleton loading cards ─────────────────────────── */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  width: 100%;
  margin-top: 10px;
}

.skeleton-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  height: 280px;
  display: flex;
  flex-direction: column;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-head {
  height: 60px;
  border-bottom: 1px solid var(--line);
}

.skeleton-body {
  flex: 1;
  margin: 18px 22px;
  border-radius: 8px;
  background: var(--line);
  opacity: 0.4;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@media (max-width: 900px) {
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Charts grid ────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.charts-grid[hidden] {
  display: none;
}

/* ── Chart card ─────────────────────────────────────── */
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(20, 34, 52, 0.07);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}

.chart-card:hover {
  box-shadow: 0 16px 48px rgba(20, 34, 52, 0.11);
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.chart-card-head h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink-strong);
  margin-bottom: 3px;
}

.chart-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.4;
}

.chart-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--proof);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.chart-wrap {
  flex: 1;
  position: relative;
  padding: 18px 22px 18px;
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-full {
    grid-column: auto;
  }

  .stats-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stats-toolbar-right {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .stats-toolbar {
    margin-bottom: 18px;
    padding: 10px 0 16px;
  }

  .stats-toolbar-left,
  .stats-toolbar-right,
  .network-toggles {
    width: 100%;
  }

  .time-filter-group,
  .granularity-group {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .time-btn,
  .gran-btn {
    flex: 1 0 auto;
    min-width: 42px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .stats-toolbar .check {
    width: calc(50% - 5px);
    min-width: 140px;
    flex: 1 1 140px;
  }

  .network-toggles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .net-toggle {
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    height: 36px;
    padding-inline: 10px;
    font-size: 0.76rem;
  }

  .skeleton-grid,
  .charts-grid {
    gap: 12px;
  }

  .chart-card {
    border-radius: 10px;
  }

  .chart-card-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .chart-badge {
    align-self: flex-start;
  }

  .chart-wrap {
    min-height: 230px;
    padding: 12px 8px 14px;
  }

  .chart-wrap canvas {
    min-height: 220px;
  }
}

@media (max-width: 390px) {
  .network-toggles {
    grid-template-columns: 1fr;
  }

  .stats-toolbar .check {
    width: 100%;
  }
}
