/* Overrides to match schedule-blueprint + interactive-blueprint; PDF layer; room labels visible */
.map-viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.map-viewport.panning {
  cursor: grabbing;
}

/* Blueprint background: solid by default; grid optional via .show-grid */
.canvas-wrap {
  background-color: #0d0d0d;
}

.canvas-wrap.show-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

.blueprint-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

.overlay-layer,
#pdfLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#pdfLayer {
  z-index: 0;
  pointer-events: none;
  background: transparent;
  mix-blend-mode: multiply;
}

#pdfLayer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.overlay-layer {
  z-index: 1;
  transition: opacity 0.12s ease-out;
}

.overlay-layer.floor-changing {
  opacity: 0;
  pointer-events: none;
}

.overlay-layer svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.overlay-layer #hallwaysLayer,
.overlay-layer #stairwaysLayer {
  pointer-events: none;
}

.overlay-layer .shape-group,
.overlay-layer .map-shape {
  pointer-events: all;
  cursor: pointer;
}

#hallwaysLayer {
  z-index: 2;
}

#stairwaysLayer {
  z-index: 4;
}

.rooms-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.rooms-layer .map-box {
  pointer-events: auto;
  cursor: pointer;
}

.rooms-layer .map-box.has-class-now {
  border-color: #2d8a4e;
  background: rgba(45, 138, 78, 0.25);
}

.rooms-layer .map-box.no-class-now {
  border-color: #b54a4a;
  background: rgba(181, 74, 74, 0.2);
}

.rooms-layer .map-box.search-highlight {
  border-color: #f9d65c;
  box-shadow: 0 0 0 2px #f9d65c;
}

#hallwaysLayer {
  --box-border-color: rgba(77, 179, 255, 0.9);
  --box-fill-color: rgba(77, 179, 255, 0.18);
}

.map-shape.hallway-box {
  fill: var(--box-fill-color);
  stroke: var(--box-border-color);
  stroke-width: 0.4;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.map-shape.stairway-box {
  fill: rgba(122, 156, 173, 0.22);
  stroke: #7a9cad;
  stroke-width: 0.4;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}

.map-shape.selected {
  stroke: #f9d65c;
  stroke-width: 0.6;
}

.map-shape-label {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.05px;
  text-transform: uppercase;
  fill: #ffffff;
  paint-order: stroke fill;
  stroke: rgba(0, 0, 0, 0.9);
  stroke-width: 0.35;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
  user-select: none;
}

.room-popup {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.room-popup.open {
  display: flex;
}

.room-popup-content {
  background: #1f1f1f;
  border: 1px solid #2e2e2e;
  border-radius: 12px;
  max-width: 900px;
  width: min(94vw, 900px);
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.room-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-popup-header h2 {
  margin: 0;
  font-size: 20px;
}

.room-popup-meta {
  font-size: 13px;
  color: #bdbdbd;
}

.room-popup-close {
  border: 1px solid #3a3a3a;
  background: #222;
  color: #e6e6e6;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.room-popup-close:hover {
  background: #2b2b2b;
}

/* Mobile: popup slightly smaller, easier to close and scroll (includes landscape phone) */
@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .room-popup {
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .room-popup-content {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    border-radius: 10px;
    gap: 10px;
  }

  .room-popup-header h2 {
    font-size: 17px;
  }

  .room-popup-close {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
  }
}

@media (max-width: 480px) {
  .room-popup-content {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 11px 12px;
  }

  .room-popup-header h2 {
    font-size: 16px;
  }
}

.room-popup-image-wrap {
  width: 100%;
  background: #101010;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  overflow: hidden;
}

.room-popup-image-wrap img {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  display: block;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .room-popup-image-wrap img {
    max-height: 220px;
  }
}

@media (max-width: 480px) {
  .room-popup-image-wrap img {
    max-height: 180px;
  }
}

.room-popup-schedule {
  font-size: 13px;
  color: #e6e6e6;
}

.room-popup-fullday-details {
  margin-top: 4px;
}

.room-popup-fullday-details summary {
  font-size: 13px;
  color: #8a8a8f;
  cursor: pointer;
  list-style: none;
  padding: 6px 0;
}

.room-popup-fullday-details summary::-webkit-details-marker {
  display: none;
}

.room-popup-fullday-details summary::before {
  content: "▶ ";
  font-size: 10px;
}

.room-popup-fullday-details[open] summary::before {
  content: "▼ ";
}

.room-popup-fullday {
  max-height: 240px;
  overflow-y: auto;
  font-size: 13px;
  color: #e6e6e6;
  border: 1px solid #2d2d2d;
  border-radius: 6px;
  background: #151515;
  margin-top: 6px;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .room-popup-fullday {
    max-height: 180px;
    -webkit-overflow-scrolling: touch;
  }

  .room-popup-fullday-details summary {
    padding: 10px 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

.room-popup-fullday-row {
  padding: 6px 10px;
  border-bottom: 1px solid #252525;
}

.room-popup-fullday-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.room-popup-fullday-row:last-child {
  border-bottom: none;
}

.room-popup-fullday-row.current-hour {
  background: #252525;
  border-left: 3px solid #5ba3e8;
  padding-left: 7px;
}

.room-popup-next {
  font-size: 12px;
  color: #8a8a8f;
}

.room-popup-next:not(:empty) {
  padding: 6px 0;
  border-top: 1px solid #2d2d2d;
}

/* Projector / TV / touch: lock scroll when modal open */
body.modal-open {
  overflow: hidden;
}

/* Touch-friendly controls (min 44px tap target) */
.panel button,
.panel select,
.panel input[type="checkbox"] + label,
.panel .btn-tool {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 14px;
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .panel .btn-tool {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15px;
  }
}

.panel select {
  width: 100%;
  cursor: pointer;
}

.room-popup-close {
  min-height: 48px;
  min-width: 48px;
  padding: 12px 20px;
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

/* Panel: section separation, solid buttons */
.panel section {
  border-top: 1px solid #2e2e2e;
  padding-top: 14px;
}

.panel section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.panel .btn-tool {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #e6e6e6;
}

.panel .btn-tool:hover {
  background: #353535;
  border-color: #454545;
}

.panel-shortcuts {
  margin: 8px 0 0;
  font-size: 11px;
  color: #8a8a8f;
  line-height: 1.4;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .panel-shortcuts {
    display: none; /* keyboard shortcuts less relevant on touch */
  }
}

.search-results {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  background: #151515;
  margin-top: 4px;
}

.search-results-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #e6e6e6;
  border-bottom: 1px solid #252525;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.search-results-item:last-child {
  border-bottom: none;
}

.search-results-item:hover {
  background: #252525;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .search-results-item {
    padding: 12px 14px;
    font-size: 15px;
    min-height: 48px;
  }
}

.search-results-item.search-highlight {
  border-left: 3px solid #5ba3e8;
  padding-left: 7px;
}

/* Status line: visible on all screens */
.workspace .status,
#status {
  padding: 8px 12px;
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  font-size: 13px;
  color: #c6c6c6;
  min-height: 2.5em;
  min-width: 0;
  overflow-wrap: break-word;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .workspace .status,
  #status {
    display: none; /* map is main thing on mobile */
  }
}

.error-block {
  margin-top: 8px;
  padding: 10px 12px;
  background: #2a1a1a;
  border: 1px solid #4a2a2a;
  border-radius: 6px;
  font-size: 13px;
  color: #e6b0b0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-retry {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #e6e6e6;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.btn-retry:hover {
  background: #353535;
}

/* Desktop: collapsible side panel */
.panel-collapse-btn {
  display: none;
  position: absolute;
  right: 8px;
  top: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #e6e6e6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}

.panel-collapse-btn:hover {
  background: #353535;
}

/* Only show collapse button on desktop (not landscape phone) */
@media (min-width: 769px) and (min-height: 601px) {
  .panel {
    position: relative;
    transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease;
  }

  .panel-collapse-btn {
    display: flex;
  }

  .app.panel-collapsed {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .app.panel-collapsed .panel {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    padding: 12px 8px !important;
    overflow: hidden;
  }

  .app.panel-collapsed .panel h1,
  .app.panel-collapsed .panel .panel-home-link,
  .app.panel-collapsed .panel section {
    display: none !important;
  }

  .app.panel-collapsed .panel .panel-collapse-btn {
    position: static;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 769px) and (max-height: 600px) {
  .panel-collapse-btn {
    display: none !important;
  }
}

/* Responsive: collapsible panel only on small screens (PC keeps side-by-side) */
.panel-toggle {
  display: none;
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  z-index: 12;
  padding: 12px 20px;
  min-height: 48px;
  min-width: 48px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #e6e6e6;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.panel-toggle:hover {
  background: #353535;
}

.panel-toggle:active {
  background: #2e2e2e;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .panel-toggle {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 480px) {
  .panel-toggle {
    padding: 10px 14px;
    font-size: 14px;
    right: max(8px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
  }
}

.panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 11;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px), ((orientation: landscape) and (max-height: 600px)) {
  .panel-toggle {
    display: block;
  }

  .app .panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 90vw);
    z-index: 12;
    transform: translateX(100%);
    transition: transform 0.25s ease-out;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border-right: none;
    padding: 12px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    gap: 10px;
  }

  /* Simpler panel: compact title and home link */
  .app .panel h1 {
    font-size: 16px;
    margin: 0 0 6px 0;
  }

  .app .panel .panel-home-link {
    margin: 0 0 10px 0;
    font-size: 12px;
  }

  .app .panel section {
    padding-top: 10px;
  }

  .app .panel h2 {
    font-size: 13px;
    margin: 0 0 6px 0;
    color: #a0a0a0;
  }

  .app .panel label {
    font-size: 11px;
  }

  /* Pamja: only fullscreen + reset on mobile, hide grid and shortcuts */
  .app .panel section:nth-of-type(3) .checkbox-row,
  .app .panel section:nth-of-type(3) .panel-shortcuts {
    display: none;
  }

  .app .panel section:nth-of-type(3) .button-row {
    display: flex !important;
    gap: 6px;
  }

  .app .panel section:nth-of-type(3) .btn-tool {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Kati: compact – PDF opacity smaller */
  .app .panel section:nth-of-type(2) label[for="pdfOpacity"] {
    font-size: 11px;
  }

  .app .panel section:nth-of-type(2) #pdfOpacity {
    height: 6px;
  }

  /* Kohë: compact */
  .app .panel section:nth-of-type(4) .note {
    font-size: 11px;
  }

  .app.panel-open .panel {
    transform: translateX(0);
  }

  .app.panel-open .panel-backdrop {
    display: block;
  }
}

/* Landscape (phone sideways): panel beside map, no drawer */
@media (orientation: landscape) and (max-height: 600px) {
  .panel-toggle {
    display: none !important;
  }

  .app .panel {
    position: static !important;
    transform: none !important;
    width: auto !important;
    min-width: 0;
    max-height: 100%;
    border-radius: 8px;
    border: 1px solid #2e2e2e;
    box-shadow: none;
  }
}

@media (max-width: 480px) {
  .app .panel {
    width: min(100%, 100vw - 16px);
    padding: 10px;
  }

  .app .panel h1 {
    font-size: 15px;
  }

  .app .panel section:nth-of-type(3) .btn-tool {
    font-size: 12px;
  }
}

/* Fullscreen: map fills screen */
.canvas-wrap.fullscreen {
  position: fixed;
  inset: 0;
  max-width: none;
  aspect-ratio: auto;
  z-index: 15;
  border-radius: 0;
  border: none;
}

.canvas-wrap.fullscreen .map-viewport {
  border-radius: 0;
}

/* In fullscreen, popup must be absolute so it fills the fullscreen element (fixed can escape in some browsers) */
.canvas-wrap.fullscreen .room-popup {
  position: absolute;
}
