/* School Finder Styles */

/* Tool Container */
.tool-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
}

@media (min-width: 768px) {
  .tool-container {
    flex-direction: row;
  }
}

/* Sidebar */
.tool-sidebar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  max-height: 35vh;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .tool-sidebar {
    width: 360px;
    min-width: 360px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
}

.sidebar-content {
  padding: 1rem;
}

.tool-section {
  background: var(--card);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.tool-section h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem 0;
  color: var(--text);
}

/* Form Elements */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

input[type="text"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg);
  color: var(--text);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-with-suggestions {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--hover-bg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--text-muted);
  color: white;
}

.btn-secondary:hover {
  opacity: 0.9;
}

.btn-icon {
  font-size: 1.1rem;
}

.divider {
  display: flex;
  align-items: center;
  margin: 0.75rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 0 0.75rem;
}

/* Filter Pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.filter-pill {
  padding: 0.35rem 0.75rem;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}

.filter-pill:hover {
  background: var(--border);
}

.filter-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Results Summary */
.results-summary {
  display: flex;
  gap: 1rem;
  justify-content: space-around;
}

.summary-stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Results List */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.school-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}

.school-card:hover {
  background: var(--hover-bg);
}

.school-card.selected {
  border-color: var(--primary);
  background: var(--hover-bg);
}

.school-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.school-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.2;
}

.school-distance-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  background: var(--accent);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
}

.school-card-subheader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.school-address {
  color: var(--text);
}

.school-walk {
  color: var(--text-muted);
}

.school-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text);
}

.school-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.ofsted-indicators {
  display: flex;
  gap: 3px;
}

.ofsted-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.school-stat {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.school-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.4rem;
  background: var(--card);
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text);
}

.school-badge.primary {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--primary);
}

.school-badge.secondary {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.school-badge.ofsted-outstanding {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.school-badge.ofsted-good {
  background: var(--text-muted);
  color: white;
  border-color: var(--text-muted);
}

.school-badge.ofsted-ri {
  background: var(--warning);
  color: #212529;
  border-color: var(--warning);
}

.school-badge.ofsted-inadequate {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.school-badge.ofsted-inspected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  text-decoration: none;
}

a.school-badge.ofsted-inspected:hover {
  opacity: 0.9;
}

/* Ofsted grade colors for perf-value */
.perf-value.ofsted-outstanding,
.perf-value.ofsted-good,
.perf-value.ofsted-ri,
.perf-value.ofsted-inadequate {
  font-size: 0.85rem;
}

.perf-value.ofsted-outstanding {
  color: var(--success);
}

.perf-value.ofsted-good {
  color: var(--text);
}

.perf-value.ofsted-ri {
  color: var(--warning);
}

.perf-value.ofsted-inadequate {
  color: var(--danger);
}

.perf-stat-wide {
  grid-column: 1 / -1;
}

/* Map Container */
.map-container {
  max-height: calc(100vh - 120px);
  flex: 1;
  position: relative;
  min-height: 500px;
}

.map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.fab {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card);
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* Loading */
.loading-indicator {
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Map Popup - Note: Leaflet popups don't inherit CSS vars well, using safe fallbacks */
.school-popup {
  min-width: 250px;
}

.school-popup h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #2563eb;
}

.school-popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.school-popup-details {
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 0.5rem;
}

.school-popup-details p {
  margin: 0.25rem 0;
}

.school-popup-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.school-popup-links a {
  font-size: 0.8rem;
  color: #2563eb;
  text-decoration: none;
}

.school-popup-links a:hover {
  text-decoration: underline;
}

/* Performance Data in Popup */
.school-popup-performance {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 0.6rem;
  margin: 0.5rem 0;
}

.perf-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.perf-stat {
  text-align: center;
  background: white;
  border-radius: 4px;
  padding: 0.4rem;
}

.perf-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
}

.perf-value.perf-positive {
  color: #10b981;
}

.perf-value.perf-negative {
  color: #ef4444;
}

.perf-label {
  display: block;
  font-size: 0.65rem;
  color: #6b7280;
  line-height: 1.2;
}

.perf-above {
  display: block;
  font-size: 0.6rem;
  color: #10b981;
  font-weight: 600;
  margin-top: 2px;
}

.perf-below {
  display: block;
  font-size: 0.6rem;
  color: #ef4444;
  font-weight: 600;
  margin-top: 2px;
}

.perf-avg {
  display: block;
  font-size: 0.6rem;
  color: #6b7280;
  margin-top: 2px;
}

/* SEO Content */
.seo-content {
  background: var(--bg-secondary);
  padding: 2rem 1rem;
}

.seo-inner {
  max-width: 800px;
  margin: 0 auto;
}

.content-section {
  margin-bottom: 1.5rem;
}

.content-section h2 {
  font-size: 1.25rem;
  color: var(--text);
  margin: 0 0 0.5rem 0;
}

.content-section p {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 0.5rem 0;
}

.content-section a {
  color: var(--primary);
}

.city-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.city-links a {
  padding: 0.35rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.city-links a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Data Note */
.data-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.data-note a {
  color: var(--primary);
}

/* Leaflet Overrides */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.leaflet-popup-content {
  margin: 12px;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(37, 99, 235, 0.6);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(37, 99, 235, 0.9);
  color: white;
}

/* Custom school markers */
.school-marker {
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.school-marker.primary {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.15);
}

.school-marker.secondary {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
}

/* City Page Styles */
.city-stats-section .city-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.city-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.city-stats .stat-row:last-child {
  border-bottom: none;
}

.city-stats .stat-label {
  font-size: 0.85rem;
  color: var(--text);
}

.city-stats .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.breadcrumb {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: underline;
}

.breadcrumb a:hover {
  opacity: 0.8;
}

/* School list in SEO content */
.school-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.school-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.school-list-item .school-name {
  font-weight: 500;
  color: var(--text);
}

.school-list-item .school-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.school-list-item .school-badges {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}
