:root {
  --green:  #22c55e;
  --yellow: #f59e0b;
  --red:    #ef4444;
  --grey:   #6b7280;
  --accent:  #F3EC18;
  --accent-h:#d4ce00;
  --on-accent:#1a1a1a;
  /* dark brand tokens (markers + popups) */
  --dark:   #0f172a;
  --card:   #1e293b;
  --border: #334155;
  /* light chrome tokens (toolbar + controls) */
  --ink:    #0f172a;
  --ink-2:  #475569;
  --ink-3:  #94a3b8;
  --surface:#ffffff;
  --surface-2:#f1f5f9;
  --line:   #e2e8f0;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* safe area pentru iPhone cu notch */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Toolbar ─────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  position: relative;
  z-index: 1000;
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.logo-img {
  height: 38px;
  width: auto;
  display: block;
}

#stats-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px 13px;
  border-radius: 9px;
  font-weight: 500;
  white-space: nowrap;
}

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

.stat b { color: var(--ink); font-weight: 700; }

.stat.total {
  background: transparent;
  border: none;
  color: var(--ink-3);
  padding-left: 4px;
}

#search-area {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.lang-switch {
  margin-left: auto;
}

.search-wrap { position: relative; display: flex; align-items: center; }

.search-wrap svg {
  position: absolute;
  left: 12px;
  width: 15px; height: 15px;
  color: var(--ink-3);
  pointer-events: none;
}

#search-input {
  padding: 8px 12px 8px 34px;
  width: 240px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: .18s;
}

#search-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(243,236,24,.30);
}

#search-input::placeholder { color: var(--ink-3); }

#search-btn {
  padding: 8px 18px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background .18s;
}

#search-btn:hover { background: var(--accent-h); }

/* ── Language switch RO/EN ───────────────────────────── */
.lang-switch {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
}
.lang-opt {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.active { background: var(--accent); color: var(--on-accent); }

/* ── Map ─────────────────────────────────────────────── */
#map {
  width: 100%;
  flex: 1;
  min-height: 0;
}

/* ── Loader pill ─────────────────────────────────────── */
#loader {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  background: rgba(255,255,255,.97);
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(15,23,42,.1);
  backdrop-filter: blur(6px);
}

#loader.on { display: flex; }

.spin {
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── Marker ──────────────────────────────────────────── */
.ev-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform .12s;
  filter: drop-shadow(0 3px 7px rgba(0,0,0,.28));
}

.ev-marker:hover { transform: scale(1.1); }

.ev-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid currentColor;
}

.ev-info {
  background: white;
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 3px;
  white-space: nowrap;
  border-left: 3px solid currentColor;
}

.ev-info-line {
  font-size: 10px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.55;
}

/* ── Popup ───────────────────────────────────────────── */
.evpopup .leaflet-popup-content-wrapper {
  background: var(--dark);
  color: #e2e8f0;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
  padding: 0;
  overflow: hidden;
}

.evpopup .leaflet-popup-tip-container { margin-top: -1px; }
.evpopup .leaflet-popup-tip { background: var(--dark); }
.evpopup .leaflet-popup-content { margin: 0; min-width: 520px; max-width: 680px; font-size: 14px; }
.evpopup .leaflet-popup-close-button {
  width: 22px !important;
  height: 22px !important;
  top: 8px !important;
  right: 8px !important;
  background: rgba(15,23,42,.6) !important;
  border: 1px solid #475569 !important;
  border-radius: 50% !important;
  color: #cbd5e1 !important;
  font-size: 14px !important;
  font-weight: 700;
  line-height: 20px !important;
  text-align: center;
  z-index: 1000;
  transition: background .15s, color .15s;
}
.evpopup .leaflet-popup-close-button:hover {
  background: #ef4444 !important;
  color: #fff !important;
}

.ph { padding: 12px 14px 10px; border-bottom: 1px solid var(--border); background: var(--card); }
.ph-name { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 3px; padding-right: 16px; }
.ph-addr { font-size: 12px; color: #94a3b8; margin-bottom: 2px; }
.ph-owner { font-size: 11px; color: #64748b; }

.ph-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 7px;
}

.pb { padding: 10px 14px 12px; }
.pb-title { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #64748b; margin-bottom: 7px; }

.conn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: var(--card);
  border-radius: 8px;
  margin-bottom: 4px;
}

.conn-left { display: flex; align-items: center; gap: 6px; }

.conn-badge {
  background: #334155;
  color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.conn-kw { font-size: 11px; color: #94a3b8; }

.conn-right { text-align: right; }
.conn-price { font-size: 12px; font-weight: 700; color: var(--accent); }
.conn-state { font-size: 10px; margin-top: 1px; }
.s-ok  { color: var(--green);  }
.s-bad { color: var(--red);    }
.s-occ { color: var(--yellow); }

/* ── Legend ──────────────────────────────────────────── */
#legend {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  background: rgba(255,255,255,.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 12px;
  color: var(--ink-2);
  box-shadow: 0 4px 16px rgba(15,23,42,.08);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

#legend h4 {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
}

.leg-row { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; font-weight: 500; }
.leg-row:last-child { margin-bottom: 0; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Embed: legenda sus, fără toolbar */
.embed #legend {
  bottom: auto;
  left: 0;
  right: 0;
  top: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid var(--line);
  padding: 7px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 14px;
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
}
.embed #legend h4 { display: none; }
.embed .leg-row { margin-bottom: 0; font-size: 11px; gap: 6px; }
.embed .leg-dot  { width: 8px; height: 8px; }
.embed .leaflet-top.leaflet-right { top: 36px; }

/* Mobil: bandă orizontală sub toolbar */
@media (max-width: 560px) {
  .leaflet-top.leaflet-right { top: 36px; }

  #legend {
    bottom: auto;
    left: 0;
    right: 0;
    top: 52px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid var(--line);
    padding: 7px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 2px 6px rgba(15,23,42,.06);
  }
  #legend h4 { display: none; }
  .leg-row { margin-bottom: 0; font-size: 11px; gap: 6px; }
  .leg-dot  { width: 8px; height: 8px; }
}

/* ── Locate me button ────────────────────────────────── */
.ev-locate {
  border: none !important;
  box-shadow: 0 4px 16px rgba(15,23,42,.1) !important;
  border-radius: 10px !important;
  overflow: hidden;
  margin-top: 10px !important;
}
.ev-locate a {
  width: 42px !important;
  height: 42px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.97) !important;
  color: var(--ink-2) !important;
  border: none !important;
  transition: background .15s, color .15s;
}
.ev-locate a:hover { background: var(--surface-2) !important; color: var(--accent) !important; }
.ev-locate svg { width: 24px; height: 24px; }

/* punctul de locație al utilizatorului */
.user-loc { position: relative; width: 18px; height: 18px; }
.user-loc-core {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; transform: translate(-50%,-50%);
  background: #2563eb; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 3px rgba(0,0,0,.4);
}
.user-loc-pulse {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; transform: translate(-50%,-50%);
  background: #3b82f6; border-radius: 50%; opacity: .5;
  animation: userpulse 1.8s ease-out infinite;
}
@keyframes userpulse {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity: .5; }
  100% { transform: translate(-50%,-50%) scale(3.2); opacity: 0;  }
}

/* ── Leaflet controls polish ─────────────────────────── */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 16px rgba(15,23,42,.1) !important;
  border-radius: 10px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  color: var(--ink-2) !important;
  background: rgba(255,255,255,.97) !important;
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  font-size: 18px !important;
  transition: background .15s, color .15s;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
  color: var(--ink) !important;
}
.leaflet-control-attribution {
  background: rgba(255,255,255,.85) !important;
  border-radius: 7px 0 0 0 !important;
  font-size: 10px !important;
  color: var(--ink-3) !important;
  padding: 2px 7px !important;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }

/* ── Layers control (theme switcher) ─────────────────── */
.leaflet-control-layers {
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 16px rgba(15,23,42,.1) !important;
  background: rgba(255,255,255,.97) !important;
  overflow: hidden;
}
.leaflet-control-layers-toggle {
  width: 38px !important;
  height: 38px !important;
  background-size: 20px 20px !important;
}
.leaflet-control-layers-expanded {
  padding: 10px 12px !important;
  color: var(--ink-2) !important;
  font-size: 13px !important;
  font-weight: 500;
}
.leaflet-control-layers-expanded label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s;
}
.leaflet-control-layers-expanded label:hover { background: var(--surface-2); }
.leaflet-control-layers-selector { accent-color: var(--accent); margin: 0 2px 0 0; }
.leaflet-control-layers-base { line-height: 1.6; }

/* ── Navigation floating popover ─────────────────────── */
.ev-nav-float {
  position: fixed;
  z-index: 10000;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

/* ══════════════════════════════════════════════════════
   Tabletă (≤ 860px) — stats dispar, bara rămâne un rând
   ══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  #stats-bar { display: none; }
  #toolbar { height: 68px; gap: 14px; padding: 0 20px; }
  .logo-img { height: 42px; }
  #search-area { flex: 1; justify-content: flex-end; gap: 10px; }
  #search-input { width: 300px; max-width: 100%; font-size: 14px; padding: 10px 14px 10px 36px; }
  .search-wrap svg { width: 16px; height: 16px; left: 12px; }
  #search-btn { padding: 10px 20px; font-size: 14px; }
  .lang-opt { padding: 10px 14px; font-size: 13px; }
}

/* ══════════════════════════════════════════════════════
   Mobil (≤ 560px) — un singur rând compact
   ══════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .leaflet-top.leaflet-right { top: 36px; }

  #toolbar { height: 52px; padding: 0 12px; gap: 8px; }
  .logo-img    { height: 24px; }
  #search-area { flex: 1; min-width: 0; gap: 6px; }
  .search-wrap { flex: 1; min-width: 0; }
  #search-input {
    width: 100%;
    font-size: 13px;
    padding: 7px 10px 7px 30px;
  }
  .search-wrap svg { width: 13px; height: 13px; left: 9px; }
  #search-btn  { padding: 7px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
  .lang-opt    { padding: 6px 8px; font-size: 11px; }

  /* Popup mai compact */
  .evpopup .leaflet-popup-content { min-width: 0 !important; max-width: calc(100vw - 48px) !important; font-size: 13px !important; }
}

/* ══════════════════════════════════════════════════════
   Touch — controale mai mari pe orice ecran tactil
   ══════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 20px !important;
  }
  .ev-locate a   { width: 50px !important; height: 50px !important; }
  .ev-locate svg { width: 26px; height: 26px; }

  .evpopup .leaflet-popup-content {
    min-width: min(260px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 32px) !important;
    font-size: 13px !important;
  }
}

/* ══════════════════════════════════════════════════════
   Bottom sheet — mobile popup (≤560px)
   ══════════════════════════════════════════════════════ */
#ev-sheet-backdrop {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#ev-sheet-backdrop.on {
  opacity: 1;
  pointer-events: auto;
}

/* ── Sheet CSS variables — dark (default) ──────────── */
#ev-bottom-sheet {
  --sh-surface:  #0f172a;
  --sh-card:     #1e293b;
  --sh-line:     #334155;
  --sh-divider:  #1e293b;
  --sh-ink1:     #ffffff;
  --sh-ink2:     #e2e8f0;
  --sh-ink3:     #94a3b8;
  --sh-ink4:     #64748b;
}
/* ── Sheet CSS variables — light (voyager/positron/osm) */
#ev-bottom-sheet.map-light {
  --sh-surface:  #f8fafc;
  --sh-card:     #ffffff;
  --sh-line:     #e2e8f0;
  --sh-divider:  #f1f5f9;
  --sh-ink1:     #0f172a;
  --sh-ink2:     #1e293b;
  --sh-ink3:     #475569;
  --sh-ink4:     #94a3b8;
}

#ev-bottom-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2001;
  background: var(--sh-surface);
  border-radius: 20px 20px 0 0;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,1,.6,1), background .2s;
}
#ev-bottom-sheet.on {
  transform: translateY(0);
}

.ev-sheet-handle-wrap {
  padding: 10px 0 6px;
  display: flex; justify-content: center;
  background: inherit;
}

.ev-sheet-handle {
  width: 38px; height: 4px;
  background: var(--sh-line);
  border-radius: 2px;
}

.ev-sheet-nav {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px 10px;
  background: inherit;
  border-bottom: 1px solid var(--sh-line);
}

.ev-sheet-back {
  flex-shrink: 0;
  width: 34px; height: 34px;
  background: var(--sh-card);
  border: 1px solid var(--sh-line);
  border-radius: 50%;
  color: var(--sh-ink1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.ev-sheet-back:active { background: var(--sh-line); }

.ev-sheet-title {
  font-size: 15px; font-weight: 700; color: var(--sh-ink1);
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#ev-sheet-body {
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* 3. Sticky Navigate button */
.ev-sheet-sticky-nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px 20px;
  background: var(--sh-surface);
  border-top: 1px solid var(--sh-line);
}
