/* Synthesse — Sistem Monitorizare Calitate Aer Constanta */

/* ============================================================
   1. Variabile si reset
   ============================================================ */
:root {
  --bg:           #0f1117;
  --bg-surface:   #1a1d27;
  --bg-card:      #20243a;
  --border:       #2d3148;
  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --navbar-h:     52px;

  /* Niveluri EU calitate aer */
  --eu-1: #22c55e;  /* Bun       */
  --eu-2: #84cc16;  /* Acceptabil */
  --eu-3: #f59e0b;  /* Moderat   */
  --eu-4: #f97316;  /* Slab      */
  --eu-5: #ef4444;  /* Foarte slab */
}

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

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

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

/* ============================================================
   2. Navbar
   ============================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 1000;
}

.navbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon   { color: var(--primary); font-size: 18px; }
.brand-text   { font-weight: 700; font-size: 16px; }
.brand-sub    { color: var(--text-muted); font-size: 12px; }

.navbar-links { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-link     { color: var(--text-muted); font-size: 13px; transition: color .15s; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link-dashboard { color: var(--primary); }

.nav-btn-logout {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 12px; border-radius: 6px;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.nav-btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ============================================================
   3. Layout principal
   ============================================================ */
.main-content {
  position: fixed;
  top: var(--navbar-h); left: 0; right: 0; bottom: 0;
  overflow-y: auto;
}

/* ============================================================
   4. Harta Leaflet
   ============================================================ */
#map { width: 100%; height: 100%; }

/* ============================================================
   5. Panouri harta
   ============================================================ */
.map-panel {
  position: absolute;
  top: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  z-index: 500;
  min-width: 180px;
  max-width: 240px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
}

.map-panel-left  { left: 16px; }
.map-panel-right { right: 16px; max-width: 260px; }

.panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.panel-close {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 2px 6px;
}
.panel-close:hover { color: var(--text); }

.panel-footer {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Dropdown poluant */
.pollutant-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.pollutant-select:focus { border-color: var(--primary); }

/* Legenda harta */
.legend { display: flex; flex-direction: column; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot  { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* Panou statie */
.station-name    { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.station-type    { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.station-readings { display: flex; flex-direction: column; gap: 6px; }
.station-reading { display: flex; justify-content: space-between; font-size: 13px; }
.station-reading-val { font-weight: 600; }
.station-age     { margin-top: 10px; font-size: 11px; color: var(--text-muted); }

/* Markeri colorati */
.marker-eu-1 { background: var(--eu-1); }
.marker-eu-2 { background: var(--eu-2); }
.marker-eu-3 { background: var(--eu-3); }
.marker-eu-4 { background: var(--eu-4); }
.marker-eu-5 { background: var(--eu-5); }
.marker-eu-0 { background: var(--text-muted); }

/* Banner stare sistem */
.system-status {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-label { color: var(--text-muted); }
.status-label strong { color: var(--text); }

.status-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  padding-left: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ok         { background: var(--success); }
.status-degradat   { background: var(--warning); }
.status-critic     { background: var(--danger); }
.status-necunoscut { background: var(--text-muted); }

/* Panou filtrare retele (admin only) */
.nf-row {
  margin-bottom: 3px;
}

.nf-all-row {
  margin-bottom: 0;
}

.nf-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
}

.nf-label input[type=checkbox] {
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.nf-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nf-badge {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Buton fullscreen Leaflet */
.leaflet-fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  transition: background .15s, color .15s;
}
.leaflet-fullscreen-btn:hover {
  background: var(--bg-card);
  color: var(--primary);
}

/* ============================================================
   6. Formulare auth
   ============================================================ */
.auth-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.auth-logo  { font-size: 32px; text-align: center; margin-bottom: 8px; color: var(--primary); }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-links { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
               text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.form-input  {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus  { border-color: var(--primary); }
.form-input::placeholder { color: var(--text-muted); }

/* ============================================================
   7. Butoane
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 7px; padding: 9px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-full    { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-sm  { padding: 5px 12px; font-size: 12px; border-radius: 5px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; border-radius: 4px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }

/* ============================================================
   8. Alerte
   ============================================================ */
.alert {
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error   { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }

/* ============================================================
   9. Dashboard layout
   ============================================================ */
.dashboard-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.dashboard-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.sidebar-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.sidebar-btn {
  background: none; border: none;
  color: var(--text-muted); padding: 9px 12px;
  border-radius: 6px; font-size: 13px;
  cursor: pointer; text-align: left;
  transition: all .15s;
}
.sidebar-btn:hover  { background: var(--bg-card); color: var(--text); }
.sidebar-btn.active { background: rgba(59,130,246,.15); color: var(--primary); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.dashboard-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 18px; font-weight: 600; }

.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.form-select-sm {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 5px 10px;
  font-size: 12px; cursor: pointer; outline: none;
}
.form-select-sm:focus { border-color: var(--primary); }
.form-input-sm {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 5px 10px;
  font-size: 12px; outline: none;
}
.form-input-sm:focus { border-color: var(--primary); }

.form-select-xs {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); padding: 2px 6px;
  font-size: 11px; cursor: pointer; outline: none;
}

/* ============================================================
   10. Tabele
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-surface); }
.table-empty { text-align: center; color: var(--text-muted); padding: 24px !important; }
.actions-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.poluanti-cell { font-size: 11px; color: var(--text-muted); max-width: 200px; }

/* ============================================================
   11. Badge-uri
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.badge-role         { background: rgba(59,130,246,.2);  color: #93c5fd; }
.badge-source       { background: rgba(168,85,247,.2);  color: #d8b4fe; }
.badge-status-activ    { background: rgba(34,197,94,.2);  color: #86efac; }
.badge-status-pending  { background: rgba(245,158,11,.2); color: #fcd34d; }
.badge-status-respins  { background: rgba(239,68,68,.2);  color: #fca5a5; }
.badge-status-suspendat{ background: rgba(100,116,139,.2);color: #94a3b8; }

/* ============================================================
   12. Grafice dashboard tech
   ============================================================ */
.chart-container {
  position: relative;
  height: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.chart-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}
.measurements-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   13. Banner incertitudine
   ============================================================ */
.uncertainty-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  color: #fcd34d;
}
.uncertainty-icon { font-size: 16px; flex-shrink: 0; }

/* ============================================================
   14. Banner alerta depasire prag (panoul statiei)
   ============================================================ */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  margin-top: 10px;
  line-height: 1.4;
}

/* Depasire limita EU alert -- rosu */
.alert-banner--eu {
  background: rgba(239, 68, 68, .15);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5;
}
.alert-banner--eu .alert-banner__icon { color: #ef4444; }

/* Depasire limita personala (mai stricta decat EU) -- amber */
.alert-banner--personal {
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .35);
  color: #fcd34d;
}
.alert-banner--personal .alert-banner__icon { color: #f59e0b; }

.alert-banner__icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ============================================================
   15. Modal profil utilizator (praguri personale)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  position: relative;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Tabel praguri din modal */
.modal-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.modal-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.modal-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.modal-table tr:last-child td { border-bottom: none; }

.modal-prag-input {
  width: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.modal-prag-input:focus { border-color: var(--primary); }
.modal-prag-input::-webkit-inner-spin-button { opacity: .5; }

.modal-prag-eu {
  font-size: 11px;
  color: var(--text-muted);
}

.modal-warning {
  font-size: 11px;
  color: #f59e0b;
  font-style: italic;
  margin-top: 3px;
  display: block;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.modal-erori {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #fca5a5;
  margin-bottom: 14px;
}

.modal-erori ul {
  margin: 4px 0 0 16px;
}

/* ============================================================
   16. Probleme consolidate / Interventii
   ============================================================ */

/* Variabila text-secondary (alias mai cald decat text-muted) */
:root { --text-secondary: #94a3b8; }

/* Badge severitate */
.sev-critic,
.sev-warning,
.sev-info {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.sev-critic  { background: rgba(239,68,68,0.12);  color: #ef4444; border: 1px solid rgba(239,68,68,0.35); }
.sev-warning { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.35); }
.sev-info    { background: rgba(59,130,246,0.12); color: #3b82f6; border: 1px solid rgba(59,130,246,0.35); }

/* Evidentierea randurilor critice in tabel */
.data-table .row-critic td { background: rgba(239,68,68,0.04); }
.data-table .row-critic:hover td { background: rgba(239,68,68,0.08); }

/* Bara notificari alti useri */
.notif-bar {
  padding: 8px 14px;
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* Badge numeric in sidebar (probleme critice) */
.sidebar-count {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 2px;
}
