/* ============================================================
   Solar Parks Dashboard — Dark Theme
   ============================================================ */

:root {
  --bg:         #0b0f19;
  --surface:    #131a2b;
  --surface2:   #1a2338;
  --border:     #1e2d45;
  --text:       #e2e8f0;
  --text-dim:   #8494a7;
  --text-muted: #4a5568;
  --park1:      #3b82f6;
  --park1-glow: rgba(59, 130, 246, 0.15);
  --park2:      #10b981;
  --park2-glow: rgba(16, 185, 129, 0.15);
  --park3:      #f59e0b;
  --park3-glow: rgba(245, 158, 11, 0.15);
  --radius:     12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Header ------------------------------------------------- */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sun-icon {
  font-size: 1.6rem;
  color: #fbbf24;
  margin-right: 4px;
}

.brand {
  color: #94a3b8;
  font-weight: 600;
}

.brand-sep {
  color: #3b82f6;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-update {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1.3rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-refresh:hover {
  background: var(--border);
  color: var(--text);
}

.btn-refresh.spinning {
  animation: spin 0.8s linear infinite;
}

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

/* --- Main --------------------------------------------------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* --- Totals strip ------------------------------------------- */

.totals-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.total-item {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}

.total-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.total-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.total-unit {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Park cards --------------------------------------------- */

.park-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.park-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.park-card:hover {
  transform: translateY(-2px);
}

.park-card.park1 { border-top: 3px solid var(--park1); }
.park-card.park1:hover { box-shadow: 0 8px 32px var(--park1-glow); }
.park-card.park2 { border-top: 3px solid var(--park2); }
.park-card.park2:hover { box-shadow: 0 8px 32px var(--park2-glow); }
.park-card.park3 { border-top: 3px solid var(--park3); }
.park-card.park3:hover { box-shadow: 0 8px 32px var(--park3-glow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.capacity-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.stat {
  flex: 1;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Power bar */
.card-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}

.power-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 1s ease-out;
}

.park1 .power-bar { background: var(--park1); }
.park2 .power-bar { background: var(--park2); }
.park3 .power-bar { background: var(--park3); }

/* Sparkline */
.card-chart {
  height: 80px;
  margin-bottom: 10px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.total-energy { font-weight: 500; }

/* --- Main chart --------------------------------------------- */

.main-chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.main-chart-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.main-chart {
  height: 340px;
}

/* --- Header nav --------------------------------------------- */

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface2);
}

.nav-link.active {
  color: var(--text);
  background: var(--surface2);
}

/* --- Explorer ----------------------------------------------- */

.explorer-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 24px;
}

/* Control bar */
.control-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Breadcrumb */
.scope-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

.crumb {
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}

.crumb:hover {
  color: var(--text);
  background: var(--surface2);
}

.crumb.active {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.crumb-sep {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Mode label */
.mode-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

/* View toggle group — centered, visually distinct from selectors */
.view-toggles {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 auto;
  border: 1px dashed var(--text-muted);
  border-radius: 6px;
  overflow: hidden;
}

.view-toggles .toggle-btn {
  border: none;
  border-radius: 0;
}

.view-toggles .toggle-btn + .toggle-btn {
  border-left: 1px dashed var(--text-muted);
}

.view-toggles .toggle-btn.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: transparent;
}

.view-toggles .toggle-btn.active + .toggle-btn {
  border-left-color: transparent;
}

/* Toggle buttons */
.control-toggles {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.toggle-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.toggle-btn.disabled,
.toggle-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.date-input:disabled,
.ctrl-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Time presets */
.time-presets {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px;
}

.preset-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  color: var(--text);
}

.preset-btn.active {
  background: var(--border);
  color: var(--text);
  font-weight: 600;
}

/* Date inputs */
.date-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 6px;
  width: 130px;
}

.date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
}

.date-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Selects */
.control-selects {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.ctrl-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 100px;
}

.ctrl-select option {
  background: var(--surface);
  color: var(--text);
}

/* Coverage bar */
.coverage-section {
  margin-bottom: 8px;
}

.coverage-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

/* Explorer chart */
.explorer-chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
}

.explorer-chart {
  height: 60vh;
  min-height: 360px;
}

/* Context panel */
.context-panel {
  display: flex;
  gap: 12px;
}

.ctx-item {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
}

.ctx-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.ctx-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Loading indicator */
.loading-indicator {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* --- Responsive --------------------------------------------- */

@media (max-width: 768px) {
  main { padding: 12px; }

  .totals-strip { gap: 8px; }
  .total-item { padding: 12px; }
  .total-value { font-size: 1.3rem; }

  .park-cards { grid-template-columns: 1fr; gap: 12px; }

  .main-chart { height: 260px; }

  /* Explorer responsive */
  .explorer-main { padding: 8px 12px; }

  .control-row { gap: 8px; }

  .time-presets { flex-wrap: wrap; }

  .date-inputs { width: 100%; }
  .date-input { flex: 1; }

  .control-selects {
    margin-left: 0;
    width: 100%;
  }
  .ctrl-select { flex: 1; }

  .explorer-chart {
    height: 50vh;
    min-height: 280px;
  }

  .context-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}
