/* ==========================================================================
   Route Optimiser Tool (AU) - Tool-Specific Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tool Container Layout - capped-sidebar pattern (grid-correct): .tool-sidebar
   and .map-container get the SAME literal pixel value on height/max-height,
   sidebar additionally needs min-height: 0 as a grid child for the cap to
   engage. Do not set display/max-height on .tool-container itself - global.css
   already sets it to grid, and redeclaring flex here is exactly the mismatch
   that broke dark-sky-finder-au's sidebar (see that CLAUDE.md/compliance-audit
   incident write-up). No height set here at all deliberately.
   -------------------------------------------------------------------------- */

.tool-sidebar {
  max-height: 650px;
  min-height: 0;
  overflow-y: auto;
}

.map-container {
  height: 650px;
}

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

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

/* --------------------------------------------------------------------------
   Tool Info Box
   -------------------------------------------------------------------------- */
.tool-info {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.tool-item {
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
}

/* Verbatim G-NAF/Overture attribution block (au-address-cook/PROVENANCE.md)
   - same card look as .tool-info, kept as its own class since the markup
   is copied verbatim per the EULA rather than rebuilt with this page's
   own class names. */
.data-attribution {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.data-attribution p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 10px;
}

.data-attribution p:last-child {
  margin-bottom: 0;
}

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

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

/* --------------------------------------------------------------------------
   Results Box
   -------------------------------------------------------------------------- */
.results-box {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
  min-height: 60px;
  font-size: 13px;
  line-height: 1.6;
}

.results-box:empty::before {
  content: "Results will appear here...";
  color: var(--text-muted);
  font-style: italic;
}

.results-box strong {
  color: var(--primary);
}

.results-box ol {
  margin: 8px 0;
  padding-left: 20px;
}

.results-box li {
  padding: 4px 0;
}

/* --------------------------------------------------------------------------
   Demo Section
   -------------------------------------------------------------------------- */
.demo-section {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.demo-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

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

/* --------------------------------------------------------------------------
   Postcode Suggestions Dropdown
   -------------------------------------------------------------------------- */
.input-with-suggestions {
  position: relative;
}

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

.suggestions.show {
  display: block;
}

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

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

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

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

/* --------------------------------------------------------------------------
   Address Autocomplete (appears once a postcode with an address shard is
   entered; hidden by default so a postcode with no shard degrades to
   today's postcode-only behaviour with no empty/dead field on screen)
   -------------------------------------------------------------------------- */
.address-field {
  display: none;
  margin-top: 8px;
}

.address-field.show {
  display: block;
}

.suggestions .item .item-sub {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
}

/* --------------------------------------------------------------------------
   CSV Upload (Stops section) - pattern ported from .uk's Pro route planner,
   free here per the build brief: no row cap, no template gating.
   -------------------------------------------------------------------------- */
.csv-upload-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-muted);
  font-size: 12px;
}

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

.csv-drop-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.csv-drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--hover-bg);
}

.csv-loaded-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
}

.csv-chip-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.csv-chip-clear:hover {
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Modal (column-mapping dialog) - same overlay/animation pattern as
   elevation-finder.css's share modal, with a wider variant for the
   mapping table.
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-wide {
  max-width: 560px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
}

.modal-close:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.csv-mapping-table-wrap {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.csv-mapping-table {
  width: 100%;
  border-collapse: collapse;
}

.csv-mapping-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.csv-mapping-table tr:last-child td {
  border-bottom: none;
}

.csv-mapping-table select {
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}

.csv-mapping-error {
  color: #ef4444;
  font-size: 12px;
  margin: 10px 0 0;
  min-height: 14px;
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .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;
  }

  .map-container {
    height: 500px;
    min-height: 400px;
  }

  .map {
    min-height: 400px;
    height: 500px;
  }

  .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;
  }

  .map-container {
    height: 400px;
    min-height: 350px;
  }

  .map {
    min-height: 350px;
    height: 400px;
  }
}
