/* Page Carto — carte plein cadre sous le header admin */

body.carto-page {
  height: 100vh;
  overflow: hidden;
  background: #1a1a1a;
}

body.carto-page main {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh - 3.25rem);
}

#carto-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
}

.basemap-switch {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.basemap-switch button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
}

.basemap-switch button + button {
  border-left: 1px solid var(--line);
}

.basemap-switch button.active {
  background: var(--ink);
  color: #fff;
}

.map-toolbar {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 2;
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.ign-attribution {
  position: absolute;
  left: 0.5rem;
  bottom: 3.6rem; /* au-dessus de .map-toolbar (bottom: 0.5rem) */
  z-index: 2;
  margin: 0;
  padding: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  user-select: none;
}

.tb-toggle,
.tb-recenter,
.tb-action {
  font: inherit;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  padding: 0.45rem 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  position: relative;
}

.tb-toggle {
  flex: 1;
  color: var(--muted);
}

.tb-toggle.active {
  color: var(--ink);
  box-shadow: inset 0 -3px 0 #ffeb3b;
}

#btn-obs.tb-toggle.active {
  box-shadow: inset 0 -3px 0 #ff9800;
}

#btn-odfci.tb-toggle.active {
  box-shadow: inset 0 -3px 0 #e65100;
}

.tb-action {
  flex: 0 0 auto;
  color: var(--ink);
}

.tb-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.tb-help {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 1.25rem; /* 20px — aligné Flutter _ToolbarToggle */
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: transparent;
  color: rgba(0, 0, 0, 0.55);
  font-size: 0.75rem; /* 12px */
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tb-recenter {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  border-radius: 50%;
  border: none;
  /* AppColors.accent — état « recentrer » Flutter (_RecenterButton) */
  background: #009ee2;
  color: #000;
  padding: 3px;
  box-shadow: none;
}

.tb-recenter:hover {
  filter: brightness(1.05);
}

.tb-recenter .tb-icon {
  display: block;
  width: 100%;
  height: 100%;
}

.repere-panel {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 3.6rem;
  z-index: 3;
  background: rgba(28, 27, 25, 0.92);
  color: #f5f2ec;
  border-radius: 8px;
  padding: 0.75rem 2rem 0.75rem 0.9rem;
  font-size: 0.9rem;
}

.repere-panel .k {
  color: #b8b0a4;
  display: inline-block;
  min-width: 2.5rem;
}

.repere-panel .muted {
  color: #b8b0a4;
  margin-top: 0.35rem;
}

.repere-close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.carto-toast {
  position: absolute;
  top: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: rgba(28, 27, 25, 0.92);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  max-width: 90%;
}

.carto-toast[hidden] {
  display: none;
}

/* Calque viewport (fixed) — fiable sur iOS où % dans #carto-shell échoue. */
.share-handoff-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  pointer-events: none;
}

.share-handoff-layer[hidden] {
  display: none !important;
}

.share-handoff {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: min(22rem, 100%);
  width: max-content;
  padding: 0.55rem 0.75rem;
  background: rgba(28, 27, 25, 0.92);
  border: 1px solid var(--line, #333);
  border-radius: 8px;
  color: #f5f2ec;
  text-align: center;
  box-sizing: border-box;
}

.share-handoff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
}

.share-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  background: transparent;
}

.share-btn.primary {
  background: #009ee2;
  color: #fff;
  border-color: #009ee2;
}

.share-btn:not(.primary) {
  border-color: #666;
}

.share-store-desktop {
  width: 100%;
  margin: 0;
  font-size: 0.8rem;
  text-align: center;
}

.share-store-desktop a {
  color: #009ee2;
}

.legend-dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  max-width: 22rem;
  width: calc(100% - 2rem);
  background: #1c1b19;
  color: #f5f2ec;
}

.legend-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.pei-page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.5rem 0 2rem;
}

.pei-page h1 {
  margin-bottom: 0.35rem;
}

.pei-import-panel {
  margin-top: 1.25rem;
  border: 1px solid var(--line, #333);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: #1c1b19;
  color: #f5f2ec;
}

.tb-dept {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25rem;
}

.tb-dept select {
  font: inherit;
  font-size: 0.8rem;
  max-width: 4.5rem;
  padding: 0.2rem 0.3rem;
}

.pei-import-success {
  color: #81c784;
  margin: 1rem 0 0;
}

.pei-import-dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  max-width: 34rem;
  width: calc(100% - 2rem);
  background: #1c1b19;
  color: #f5f2ec;
}

.pei-import-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.pei-import-dialog form {
  margin: 0;
  padding: 1rem 1.1rem;
}

.pei-import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pei-import-header h2,
.pei-step h3 {
  margin: 0;
}

.pei-import-header button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.5rem;
}

.pei-import-dept,
.pei-help {
  color: #b8b0a4;
  font-size: 0.9rem;
}

.pei-dept-block {
  margin-top: 0.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.pei-dept-block h3,
.pei-step h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.pei-import-dept {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f2ec;
  font-size: 0.95rem;
}

.pei-dept-row,
.pei-source-panel {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

/* display:grid ci-dessus écrase sinon l’attribut HTML hidden */
.pei-dept-row[hidden],
.pei-source-panel[hidden] {
  display: none !important;
}

.pei-field-label {
  color: #b8b0a4;
  font-size: 0.85rem;
}

.pei-step {
  margin-top: 1rem;
}

.pei-source-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0.6rem 0 0.85rem;
  padding: 0.25rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
}

.pei-segment-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 2.4rem;
  border-radius: 8px;
  cursor: pointer;
  color: #b8b0a4;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}

.pei-segment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pei-segment-option.is-active {
  background: #3d342c;
  color: #fff8ef;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.pei-segment-option:focus-within {
  outline: 2px solid #ffb300;
  outline-offset: 1px;
}

.pei-step input[type="file"],
.pei-step input[type="url"],
.pei-step select,
#pei-dept {
  font: inherit;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #12110f;
  color: inherit;
}

#pei-dept {
  width: 100%;
  max-width: 100%;
}

.pei-mapping-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.pei-import-error {
  color: #ff8a80;
  margin: 1rem 0 0;
}

.pei-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.pei-import-actions button {
  font: inherit;
  cursor: pointer;
  padding: 0.45rem 0.7rem;
}

.pei-popup {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
}

.pei-popup dt {
  font-weight: 600;
}

.pei-popup dd {
  margin: 0;
}

.legend-dialog form {
  margin: 0;
  padding: 1rem 1.1rem 1rem;
}

.legend-dialog h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.legend-dialog p {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
}

.legend-note {
  color: #b8b0a4 !important;
  font-size: 0.82rem !important;
}

.legend-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
  font-size: 0.9rem;
}

/* Colonne symbole fixe — libellés alignés comme dans l’app. */
.legend-symbol {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-list img {
  width: 28px;
  height: 28px;
  display: block;
}

.legend-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}

.legend-swatch {
  width: 28px;
  height: 6px;
  border-radius: 2px;
  flex: 0 0 auto;
}

.legend-swatch.circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.legend-swatch.poly {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  border-style: solid;
  border-width: 2px;
  box-sizing: border-box;
}

.legend-list li.legend-heading {
  margin-top: 0.85rem;
  margin-bottom: 0.45rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: #f0ebe3;
}

.eau-map-label {
  color: #007dff;
  font: 600 11px/1.2 "IBM Plex Sans", "Segoe UI", sans-serif;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
  text-shadow:
    0 0 2px #fff,
    0 0 3px #fff,
    1px 1px 0 #fff,
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff;
  max-width: 7rem;
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}

/* Tracé + échelle — parité Flutter TraceModeButtons / MapScaleBar / TracePanel */

.trace-controls {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
}

.trace-btn {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  padding: 0;
}

.trace-btn.sm {
  width: 44px;
  height: 44px;
}

.trace-btn.active {
  background: #009ee2;
  color: #fff;
}

.trace-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.trace-icon {
  display: block;
}

.trace-panel {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 3.6rem;
  z-index: 3;
  background: rgba(46, 46, 46, 0.95);
  color: #fff;
  border-radius: 10px;
  padding: 12px 2rem 12px 12px;
}

.trace-panel .trace-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.trace-panel .trace-k {
  color: #aaaaaa;
  font-size: 12px;
  font-weight: 700;
}

.trace-panel .trace-v {
  font-size: 14px;
  margin-bottom: 4px;
}

.trace-close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.map-scale {
  position: absolute;
  right: 12px;
  bottom: 3.6rem; /* au-dessus de .map-toolbar, comme .ign-attribution */
  z-index: 2;
  pointer-events: none;
}

.map-scale.panel-open {
  bottom: calc(3.6rem + 168px);
}

.map-scale-label {
  text-align: center;
  color: #000;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff;
  margin-bottom: 2px;
}

.map-scale-bar {
  display: flex;
  height: 8px;
  border: 1.5px solid #000;
  box-sizing: border-box;
}

.map-scale-bar span {
  flex: 1;
  border-right: 1.5px solid #000;
}

.map-scale-bar span:last-child {
  border-right: 0;
}

.map-scale-bar span:nth-child(odd) {
  background: #fff;
}

.map-scale-bar span:nth-child(even) {
  background: #000;
}
