/* Design System Tokens */
:root {
  --primary: #097138; /* Deep Forest Green */
  --primary-hover: #064d26;
  --primary-light: #eff7f2;
  --accent: #4CAF50; /* Vibrant Grass Green */
  
  --text-dark: #231f20; /* Charcoal Dark */
  --text-medium: #4a4a4a;
  --text-muted: #718096;
  --text-white: #ffffff;
  
  --bg-app: #f7fafc;
  --bg-sidebar: #ffffff;
  --border: #e2e8f0;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 4px 6px -1px rgba(9, 113, 56, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(9, 113, 56, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  
  --font-sans: 'Nunito', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-round: 9999px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body, html {
  height: 100%;
  width: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-dark);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 380px;
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 4px 0 24px rgba(9, 113, 56, 0.03);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: var(--text-white);
  border-bottom: 4px solid var(--accent);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title i {
  font-size: 1.8rem;
  color: #a3e635; /* Light lime accent */
}

.brand-title h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-filter-section {
  padding: 20px 20px 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

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

#search-input {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background-color: var(--bg-app);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  transition: all var(--transition-fast);
}

#search-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-sidebar);
  box-shadow: 0 0 0 4px rgba(9, 113, 56, 0.1);
}

.clear-search-btn {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast);
}

.clear-search-btn:hover {
  background-color: var(--border);
  color: var(--text-dark);
}

/* Town Filters */
.town-filter-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.town-filter-container label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.town-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.town-chips::-webkit-scrollbar {
  height: 4px;
}

.town-chips::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-round);
}

.chip {
  padding: 6px 14px;
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.chip:hover {
  background-color: var(--border);
  color: var(--text-dark);
}

.chip.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
  box-shadow: 0 2px 6px rgba(9, 113, 56, 0.2);
}

/* Results Info */
.results-count {
  padding: 12px 24px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background-color: var(--bg-app);
  border-bottom: 1px solid var(--border);
}

/* School List scroll area */
.schools-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}

.schools-list::-webkit-scrollbar {
  width: 6px;
}

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

.schools-list::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: var(--radius-round);
}

.schools-list::-webkit-scrollbar-thumb:hover {
  background: a0aec0;
}

/* School Item Card */
.school-item {
  padding: 16px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.school-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background-color: var(--primary-light);
}

.school-item.active {
  border-color: var(--primary);
  border-left: 4px solid var(--primary);
  background-color: var(--primary-light);
}

.school-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
}

.school-item .school-town {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.school-item .school-address {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 2px;
}

.school-item .school-address i {
  margin-top: 2px;
}

/* Map Area styling */
.map-area {
  flex: 1;
  height: 100%;
  position: relative;
}

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

/* Custom Leaflet Marker Style */
.custom-marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  background: var(--primary);
  transform: rotate(-45deg);
  box-shadow: -1px 3px 5px rgba(0, 0, 0, 0.35);
  border: 2px solid var(--text-white);
  transition: all var(--transition-fast);
}

.custom-marker-pin::after {
  content: '';
  width: 12px;
  height: 12px;
  margin: 8px 0 0 8px;
  background: var(--text-white);
  position: absolute;
  border-radius: 50%;
}

.custom-marker-pin.active {
  background: var(--accent);
  transform: rotate(-45deg) scale(1.2);
  z-index: 1000 !important;
}

/* Leaflet Popup Styling Override */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  font-family: var(--font-sans);
  margin: 12px 14px;
}

.leaflet-popup-content h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.leaflet-popup-content p {
  font-size: 0.85rem;
  color: var(--text-medium);
  margin-bottom: 10px;
}

.leaflet-popup-tip {
  box-shadow: var(--shadow-md);
}

/* Detail Card Overlay on Map */
.detail-card-overlay {
  position: absolute;
  bottom: 24px;
  left: 24px;
  right: 24px;
  z-index: 1000;
  display: none;
  pointer-events: none; /* Let clicks pass through outside the card */
}

.detail-card {
  width: 100%;
  max-width: 450px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px -5px rgba(9, 113, 56, 0.15), 0 4px 12px -2px rgba(0, 0, 0, 0.1);
  padding: 24px;
  position: relative;
  pointer-events: auto; /* Enable clicks inside card */
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.detail-card.show {
  transform: translateY(0);
  opacity: 1;
}

.close-card-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--primary-light);
  border: none;
  color: var(--primary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.close-card-btn:hover {
  background-color: var(--primary);
  color: var(--text-white);
}

.card-town {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-block;
  margin-bottom: 8px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 12px;
  line-height: 1.3;
}

.card-info-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-medium);
  margin-bottom: 20px;
}

.card-info-item i {
  color: var(--primary);
  margin-top: 3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-white);
  border: 1px solid var(--primary);
  box-shadow: 0 4px 12px rgba(9, 113, 56, 0.15);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(9, 113, 56, 0.25);
}

/* Mobile View Switching Elements */
.mobile-view-toggle {
  display: none;
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  background-color: var(--primary);
  color: var(--text-white);
  border: none;
  border-radius: var(--radius-round);
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.mobile-view-toggle:hover {
  background-color: var(--primary-hover);
  transform: translateX(-50%) translateY(-1px);
}

/* Responsive Sizing (e.g., inside Narrow Containers or Mobile Screen) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(0);
    transition: transform var(--transition-normal);
  }
  
  .map-area {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
  }
  
  .app-container.show-map .sidebar {
    transform: translateX(-100%);
  }
  
  .app-container.show-list .map-area {
    visibility: hidden;
  }
  
  .mobile-view-toggle {
    display: inline-flex;
  }
  
  .detail-card-overlay {
    bottom: 84px; /* Move above toggle button */
    left: 12px;
    right: 12px;
  }
  
  .detail-card {
    max-width: 100%;
  }
}
