/* ============================================
   CRAIOVA EV CHARGING MAP - Premium UI
   ============================================ */

:root {
  --primary: #0066FF;
  --primary-dark: #0052CC;
  --primary-light: #E6F0FF;
  --accent: #00D4AA;
  --accent-dark: #00B894;
  --supercharger: #FF6B35;
  --hybrid: #7C3AED;
  --ac: #0EA5E9;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-hover: #F1F5F9;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --primary: #4D9FFF;
  --primary-dark: #3385FF;
  --primary-light: #1A2744;
  --bg: #0B1120;
  --surface: #151F32;
  --surface-hover: #1E293B;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: #1E293B;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ===== LOADING SCREEN ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #0B1120 0%, #1A1F3A 50%, #0B1120 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
  animation: fadeInUp 0.8s ease;
}

.loader-logo {
  margin-bottom: 24px;
}

.city-crest {
  width: 80px;
  height: auto;
  filter: drop-shadow(0 4px 20px rgba(0, 102, 255, 0.4));
  animation: pulse-glow 2s ease-in-out infinite;
}

.loader-text h2 {
  color: #FFF;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.loader-text p {
  color: #94A3B8;
  font-size: 0.95rem;
  font-weight: 400;
}

.loader-bar {
  margin-top: 32px;
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}

.loader-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  animation: loading 1.5s ease-in-out forwards;
}

@keyframes loading {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 20px rgba(0, 102, 255, 0.4)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 4px 30px rgba(0, 102, 255, 0.7)); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER ===== */
#main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] #main-header {
  background: rgba(11, 17, 32, 0.9);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-crest {
  width: 36px;
  height: auto;
}

.header-title h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.header-title .accent {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-title .subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-mini {
  display: flex;
  gap: 6px;
  margin-right: 8px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.stat-chip.dc {
  background: rgba(124, 58, 237, 0.1);
  color: var(--hybrid);
}

.stat-chip.ac {
  background: rgba(14, 165, 233, 0.1);
  color: var(--ac);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--surface-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 0.9rem;
}

.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: scale(1.05);
}

/* ===== MAP ===== */
#map {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.leaflet-control-zoom {
  display: none !important;
}

/* ===== MAP CONTROLS ===== */
#map-controls {
  position: fixed;
  right: 16px;
  bottom: 80px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.control-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

/* ===== FILTER PANEL ===== */
#filter-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.filter-chips {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border-radius: 50px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.filter-chip {
  padding: 8px 14px;
  border: none;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter-chip.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
}

.filter-chip.active[data-filter="supercharger"] {
  background: var(--supercharger);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.filter-chip.active[data-filter="hybrid"] {
  background: var(--hybrid);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.filter-chip.active[data-filter="ac"] {
  background: var(--ac);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

/* ===== SEARCH ===== */
#search-panel {
  position: fixed;
  top: 80px;
  left: 16px;
  z-index: 1000;
  width: 320px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.search-box i {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-box input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
  font-family: var(--font);
}

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

.search-clear {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition);
}

.search-clear:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.hidden {
  display: none !important;
}

#search-results {
  margin-top: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--surface-hover);
}

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.search-result-icon.supercharger { background: var(--supercharger); }
.search-result-icon.hybrid { background: var(--hybrid); }
.search-result-icon.ac { background: var(--ac); }

.search-result-text {
  flex: 1;
}

.search-result-text .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.search-result-text .power {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--surface);
  z-index: 1001;
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar.show {
  transform: translateX(0);
  display: flex !important;
}

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

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-stat {
  text-align: center;
}

.stat-number {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-mono);
}

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

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.station-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.station-card:hover {
  background: var(--surface-hover);
  transform: translateX(4px);
}

.station-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
}

.station-card-icon.supercharger { background: linear-gradient(135deg, var(--supercharger), #FF8C42); }
.station-card-icon.hybrid { background: linear-gradient(135deg, var(--hybrid), #A78BFA); }
.station-card-icon.ac { background: linear-gradient(135deg, var(--ac), #38BDF8); }

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

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

.station-card-info .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 10px;
}

.station-card-power {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ===== DETAIL PANEL ===== */
#detail-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 1001;
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#detail-panel.show {
  transform: translateX(-50%) translateY(0);
  display: block !important;
}

.detail-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.detail-body {
  padding: 20px;
}

.detail-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.detail-type.supercharger { background: rgba(255,107,53,0.1); color: var(--supercharger); }
.detail-type.hybrid { background: rgba(124,58,237,0.1); color: var(--hybrid); }
.detail-type.ac { background: rgba(14,165,233,0.1); color: var(--ac); }

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.info-row i {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface-hover);
}

.action-btn.primary {
  background: var(--primary);
  color: white;
  border: none;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== LEGEND ===== */
#legend {
  position: fixed;
  bottom: 76px;
  left: 16px;
  z-index: 999;
  display: flex;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-radius: 50px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.supercharger { background: var(--supercharger); box-shadow: 0 0 6px rgba(255,107,53,0.4); }
.legend-dot.hybrid { background: var(--hybrid); box-shadow: 0 0 6px rgba(124,58,237,0.4); }
.legend-dot.ac { background: var(--ac); box-shadow: 0 0 6px rgba(14,165,233,0.4); }

/* ===== CUSTOM MARKERS ===== */
.custom-marker {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.custom-marker:hover {
  transform: scale(1.2);
  z-index: 9999 !important;
}

.marker-pin {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  border: 3px solid white;
  position: relative;
}

.marker-pin.supercharger { background: linear-gradient(135deg, var(--supercharger), #FF8C42); }
.marker-pin.hybrid { background: linear-gradient(135deg, var(--hybrid), #A78BFA); }
.marker-pin.ac { background: linear-gradient(135deg, var(--ac), #38BDF8); }

.marker-pin i {
  transform: rotate(45deg);
  color: white;
  font-size: 12px;
}

.marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation: markerPulse 2s ease-out infinite;
}

.marker-pulse.supercharger { background: var(--supercharger); }
.marker-pulse.hybrid { background: var(--hybrid); }
.marker-pulse.ac { background: var(--ac); }

@keyframes markerPulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.marker-label {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--text);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  font-family: var(--font-mono);
}

/* ===== LEAFLET POPUP ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  min-width: 220px;
}

.leaflet-popup-tip {
  box-shadow: none !important;
}

.popup-content {
  padding: 16px;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.popup-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.popup-icon.supercharger { background: var(--supercharger); }
.popup-icon.hybrid { background: var(--hybrid); }
.popup-icon.ac { background: var(--ac); }

.popup-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.popup-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.popup-details {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--surface-hover);
  border-radius: 8px;
  margin-bottom: 12px;
}

.popup-detail-item {
  text-align: center;
  flex: 1;
}

.popup-detail-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-mono);
}

.popup-detail-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.popup-btn {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: var(--transition);
}

.popup-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #search-panel {
    width: calc(100vw - 32px);
    left: 16px;
  }

  #sidebar {
    width: 100%;
  }

  #detail-panel {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .stats-mini {
    display: none;
  }

  .filter-chips {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .filter-chips::-webkit-scrollbar {
    display: none;
  }

  #legend {
    display: none;
  }

  .header-title h1 {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .filter-chip span {
    display: none;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== ANIMATIONS ===== */
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes slideInUp {
  from { transform: translateX(-50%) translateY(100%); }
  to { transform: translateX(-50%) translateY(0); }
}

/* ===== DARK MAP TILES ===== */
[data-theme="dark"] .leaflet-tile {
  filter: brightness(0.7) contrast(1.1) saturate(0.8);
}
