/* ==========================================================================
   Drive Time Map Tool - Tool-Specific Styles
   Only styles unique to this tool
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tool Container Layout
   -------------------------------------------------------------------------- */
.tool-container {
  display: flex;
  min-height: 800px;
  background-color: var(--bg);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.tool-sidebar {
  width: 380px;
  background-color: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.sidebar-content {
  padding: 20px;
}

.sidebar-content label {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-muted);
  display: block;
}

.tool-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tool-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.tool-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Measurement panels (Drive Time / Radius) toggle visibility */
.measure-panel.hidden {
  display: none;
}

/* --------------------------------------------------------------------------
   Search Suggestions
   -------------------------------------------------------------------------- */
.suggestions {
  position: relative;
  background-color: var(--card);
  border: 1px solid var(--border);
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  display: none;
  box-shadow: var(--shadow);
}

.suggestions.show {
  display: block;
}

.suggestions .item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background-color 0.2s ease;
}

.suggestions .item:last-child {
  border-bottom: none;
}

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

/* --------------------------------------------------------------------------
   Segmented Toggles (Mode / Measurement Type / Radius Unit)
   -------------------------------------------------------------------------- */
.seg-toggle {
  display: flex;
  gap: 0;
  margin: 4px 0 0;
  background-color: var(--hover-bg);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.seg-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Big Value Display (minutes / radius)
   -------------------------------------------------------------------------- */
.big-display {
  text-align: center;
  padding: 20px;
  margin: 16px 0;
  background-color: var(--glass);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.big-display span:first-child {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
}

.big-display-unit {
  font-size: 16px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* --------------------------------------------------------------------------
   Notes & Results
   -------------------------------------------------------------------------- */
.field-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 0 0;
  line-height: 1.5;
}

.area-note {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 10px 0 0;
  min-height: 1.2em;
}

/* --------------------------------------------------------------------------
   Button Groups
   -------------------------------------------------------------------------- */
.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Postcodes Section (count summary + CSV download)
   -------------------------------------------------------------------------- */
.postcode-section {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.02));
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 24px;
}

.postcode-section h3 {
  margin-bottom: 12px;
}

.postcode-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.postcode-count strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.postcode-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

.postcode-unavailable {
  color: var(--text-muted);
  font-style: italic;
}

.postcode-section .field-note {
  margin-top: 8px;
}

.postcode-section .field-note.hidden {
  display: none;
}

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

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

#map .leaflet-container {
  width: 100% !important;
  height: 100% !important;
}

/* --------------------------------------------------------------------------
   Map Legend Control
   -------------------------------------------------------------------------- */
.map-legend {
  background: var(--glass);
  backdrop-filter: blur(12px);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  max-width: 250px;
  line-height: 1.5;
}

.map-legend strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.map-legend .legend-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Print-only Header (hidden on screen)
   -------------------------------------------------------------------------- */
.print-only {
  display: none;
}

/* --------------------------------------------------------------------------
   Mobile FAB (Floating Action Button)
   -------------------------------------------------------------------------- */
.fab {
  display: none;
  width: 56px;
  height: 56px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 9999;
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .tool-container {
    flex-direction: column;
    height: calc(100vh - 250px);
  }

  .tool-sidebar {
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    transition: max-height 0.3s ease;
  }

  .tool-sidebar.collapsed {
    max-height: 0;
    overflow: hidden;
  }

  .map-container {
    max-height: calc(100vh - 120px);
    flex: 1;
  }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 600px) {
  .sidebar-content {
    padding: 16px;
  }

  .tool-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
  }

  .big-display span:first-child {
    font-size: 28px;
  }

  .big-display-unit {
    font-size: 14px;
  }

  .map-container {
    max-height: calc(100vh - 120px);
    min-height: 400px;
  }
}

/* --------------------------------------------------------------------------
   Print Styles - clean printable map (also a Save-as-PDF fallback)
   -------------------------------------------------------------------------- */
@media print {
  @page {
    size: A4 landscape;
    margin: 1cm;
  }

  /* Hide site chrome (header, footer, ads, cookie banner) and the SEO content */
  body > *:not(main) {
    display: none !important;
  }

  main > *:not(.tool-container) {
    display: none !important;
  }

  /* Hide the sidebar, map controls and on-screen legend */
  .tool-sidebar,
  #fabSettings,
  .map-fullscreen-btn,
  #toast,
  .leaflet-control-zoom,
  .leaflet-control-attribution,
  .map-legend {
    display: none !important;
  }

  .tool-container {
    display: block !important;
    min-height: 0 !important;
  }

  .map-container {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  /* Live map default: keep the previous 16cm print size so the no-isochrone
     edge case still prints the on-screen map. The .printing-captured class
     below replaces it with the baked image once we have one. */
  #map {
    width: 100% !important;
    height: 16cm !important;
  }

  body.printing-captured #map {
    display: none !important;
  }

  /* Print-only elements (title block + captured map image) */
  .print-only {
    display: block !important;
  }

  .print-image {
    max-width: 100%;
    max-height: 17cm;
    width: auto;
    height: auto;
    margin: 0 auto;
  }

  .print-header {
    margin-bottom: 0.35cm;
    color: #000;
  }

  .print-header strong {
    display: block;
    font-size: 16pt;
  }

  .print-header span {
    display: block;
    font-size: 9pt;
    color: #444;
    margin-top: 2px;
  }
}
