/* ——— Botón imprimir ——— */
.print-map-btn {
  background: #fff;
  color: #17202a;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  white-space: nowrap;
}
.print-map-btn:hover { background: #f0f2f5; }

/* Solo visible en la barra móvil */
.print-map-btn-mobile {
  display: none;
  flex: 1;
  max-width: 200px;
  background: #fff;
  color: #17202a;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
}

@media (max-width: 750px) {
  /* Ocultar botón de escritorio en móvil */
  .print-map-btn {
    display: none !important;
  }
  .print-map-btn-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .layers-mobile-bar {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .layers-open-btn {
    flex: 1;
    max-width: none;
  }
}

.print-modal[hidden] { display: none !important; }
.print-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.print-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 28, 0.55);
  backdrop-filter: blur(4px);
}
.print-modal-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1200px, 96vw);
  height: min(92vh, 900px);
  margin: auto;
  background: #f4f6f8;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.print-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e6eb;
  flex-shrink: 0;
}
.print-modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.print-modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #445;
}
.print-modal-close:hover { background: #eef1f4; }

.print-modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e6eb;
  flex-shrink: 0;
}
.print-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-color-switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.print-color-label {
  font-size: 13px;
  font-weight: 600;
  color: #445;
}
.print-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.print-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.print-switch-track {
  position: relative;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: #e8edf2;
  border: 1px solid #c5ced8;
  transition: background 0.2s, border-color 0.2s;
}
.print-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform 0.2s, background 0.2s;
}
.print-switch-text {
  font-size: 12px;
  font-weight: 700;
  min-width: 44px;
  color: #445;
}
.print-switch.is-dark .print-switch-track {
  background: #1b2a3f;
  border-color: #3c5774;
}
.print-switch.is-dark .print-switch-thumb {
  transform: translateX(22px);
  background: #7dd3fc;
}
.print-switch.is-dark .print-switch-text {
  color: #1b2a3f;
}
.print-switch input:focus-visible + .print-switch-track {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.print-export-wrap { position: relative; }
.print-export-wrap .button,
.print-toolbar-right .button {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #d0d7de;
  background: #fff;
  cursor: pointer;
}
.print-toolbar-right .button-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.print-toolbar-right .button-primary:hover { background: #1d4ed8; }
.print-export-wrap .button.secondary:hover { background: #f0f2f5; }
.print-export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 120px;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 4px;
  z-index: 10;
}
.print-export-menu[hidden] { display: none !important; }
.print-export-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #17202a;
}
.print-export-item:hover { background: #eef1f4; }
.print-toolbar-right .button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.print-modal-body {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.print-layers-side {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e2e6eb;
  overflow: auto;
  padding: 12px;
}
.print-layers-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6d7782;
  margin-bottom: 10px;
}
.print-layers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.print-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e2e6eb;
  background: #fafbfc;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  width: 100%;
}
.print-layer-item.is-on {
  border-color: #93c5fd;
  background: #eff6ff;
}
.print-layer-item.is-off { opacity: 0.55; }
.print-layer-item .print-layer-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #eef1f4;
  flex-shrink: 0;
}
.print-layers-mobile {
  display: none;
  padding: 12px 16px 16px;
  background: #fff;
  border-top: 1px solid #e2e6eb;
  max-height: 28vh;
  overflow: auto;
  flex-shrink: 0;
}

.print-preview-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #e8edf2;
}
.print-preview-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  /* pan nativo en 1 dedo; el pellizco se maneja en JS */
  touch-action: pan-x pan-y;
  cursor: grab;
}
.print-preview-scroll.is-dragging { cursor: grabbing; }
.print-preview-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d0d7de;
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 5;
}
.print-preview-zoom .zoom-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.print-preview-zoom .zoom-btn:hover { background: #eef1f4; }
.print-preview-zoom .zoom-label {
  font-size: 12px;
  font-family: ui-monospace, monospace;
  min-width: 40px;
  text-align: center;
  color: #445;
}

.print-sheet {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  /* Proporción tamaño carta / Letter apaisado (11" × 8.5") */
  width: 1056px;
  height: 816px;
}
.print-sheet.is-dark { background: #152238; }
.print-legend-col {
  width: 28%;
  flex-shrink: 0;
  background: #f8f8f8;
  border-right: none;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.print-sheet.is-dark .print-legend-col {
  background: #1b2a3f;
}
.print-legend-col img,
.print-legend-host {
  width: 100%;
  height: 100%;
  display: block;
}
.print-legend-host {
  overflow: hidden;
}
.print-legend-host svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.print-map-col {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #f8f8f8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: none;
}
.print-sheet.is-dark .print-map-col { background: #1b2a3f; }
.print-map-stage {
  position: relative;
  /* width/height en px los calcula JS (aspect exacto del SVG) */
  flex: 0 0 auto;
  overflow: hidden;
  line-height: 0;
}
.print-svg-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.print-svg-host svg {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.print-logo-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.print-logo {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: 0;
  background: transparent;
  padding: 0;
  height: auto;
  aspect-ratio: 1;
  z-index: 3;
}
.print-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.print-logo.is-hidden {
  display: none !important;
}


body.print-modal-open { overflow: hidden; }

@media (max-width: 750px) {
  .print-modal-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    margin: 0;
  }
  .print-modal-body { flex-direction: column; }
  .print-layers-side { display: none; }
  .print-layers-mobile { display: block; }
  .print-layers-mobile .print-layers-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .print-preview-scroll { padding: 10px; }
  .print-modal-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .print-toolbar-right { width: 100%; }
  .print-export-wrap .button { width: 100%; }
}


/* ——— Leyenda secundaria (símbolos activos) ———
   Overlay fijo: no cambia tamaño de la hoja ni del SVG principal.
   Sin scroll (imprimible): el JS compacta filas si hay muchas. */
.print-secondary-legend {
  /* Anclada al borde inferior de la columna del SVG de leyenda */
  --sl-z: var(--print-preview-zoom, 1);
  position: absolute;
  left: calc(6px * var(--sl-z));
  right: calc(6px * var(--sl-z));
  top: auto;
  bottom: calc(6px * var(--sl-z));
  z-index: 3;
  max-height: calc(110px * var(--sl-z));
  overflow: hidden;
  padding: calc(5px * var(--sl-z)) calc(7px * var(--sl-z));
  border-radius: calc(6px * var(--sl-z));
  background: rgba(248, 248, 248, 0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}
.print-secondary-legend[hidden] {
  display: none !important;
}
.print-sheet.is-dark .print-secondary-legend {
  background: rgba(27, 42, 63, 0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.print-secondary-legend-title {
  font-size: calc(8px * var(--sl-z, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6570;
  margin-bottom: calc(4px * var(--sl-z, 1));
}
.print-sheet.is-dark .print-secondary-legend-title {
  color: #9aaec4;
}
.print-secondary-legend-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.print-secondary-legend-row {
  display: flex;
  align-items: center;
  gap: calc(5px * var(--sl-z, 1));
  min-height: calc(13px * var(--sl-z, 1));
}
.print-secondary-legend-icon {
  width: calc(13px * var(--sl-z, 1));
  height: calc(13px * var(--sl-z, 1));
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.print-secondary-legend-label {
  font-size: calc(9px * var(--sl-z, 1));
  font-weight: 600;
  color: #17202a;
  line-height: 1.15;
}
.print-sheet.is-dark .print-secondary-legend-label {
  color: #f0f4f8;
}


/* ——— Logos institucionales (solo impresión; no tocan el SVG del mapa) ——— */
.print-map-col {
  /* ya tiene position:relative en reglas previas; refuerzo */
  position: relative;
}
.print-brand-overlay {
  /* Solo pegado al tope; margen derecho para no pegar al borde.
     Tamaños escalan con --print-preview-zoom (mismo truco que la leyenda secundaria). */
  --br-z: var(--print-preview-zoom, 1);
  position: absolute;
  top: 0;
  right: calc(12px * var(--br-z));
  left: auto;
  z-index: 6;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-start;
  gap: calc(8px * var(--br-z));
  pointer-events: none;
}
.print-brand-card {
  /* Base 130×130 a zoom 100% (antes 100); crece/encoge con el zoom de la hoja */
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: calc(130px * var(--br-z));
  height: calc(130px * var(--br-z));
  padding: calc(10px * var(--br-z));
  border-radius: 0 0 calc(12px * var(--br-z)) calc(12px * var(--br-z));
  background: #272062;
  box-shadow: 0 2px 8px rgba(39, 32, 98, 0.28);
  border: none;
}
.print-sheet.is-dark .print-brand-card {
  background: #272062;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.print-brand-card img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: calc(110px * var(--br-z));
  max-height: calc(110px * var(--br-z));
  object-fit: contain;
}


.print-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}
.print-label {
  position: absolute;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  line-height: 1.15;
  white-space: pre;
  text-align: center;
  pointer-events: none;
}
.print-label.is-hidden { display: none !important; }

.print-layer-icon-text {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: #e8eef5 !important;
  background-image: none !important;
  font-weight: 800;
  font-size: 14px;
  color: #272062;
}
