/* Responsive Media Queries (Mobile & Tablet) */
@media (max-width: 768px) {
  .sidebar-panel {
    width: calc(100vw - 16px);
    height: calc(100% - 16px - env(safe-area-inset-top, 0px));
    margin: max(8px, env(safe-area-inset-top, 8px)) 8px 8px 8px;
    max-width: none;
    border-radius: var(--radius-md);
  }

  /* Mobile Floating Controls Positioning */
  .leaflet-control-zoom {
    display: none !important;
  }

  .map-recenter-btn {
    top: max(16px, env(safe-area-inset-top, 16px));
    right: 14px;
    bottom: auto !important;
    z-index: 1000;
  }

  .sidebar-collapsed .sidebar-panel {
    transform: translateY(calc(100% + 30px));
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-header {
    padding: max(10px, env(safe-area-inset-top, 10px)) 12px 10px 12px;
  }

  .sidebar-header h1 {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logo-area {
    gap: 6px;
    min-width: 0;
  }

  .header-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .sidebar-content {
    padding: 12px;
  }

  .input-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
  }

  .input-row .input-group.half {
    flex: 1;
    width: 50%;
    min-width: 0;
  }

  .input-group label {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .input-wrapper input {
    font-size: 0.85rem;
  }

  .floating-panel-toggle {
    top: 12px;
    left: 12px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }

  .metric-box {
    padding: 8px 4px;
  }

  .metric-value {
    font-size: 0.95rem;
  }

  .metric-label {
    font-size: 0.65rem;
  }

  .connector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .checkbox-tag {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .modal-card {
    width: calc(100vw - 24px);
    max-height: 90vh;
    margin: 12px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .sidebar-panel {
    width: calc(100vw - 12px);
    margin: max(6px, env(safe-area-inset-top, 6px)) 6px 6px 6px;
    height: calc(100% - 12px - env(safe-area-inset-top, 0px));
  }

  .sidebar-header {
    padding: max(8px, env(safe-area-inset-top, 8px)) 10px 8px 10px;
  }

  .logo-area h1 {
    font-size: 0.86rem;
  }

  .icon-logo {
    width: 18px;
    height: 18px;
  }

  .header-actions {
    gap: 3px;
  }

  .btn-icon {
    width: 30px;
    height: 30px;
  }

  .floating-panel-toggle {
    top: max(10px, env(safe-area-inset-top, 10px));
    left: 10px;
  }

  .input-wrapper {
    margin-top: 2px;
  }
}

/* ==========================================================================
   Brand-Aware MarkerCluster CSS (Option A)
   ========================================================================== */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.25s ease-out, opacity 0.25s ease-in;
}

.poi-cluster-marker {
  background: transparent !important;
  border: none !important;
}

.poi-cluster-inner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--brand-color, #06b6d4);
  box-shadow: 0 0 16px var(--brand-color, rgba(6, 182, 212, 0.5)), 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-family: var(--font-heading, var(--font-sans));
  font-weight: 700;
  line-height: 1;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.poi-cluster-marker:hover .poi-cluster-inner {
  transform: scale(1.12);
  box-shadow: 0 0 24px var(--brand-color, rgba(6, 182, 212, 0.8)), 0 6px 18px rgba(0, 0, 0, 0.6);
  z-index: 999;
}

.poi-cluster-inner .cluster-badge-icon {
  font-size: 0.65rem;
  opacity: 0.9;
  margin-bottom: 1px;
}

.poi-cluster-inner .cluster-count {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* DC Fast Charger Badge Indicator on Cluster */
.poi-cluster-inner .cluster-dc-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000000;
  font-size: 0.60rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Multi-brand Cluster special gradient border */
.cluster-multibrand .poi-cluster-inner {
  background: radial-gradient(circle at 30% 30%, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border: 2px solid transparent;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
  position: relative;
}

.cluster-multibrand .poi-cluster-inner::before {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: -2px;
  right: -2px;
  background: linear-gradient(135deg, #a855f7 0%, #3b82f6 33%, #10b981 66%, #ef4444 100%);
  border-radius: 50%;
  z-index: -1;
}

/* Tooltip Breakdown for Clusters */
.leaflet-tooltip.cluster-tooltip-breakdown {
  background: rgba(15, 23, 42, 0.94) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px !important;
  color: #f8fafc !important;
  font-family: var(--font-sans) !important;
  padding: 8px 12px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-tooltip.cluster-tooltip-breakdown::before {
  border-top-color: rgba(15, 23, 42, 0.94) !important;
}

.cluster-breakdown-title {
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 4px;
  color: var(--primary, #06b6d4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 3px;
}

.cluster-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.76rem;
  margin-top: 2px;
}

.cluster-breakdown-row .brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Floating Recenter Location Button */
.map-recenter-btn {
  position: absolute;
  bottom: 98px;
  right: 10px;
  z-index: 1000;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: var(--card-bg, rgba(15, 23, 42, 0.85));
  border: 2px solid rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  color: var(--primary, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.map-recenter-btn i {
  width: 16px;
  height: 16px;
}

.map-recenter-btn:hover {
  transform: scale(1.06);
  background: var(--primary, #06b6d4);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.6);
  border-color: var(--primary, #06b6d4);
}

.map-recenter-btn.locating {
  animation: locatePulse 1.2s infinite alternate;
  color: #38bdf8;
  border-color: #38bdf8;
}

@keyframes locatePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  100% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
}

body.light-theme .map-recenter-btn {
  background: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.2);
  color: #0284c7;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

body.light-theme .map-recenter-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

/* User GPS Marker Pulse animation */
.custom-user-gps-pin {
  background: transparent;
  border: none;
}

.user-gps-pulse-dot {
  width: 32px;
  height: 32px;
  background: #0284c7;
  border: 3px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7), 0 4px 14px rgba(0, 0, 0, 0.4);
  animation: gpsPulseHalo 2s infinite;
}

.user-gps-pulse-dot i {
  width: 16px;
  height: 16px;
}

@keyframes gpsPulseHalo {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.8), 0 4px 14px rgba(0, 0, 0, 0.4);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(56, 189, 248, 0), 0 4px 14px rgba(0, 0, 0, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0), 0 4px 14px rgba(0, 0, 0, 0.4);
  }
}

/* Brand Grid Select All / Unselect All Headers */
.brand-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 6px;
}

.bulk-select-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--primary, #06b6d4);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s, color 0.2s;
}

.btn-text-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

body.light-theme .btn-text-link {
  color: #0284c7;
}

.bullet-divider {
  color: var(--border-color, #475569);
  font-size: 0.7rem;
}

/* POI Filter Text Search Box */
.poi-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.poi-search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted, #94a3b8);
  pointer-events: none;
}

.poi-search-input {
  padding-left: 32px !important;
  padding-right: 30px !important;
  font-size: 0.8rem !important;
  height: 36px !important;
  border-radius: 8px !important;
  width: 100%;
}

.clear-input-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
}

.clear-input-btn i {
  width: 14px;
  height: 14px;
}

.clear-input-btn:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

/* Per-Stop Custom Charge Target Selector Control Row */
.stop-target-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
  font-size: 0.78rem;
  transition: all 0.2s ease;
}

.stop-target-control-row label {
  color: var(--primary, #06b6d4);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stop-target-select {
  background: var(--bg-card, rgba(15, 23, 42, 0.85));
  color: var(--text-heading, #f8fafc);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  max-width: 175px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stop-target-select:focus,
.stop-target-select:hover {
  border-color: var(--primary, #06b6d4);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.stop-target-select option {
  background: #0d1425 !important;
  color: #f8fafc !important;
}

body.light-theme .stop-target-control-row {
  background: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.22);
}

body.light-theme .stop-target-control-row label {
  color: #0284c7;
}

body.light-theme .stop-target-select {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.light-theme .stop-target-select option {
  background: #ffffff;
  color: #0f172a;
}

/* ==========================================================================
   v2.0.0 UI/UX Tabbed Control & Mobile Drawer Styles
   ========================================================================== */

/* Header Logo Image */
.app-header-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.4));
}

/* 4-Tab Segmented Navigation Bar */
.sidebar-nav-tabs {
  display: flex;
  background: rgba(10, 16, 28, 0.75);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  gap: 4px;
  flex-shrink: 0;
}

body.light-theme .sidebar-nav-tabs {
  background: rgba(226, 232, 240, 0.85);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab i {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-heading);
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
  background: var(--primary);
  color: #0b0f19;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.nav-tab.active i {
  transform: scale(1.1);
}

/* Tab Pane Views */
.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeInPane 0.2s ease-out;
}

.tab-pane.hidden {
  display: none !important;
}

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

/* Mobile Drawer Drag Handle */
.mobile-drawer-handle {
  display: none;
  width: 100%;
  padding: 8px 0 4px 0;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  touch-action: pan-y;
  background: var(--bg-sidebar);
}

.drawer-pill {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

body.light-theme .drawer-pill {
  background: rgba(0, 0, 0, 0.25);
}

/* Form Controls & Unit Badges */
.form-control-select {
  width: 100%;
  padding: 12px 14px;
  background: rgba(10, 15, 26, 0.7);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  color-scheme: dark;
}

.form-control-select:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  background: rgba(10, 15, 26, 0.95);
}

.form-control-select option {
  background-color: #0d1425 !important;
  color: #f8fafc !important;
  padding: 8px 12px;
}

body.light-theme .form-control-select {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

body.light-theme .form-control-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

.unit-badge {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}

.empty-timeline-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
  font-size: 0.85rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

/* Mobile Responsiveness & Bottom Sheet Styles (< 768px) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column-reverse;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .sidebar-panel {
    width: 100%;
    height: auto;
    max-height: 70dvh;
    margin: 0;
    position: absolute;
    bottom: 0;
    left: 0;
    top: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-drawer-handle {
    display: flex;
  }

  .sidebar-collapsed .sidebar-panel {
    transform: translateY(calc(100% - 48px));
    opacity: 1;
    pointer-events: auto;
  }

  .floating-panel-toggle {
    top: auto;
    bottom: 60px;
    left: 16px;
  }
}
