/* ==========================================================================
   Distance Between Canadian Postal Codes - Tool-Specific Styles
   Base layout copied from ca-postcode-mapper.css (same !important
   override reasoning: global.css's .tool-container grid loads after
   this file and wins on equal specificity without it).
   ========================================================================== */

.tool-container {
  display: flex !important;
  height: 700px !important;
  max-height: 700px !important;
  overflow: hidden !important;
  background-color: var(--bg);
}

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

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

.sidebar-content {
  padding: 20px;
}

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

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

.tool-section h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
}

.mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.mode-tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.mode-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

#postcodeA,
#postcodeB,
#matrixInput {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

#matrixInput {
  min-height: 140px;
  resize: vertical;
}

.pair-swap-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
}

.pair-swap-row button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 8px;
}

/* Result boxes sit directly under the button that produced them, not
   pushed down the sidebar - the estate's own "a control that asks a
   question sits where the eye already is" finding. */
.pair-result {
  margin-top: 12px;
  min-height: 20px;
  font-size: 13px;
  line-height: 1.6;
}

.pair-distance {
  color: var(--text);
  margin: 0;
}

.pair-failed {
  color: var(--text-muted);
  margin: 0 0 4px;
}

.pair-failed.fetch-error {
  color: var(--danger);
  font-weight: 600;
}

.looking-up {
  color: var(--text-muted);
  font-style: italic;
}

.batch-progress {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}

.batch-progress.batch-error {
  color: var(--danger);
  font-weight: 600;
}

.matrix-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

.matrix-failed-list {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
  padding-left: 18px;
}

.matrix-summary {
  font-size: 12px;
  color: var(--text);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 8px 10px;
  margin: 10px 0;
  line-height: 1.5;
}

.matrix-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.matrix-table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: center;
}

.matrix-table thead th {
  background: var(--bg-secondary);
  color: var(--text);
  font-weight: 600;
}

.matrix-table tbody th {
  background: var(--bg-secondary);
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

.matrix-table td {
  color: var(--text);
}

.matrix-table .matrix-diagonal {
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.matrix-table .matrix-uncertain {
  color: var(--text-muted);
}

.matrix-map-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 0 4px;
}

/* Made obviously clickable, not just technically clickable: a real
   cursor change and a hover background on every real (non-diagonal)
   cell, on top of the static hint line above the table. */
.matrix-table .matrix-cell-pair {
  cursor: pointer;
}

.matrix-table .matrix-cell-pair:hover,
.matrix-table .matrix-cell-pair:focus-visible {
  background: var(--bg-secondary);
  outline: none;
}

/* The pair currently drawn on the map - a persistent highlight, not
   just a hover state, so it stays visible after the pointer moves away
   and reads clearly on a touch device where there is no hover at all. */
.matrix-table .matrix-cell-selected {
  background: rgba(37, 99, 235, 0.15);
  box-shadow: inset 0 0 0 2px #2563eb;
}

.matrix-selected-label {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  margin: 8px 0 0;
}

/* Markers, shared shape with ca-postcode-mapper.js's own icons. */
.ca-marker-pin {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.ca-marker-centre-dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #d97706;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.popup-precision {
  font-weight: 600;
  margin: 4px 0;
}

.popup-caveat {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

@media (max-width: 900px) {
  .tool-container {
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
  }
  .tool-sidebar {
    width: 100%;
    max-height: 400px;
  }
  .map-container .map {
    height: 400px;
  }
  .matrix-table {
    font-size: 11px;
  }
}

/* Cross-link box to the other three CA tools, same style as
   ca-postcode-radius.css's .tool-distinction. */
.tool-distinction {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-distinction a {
  color: var(--primary);
}

/* Accuracy panel, same shape as ca-postcode-radius.css's. */
.accuracy-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 3rem;
}

.accuracy-panel h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.accuracy-panel p,
.accuracy-panel li {
  color: var(--text-muted);
  line-height: 1.7;
}

.accuracy-panel ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.accuracy-panel li {
  margin-bottom: 0.5rem;
}

.tool-jump-link {
  font-size: 0.9rem;
  margin-top: 4px;
}
