/* ============================================
   Summer Holiday Activities Map — Styles
   Mobile-first, warm & family-friendly
   ============================================ */

:root {
  --primary: #e8723a;
  --primary-light: #f5a67b;
  --primary-dark: #c45a28;
  --secondary: #5bb5a6;
  --secondary-light: #8ed4c8;
  --accent: #f0c040;
  --accent-light: #fce08a;
  --bg: #faf6f0;
  --bg-warm: #f5ede3;
  --sidebar-bg: #ffffff;
  --text: #2d2a26;
  --text-light: #6b6560;
  --text-muted: #9e9590;
  --border: #e8e0d8;
  --shadow: 0 2px 12px rgba(45, 42, 38, 0.08);
  --shadow-lg: 0 4px 24px rgba(45, 42, 38, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;

  /* Category colours */
  --cat-park: #4caf50;
  --cat-museum: #8d6e63;
  --cat-theatre: #ab47bc;
  --cat-workshop: #ff7043;
  --cat-swimming: #29b6f6;
  --cat-cinema: #5c6bc0;
  --cat-farm: #8bc34a;
  --cat-adventure: #ff5722;
  --cat-library: #7986cb;
  --cat-event: #e91e63;
  --cat-softplay: #26a69a;
  --cat-sports: #66bb6a;
  --cat-beach: #ffd54f;
  --cat-woodland: #2e7d32;
  --cat-railway: #78909c;
  --cat-themepark: #d81b60;
  --cat-water: #00bcd4;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
}

/* ---- Mobile header ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  height: 52px;
}

.mobile-title {
  font-size: 16px;
  font-weight: 700;
}

.sidebar-toggle,
.view-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover,
.view-toggle:hover {
  background: rgba(255,255,255,0.15);
}

/* ---- App container ---- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 340px;
  min-width: 340px;
  max-width: 340px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 20px 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  position: relative;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 4px;
}

.sidebar-subtitle {
  font-size: 13px;
  opacity: 0.85;
  font-weight: 400;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.8;
}
.sidebar-close:hover { opacity: 1; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Filter sections ---- */
.filter-section {
  margin-bottom: 20px;
}

.filter-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 8px;
}

/* ---- Search ---- */
.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  transition: border-color var(--transition);
  outline: none;
}
.search-input:focus {
  border-color: var(--primary);
  background: white;
}
.search-input::placeholder {
  color: var(--text-muted);
}

/* ---- Date slider ---- */
.date-slider {
  margin: 8px 4px 20px;
}

.date-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
  margin-top: -4px;
}

/* NoUiSlider overrides */
.noUi-target {
  background: var(--border);
  border: none;
  border-radius: 4px;
  height: 8px !important;
  box-shadow: none;
}
.noUi-connect {
  background: var(--primary);
  border-radius: 4px;
}
.noUi-horizontal .noUi-handle {
  width: 22px !important;
  height: 22px !important;
  top: -8px !important;
  right: -11px !important;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: grab;
}
.noUi-horizontal .noUi-handle::before,
.noUi-horizontal .noUi-handle::after {
  display: none;
}
.noUi-handle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.noUi-tooltip {
  background: var(--text);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 6px;
  border: none;
}

/* ---- Toggle buttons ---- */
.toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-btn {
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
  white-space: nowrap;
}
.toggle-btn:hover {
  border-color: var(--primary-light);
  color: var(--text);
}
.toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---- Category grid ---- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
  white-space: nowrap;
}
.cat-btn .cat-emoji {
  font-size: 16px;
  flex-shrink: 0;
}
.cat-btn:hover {
  border-color: var(--primary-light);
  color: var(--text);
}
.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---- Share / Reset buttons ---- */
.share-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-btn,
.reset-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.share-btn {
  background: var(--secondary);
  color: white;
  border: none;
}
.share-btn:hover {
  background: var(--secondary-light);
  color: var(--text);
}
.reset-btn {
  background: white;
  color: var(--text-light);
  border: 2px solid var(--border);
}
.reset-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ---- Results count ---- */
.results-count {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  padding: 12px 0 4px;
}

/* ---- Map ---- */
.map-container {
  flex: 1;
  height: 100vh;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* ---- Leaflet popup overrides ---- */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0 !important;
  min-width: 240px;
  max-width: 300px !important;
}
.leaflet-popup-tip {
  box-shadow: var(--shadow) !important;
}

/* Popup card */
.popup-card {
  padding: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.popup-card-header {
  padding: 12px 14px 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.popup-card-header .popup-category {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 2px;
}
.popup-card-header .popup-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}
.popup-card-body {
  padding: 10px 14px 12px;
}
.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.popup-badge.free {
  background: #e8f5e9;
  color: #2e7d32;
}
.popup-badge.mixed {
  background: #fff8e1;
  color: #f57f17;
}
.popup-badge.paid {
  background: #fce4ec;
  color: #c62828;
}
.popup-badge.rainy {
  background: #e3f2fd;
  color: #1565c0;
}
.popup-detail {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
  line-height: 1.45;
}
.popup-detail strong {
  color: var(--text);
}
.popup-description {
  font-size: 13px;
  color: var(--text);
  margin: 6px 0;
  line-height: 1.5;
}
.popup-links {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition);
}
.popup-link.primary {
  background: var(--primary);
  color: white;
}
.popup-link.primary:hover {
  background: var(--primary-dark);
}
.popup-link.secondary {
  background: var(--bg);
  color: var(--text-light);
}
.popup-link.secondary:hover {
  background: var(--border);
  color: var(--text);
}

/* ---- List view ---- */
.list-container {
  flex: 1;
  height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.list-container.hidden {
  display: none;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.list-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.list-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  background: #fef0e6;
  padding: 2px 10px;
  border-radius: 12px;
}

.list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.list-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}
.list-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.list-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.list-card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.list-card-area {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.list-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.list-card-desc {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 4px;
}
.list-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.list-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ---- Custom map markers ---- */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 16px;
}
.custom-marker-inner {
  transform: rotate(45deg);
  line-height: 1;
}

/* Marker cluster overrides */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(232, 114, 58, 0.25) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--primary) !important;
  color: white !important;
  font-weight: 800 !important;
  font-size: 13px !important;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .app-container {
    padding-top: 52px;
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 85vw;
    max-width: 340px;
    min-width: 280px;
    height: auto;
    transform: translateX(-100%);
    z-index: 900;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 899;
  }
  .sidebar-overlay.visible {
    display: block;
  }

  .map-container,
  .list-container {
    height: calc(100vh - 52px);
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

@media (max-width: 400px) {
  .sidebar {
    width: 92vw;
  }
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
  .toggle-group {
    gap: 4px;
  }
  .toggle-btn {
    padding: 5px 8px;
    font-size: 12px;
  }
}

/* ---- Print ---- */
@media print {
  .sidebar,
  .mobile-header,
  .share-section {
    display: none !important;
  }
  .map-container {
    width: 100% !important;
    height: 100vh !important;
  }
  .leaflet-control-container {
    display: none;
  }
  .list-container {
    display: flex !important;
    height: auto !important;
  }
  .list-scroll {
    overflow: visible !important;
    height: auto !important;
  }
  .list-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  body {
    overflow: visible !important;
  }
}

/* ---- Scrollbar for sidebar ---- */
@media (hover: hover) {
  .sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* ---- Toast notification ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
}

/* ---- Loading state ---- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 246, 240, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}