/* Fuel Supply Intelligence Dashboard – Terminal Style */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;
  --border: #2a3a50;
  --border-focus: #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #22d3ee;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --status-normal: #10b981;
  --status-tight: #f59e0b;
  --status-disruption: #f97316;
  --status-elevated: #ef4444;
  --status-severe: #dc2626;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logo {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: -0.5px;
}

.topbar-logo span { color: var(--text-muted); font-weight: 400; }

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

.topbar-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.topbar-nav a:hover, .topbar-nav a.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

.topbar-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 8px; height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ── Alert banner ── */
.alert-banner {
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.alert-banner.info { background: rgba(59,130,246,0.1); color: var(--accent-blue); border-color: rgba(59,130,246,0.2); }
.alert-banner.warning { background: rgba(245,158,11,0.1); color: var(--accent-yellow); border-color: rgba(245,158,11,0.2); }
.alert-banner.critical { background: rgba(239,68,68,0.1); color: var(--accent-red); border-color: rgba(239,68,68,0.2); }

.alert-banner-icon { font-size: 16px; }

/* ── Layout ── */
.dashboard {
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

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

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

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.card-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.card-body { padding: 16px; }
.card-body.compact { padding: 12px; }

/* ── Status indicator ── */
.status-banner {
  padding: 20px 24px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.status-banner .status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.status-banner .status-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 2px;
}

.status-banner .status-info p {
  font-size: 13px;
  opacity: 0.8;
}

.status-normal { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); }
.status-normal .status-icon { background: rgba(16,185,129,0.2); color: var(--status-normal); }
.status-normal h2 { color: var(--status-normal); }

.status-tight { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); }
.status-tight .status-icon { background: rgba(245,158,11,0.2); color: var(--status-tight); }
.status-tight h2 { color: var(--status-tight); }

.status-disruption { background: rgba(249,115,22,0.1); border: 1px solid rgba(249,115,22,0.3); }
.status-disruption .status-icon { background: rgba(249,115,22,0.2); color: var(--status-disruption); }
.status-disruption h2 { color: var(--status-disruption); }

.status-elevated { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); }
.status-elevated .status-icon { background: rgba(239,68,68,0.2); color: var(--status-elevated); }
.status-elevated h2 { color: var(--status-elevated); }

.status-severe { background: rgba(220,38,38,0.15); border: 1px solid rgba(220,38,38,0.4); }
.status-severe .status-icon { background: rgba(220,38,38,0.2); color: var(--status-severe); }
.status-severe h2 { color: var(--status-severe); }

/* ── Stat boxes ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}

.stat-box .stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.stat-box .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.stat-box .stat-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(42,58,80,0.5);
  color: var(--text-secondary);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

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

/* ── Badges/Pills ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-green { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--accent-orange); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.badge-purple { background: rgba(168,85,247,0.15); color: var(--accent-purple); }
.badge-gray { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.badge-cyan { background: rgba(34,211,238,0.15); color: var(--accent-cyan); }

/* ── News feed ── */
.news-feed { max-height: 500px; overflow-y: auto; }

.news-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42,58,80,0.4);
  transition: background 0.15s;
}

.news-item:hover { background: var(--bg-card-hover); }
.news-item.pinned { border-left: 3px solid var(--accent-yellow); }

.news-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.news-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.news-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}

.news-item-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Map container ── */
#incident-map {
  width: 100%;
  height: 450px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-textarea { min-height: 80px; resize: vertical; }

.form-input::placeholder { color: var(--text-muted); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  accent-color: var(--accent-blue);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.btn:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }

.btn-primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.btn-primary:hover { background: #2563eb; }

.btn-success {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.btn-success:hover { background: #059669; }

.btn-danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--accent-yellow);
  border-color: var(--accent-yellow);
  color: #000;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; }

/* ── Confidence meter ── */
.confidence-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.confidence-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.confidence-low { background: var(--accent-red); }
.confidence-moderate { background: var(--accent-yellow); }
.confidence-strong { background: var(--accent-blue); }
.confidence-verified { background: var(--accent-green); }

/* ── Report cards (incident map popups etc) ── */
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}

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

.report-type {
  font-weight: 600;
  font-size: 13px;
}

.report-type.out { color: var(--accent-red); }
.report-type.queue { color: var(--accent-orange); }
.report-type.open { color: var(--accent-green); }
.report-type.pricing { color: var(--accent-yellow); }

/* ── Tab navigation ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-sans);
}

.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }

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

/* ── Loading state ── */
.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

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

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 32px; margin-bottom: 8px; }
.empty-state-text { font-size: 13px; }

/* ── Source attribution ── */
.source-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.source-tag a {
  color: var(--accent-blue);
  text-decoration: none;
}

.source-tag a:hover { text-decoration: underline; }

.timestamp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 32px;
}

.footer a { color: var(--accent-blue); text-decoration: none; }

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

@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 8px; padding: 12px 16px; }
  .topbar-nav { flex-wrap: wrap; }
  .dashboard { padding: 12px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  #incident-map { height: 300px; }
}

/* ── Leaflet map popup overrides ── */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4) !important;
}

.leaflet-popup-tip { background: var(--bg-card) !important; }

.leaflet-popup-content {
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
  color: var(--text-secondary) !important;
}

.leaflet-popup-content strong { color: var(--text-primary); }

/* ── Admin specific ── */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 56px);
}

.admin-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px 0;
}

.admin-sidebar a {
  display: block;
  padding: 10px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.admin-sidebar a:hover, .admin-sidebar a.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-left: 3px solid var(--accent-cyan);
}

.admin-main { padding: 24px; }

.admin-page-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    display: flex;
    overflow-x: auto;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-sidebar a { white-space: nowrap; padding: 12px 16px; }
}

/* ── Report form (mobile-first) ── */
.report-form-container {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px;
}

.report-form-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.report-form-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.report-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.report-type-btn {
  padding: 14px 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
  font-size: 13px;
}

.report-type-btn:hover { border-color: var(--text-muted); }
.report-type-btn.selected { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(59,130,246,0.1); }

.report-type-btn .icon { font-size: 20px; display: block; margin-bottom: 4px; }

.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}

.photo-upload-area:hover { border-color: var(--text-muted); }
.photo-upload-area.dragover { border-color: var(--accent-blue); background: rgba(59,130,246,0.05); }

.photo-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.photo-preview img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ── Success message ── */
.success-message {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--accent-green);
}

.success-message h3 { font-size: 16px; margin-bottom: 4px; }
.success-message p { font-size: 13px; opacity: 0.8; }
