/* ═══════════════════════════════════════════════════════════════
   CRYPTO METRICS DASHBOARD — LAYOUT UTILITIES

   Grid-based dashboard template system. Use these classes to build
   metric cards, stat panels, and chart sections.
   ═══════════════════════════════════════════════════════════════ */

/* ── Dashboard grid ─────────────────────────────────────────── */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) 0;
}

.dashboard-grid {
  display: grid;
  gap: var(--space-5);
  width: 100%;
}

/* 4-column stat cards row */
.dashboard-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* 3-column layout */
.dashboard-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 2-column layout */
.dashboard-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* 1+3 layout (sidebar + main) */
.dashboard-grid-sidebar {
  grid-template-columns: 280px 1fr;
}

/* 8-col flexible grid */
.dashboard-grid-flex {
  grid-template-columns: repeat(8, 1fr);
}

/* ── Stat card ──────────────────────────────────────────────── */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  transition: all var(--ease-smooth);
}

.stat-card:hover {
  border-color: rgba(59, 130, 246, 0.2);
  box-shadow: var(--shadow-hover), 0 0 30px rgba(59, 130, 246, 0.05);
}

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.stat-card-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon.blue {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue-bright);
}
.stat-card-icon.purple {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple-bright);
}
.stat-card-icon.green {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
}
.stat-card-icon.warm {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-warm);
}
.stat-card-icon.cyan {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
}
.stat-card-icon.red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

.stat-card-value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card-value.sm {
  font-size: var(--text-xl);
}

.stat-card-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.stat-card-change.up {
  background: rgba(34, 197, 94, 0.1);
  color: var(--accent-green);
}
.stat-card-change.down {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
}

.stat-card-change.neutral {
  background: var(--bg-2);
  color: var(--text-1);
}

.stat-card-spark {
  margin-top: auto;
  height: 40px;
  opacity: 0.6;
}

/* ── Metric panel (mid-size card) ──────────────────────────── */
.metric-panel {
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: all var(--ease-smooth);
}

.metric-panel:hover {
  border-color: rgba(139, 92, 246, 0.15);
  box-shadow: var(--shadow-hover), var(--shadow-glow-purple);
}

.metric-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--bg-3);
}

.metric-panel-title {
  font-size: var(--text-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.metric-panel-body {
  /* chart container */
}

/* ── Chart container ────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-container.sm { height: 200px; }
.chart-container.xl { height: 360px; }
.chart-container.full { height: 100%; min-height: 300px; }

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Data table ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  border-bottom: 1px solid var(--bg-3);
  background: var(--bg-0);
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-1);
  border-bottom: 1px solid rgba(37, 40, 74, 0.4);
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover td {
  background: var(--bg-2);
  color: var(--text-0);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .mono { font-family: var(--font-mono); }

/* ── Period selector ────────────────────────────────────────── */
.period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-0);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius-md);
  padding: 3px;
}

.period-btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-1);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--ease-smooth);
}

.period-btn:hover {
  color: var(--text-0);
  background: var(--bg-2);
}

.period-btn.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ── Holder distribution bar ───────────────────────────────── */
.holder-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.holder-bar-label {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--text-1);
  width: 100px;
  flex-shrink: 0;
}

.holder-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.holder-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.holder-bar-fill.blue {
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-bright));
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}
.holder-bar-fill.purple {
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-purple-bright));
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}
.holder-bar-fill.green {
  background: linear-gradient(90deg, var(--accent-green-dim), var(--accent-green));
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}
.holder-bar-fill.cyan {
  background: linear-gradient(90deg, #0891b2, var(--accent-cyan));
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}
.holder-bar-fill.warm {
  background: linear-gradient(90deg, #d97706, var(--accent-warm));
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.holder-bar-pct {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-1);
  width: 48px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Progress ring (SVG) ────────────────────────────────────── */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--bg-2);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Activity feed ──────────────────────────────────────────── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid rgba(37, 40, 74, 0.3);
  align-items: flex-start;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-0);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.activity-desc {
  font-size: var(--text-sm);
  color: var(--text-1);
  margin-top: 2px;
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-2);
  font-family: var(--font-mono);
  margin-top: var(--space-1);
}

/* ── Token price row ────────────────────────────────────────── */
.price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid rgba(37, 40, 74, 0.3);
}

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

.price-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-symbol {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-0);
}

.price-exchange {
  font-size: var(--text-xs);
  color: var(--text-2);
}

.price-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-0);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.price-change {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: right;
}

.price-change.up { color: var(--accent-green); }
.price-change.down { color: var(--accent-red); }

/* ── Navigation tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--bg-3);
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-1);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color var(--ease-smooth);
  font-family: var(--font-sans);
}

.tab:hover { color: var(--text-0); }

.tab.active {
  color: var(--text-0);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-blue);
  border-radius: var(--radius-pill);
}

.tab-badge {
  margin-left: var(--space-2);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  color: var(--text-1);
}

/* ── Tooltip (custom) ───────────────────────────────────────── */
.chart-tooltip {
  position: absolute;
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-0);
  box-shadow: var(--shadow-card-lg);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 150ms ease;
  min-width: 140px;
}

.chart-tooltip.visible { opacity: 1; }

.chart-tooltip-label {
  color: var(--text-2);
  font-size: var(--text-xs);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chart-tooltip-value {
  font-size: var(--text-md);
  font-weight: 600;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  gap: var(--space-4);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 28px;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-0);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-1);
  max-width: 360px;
}

/* ── Responsive dashboard ───────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-sidebar { grid-template-columns: 1fr; }
  .dashboard-grid-flex { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  .dashboard-grid-4,
  .dashboard-grid-3,
  .dashboard-grid-2,
  .dashboard-grid-flex { grid-template-columns: 1fr; }

  .stat-card-value { font-size: var(--text-2xl); }
  .chart-container { height: 220px; }
  .chart-container.xl { height: 280px; }
}
