:root {
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(15, 23, 42, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* SacRT Theme Colors */
  --sacrt-blue: #004b87;
  --sacrt-blue-glow: rgba(0, 75, 135, 0.4);
  --sacrt-gold: #f2a900;
  --sacrt-gold-glow: rgba(242, 169, 0, 0.45);
  --sacrt-gold-neon: #ffc82c;
  
  --sidebar-width: 380px;
  --glass-bg: rgba(11, 15, 25, 0.82);
  --glass-blur: blur(20px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  position: relative;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.app-logo {
  max-width: 100%;
  height: auto;
  max-height: 160px;
  filter: drop-shadow(0 0 12px rgba(242, 169, 0, 0.25));
  transition: filter 0.3s ease;
}

.app-logo:hover {
  filter: drop-shadow(0 0 20px rgba(242, 169, 0, 0.4));
}

/* Stats Panel */
.stats-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 24px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--sacrt-gold-glow);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--sacrt-gold-neon);
  text-shadow: 0 0 10px var(--sacrt-gold-glow);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search Box */
.search-box {
  margin: 0 24px 16px 24px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--sacrt-gold);
  box-shadow: 0 0 0 3px var(--sacrt-gold-glow);
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.clear-btn:hover {
  color: var(--text-primary);
}

/* Control Actions */
.control-actions {
  display: flex;
  gap: 10px;
  margin: 0 24px 20px 24px;
}

.action-btn {
  flex: 1;
  padding: 10px;
  background: rgba(0, 75, 135, 0.15);
  border: 1px solid rgba(0, 75, 135, 0.4);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--sacrt-blue);
  box-shadow: 0 0 12px var(--sacrt-blue-glow);
  border-color: var(--sacrt-blue);
}

.action-btn:active {
  transform: scale(0.97);
}

/* Route List */
.route-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px 24px;
  display: flex;
  flex-direction: column;
}

.route-list-container h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  border-left: 3px solid var(--sacrt-gold);
  padding-left: 8px;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 0;
}

.route-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.route-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.route-item.active-filter {
  background: rgba(242, 169, 0, 0.08);
  border-color: var(--sacrt-gold);
}

.route-badge {
  min-width: 44px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-right: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.route-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.route-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.route-desc {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.route-toggle {
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px;
  transition: color 0.2s;
}

.route-item:hover .route-toggle {
  color: var(--text-primary);
}

/* Sidebar Scrollbar */
.route-list-container::-webkit-scrollbar {
  width: 6px;
}

.route-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.route-list-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.route-list-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

.footer-sub {
  margin-top: 4px;
  font-weight: 300;
}

/* Map Container */
.map-container {
  flex: 1;
  height: 100%;
  background-color: #1a1e2a;
  z-index: 1;
}

/* Live Indicator Overlay */
.live-indicator-overlay {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 999;
  pointer-events: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-ring 2s infinite ease-in-out;
}

.live-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

#last-updated {
  color: var(--sacrt-gold);
  font-weight: 600;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Custom Bus Marker on Map */
.bus-marker-icon {
  background: none;
  border: none;
}

.bus-marker-wrapper {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sacrt-gold);
  border: 2px solid #ffffff;
  box-shadow: 0 0 15px var(--sacrt-gold-glow), inset 0 2px 4px rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.4s ease;
  cursor: pointer;
}

.bus-marker-icon-glow {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0f19;
  font-size: 15px;
}

.bus-marker-heading {
  position: absolute;
  top: -8px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 9px solid var(--sacrt-gold-neon);
  filter: drop-shadow(0 -2px 3px rgba(0,0,0,0.3));
}

.bus-marker-route {
  position: absolute;
  bottom: -6px;
  background: #0b0f19;
  color: #ffffff;
  border: 1px solid var(--sacrt-gold);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* Selected Bus Styling */
.bus-marker-wrapper.selected {
  background: #ff3b30;
  border-color: #ffffff;
  box-shadow: 0 0 25px rgba(255, 59, 48, 0.8);
  transform: scale(1.15);
}

.bus-marker-wrapper.selected .bus-marker-heading {
  border-bottom-color: #ff3b30;
}

.bus-marker-wrapper.selected .bus-marker-route {
  border-color: #ff3b30;
}

/* Custom Leaflet Popups */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  color: var(--text-primary) !important;
  border-radius: 14px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
  padding: 4px;
}

.leaflet-popup-tip {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color);
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  font-family: 'Outfit', sans-serif !important;
  line-height: 1.4;
}

.popup-bus-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.popup-route-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.popup-bus-title {
  font-size: 14px;
  font-weight: 700;
}

.popup-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.popup-label {
  color: var(--text-secondary);
}

.popup-val {
  font-weight: 500;
  color: var(--text-primary);
}

/* Leaflet Zoom Control Styling */
.leaflet-bar {
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.leaflet-bar a {
  background-color: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur);
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  transition: all 0.2s;
}

.leaflet-bar a:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Mobile Sidebar Toggle Button */
.mobile-sidebar-toggle {
  display: none;
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1001;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .mobile-sidebar-toggle {
    display: flex;
  }
  
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .live-indicator-overlay {
    bottom: auto;
    top: 20px;
    right: 20px;
  }
}
