/* UK Counties & Councils - Stage 1 drill slice. Layout/breadcrumb/label
   rules adapted directly from postcode-areas.css's own proven pattern
   (tool-container/tool-sidebar/breadcrumb/map), same values, cc- prefix
   instead of pa- - no shared class exists across tools yet, per this
   estate's established per-tool-CSS-file convention. */

/* Three top-level grid children (2026-09-15, Dan's mobile-ordering
   ruling), placed by name rather than by source order or `order`, so
   the same three pieces can be arranged differently per breakpoint:
   desktop keeps today's two-column look (find+browse and details
   stacked in the left column, map spanning both rows on the right);
   mobile puts find+browse ABOVE the map and details below it - see
   the @media (max-width: 640px) block below for the mobile areas.
   CSS `order` could not do this on its own: it only reorders direct
   siblings within one grid, and cannot reach inside a single sidebar
   element to promote just ITS first two sections past a sibling.
   Real trade-off, accepted rather than hidden (Dan's own choice of
   option (a)): find+browse and details are now two independently-
   sized cards, not one shared 700px scrollbox spanning both - see
   .cc-find-browse's own comment below for why that's fine. */
.tool-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "find map"
    "details map";
  gap: var(--spacing-md, 16px);
  align-items: start;
  min-height: 640px;
}

.cc-find-browse {
  grid-area: find;
}

.tool-sidebar {
  grid-area: details;
  max-height: 700px;
  overflow-y: auto;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Same card styling as .tool-sidebar, deliberately NOT the same
   max-height:700px/overflow-y:auto scrollbox - .cc-find-browse's own
   content (the postcode lookup form plus the Browse section, whose own
   index list is already capped at 260px, see .cc-index-list below) is
   short enough on its own that the cap would never engage; giving it
   one anyway would be a no-op today and a silent trap the day someone
   adds more content here without noticing it should be capped like
   .tool-sidebar is. */
.cc-find-browse {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.cc-map-wrap {
  grid-area: map;
}

.sidebar-content {
  padding: 20px;
}

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

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

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

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

.cc-lookup-result {
  margin-top: 12px;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-muted, #f3f4f6);
  color: var(--text-body, #1f2937);
  line-height: 1.6;
}

.cc-lookup-error {
  background: #fef2f2;
  color: #991b1b;
}

/* Sidebar index (2026-09-14) - its own bounded, internally scrolling
   box, independent of .tool-sidebar's own scroll behaviour (which
   resets to normal page scroll on mobile, see the @media block below -
   without its own cap, a 218- or 650-row list would make the whole
   page painfully long to scroll on a phone just to reach anything
   below it). 260px comfortably shows 8-9 rows before scrolling on
   desktop; unchanged at mobile widths deliberately, since a SHORT
   internal scroll region is exactly what avoids relying on page
   scroll there. */
#cc-index-filter {
  margin-bottom: 8px;
}

.cc-index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
}

.cc-index-row {
  padding: 10px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-body, #1f2937);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.cc-index-row:last-child {
  border-bottom: none;
}

.cc-index-row:hover,
.cc-index-row:focus {
  background: var(--surface-muted, #f3f4f6);
  outline: none;
}

.cc-index-row[hidden] {
  display: none;
}

.cc-index-empty {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
}

.cc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 6px;
  background: var(--surface-muted, #f3f4f6);
  border-radius: 8px;
}

/* Real button chrome and a real 44px touch target - Postcode Areas'
   own hard-won mobile lesson (a bare link-styled breadcrumb read as
   not-clickable and sat under the touch-target floor), built in from
   this file's first commit rather than found broken a second time. */
.cc-breadcrumb button {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
  color: var(--link-color, #2563eb);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  min-width: 44px;
}

.cc-breadcrumb button:disabled {
  background: var(--surface-muted, #e5e7eb);
  color: var(--text-primary, #111827);
  border-color: transparent;
  cursor: default;
  font-weight: 600;
}

.cc-breadcrumb .cc-breadcrumb-sep {
  color: var(--text-muted, #6b7280);
}

.cc-stats {
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
}

.cc-map-wrap .map {
  width: 100%;
  height: 640px;
  border-radius: 8px;
}

.cc-label {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  font-weight: 700;
  font-size: 12px;
  color: #1a1a1a;
  text-shadow:
    -1px -1px 0 rgba(255,255,255,0.85),
    1px -1px 0 rgba(255,255,255,0.85),
    -1px 1px 0 rgba(255,255,255,0.85),
    1px 1px 0 rgba(255,255,255,0.85);
  pointer-events: none;
}

.cc-label::before {
  display: none;
}

html[data-theme="dark"] .cc-label {
  color: #f5f5f5;
  text-shadow:
    -1px -1px 0 rgba(0,0,0,0.85),
    1px -1px 0 rgba(0,0,0,0.85),
    -1px 1px 0 rgba(0,0,0,0.85),
    1px 1px 0 rgba(0,0,0,0.85);
}

@media (max-width: 640px) {
  .tool-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "find"
      "map"
      "details";
  }

  .tool-sidebar {
    max-height: none;
    overflow-y: visible;
  }
}

.cc-pin-label {
  font-size: 11px;
}

.cc-export-count {
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
  margin-bottom: 8px;
}

.cc-export-error {
  background: #fef2f2;
  color: #991b1b;
}

#cc-export-button,
#cc-geojson-button {
  margin-bottom: 8px;
}

/* Print / Save as PDF - Territory Mapper's own @media print pattern
   (no Postcode Areas precedent exists for this - CSV is its only
   export). Hides this tool's own input/editing chrome (the postcode
   lookup form, stats, export/print buttons); the breadcrumb stays
   visible - it's the only thing on the page saying WHICH region a
   printed map is scoped to. */
@media print {
  .tool-sidebar,
  .cc-find-browse {
    display: none !important;
  }

  .tool-container {
    display: block;
  }

  .cc-map-wrap .map {
    height: 70vh;
    page-break-inside: avoid;
  }
}
