:root {
  --control-size: 44px;
  --control-bg: rgba(20, 20, 20, 0.55);
  --control-bg-hover: rgba(20, 20, 20, 0.8);
  --marker-color: #f4a6a6;
  color-scheme: dark;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

#panorama {
  position: absolute;
  inset: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.hidden { display: none !important; }

/* Zona "hover" en la esquina: invisible hasta que el cursor entra, o
   siempre visible al tacto en mobile (sin hover real). */
.hover-zone {
  position: absolute;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 16px;
}
.hover-zone.top-right {
  top: env(safe-area-inset-top, 0px);
  right: 0;
}

.control-btn {
  width: var(--control-size);
  height: var(--control-size);
  border-radius: 50%;
  border: none;
  background: var(--control-bg);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.hover-zone.top-right:hover .control-btn,
.control-btn:focus-visible {
  opacity: 1;
}
.control-btn:hover { background: var(--control-bg-hover); }
.control-btn.is-on { opacity: 0.9; }

/* Rótulos: cada imagen se ubica por su centro (x, y) y su ancho (w), en % del visor */
.branding-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.branding-layer img {
  position: absolute;
  transform: translate(-50%, -50%);
  height: auto;
}

/* Minimapa: x, y (centro) y ancho se aplican desde el script */
.minimap-wrap {
  position: absolute;
  z-index: 10;
  transform: translate(-50%, -50%);
  line-height: 0;
}
#miniMap {
  position: relative;
  display: block;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  opacity: var(--map-opacity, 0.9);
  transition: opacity 0.2s ease;
}
#miniMap:hover,
#miniMap:focus-within { opacity: 1; }

/* el contenedor se ajusta al plano: así las posiciones en % coinciden con la imagen */
#miniMapImage {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* escenas del plano: tocá una para ir directo */
.minimap-scene {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.minimap-scene::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
}
.minimap-scene:hover::before { background: var(--marker-color); }

/* nombre del proyecto y planta, debajo del minimapa */
.minimap-caption {
  margin-top: 5px;
  line-height: 1.25;
  text-align: center;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.7);
  opacity: var(--map-opacity, 0.9);
  pointer-events: none;
}
.minimap-caption strong { display: block; font-size: 13px; }
.minimap-caption span { display: block; opacity: 0.9; }

/* diagnóstico del giroscopio */
.diag { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.diag-box { width: min(440px, 92vw); max-height: 86vh; overflow: auto; padding: 16px; border-radius: 14px; background: rgba(24, 24, 28, 0.97); color: #fff; font-size: 14px; line-height: 1.4; }
.diag-box p { margin: 8px 0; }
.diag-box pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: rgba(255, 255, 255, 0.08); border-radius: 8px; padding: 8px; margin: 8px 0 12px; }

/* posición actual: punto chico + cono que sale desde el punto hacia afuera */
.minimap-marker {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.minimap-dot {
  position: absolute;
  width: var(--marker-size, 12px);
  height: var(--marker-size, 12px);
  left: calc(var(--marker-size, 12px) / -2);
  top: calc(var(--marker-size, 12px) / -2);
  border-radius: 50%;
  background: var(--marker-color);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.minimap-dot.has-icon {
  background: center / contain no-repeat;
  border-radius: 0;
  box-shadow: none;
}
/* el vértice (el ángulo agudo) queda en el centro del punto; se abre hacia arriba y rota sobre ese vértice */
.minimap-cone {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  z-index: 1;
}
.minimap-cone::before {
  content: "";
  position: absolute;
  left: calc(var(--cone-w, 36px) / -2);
  top: calc(var(--cone-h, 44px) * -1);
  width: var(--cone-w, 36px);
  height: var(--cone-h, 44px);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: linear-gradient(to top, var(--marker-color) 0%, transparent 100%);
}

/* Menú lateral */
.menu-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  z-index: 25;
  display: flex;
  flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px;
  box-sizing: border-box;
  background: rgba(24, 24, 28, 0.92);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; }
.menu-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 6px 10px; }
.menu-floors { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 10px; }
.menu-chip {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.menu-chip.is-on { background: #fff; color: #111; border-color: #fff; }
.menu-scenes { overflow-y: auto; flex: 1; }
.menu-scene {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.menu-scene:hover { background: rgba(255, 255, 255, 0.12); }
.menu-scene.is-current { background: rgba(255, 255, 255, 0.2); }
.menu-scene img,
.menu-scene .ph {
  width: 64px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: #333;
  flex: none;
}

/* Colocar un punto desde el editor: mira tipo objetivo */
#panorama.placing {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><circle cx='16' cy='16' r='11' fill='none' stroke='black' stroke-opacity='.55' stroke-width='4'/><circle cx='16' cy='16' r='11' fill='none' stroke='white' stroke-width='2'/><circle cx='16' cy='16' r='3' fill='%23ff4040' stroke='white' stroke-width='1.5'/></svg>") 16 16, crosshair;
}

/* Avisos breves (p. ej. giroscopio sin datos) */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(520px, 90vw);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
  z-index: 30;
}

/* Sin hover (táctil): los botones se ven siempre */
@media (hover: none) {
  .control-btn { opacity: 0.8; }
}

/* los botones propios de Pannellum (zoom / pantalla completa) van abajo a la derecha, para no tapar los rótulos */
.pnlm-controls-container { top: auto !important; left: auto !important; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
