/* ===================================================
   Green Button Energy Viewer — styles.css
   =================================================== */

:root {
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1a202c;
  --muted:     #718096;
  --accent:    #3b82f6;
  --accent-dk: #2563eb;
  --peak:      #ef4444;
  --mid:       #f59e0b;
  --off:       #22c55e;
  --success:   #22c55e;
  --error:     #ef4444;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: flex; }

/* ===================================================
   UPLOAD SCREEN
   =================================================== */
#upload-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.upload-hero {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.upload-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  margin-bottom: 0.5rem;
}

.upload-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.upload-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.upload-link-row { font-size: 0.9rem; color: var(--muted); }

/* Drop zone */
.drop-zone {
  width: 100%;
  margin-top: 0.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}
.drop-zone:hover,
.drop-zone:focus-visible { border-color: var(--accent); }
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-icon { color: var(--muted); }
.drop-primary { font-weight: 500; color: var(--text); }
.drop-or { font-size: 0.85rem; color: var(--muted); }
.drop-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

/* Buttons */
.btn-primary {
  display: inline-block;
  padding: 0.55rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dk); text-decoration: none; }

.btn-secondary {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: #eff6ff; }

.btn-ghost {
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* Divider with text */
.upload-divider {
  width: 100%;
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0.5rem;
}
.upload-divider::before, .upload-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.upload-divider span { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.upload-hint { font-size: 0.8rem; color: var(--muted); }

/* Error banner */
.error-banner {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.9rem;
  text-align: left;
}
.hidden { display: none !important; }

/* ===================================================
   APP SCREEN
   =================================================== */
#app-screen {
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  gap: 1rem;
}

.app-header-left {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--accent);
}
.app-title {
  font-weight: 600; font-size: 1rem; color: var(--text);
  white-space: nowrap;
}

.app-header-right {
  display: flex; align-items: center; gap: 0.75rem;
  flex-shrink: 0;
}
.header-date-range { font-size: 0.8rem; color: var(--muted); }

/* ── Tab nav ── */
.tab-nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tab panels ── */
.tab-content {
  flex: 1;
  overflow-y: auto;
}

.tab-panel { display: none; padding: 1.5rem; }
.tab-panel.active { display: block; }

/* ===================================================
   KPI CARDS
   =================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-grid--tou {
  grid-template-columns: repeat(3, 1fr);
}

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

.kpi-card--peak   { border-left: 4px solid var(--peak); }
.kpi-card--mid    { border-left: 4px solid var(--mid); }
.kpi-card--off    { border-left: 4px solid var(--off); }

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

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

.kpi-value--sm { font-size: 1rem; }

.kpi-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ===================================================
   CHARTS
   =================================================== */
.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.chart-card--wide  { /* used in grid context */ }
.chart-card--full  { width: 100%; }

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap--tall {
  height: 320px;
}

/* ===================================================
   CONTROLS BAR
   =================================================== */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.control-select {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.control-select:focus { border-color: var(--accent); }

/* ===================================================
   HEATMAP
   =================================================== */
.heatmap-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
}

#chart-hourly-heatmap {
  display: block;
  cursor: crosshair;
}

.heatmap-tooltip {
  position: fixed;
  background: rgba(26, 32, 44, 0.9);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  line-height: 1.5;
}

/* ===================================================
   TABLE
   =================================================== */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--border);
  border-bottom: none;
  background: var(--bg);
}

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 900px) {
  .chart-row { grid-template-columns: 1fr; }
  .chart-card--wide { grid-column: auto; }
}

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid--tou { grid-template-columns: 1fr; }
  .tab-panel { padding: 1rem; }
  .app-header { padding: 0.6rem 1rem; }
  .header-date-range { display: none; }
  .chart-wrap { height: 220px; }
  .chart-wrap--tall { height: 260px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .upload-hero h1 { font-size: 1.4rem; }
  .kpi-value { font-size: 1.3rem; }
  .tab-btn { padding: 0.65rem 0.9rem; font-size: 0.82rem; }
}
