/* ===== Critical Minerals Dashboard — Light Theme ===== */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f7fa;
  --bg-card: #ffffff;
  --text-primary: #333;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #e0e0e0;
  --accent: #1f77b4;
  --accent-light: #d4e6f1;
  --accent-dark: #154c79;
  --positive: #2ca02c;
  --negative: #d62728;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 10px;
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

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

.header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header h1 span {
  color: var(--accent);
}

.header-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Filters Bar ===== */
.filters {
  max-width: 1400px;
  margin: 1.25rem auto 0;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input[type="range"] {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 160px;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.year-display {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 80px;
}

/* ===== KPI Cards Row ===== */
.kpi-row {
  max-width: 1400px;
  margin: 1.25rem auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-hover);
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-change {
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: 0.15rem;
}

.kpi-change.positive { color: var(--positive); }
.kpi-change.negative { color: var(--negative); }

/* ===== Dashboard Grid ===== */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: box-shadow 0.2s;
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel.full-width {
  grid-column: 1 / -1;
}

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

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.panel-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.panel-controls select {
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.chart-container {
  width: 100%;
  min-height: 340px;
}

/* ===== Section Divider ===== */
.section-divider {
  max-width: 1400px;
  margin: 2rem auto 1.25rem;
  padding: 0 2rem;
  border-top: 2px solid var(--border);
  padding-top: 1.5rem;
}

.section-header {
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ===== Tabs (for future datasets) ===== */
.tab-bar {
  max-width: 1400px;
  margin: 1.25rem auto 0;
  padding: 0 2rem;
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}

.tab {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ===== Tab Content ===== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Loading ===== */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.75rem;
}

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

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .header { padding: 0.75rem 1rem; }
  .filters, .kpi-row, .dashboard, .tab-bar { padding: 0 1rem; }
  .kpi-row { grid-template-columns: 1fr; }
}
