/* ==========================================================================
   Canton et intercommunalité (France) - styles propres à l'outil

   Repris de fr-elevation-finder.css (même forme d'outil : recherche, clic sur
   la carte, boîte de résultat, sélecteur de désambiguïsation), avec la liste de
   couches (commune, arrondissement, canton, intercommunalité) à la place du
   grand chiffre. Le toast n'est PAS restylé ici (composant partagé, global.css).
   ========================================================================== */

.tool-container {
  background-color: var(--bg);
}

.tool-sidebar {
  width: 380px;
  background-color: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-height: 626px;
  min-height: 0;
  overflow-y: auto;
}

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

.sidebar-content label:first-of-type {
  margin-top: 0;
}

.tool-section {
  margin-bottom: 28px;
}

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

.input-section {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--card) 100%);
  margin: -20px -20px 0 -20px;
  padding: 20px;
  border-radius: 12px 12px 0 0;
}

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

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

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

.click-hint {
  display: none;
  font-size: 0.82rem;
  color: var(--primary);
  background: var(--glass);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 10px;
}

#map.click-armed {
  cursor: crosshair;
}

/* --------------------------------------------------------------------------
   Result display
   -------------------------------------------------------------------------- */
.result-box {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: left;
}

.result-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.result-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-point {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.layers {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.layer {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.layer-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.layer-value {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.95rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.layer-value strong {
  color: var(--primary);
  font-size: 1.02rem;
}

.layer-code {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.layer-none {
  font-weight: 700;
  color: var(--text);
}

.layer-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.layer-warn {
  display: block;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #92400e;
  background: #fef3c7;
  border-left: 3px solid #d97706;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 4px;
}

.layer-warn svg {
  vertical-align: -2px;
}

html[data-theme='dark'] .layer-warn {
  background: rgba(217, 119, 6, 0.15);
  color: #fbbf24;
}

.epci-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.canton-legend {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.85rem;
}

.canton-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canton-legend .swatch {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.source-line {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 12px 0 0;
}

.loading-note {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.suggestion-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suggestion-btn {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.suggestion-btn:hover {
  background: var(--hover-bg);
}

/* --------------------------------------------------------------------------
   About / attribution + related tools
   -------------------------------------------------------------------------- */
.tool-info {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
}

.tool-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 8px;
}

.tool-info p:last-child {
  margin-bottom: 0;
}

.related-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.related-link {
  display: block;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  text-decoration: none;
}

.related-link strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 2px;
}

.related-link span {
  color: var(--text-muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Map container + mobile FAB
   -------------------------------------------------------------------------- */
.map-container {
  position: relative;
  overflow: hidden;
  height: 626px;
  align-self: start;
}

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

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

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .tool-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    overflow-y: visible;
  }

  .tool-sidebar.collapsed {
    max-height: 0;
    overflow: hidden;
  }

  .map-container {
    height: 400px;
  }

  /* Fills the 400 px box on a phone (2026-10-11): the desktop min-height of 500px made the map 100 px taller than
     its box, which hides overflow, so the bottom of the map and its attribution were cut off. */
  .map {
    min-height: 0;
  }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
  }
}

@media (max-width: 600px) {
  .input-section {
    margin: -16px -16px 0 -16px;
    padding: 16px;
  }
}

.field-status {
  margin-top: 6px;
  font-size: 13px;
}

.field-error {
  color: #dc2626;
  margin: 0;
}

/* Desambiguisation - repris de ca-distance-between.css tel quel */
.ambiguous-picker p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 6px;
}

.ambiguous-picker ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.candidate-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.candidate-btn:hover {
  background: var(--hover-bg);
}

/* Meme famille visuelle que .result-group-expander sur
   fr-nearest-postcodes.css - "il y a plus a voir", cliquable. */
.candidate-expand {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px dashed #d97706;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}

.candidate-expand:hover {
  background: #fde68a;
}

html[data-theme='dark'] .candidate-expand {
  background: rgba(217, 119, 6, 0.15);
  color: #fbbf24;
  border-color: #d97706;
}

.precision-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}
