/* ══════════════════════════════════════════════════════
   NUGGET S.A. — map.css
   Full-page live map with dark/gold theme
══════════════════════════════════════════════════════ */

:root {
  --gold:         #f5a623;
  --gold-light:   #ffd166;
  --gold-glow:    rgba(245, 166, 35, 0.25);
  --bg:           #080808;
  --bg-2:         #111111;
  --bg-card:      #141414;
  --surface:      #1f1f1f;
  --border:       rgba(255,255,255,0.07);
  --text:         #f0f0f0;
  --text-muted:   #8a8a8a;
  --text-dim:     #444;
  --online:       #2ecc71;
  --radius:       10px;
  --nav-h:        52px;
  --sidebar-w:    300px;
  --transition:   0.3s cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ═══════════ NAVBAR ═══════════ */
.map-nav {
  height: var(--nav-h);
  background: rgba(8,8,8,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  gap: 1rem;
  position: relative;
  z-index: 1001;
  flex-shrink: 0;
}

.map-nav-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.map-nav-back:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.15);
}

.map-nav-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  justify-content: center;
}

.map-nav-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 5px;
  background: var(--bg-card);
}

.map-nav-name {
  font-weight: 700;
  color: var(--gold);
}

.map-nav-sep { color: var(--text-dim); }

#navTitle { color: var(--text-muted); }

.map-lang-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  border: 1.5px solid rgba(245,166,35,0.3);
  border-radius: 6px;
  background: rgba(245,166,35,0.07);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.map-lang-btn:hover {
  background: rgba(245,166,35,0.15);
  border-color: rgba(245,166,35,0.55);
}

/* ═══════════ LAYOUT ═══════════ */
.map-layout {
  position: relative;
  height: calc(100vh - 52px); /* 52px = snav height */
  overflow: hidden;
}

/* ═══════════ FLOATING DRIVER PANEL ═══════════ */
.map-driver-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 270px;
  height: 100%;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 700;
  transform: translateX(-100%);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.24s;
  overflow: hidden;
}
.map-driver-panel.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}

.mdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mdp-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ═══════════ MAP NAVBAR HUD ═══════════ */
.map-hud {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.22rem 0.6rem;
  flex-shrink: 0;
}
.map-hud-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
}
.map-hud-icon {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.map-hud-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.map-hud-refresh .refresh-bar-track {
  width: 34px;
  height: 3px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}
.map-hud-refresh .refresh-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 2.4ch;
}

/* Blocks */
.sidebar-block {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* Server pills */
.server-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.server-pill {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.server-pill:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

.server-pill.active {
  color: var(--gold);
  border-color: rgba(245,166,35,0.4);
  background: rgba(245,166,35,0.1);
}

/* Status */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.online  { background: var(--online); box-shadow: 0 0 6px var(--online); animation: dotPulse 2s ease-in-out infinite; }
.status-dot.error   { background: #e74c3c; }
.status-dot.loading { background: var(--gold); animation: dotPulse 1s ease-in-out infinite; }

@keyframes dotPulse {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.4; }
}

/* Count */
.driver-count-wrap {
  padding: 1.1rem 1.1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.driver-count-num {
  font-family: 'Bebas Neue', 'Inter', sans-serif;
  font-size: 3.2rem;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 0.03em;
  transition: color 0.3s;
}

.driver-count-label {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

/* Refresh */
.refresh-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.refresh-bar-track {
  flex: 1;
  height: 3px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.refresh-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--gold);
  transform-origin: left;
  transition: transform 1s linear;
  border-radius: 3px;
}

.refresh-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 26px;
  text-align: right;
}

.refresh-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.refresh-btn:hover {
  color: var(--gold);
  border-color: rgba(245,166,35,0.35);
  background: rgba(245,166,35,0.07);
}

.refresh-btn.spinning i { animation: spin 0.6s linear; }

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

/* Driver list */
.driver-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.driver-list::-webkit-scrollbar { width: 4px; }
.driver-list::-webkit-scrollbar-track { background: transparent; }
.driver-list::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 4px; }

.driver-empty {
  padding: 1.5rem 1.1rem;
  font-size: 0.83rem;
  color: var(--text-dim);
  text-align: center;
}

/* Driver item */
.driver-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--transition);
}

.driver-item:hover { background: rgba(255,255,255,0.04); }
.driver-item.active { background: rgba(245,166,35,0.08); }

.driver-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(245,166,35,0.12);
  border: 1.5px solid rgba(245,166,35,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 700;
  flex-shrink: 0;
}

.driver-info { flex: 1; min-width: 0; }

.driver-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-location {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.driver-heading {
  font-size: 1rem;
  color: var(--gold);
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.sidebar-footer i { color: var(--text-dim); font-size: 0.7rem; }
#totalOnline { color: var(--text-muted); font-weight: 600; }


/* ═══════════ MAP ═══════════ */
.map-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #070a0f;
}

/* ETS2 tile filter — warm dark theme aligned with gold/dark site */
.ets2-tiles {
  filter: brightness(0.86) contrast(1.06) saturate(1.15) sepia(0.18) hue-rotate(-8deg);
  transition: filter 0.4s;
}

/* Leaflet override — dark theme */
.leaflet-container {
  background: #070a0f !important;
  font-family: 'Inter', sans-serif !important;
}

.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  background: rgba(14,14,14,0.9) !important;
  backdrop-filter: blur(8px) !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}

.leaflet-control-zoom a {
  background: transparent !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
  transition: color 0.2s, background 0.2s !important;
}

.leaflet-control-zoom a:hover {
  color: var(--gold) !important;
  background: rgba(245,166,35,0.1) !important;
}

.leaflet-attribution-flag { display: none !important; }

.leaflet-control-attribution {
  background: rgba(8,8,8,0.75) !important;
  color: var(--text-dim) !important;
  backdrop-filter: blur(6px) !important;
  font-size: 0.67rem !important;
  border-radius: 6px 0 0 0 !important;
  padding: 2px 6px !important;
}

.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* Custom map controls */
.map-controls {
  position: absolute;
  bottom: 1.5rem;
  right: 1rem;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.map-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(14,14,14,0.9);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  backdrop-filter: blur(8px);
}

.map-ctrl-btn:hover {
  color: var(--gold);
  background: rgba(14,14,14,0.97);
  border-color: rgba(245,166,35,0.4);
}

.map-ctrl-btn.active {
  color: var(--gold);
  background: rgba(245,166,35,0.13);
  border-color: rgba(245,166,35,0.45);
}

/* Draw-mode: active button glows red */
.map-ctrl-btn.active[id="btnDrawRoute"] {
  color: #e8003d;
  background: rgba(232,0,61,0.13);
  border-color: rgba(232,0,61,0.5);
}

/* Separator between control groups */
.map-ctrl-sep {
  height: 1px;
  background: var(--border);
  margin: 0.15rem 4px;
}

/* Crosshair cursor while drawing */
.draw-mode .leaflet-container,
.draw-mode .leaflet-interactive {
  cursor: crosshair !important;
}

/* Route hint banner */
.route-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  background: rgba(10,10,10,0.88);
  border: 1px solid rgba(232,0,61,0.4);
  border-radius: 8px;
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #f0f0f0;
  backdrop-filter: blur(10px);
  pointer-events: none;
  white-space: nowrap;
  animation: hintFadeIn 0.25s ease;
}

.route-hint i {
  color: #e8003d;
  font-size: 0.8rem;
  animation: pencilPulse 1.4s ease-in-out infinite;
}

@keyframes hintFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes pencilPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* Loading overlay */
.map-loading {
  position: absolute;
  inset: 0;
  background: rgba(8,8,8,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 900;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: opacity 0.4s;
}

.map-loading i { font-size: 2rem; color: var(--gold); }
.map-loading.hidden { opacity: 0; pointer-events: none; }

/* ═══════════ DRIVER MARKERS ═══════════ */

/* Pulsing ring */
@keyframes markerPulse {
  0%   { transform: scale(1);   opacity: 0.75; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

.driver-marker-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.driver-pulse {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: rgba(245,166,35,0.45);
  animation: markerPulse 2.2s ease-out infinite;
  pointer-events: none;
}

/* Nugget image marker */
.driver-nugget {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(8,8,8,0.7);
  box-shadow: 0 2px 10px rgba(0,0,0,0.7), 0 0 8px rgba(245,166,35,0.3);
  position: relative;
  z-index: 1;
  pointer-events: none;
  transition: transform 0.15s;
}

.leaflet-marker-icon:hover .driver-nugget {
  transform: scale(1.12);
}

/* City dots — tiered sizes */
.city-dot-icon {
  border-radius: 50%;
  background: rgba(210, 205, 170, 0.85);
  border: 1.5px solid rgba(120, 110, 70, 0.7);
  box-shadow: 0 0 3px rgba(0,0,0,0.55);
  width: 100%;
  height: 100%;
}
/* Tier 1 — capital dot: slightly brighter */
.city-dot-t1 {
  background: rgba(240, 230, 170, 0.95);
  border-color: rgba(180, 155, 60, 0.85);
}

/* City labels — clean minimal style, no box */
.leaflet-tooltip.city-tt {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: rgba(235, 225, 165, 0.82);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow:
    0 0 4px rgba(0,0,0,0.95),
    1px 1px 3px rgba(0,0,0,0.9),
    -1px -1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  /* Short transition: just enough to hide micro-jitter, not enough to lag */
  transition: opacity 0.1s linear;
}

/* Tier sizes */
.city-tt-t1 { font-size: 0.73rem; }
.city-tt-t2 { font-size: 0.63rem; color: rgba(215, 205, 145, 0.70); }
.city-tt-t3 { font-size: 0.57rem; color: rgba(200, 190, 130, 0.58); }

.leaflet-tooltip.city-tt::before { display: none !important; }



/* Driver popup */
.leaflet-popup-content-wrapper {
  background: rgba(14,14,14,0.97) !important;
  border: 1px solid rgba(245,166,35,0.3) !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7) !important;
  color: var(--text) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: 'Inter', sans-serif !important;
}

.leaflet-popup-tip-container { display: none !important; }

.popup-inner {
  padding: 0.9rem 1.1rem;
  min-width: 180px;
}

.popup-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.popup-city {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--gold);
  text-decoration: none;
}

.popup-link:hover { text-decoration: underline; }
.popup-link i { font-size: 0.68rem; }

/* Close button */
.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  top: 6px !important;
  right: 8px !important;
  font-size: 16px !important;
  padding: 0 !important;
}

.leaflet-popup-close-button:hover { color: var(--text) !important; }


/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 640px) {
  /* Driver panel takes full width on mobile */
  .map-driver-panel {
    width: 100%;
    height: 60vh;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
  }
  .map-driver-panel.open {
    transform: translateY(0);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  }
}

/* ═══════════ SCROLLBAR ═══════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(245,166,35,0.4); }

::selection { background: rgba(245,166,35,0.3); }
