/* Shared variables */
:root {
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #111827;
  --accent: #ef4444;
  --accent-light: #f87171;
  --text-light: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --success: #22c55e;
  --warn: #fbbf24;
  --radius: 0.5rem;
  --transition: 0.2s ease;
}

/* Dark mode is default - explicitly set */
html,
body,
body.dark-mode {
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #111827;
  --text-light: #e2e8f0;
  --text-muted: #94a3b8;
}

/* Light mode override */
body.light-mode {
  --bg-dark: #f5f5f5;
  --bg-panel: #ffffff;
  --bg-panel-alt: #eeeeee;
  --text-light: #1a1a1a;
  --text-muted: #666;
}

/* globals */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
}

.layout { display: flex; height: 100vh; }

/* sidebar */
.sidebar {
  width: 240px;
  background-color: var(--bg-dark);
  display: flex;
  flex-direction: column;
  padding-top: 1.5rem;
  transition: width var(--transition);
  border-right: 1px solid #1e293b;
  z-index: 10;
}
.sidebar.collapsed { width: 80px; }
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 2rem;
  padding: 0 1rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 4px solid transparent;
  transition: all var(--transition);
  font-weight: 500;
  font-size: clamp(0.9rem, 2vw, 0.95rem);
}
.nav-link:hover,
.nav-link.active {
  background-color: var(--bg-panel);
  color: white;
  border-left-color: var(--accent);
}
.logout {
  margin-top: auto;
  margin-bottom: 1.5rem;
  color: var(--accent-light);
  cursor: pointer;
}
.sidebar.collapsed .text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s;
}
.icon {
  font-size: 1.25rem;
  min-width: 1.5rem;
  text-align: center;
}

/* main content */
.main-content {
  flex: 1;
  padding: clamp(1rem, 3vw, 1.5rem);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-alt);
  overflow: hidden;
}
.top-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
#menuToggle {
  background: var(--bg-panel);
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#menuToggle:hover { background: #334155; }
.page-title {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* stats cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-box {
  background: var(--bg-panel);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border-left: 5px solid var(--primary);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: 500;
  text-align: center;
  transition: transform var(--transition);
}
.stat-box:hover { transform: translateY(-2px); }
.stat-box.green { border-left-color: var(--success); }

/* map */
#map-container {
  flex: 1;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-dark);
  border: 1px solid var(--bg-panel);
  min-height: 300px;
}
#map { height: 100%; width: 100%; }
#map-loading {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.125rem;
  z-index: 5;
}

/* popup btn */
.popup-button {
  margin-top: 0.75rem;
  background: #334155;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  text-align: center;
  width: 100%;
  min-height: 36px;
}
.popup-button:hover { background: #475569; }

/* link inside popups for directions */
.popup-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.popup-link:hover { text-decoration: underline; }

/* responsive */
@media (max-width: 767px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--bg-panel);
    overflow-x: auto;
    position: relative;
  }
  .sidebar.collapsed {
    height: 60px;
    width: 100%;
  }
  .sidebar .nav-link,
  .logo,
  .logout { padding: 0.5rem 1rem; font-size: 0.9rem; }
  .sidebar .icon { font-size: 1.4rem; }
  .main-content { padding: 1rem; }
  .stats { grid-template-columns: 1fr; }
  #menuToggle { display: none; }
  .page-title { font-size: 1.25rem; }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 200px; }
  .sidebar.collapsed { width: 72px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
