/*
 * Project Map screen — PDF floor plan viewer with equipment pins.
 * Responsive: the canvas scroll area supports native touch pinch/scroll on
 * phones, and mouse wheel/scroll on desktop; pins are positioned by percent
 * so they stay correct at any zoom level or viewport size.
 */

#screen-project-map .pm-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface-2, var(--surface-soft, #f5f8fb));
  border-bottom: 1px solid var(--line, #e4ebf1);
}

#screen-project-map .pm-floor-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
#screen-project-map .pm-floor-tabs::-webkit-scrollbar { display: none; }

.pm-floor-tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line, #e4ebf1);
  background: var(--surface, #fff);
  color: var(--ink, #1f2d3d);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pm-floor-tab.active {
  background: var(--navy, #426482);
  border-color: var(--navy, #426482);
  color: #fff;
}
.pm-floor-tab__count {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-inline-start: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  font-size: 10px;
}
.pm-floor-tab:not(.active) .pm-floor-tab__count {
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.pm-viewer-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--nav-h, 0px) - 170px);
  min-height: 320px;
}

.pm-viewer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line, #e4ebf1);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft, #556170);
}
.pm-viewer-controls #pm-add-pin-toggle.active {
  background: var(--coral, #ff6b57);
  border-color: var(--coral, #ff6b57);
  color: #fff;
}

.pm-canvas-scroll {
  flex: 1;
  overflow: auto;
  background: #cfd8e0;
  /* Panning/zooming is handled entirely by our own pointer-event based
     drag + wheel-zoom (see pmWireCanvasPanZoom in js/project-map.js) —
     touch-action:none stops the browser's native scroll/pinch from
     fighting with it (native pinch used to zoom the whole page instead
     of the map). */
  touch-action: none;
  cursor: grab;
  display: flex;
}
.pm-canvas-scroll--panning {
  cursor: grabbing;
}
.pm-canvas-scroll--adding {
  cursor: crosshair;
}

.pm-canvas-stage {
  position: relative;
  margin: auto;
  line-height: 0;
  background: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.pm-canvas-stage--adding {
  cursor: crosshair;
}
.pm-canvas-stage canvas,
.pm-canvas-stage img#pm-map-image {
  display: block;
  max-width: none;
}

.pm-pins-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pm-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  border: 0;
  background: none;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
  pointer-events: auto;
}
.pm-pin:active { transform: translate(-50%, -100%) scale(0.9); }

.pm-hint {
  margin: 0;
  padding: 8px 14px;
  background: var(--coral-soft, rgba(255,107,87,.14));
  color: var(--coral, #ff6b57);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

#screen-project-map .pg-empty {
  margin-top: 40px;
}

@media (max-width: 640px) {
  #screen-project-map .pm-viewer-controls span#pm-zoom-label { min-width: 40px; text-align: center; }
}

/* -------------------------------------------------------------------------
   Equipment location picker (embedded in the Equipment form) + the
   read-only mini-map card on Equipment Detail. Reuses .pm-canvas-scroll /
   .pm-canvas-stage / .pm-pins-layer / .pm-pin styling above.
-------------------------------------------------------------------------- */
#epm-location-modal .pm-viewer-wrap { height: 360px; }

.epm-mini-map {
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 14px;
  background: #cfd8e0;
  border: 1px solid var(--clr-border-2, #e4ebf1);
}
.epm-mini-map__inner {
  position: relative;
  width: max-content;
  line-height: 0;
}
.epm-mini-map__inner img {
  display: block;
  max-width: none;
  width: 900px;
}
.epm-mini-map__pin {
  font-size: 22px;
  pointer-events: none;
}

/* -------------------------------------------------------------------------
   Project equipment list — tap an item to jump straight to its pin.
-------------------------------------------------------------------------- */
.pm-equipment-list {
  margin: 0 14px 8px;
  border: 1px solid var(--line, #e4ebf1);
  border-radius: 12px;
  background: var(--surface, #fff);
  overflow: hidden;
}
.pm-equipment-list__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--surface-soft, #f5f8fb);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink, #1f2d3d);
  cursor: pointer;
}
.pm-equipment-list__toggle span:first-child { flex: 1; text-align: start; }
.pm-equipment-list__toggle svg { transition: transform .15s ease; }
.pm-equipment-list__toggle--open svg { transform: rotate(180deg); }

.pm-equipment-list__items {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.pm-equipment-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border: 0;
  border-top: 1px solid var(--line, #e4ebf1);
  background: none;
  text-align: start;
  font-size: 12.5px;
  color: var(--ink, #1f2d3d);
  cursor: pointer;
}
.pm-equipment-list__item:hover { background: var(--surface-soft, #f5f8fb); }
.pm-equipment-list__goto {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--coral, #ff6b57);
  white-space: nowrap;
}

.pm-pin--highlight {
  animation: pmPinPulse 0.5s ease-in-out 3;
}
@keyframes pmPinPulse {
  0%, 100% { transform: translate(-50%, -100%) scale(1); }
  50% { transform: translate(-50%, -100%) scale(1.5); }
}

/* -------------------------------------------------------------------------
   World Map (Leaflet + free OpenStreetMap tiles) + the map-source toggle
   in the upload dialog.
-------------------------------------------------------------------------- */
.pm-world-map {
  flex: 1;
  min-height: 0;
}
.pm-world-map--adding { cursor: crosshair; }
.pm-world-map .leaflet-container { font-family: inherit; }

.pm-source-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.pm-source-toggle__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line, #e4ebf1);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
}
.pm-source-toggle__option:has(input:checked) {
  border-color: var(--coral, #ff6b57);
  background: var(--coral-soft, rgba(255,107,87,.08));
}
.pm-source-toggle__option input { margin: 0; }
