/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #004B87;
  --primary-light: #0070CC;
  --bg: #f5f6f8;
  --sidebar-width: 320px;
  --topbar-height: 50px;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #dde1e6;
  --radius: 6px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* === Topbar === */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

#topbar h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: 0;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn.active {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.view-btn:hover {
  color: #fff;
}

/* === Layout === */
#app {
  display: flex;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  right: 0;
}

/* === Sidebar === */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Select all / deselect all */
.select-all-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.select-all-row button {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.select-all-row button:hover {
  background: var(--bg);
  color: var(--text);
}

/* Minister checkboxes */
#minister-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
}

.minister-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.minister-item:hover {
  background: var(--bg);
}

.minister-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.minister-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.minister-name {
  font-size: 13px;
  line-height: 1.3;
}

.minister-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* Date slider */
#date-slider {
  margin: 10px 8px 6px;
}

#date-range-label {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* noUiSlider overrides */
.noUi-connect {
  background: var(--primary) !important;
}

.noUi-handle {
  border-color: var(--primary) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

.noUi-tooltip {
  font-size: 11px !important;
  padding: 2px 6px !important;
}

/* Counter */
#counter {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

#counter strong {
  color: var(--primary);
  font-size: 18px;
}

/* === Map === */
#map {
  flex: 1;
  z-index: 1;
}

/* Custom popup */
.travel-popup {
  max-width: 300px;
  max-height: 250px;
  overflow-y: auto;
}

.travel-popup h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 4px;
}

.travel-popup-entry {
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

.travel-popup-entry:last-child {
  border-bottom: none;
}

.travel-popup-entry .minister {
  font-weight: 600;
  font-size: 13px;
}

.travel-popup-entry .title {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0;
}

.travel-popup-entry .date {
  font-size: 12px;
  color: var(--text-muted);
}

.travel-popup-entry a {
  color: var(--primary-light);
  font-size: 12px;
  text-decoration: none;
}

.travel-popup-entry a:hover {
  text-decoration: underline;
}

/* Custom circle markers */
.leaflet-marker-icon.circle-marker {
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Loading state */
#app.loading #map::after {
  content: 'Laddar data...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  color: var(--text-muted);
  z-index: 500;
}

/* === Mobile === */
@media (max-width: 768px) {
  #sidebar-toggle {
    display: block;
  }

  #sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #map {
    width: 100%;
  }

  #topbar h1 {
    font-size: 14px;
  }
}
