/* ==========================================================================
   Canadian Postal Code and Address Mapper - Tool-Specific Styles
   ========================================================================== */

/* Layout: same !important override as zip-mapper.css, for the same
   documented reason - 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);
}

/* Missing from the initial port: with no flex-grow, the map pane sizes to
   its own (empty) content instead of filling the row, and collapses to a
   sliver a few pixels wide. Same rule as zip-mapper.css, the tool this
   layout was copied from. Found 2026-09-02 by screenshotting the tool
   after a batch resolve and seeing a blank map next to a populated
   results list - a case the earlier close-up screenshots never scrolled
   wide enough to catch. */
.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;
}

#singleInput,
#batchInput {
  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;
}

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

.csv-upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Precision labels */
.precision-address { color: #16a34a; font-weight: 600; }
.precision-street { color: #d97706; font-weight: 600; }
.precision-postcode { color: #d97706; font-weight: 600; }

.single-result {
  margin-top: 12px;
  min-height: 20px;
}

.single-caveat,
.result-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.single-failed {
  color: var(--text-muted);
}

/* A rejected fetch/match promise (timeout, network, CORS, server error) -
   distinct from .single-failed's "not placed", which is a normal, expected
   outcome for a real address the data just doesn't cover. */
.single-failed.fetch-error,
.batch-progress .batch-error {
  color: var(--danger);
  font-weight: 600;
}

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

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

/* Results list */
.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.result-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.result-input {
  display: block;
  color: var(--text);
  font-weight: 500;
}

.result-precision {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
}

.result-failed {
  color: var(--text-muted);
  font-size: 12px;
}

.result-reason {
  color: var(--text-muted);
}

.ambiguous-select {
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.status-ambiguous {
  background: rgba(217, 119, 6, 0.06);
}

.status-failed {
  opacity: 0.75;
}

/* Summary */
.summary-box {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

/* Markers */
.ca-marker-pin {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

/* The degraded result's centre marker: a plain amber dot, deliberately
   not pin-shaped, sitting at the middle of its own uncertainty circle. */
.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);
  position: relative;
}

.degraded-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #fff;
  color: #d97706;
  font-size: 9px;
  font-weight: 700;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d97706;
}

/* Map legend: a small, permanent key, not a tooltip that has to be
   discovered - matches the pin/circle it explains in shape and colour,
   not just words. */
.ca-map-legend {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  max-width: 230px;
}

.ca-legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0;
}

.ca-legend-icon {
  flex-shrink: 0;
  display: inline-block;
}

.ca-legend-circle-icon {
  width: 14px;
  height: 14px;
  position: relative;
}

.ca-legend-circle-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid #d97706;
  background: rgba(217, 119, 6, 0.12);
}

.ca-legend-circle-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #d97706;
  border: 1px solid #fff;
}

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

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

/* Mapping modal */
.mapping-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.mapping-modal.open {
  display: flex;
}

.mapping-modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.mapping-row {
  margin-bottom: 14px;
}

.mapping-row label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.mapping-row select {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

/* Accuracy panel. Moved below the map 2026-09-04, per Dan's ruling: the
   above-the-fold header had grown into a wall of copy in front of the
   tool (two intro paragraphs plus this whole panel, both trapped inside
   global.css's .tool-header, whose child-paragraph rule force-centres
   and caps width at 600px - never designed for body copy this long).
   Above the fold now carries only a one-line summary and a #accuracy
   jump link to here; this panel keeps its own left-aligned styling
   correctly now that it sits in .seo-content instead. */
.accuracy-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin: 16px 0 24px;
  font-size: 14px;
  line-height: 1.6;
}

.accuracy-panel h2 {
  font-size: 15px;
  margin-bottom: 8px;
}

.accuracy-panel ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.accuracy-panel li {
  margin-bottom: 4px;
}

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

/* Cross-link box to the other two 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);
}
