/* ============================================================
   Mobile Coverage Mapper — design technique sombre
   ============================================================ */

:root {
  --bg:        #0f1419;
  --bg-elev:   #1a2028;
  --bg-elev2:  #232b35;
  --border:    #2d3641;
  --border-hi: #3f4a57;
  --fg:        #e6edf3;
  --fg-dim:    #8b96a3;
  --fg-mute:   #5c6773;
  --accent:    #4ade80;      /* vert signal */
  --accent-hi: #86efac;
  --warn:      #fbbf24;
  --danger:    #f87171;
  --link-good: #22c55e;
  --link-mid:  #facc15;
  --link-low:  #fb923c;
  --link-bad:  #ef4444;
  --shadow:    0 4px 12px rgba(0,0,0,.5);

  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ------------------ Layout ------------------ */

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
}

.app--public {
  grid-template-columns: 1fr;
  grid-template-rows: 56px 1fr;
}

header.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 14px;
  text-transform: uppercase;
}

.brand .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  box-shadow: 0 0 10px var(--accent);
  vertical-align: middle;
}

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

.topbar nav a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg-dim);
}

.topbar nav a:hover {
  background: var(--bg-elev2);
  color: var(--fg);
}

.topbar nav a.active {
  background: var(--bg-elev2);
  color: var(--accent);
}

/* ------------------ Sidebar admin ------------------ */

aside.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h2 {
  margin: 0 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  font-weight: 600;
}

.search-box {
  display: flex;
  gap: 6px;
}

input, select, textarea {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

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

input[type="color"] {
  padding: 2px;
  width: 44px;
  height: 32px;
  cursor: pointer;
}

label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-mute);
  margin-bottom: 4px;
}

.field {
  margin-bottom: 12px;
}

.field-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

.field-row .field { margin-bottom: 0; }

/* ------------------ Boutons ------------------ */

button {
  background: var(--bg-elev2);
  color: var(--fg);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

button:hover { background: var(--border); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  color: #0a0e12;
  border-color: var(--accent);
}
button.primary:hover { background: var(--accent-hi); }

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
button.danger:hover { background: rgba(248,113,113,.1); }

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-dim);
}
button.ghost:hover { color: var(--fg); }

button.icon {
  padding: 6px 8px;
  font-size: 12px;
}

/* ------------------ Carte ------------------ */

.map-wrap {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: #1a1f26;
}

/* Tuiles OSM légèrement assombries pour matcher la palette dark */
.leaflet-tile-pane {
  filter: brightness(0.85) saturate(0.85) hue-rotate(180deg) invert(0.92);
}

/* Légende */
.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 12px;
  z-index: 500;
  min-width: 180px;
}

.legend h3 {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  font-weight: 600;
}

.legend .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.legend .swatch {
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

/* ------------------ Modal ------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ------------------ Liste de cellules ------------------ */

.cell-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cell-list li {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  font-size: 13px;
}

.cell-list li:last-child { border-bottom: none; }

.cell-list .cid {
  font-family: var(--font-mono);
  font-weight: 500;
}

.cell-list .meta {
  color: var(--fg-mute);
  font-size: 11px;
  margin-left: auto;
}

.cell-list .badge-pos {
  background: var(--accent);
  color: #0a0e12;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}

.cell-list .badge-nopos {
  background: var(--warn);
  color: #0a0e12;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ------------------ Mode banner ------------------ */

.mode-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warn);
  color: #0a0e12;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 500;
  box-shadow: var(--shadow);
}

/* ------------------ Popup Leaflet ------------------ */

.leaflet-popup-content-wrapper {
  background: var(--bg-elev);
  color: var(--fg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.leaflet-popup-tip { background: var(--bg-elev); }

.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 12px;
  line-height: 1.6;
}

.leaflet-popup-content h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--accent);
}

.popup-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.popup-grid dt { color: var(--fg-mute); }
.popup-grid dd { margin: 0; }

.popup-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.popup-actions button {
  font-size: 11px;
  padding: 4px 10px;
}

/* ------------------ Popup site multi-mesures ------------------ */

.meas-list {
  margin: 6px 0 8px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0,0,0,.15);
}

.meas-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.meas-item:last-child { border-bottom: none; }

.meas-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.meas-pos {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  color: #0a0e12;
}

.meas-rsrp {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
}

.meas-date {
  margin-left: auto;
  color: var(--fg-mute);
  font-family: var(--font-mono);
  font-size: 10px;
}

.meas-sub {
  color: var(--fg-dim);
  font-size: 11px;
}

.meas-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.meas-actions button {
  font-size: 10px;
  padding: 2px 8px;
}

/* "Devant" / "dedans" / "le pire" grisés dans le dropdown */
select option.disabled-position {
  color: var(--fg-mute);
  font-style: italic;
}

/* ------------------ Markers personnalisés ------------------ */

.marker-cell {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 16px solid var(--accent);
  filter: drop-shadow(0 0 4px rgba(74,222,128,.6));
}

.marker-measure {
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(0,0,0,.6);
}

/* ------------------ Scrollbar ------------------ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-mute); }

/* ------------------ Toasts ------------------ */

.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide-in .2s ease-out;
  max-width: 360px;
}

.toast.error { border-left-color: var(--danger); }
.toast.warn  { border-left-color: var(--warn); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
