/* ═════════════════════════════════════════════════════════════
   CAL FIRE Tulare Unit — FDOP Dashboard
   Shared styles for dashboard, login, and admin
   ═════════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #0d1117;
  --bg-card:   #161b22;
  --bg-header: #1a1a2e;
  --bg-section: #1e2a32;
  --text:      #e8eaed;
  --text-dim:  #90a4ae;
  --text-muted: #546e7a;
  --text-faint: #444d56;
  --green:     #1b5e20;
  --gold:      #f9a825;
  --red:       #b71c1c;
  --red-dark:  #7f0000;
  --border:    #21262d;
  --link:      #58a6ff;
  --shadow:    0 2px 8px rgba(0,0,0,0.4);
}

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

body { padding: 16px; }

/* ─── Dashboard ─────────────────────────────────────────────── */

.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-header {
  background: var(--bg-header);
  color: #fff;
  padding: 14px 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-radius: 4px;
}

.dash-header .title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.dash-header .subtitle {
  font-size: 14px;
  color: #cfd8dc;
  font-weight: normal;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* ─── Index card (DISPATCH / IC / SC / BI) ──────────────────── */

.index-card {
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.index-card .label {
  background: rgba(0,0,0,0.3);
  padding: 8px 4px;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.8px;
}

.index-card .value {
  padding: 18px 4px;
  font-size: 56px;
  font-weight: bold;
  text-align: center;
  line-height: 1;
}

.index-card.dispatch .value {
  font-size: 36px;
  letter-spacing: 1px;
}

.index-card .delta {
  padding: 5px 4px;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  background: rgba(0,0,0,0.3);
}

.index-card .delta.worsening { background: var(--red-dark); color: #fff; }
.index-card .delta.improving { background: var(--green); color: #fff; }
.index-card .delta.placeholder { background: rgba(0,0,0,0.3); color: transparent; }

.index-card .pct-label {
  background: rgba(0,0,0,0.4);
  padding: 6px 4px;
  font-size: 10px;
  text-align: center;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.85);
}

.index-card .pct-value {
  background: rgba(0,0,0,0.4);
  padding: 8px 4px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  color: #fff;
}

/* ─── Weather section ───────────────────────────────────────── */

.weather-section-header {
  background: var(--bg-section);
  padding: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--text-dim);
  letter-spacing: 0.8px;
  border-radius: 4px;
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.weather-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.weather-card .station-name {
  padding: 10px 4px;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  color: #fff;
  letter-spacing: 0.5px;
}

.weather-card .obs-time {
  padding: 6px 4px;
  font-size: 11px;
  text-align: center;
  color: #aaaaaa;
  background: rgba(0,0,0,0.4);
}

.weather-card .metric {
  display: flex;
  flex-direction: column;
}

.weather-card .metric-label {
  background: var(--bg-card);
  padding: 6px 4px;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.weather-card .metric-value {
  padding: 12px 4px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  color: var(--text);
}

.weather-card .metric-delta {
  padding: 5px 4px;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  background: var(--bg-card);
}

.weather-card .metric-delta.worsening { background: var(--red-dark); color: #fff; }
.weather-card .metric-delta.improving { background: var(--green); color: #fff; }

.dash-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  padding: 10px;
}

.dash-footer .footer-disclaimer {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.tv-mode .dash-footer .footer-disclaimer {
  font-size: 0.75vw;
  margin-top: 0.3vh;
}

/* ─── Mobile (≤ 720px): stack into 2 columns ────────────────── */
@media (max-width: 720px) {
  body { padding: 8px; }
  .dash-grid, .weather-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .index-card .value { font-size: 38px; padding: 10px 4px; }
  .index-card.dispatch .value { font-size: 24px; }
  .index-card .pct-value { font-size: 16px; }
  .weather-card .metric-value { font-size: 18px; padding: 8px 4px; }
  .dash-header { flex-direction: column; align-items: flex-start; padding: 10px; }
  .dash-header .title { font-size: 13px; }
  .dash-header .subtitle { font-size: 12px; }
}

/* ─── TV mode: auto-scale to fit any screen ─────────────────
   Uses viewport units so the dashboard fills the screen exactly,
   regardless of resolution. No scrolling, no zoom needed.
   Press F11 in browser for true fullscreen. */

.tv-mode {
  overflow: hidden;
}

.tv-mode body,
body.tv-mode {
  padding: 0;
  margin: 0;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.tv-mode .dashboard {
  max-width: 100%;
  width: 100vw;
  height: 100vh;
  padding: 0.8vw;
  gap: 0.6vh;
  display: flex;
  flex-direction: column;
}

/* Header — small fixed-ish row at top */
.tv-mode .dash-header {
  padding: 1vh 1.5vw;
  flex: 0 0 auto;
}
.tv-mode .dash-header .title    { font-size: 1.6vw; }
.tv-mode .dash-header .subtitle { font-size: 1.3vw; }

/* Indices grid — takes ~40% of vertical space */
.tv-mode .dash-grid {
  flex: 1 1 40%;
  gap: 0.6vw;
}
.tv-mode .index-card {
  display: flex;
  flex-direction: column;
}
.tv-mode .index-card .label {
  font-size: 1.2vw;
  padding: 0.8vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .index-card .value {
  font-size: 7vw;
  padding: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tv-mode .index-card.dispatch .value {
  font-size: 4vw;
}
.tv-mode .index-card .delta {
  font-size: 1.3vw;
  padding: 0.4vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .index-card .pct-label {
  font-size: 1vw;
  padding: 0.5vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .index-card .pct-value {
  font-size: 2.6vw;
  padding: 0.6vh 0.2vw;
  flex: 0 0 auto;
}

/* Weather section header — slim */
.tv-mode .weather-section-header {
  font-size: 1.3vw;
  padding: 0.8vh 1vw;
  flex: 0 0 auto;
}

/* Weather grid — takes remaining vertical space */
.tv-mode .weather-grid {
  flex: 1 1 50%;
  gap: 0.6vw;
}
.tv-mode .weather-card {
  display: flex;
  flex-direction: column;
}
.tv-mode .weather-card .station-name {
  font-size: 1.4vw;
  padding: 0.8vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .weather-card .obs-time {
  font-size: 1vw;
  padding: 0.4vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .weather-card .metric-label {
  font-size: 0.9vw;
  padding: 0.3vh 0.2vw;
  flex: 0 0 auto;
}
.tv-mode .weather-card .metric-value {
  font-size: 2.4vw;
  padding: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tv-mode .weather-card .metric-delta {
  font-size: 1.1vw;
  padding: 0.3vh 0.2vw;
  flex: 0 0 auto;
}

/* Footer — slim row at bottom */
.tv-mode .dash-footer {
  font-size: 0.9vw;
  padding: 0.6vh 1vw;
  flex: 0 0 auto;
}

/* ─── Login & forms ─────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 32px 28px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
}

.auth-box h1 {
  font-size: 20px;
  margin-bottom: 6px;
  text-align: center;
}

.auth-box .subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  font-weight: bold;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--link);
}

button.primary {
  background: var(--link);
  color: #000;
  border: none;
  padding: 11px 20px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}

button.primary:hover { background: #79b8ff; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
button.secondary:hover { border-color: var(--text-dim); }

button.danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.error-msg {
  background: rgba(183, 28, 28, 0.15);
  border: 1px solid var(--red);
  color: #ff8a80;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
}

.success-msg {
  background: rgba(27, 94, 32, 0.15);
  border: 1px solid var(--green);
  color: #a5d6a7;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── Admin layout ──────────────────────────────────────────── */

.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
}

.admin-nav {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.admin-nav button {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.5px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.admin-nav button.active {
  color: var(--link);
  border-bottom-color: var(--link);
}
.admin-nav button:hover { color: var(--text); }

.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 16px;
}

.admin-section h2 {
  font-size: 16px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.admin-section .section-help {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
  line-height: 1.5;
}

.admin-section .row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-section .row > .field { flex: 1; min-width: 200px; margin-bottom: 0; }

.admin-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  color: var(--text-muted);
  font-weight: bold;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table td input, .admin-table td select {
  padding: 6px 8px;
  font-size: 13px;
  background: #0d1117;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 3px;
  width: 100%;
}
.admin-table td.color-cell { width: 60px; }
.color-swatch {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 6px;
}

.user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.user-bar a { color: var(--link); text-decoration: none; }
.user-bar a:hover { text-decoration: underline; }

/* refresh log table */
.log-table {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}
.log-table .status-success { color: #a5d6a7; }
.log-table .status-error   { color: #ef9a9a; }

.kbd {
  font-family: ui-monospace, monospace;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .admin-section { padding: 16px; }
  .admin-section .row { flex-direction: column; gap: 0; }
  .admin-section .row > .field { margin-bottom: 14px; }
}
