/* ==========================================================================
   Measure Distance Tool - Tool-Specific Styles
   Matching other MapTools.uk tool layouts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tool Container Layout
   -------------------------------------------------------------------------- */
.tool-container {
  display: flex;
  max-height: 700px;
  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 {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

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

/* --------------------------------------------------------------------------
   Instructions Section
   -------------------------------------------------------------------------- */
.instructions-section {
  background: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px !important;
  margin-bottom: 20px !important;
  border: 1px solid var(--border);
  text-align: center;
}

.instructions-text {
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Results Box
   -------------------------------------------------------------------------- */
.results-box {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border);
}

.distance-display {
  text-align: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.distance-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.distance-unit {
  font-size: 1rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.stats-row {
  display: flex;
  justify-content: space-around;
}

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

.stat-item .stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-item .stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Unit Toggle
   -------------------------------------------------------------------------- */
.unit-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-btn {
  flex: 1 1 calc(33.333% - 6px);
  min-width: 90px;
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

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

/* --------------------------------------------------------------------------
   Transport Modes
   -------------------------------------------------------------------------- */
.transport-modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.transport-btn {
  padding: 10px 8px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.transport-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

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

.travel-result {
  background: var(--glass);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.travel-time {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success);
}

.travel-speed {
  font-size: 13px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Layer Toggle (Street/Satellite)
   -------------------------------------------------------------------------- */
.layer-toggle {
  display: flex;
  gap: 8px;
}

.layer-btn {
  flex: 1;
  padding: 10px 16px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.layer-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

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

/* --------------------------------------------------------------------------
   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;
}

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

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

/* --------------------------------------------------------------------------
   Points List
   -------------------------------------------------------------------------- */
.points-badge {
  background: var(--glass);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: auto;
}

.points-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.points-list:empty::before {
  content: "No points added yet";
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.point-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.point-number {
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.point-number.end {
  background: var(--success);
}

.point-info {
  flex: 1;
  min-width: 0;
}

.point-coords {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 11px;
}

.point-distance {
  font-weight: 500;
  color: var(--primary);
}

.point-bearing {
  font-size: 11px;
  color: var(--text-muted);
}

.point-delete {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.2s ease;
}

.point-delete:hover {
  background: var(--danger);
  color: white;
}

/* --------------------------------------------------------------------------
   Map Container
   -------------------------------------------------------------------------- */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  max-height: 700px;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

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

/* --------------------------------------------------------------------------
   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;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.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-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

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

.modal-body label:first-child {
  margin-top: 0;
}

.share-url-group {
  display: flex;
  gap: 8px;
}

.share-url-group input {
  flex: 1;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.export-buttons {
  display: flex;
  gap: 8px;
}

.export-buttons .btn {
  flex: 1;
}

/* --------------------------------------------------------------------------
   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);
}

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

  .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 {
    flex: none;
    height: 500px;
    min-height: 400px;
    max-height: 500px;
  }

  .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;
    max-height: 450px;
  }

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

  .transport-modes {
    grid-template-columns: repeat(2, 1fr);
  }

  .unit-toggle {
    gap: 6px;
  }

  .unit-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 80px;
    padding: 8px 10px;
    font-size: 12px;
  }
}
