:root {
  --bg-dark: #0f111a;
  --panel-bg: rgba(22, 25, 37, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-color: #3b82f6;
  --accent-glow: #3b82f640;
  --pin-color: #10b981;
  --pin-glow: rgba(16, 185, 129, 0.4);
  --pin-bg: rgba(16, 185, 129, 0.1);
  --font-sans: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

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

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

#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.glass-panel {
  width: 380px;
  margin-left: 0;
  transition: margin-left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 4px 0 24px rgba(0,0,0,0.4);
}

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

.header-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-container {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-core {
  width: 12px;
  height: 12px;
  background: var(--accent-color);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-color);
  z-index: 2;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent-color);
  animation: pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
  z-index: 1;
}

@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header h1 span {
  font-weight: 500;
  color: var(--text-muted);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(-2px);
}

.stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.stat-box:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.locations-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom Scrollbar */
.locations-list::-webkit-scrollbar { width: 6px; }
.locations-list::-webkit-scrollbar-track { background: transparent; }
.locations-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
.locations-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.location-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.location-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--pin-color);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.location-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.location-card:hover::before {
  opacity: 1;
}

.loc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.loc-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}

.loc-region {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.loc-amount {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pin-color);
  display: inline-flex;
  align-items: center;
  background: var(--pin-bg);
  padding: 4px 8px;
  border-radius: 6px;
}

.upload-section {
  padding: 24px;
  border-top: 1px solid var(--panel-border);
  text-align: center;
}

.upload-section p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.primary-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  width: 100%;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
  filter: brightness(1.1);
}

.primary-btn:active {
  transform: translateY(1px);
}

/* Map Styling */
.map-wrapper {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  z-index: 1;
}

.map-overlay-title {
  position: absolute;
  top: 32px;
  right: 32px;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  text-align: right;
  animation: slideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.map-overlay-title h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.map-overlay-title p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Custom Marker Styling */
.custom-pin-container {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transform: translate(-50%, -100%);
}

.custom-pin {
  position: relative;
  width: 36px;
  height: 36px;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  transform-origin: bottom center;
}

.pin-core {
  width: 21px;
  height: 21px;
  background: var(--pin-color);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: -2px 2px 8px rgba(0,0,0,0.5);
  z-index: 2;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--pin-glow);
  animation: ping 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  z-index: 1;
}

@keyframes ping {
  75%, 100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.custom-pin-container:hover .custom-pin {
  transform: translateY(-8px);
}

.custom-pin-container:hover .pin-core {
  box-shadow: -4px 4px 12px rgba(0,0,0,0.7);
  transform: rotate(-45deg) scale(1.15);
}

.pin-label {
  margin-top: 8px;
  background: rgba(15, 17, 26, 0.85);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
}

.custom-pin-container:hover .pin-label {
  background: var(--pin-color);
  color: var(--bg-dark);
  border-color: var(--pin-color);
  transform: scale(1.05);
  text-shadow: none;
}

/* Leaflet override for dark mode */
.leaflet-container {
  background: var(--bg-dark);
}
.leaflet-bar {
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.leaflet-bar a {
  background-color: var(--panel-bg);
  color: var(--text-main);
  border-bottom: 1px solid var(--panel-border);
  transition: background 0.2s;
}
.leaflet-bar a:hover {
  background-color: rgba(255,255,255,0.1);
  color: #fff;
}
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Value-based highlight colors */
.pin-gold {
  --pin-color: #fbbf24;
  --pin-glow: rgba(251, 191, 36, 0.4);
  --pin-bg: rgba(251, 191, 36, 0.1);
}

.pin-red {
  --pin-color: #ef4444;
  --pin-glow: rgba(239, 68, 68, 0.4);
  --pin-bg: rgba(239, 68, 68, 0.1);
}

.pin-lightblue {
  --pin-color: #38bdf8;
  --pin-glow: rgba(56, 189, 248, 0.4);
  --pin-bg: rgba(56, 189, 248, 0.1);
}

/* Gulf override */
.gulf-override-label {
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 1rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  background: radial-gradient(ellipse at center, rgba(15, 17, 26, 0.95) 20%, rgba(15, 17, 26, 0.8) 60%, rgba(15, 17, 26, 0) 100%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 500 !important;
}

/* Distance Line Tooltips */
.distance-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #94a3b8 !important;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-shadow: 0 2px 4px #000;
  pointer-events: none;
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  pointer-events: auto;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #10b981;
  border-color: #10b981;
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #fff;
}

/* Sidebar Toggle State */
.glass-panel.collapsed {
  margin-left: -380px;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  z-index: 9999; /* Ensure it is above Leaflet's pane overlays */
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

/* Show toggle button only when sidebar is collapsed */
.glass-panel.collapsed ~ .map-wrapper .sidebar-toggle-btn {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.05);
}

.sidebar-toggle-btn:active {
  transform: scale(0.95);
}

/* Custom Cursor Override (Triangular Pointer & Scaled 50% Larger) */
* {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24" fill="%2310b981" stroke="white" stroke-width="1.5"><polygon points="2,2 20,9 12,12 9,20"/></svg>') 2 2, default !important;
}

/* Tabs & Heatmap UI styles */
.dashboard-tabs {
  display: flex;
  padding: 0 24px 16px;
  border-bottom: 1px solid var(--panel-border);
  gap: 8px;
}

.tab-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  padding: 10px 4px;
  border-radius: 8px;
  cursor: pointer !important;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-align: center;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.tab-btn.active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.sidebar-panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-panel-content.hidden {
  display: none !important;
}

.map-overlay-title.hidden {
  display: none !important;
}

/* Filter Sections */
.filter-section {
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
}

.filter-section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #fff;
}

.filter-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.select-all-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer !important;
  transition: all 0.2s ease;
}

.select-all-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.checkbox-list::-webkit-scrollbar { width: 4px; }
.checkbox-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer !important;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.checkbox-item:hover {
  color: #fff;
}

.checkbox-item input[type="checkbox"] {
  accent-color: #10b981;
  width: 16px;
  height: 16px;
  cursor: pointer !important;
}

/* Range sliders */
.range-control {
  margin-bottom: 16px;
}

.range-control:last-child {
  margin-bottom: 0;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.range-labels span:last-child {
  color: #10b981;
  font-family: var(--font-display);
}

.range-control input[type="range"] {
  width: 100%;
  accent-color: #10b981;
  background: rgba(255,255,255,0.05);
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer !important;
}

/* Layer toggles */
.layer-toggles {
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer !important;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-control input[type="checkbox"] {
  accent-color: #10b981;
  width: 18px;
  height: 18px;
  cursor: pointer !important;
}

.toggle-text {
  user-select: none;
}

/* Heatmap Tooltip overrides */
.client-tooltip {
  background: var(--panel-bg) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
  border: 1px solid var(--panel-border) !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 0.8rem !important;
  font-family: var(--font-sans) !important;
}

/* Client markers */
.client-marker-icon {
  position: relative;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.client-marker-dot {
  width: 10px;
  height: 10px;
  background: #3b82f6;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.8);
}

/* Selected Pin Blinking Animation */
@keyframes blink-animation {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

.selected-blink {
  animation: blink-animation 0.8s infinite ease-in-out !important;
  z-index: 9999 !important; /* Keep selected pin on top */
}

/* Pulse-grow effect on the inner pin content to prevent Leaflet translate conflicts */
.selected-blink .custom-pin {
  animation: pin-pulse-grow 0.8s infinite ease-in-out !important;
}

@keyframes pin-pulse-grow {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.3); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}
