/* ============================================================
   THEME TOKENS (light/dark)
   ============================================================ */
/*#gm-visor-root {
  --bg: #ffffff;
  --text: #222;
  --panel-bg: #f9f9f9;
  --border: #ddd;
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --badge-cleaned: #4caf50;
  --badge-tagged: #fbc02d;
  --badge-pending: #9e9e9e;
  --input-bg: #fff;
  --muted: #777;
  --panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --switch-on: var(--brand, #2563eb);
}*/

/*#gm-visor-root[data-theme="dark"] {
  --bg: #1e1e1e;
  --text: #f5f5f5;
  --panel-bg: #2b2b2b;
  --border: #444;
  --overlay-bg: rgba(0, 0, 0, 0.65);
  --input-bg: #3a3a3a;
  --muted: #aaa;
  --panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}*/

/* ============================================================
     BASE
     ============================================================ */
/*#gm-visor-root {
  font-family: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  transition: background 0.3s, color 0.3s;
}*/


/* ============================================================
   VISOR V13 — DEFINICIÓN CANÓNICA
   ============================================================ */

/* =========================================
   ⚡ Desactivar animaciones durante el primer render
   ========================================= */
body.no-anim #gm-visor-carousel .v-thumb {
  transition: none !important;
}

body.draw-dragging,
body.draw-dragging * {
  user-select: none;
  -webkit-user-select: none;
}

body.draw-dragging #gm-visor-carousel,
body.draw-dragging #gm-visor-carousel * {
  pointer-events: none;
}

body.zoom-dragging #gm-visor-carousel,
body.zoom-dragging #gm-visor-carousel * {
  pointer-events: none;
}

#gm-visor-root {
  --bg: #ffffff;
  --text: #222;
  --panel-bg: #f9f9f9;
  --border: #ddd;
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --badge-cleaned: #4caf50;
  --badge-tagged: #fbc02d;
  --badge-pending: #9e9e9e;
  --input-bg: #fff;
  --muted: #777;
  --panel-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --switch-on: var(--brand, #2563eb);
}

/* === Overlay completo del visor integrado === */
#gm-visor-modal {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999 !important;
  display: none;
  /* Oculto por defecto */
  align-items: center;
  justify-content: center;
  overflow: hidden !important;
  background: rgba(0, 0, 0, 0.18); /* velo ligero para ver el mapa */
  backdrop-filter: blur(1.5px);
}

#gm-visor-modal.is-open {
  display: flex !important;
  /* Se muestra solo cuando se abre */
}

/* === Root del visor (envoltorio interno) === */
#gm-visor-root {
  width: 92vw;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: none;
  overflow: hidden !important;
  touch-action: none; /* evita scroll en touchpads/móviles */
  display: none;
  flex-direction: column;
}

#gm-visor-root.is-open {
  display: flex;               /* solo aparece al abrir */
  position: relative !important;
  inset: auto !important;
  width: 92vw;
  max-width: 1280px;
  height: 92vh;
  max-height: 900px;
  z-index: 999999 !important;
}


/* ============================================================
   🎞️ CARRUSEL DEL VISOR — VERSIÓN ÚNICA Y CORRECTA
   ============================================================ */

/* Por defecto → OCULTO hasta que el visor se abra */
#gm-visor-carousel {
  display: none !important;
}

/* Cuando el visor está abierto → mostrar carrusel */
#gm-visor-modal.is-open #gm-visor-carousel {
  display: flex !important;
}

#gm-visor-carousel {
  position: relative;
  z-index: 9999999;
  height: 104px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  /* se activará solo cuando is-open */
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

/* Thumbnail del visor (la versión correcta es .v-thumb, NO .thumb) */
#gm-visor-carousel .v-thumb {
  flex: 0 0 auto;
  width: 112px;
  height: 70px;
  border-radius: 9px;
  overflow: hidden;
  scroll-snap-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0.85;
  filter: brightness(0.95);
  /*transition: transform .18s ease,
    border-color .18s ease,
    opacity .18s ease,
    filter .18s ease;*/
  position: relative;
  cursor: pointer;
}

#gm-visor-carousel .v-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#gm-visor-carousel .v-thumb .thumb-badge-wrap {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
}
#gm-visor-carousel .v-thumb .thumb-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.08);
}
#gm-visor-carousel .v-thumb .thumb-dot.status-empty { background: var(--status-untagged); }
#gm-visor-carousel .v-thumb .thumb-dot.status-tagged { background: var(--status-tagged); }
#gm-visor-carousel .v-thumb .thumb-dot.status-clean { background: var(--status-clean); }
#gm-visor-carousel .v-thumb .thumb-dot.status-nograffiti { background: var(--status-nograffiti); }

/* Hover */
#gm-visor-carousel .v-thumb:hover {
  transform: scale(1.05);
  opacity: 0.95;
  filter: brightness(1);
}

/* Thumbnail activo */
#gm-visor-carousel .v-thumb[aria-current="true"] {
  border-color: #00aaff;
  border: 2px solid transparent;
  background: #00aaff;
  box-shadow:
    0 0 0 2px rgba(0, 170, 255, 0.4),
    0 6px 16px rgba(0, 0, 0, 0.45);
  transform: scale(1.12);
  opacity: 1;
  filter: brightness(1.05);
  z-index: 3;
}

/* ============================================================
     MODAL CONTAINER
     ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close,
.theme-toggle {
  position: absolute;
  top: 10px;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--btn-bg);
  color: var(--muted);
  transition: background 0.18s, transform 0.08s, color 0.18s;
}

.modal-close {
  right: 20px;
}

.modal-close:hover,
.theme-toggle:hover {
  background: var(--btn-bg-hover);
}

.modal-close:active,
.theme-toggle:active {
  transform: scale(0.96);
}

.modal-close {
  background: var(--btn-bg);
  color: var(--muted);
}

.theme-toggle {
  left: 20px;
}

/* ============================================================
     VISOR WRAPPER
     ============================================================ */
.visor {
  display: flex;
  align-items: stretch;
  width: 92vw;
  height: 90vh;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
  position: relative;
}

/* ============================================================
     LEFT SIDE — MAIN IMAGE + HEADER + STATS + CAROUSEL
     ============================================================ */
.visor-main {
  flex: 1 1 auto;
  min-width: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
}

.main-image {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.zoom-layer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 0 0;
  will-change: transform;
}

.zoom-layer.is-zoomed {
  cursor: grab;
}

body.zoom-dragging .zoom-layer {
  cursor: grabbing;
}

.main-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

/* — Cabecera informativa — */
.photo-header {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  background: var(--overlay-bg);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 28px;
  font-size: 13px;
  line-height: 1.35;
}

.photo-header .block {
  white-space: nowrap;
  opacity: 0.95;
  font-weight: 600;
}

/* — Mini pills estadísticas — */
.stats {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}

.stat {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.stat.cleaned {
  background: var(--badge-cleaned);
  display: none !important;
}

.stat.tagged {
  background: var(--badge-tagged);
  color: #222;
  display: none !important;
}

.stat.pending {
  background: var(--badge-pending);
}


/* — BBoxes — base */
.bbox {
  position: absolute;
  border: 2px solid var(--status-untagged);
  background: rgba(245, 158, 11, 0.16);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

/* 1) Sólo dibujado (sin datos) */
.bbox--plain {
  border-color: var(--status-untagged);
  background: rgba(245, 158, 11, 0.16);
}

/* 2) Etiquetado */
.bbox--tagged {
  border-color: var(--status-tagged);
  background: rgba(239, 68, 68, 0.16);
}

/* 3) Limpio */
.bbox--cleaned {
  border-color: var(--status-clean);
  background: rgba(34, 197, 94, 0.16);
}

/* 4) No es grafiti */
.bbox--nogra {
  border-color: var(--status-nograffiti);
  background: rgba(148, 163, 184, 0.18);
}

/* 5) Seleccionado (no cambia color de estado, solo realce) */
.bbox.active {
  border-width: 4px;
  /* tu “borde más grueso” */

}

/* ============================================================
     RIGHT PANEL
     ============================================================ */
.panel {
  flex: 0 0 320px;
  min-width: 320px;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  overflow: visible;
  /* 👈 MUY IMPORTANTE */
}



/* — Iconbar — */
.iconbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  box-shadow: 0 -1px 0 var(--border);
}

.auto-label-status {
  display: none;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.auto-label-status.is-visible {
  display: block;
}

.auto-label-status.is-success {
  color: #15803d;
}

.auto-label-status.is-error {
  color: #b91c1c;
}

.auto-label-status.is-loading {
  color: #1d4ed8;
}

/* — Panel header — */
.panel-header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  padding: 0px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.panel-header .title {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.2px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.panel-header .status {
  font-size: 13px;
  color: var(--muted);
}

.panel-header .status-inline {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  line-height: 1;
}

.scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f1f5f9;
}

.scope-btn {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.scope-btn.is-active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

/* — Campos — */
.fields {
  padding: 0px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  /* 👈 AHORA AQUÍ SÍ */
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
  font-weight: 400;
}

.field input,
.field select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: var(--input-bg);
  font-size: 12px;
}

/* — Pruebas de limpieza — */
.proofs-wrap {
  border-top: 1px solid var(--border);
  padding: 10px 16px 14px;
  border-radius: 0 0 14px 14px;
  background: #f8fafc;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  display: block !important;

  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.proofs-wrap.active {
  opacity: 1;
  max-height: 600px;
  background: rgba(34, 197, 94, 0.08);
  border-top-color: rgba(34, 197, 94, 0.28);
}

.proofs {
  display: grid;
  grid-template-columns: repeat(2, 112px);
  gap: 10px;
  align-items: stretch;
  justify-content: start;
}


.proof {
  width: 100px;
  height: 60px;
  background: #ddd;
  border-radius: 8px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.proof::after {
  content: "+";
  position: absolute;
  color: #555;
  font-size: 24px;
  top: 14px;
  left: 40px;
}

#proofHelp {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 0;
  border-bottom: 0;
}


/* ============================================================
   FIX — Ensure overlays and photo-header appear ABOVE image
   ============================================================ */
.main-image {
  position: relative;
  padding-top: 44px;
  padding-bottom: 0px;
}

.main-image img {
  position: relative;
  z-index: 1;
}

.photo-header,
.stats,
.overlay-layer {
  z-index: 2;
}

/* ============================================================
   🎛️ Unified FAB-style controls (Draw / Clean / No-Graffiti)
   ============================================================ */
.iconbtn {
  --btn-size: var(--fab-size-sm);
  width: var(--btn-size);
  height: var(--btn-size);
  min-width: var(--btn-size);
  min-height: var(--btn-size);
  border: none;
  background: var(--btn-bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: none;
  transition: background 0.2s, color 0.2s, transform 0.08s;
}

.iconbtn svg,
.iconbtn img {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

#btn-open-gmaps img,
#btn-open-gmaps svg {
  transform: translateX(1px);
}

.iconbtn:hover {
  background: var(--btn-bg-hover);
}

.iconbtn:active {
  transform: scale(0.97);
}

/* Ocultar botón "No es un grafiti" en visor (lógica permanece) */
.iconbar #btn-nogra {
  display: none;
}

/* Estado activo por tipo */
#btn-bbox.active {
  background: var(--status-untagged); /* gris para modo dibujo (no se confunde con “datos”) */
  color: var(--on-brand);
}

#btn-clean.active,
#btn-clean.active-clean {
  background: var(--status-clean);
  color: var(--on-brand);
}

#btn-nogra.active {
  background: var(--status-nograffiti);
  color: var(--on-brand);
}

#btn-del-ann.active {
  background: #ef4444;
  color: var(--on-brand);
}

.iconbtn.active:hover,
.iconbtn.active-clean:hover {
  box-shadow: none;
}

/* ============================================================
   🔒 Campos bloqueados (sin instancias o marcado "no grafiti")
   ============================================================ */
/* 🔒 Campos bloqueados */
#fields.fields--disabled {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(60%) brightness(0.85);
  transition: all 0.25s ease;
}

/* Etiquetas atenuadas */
#fields.fields--disabled label {
  color: #c4c4c4 !important;
  opacity: 0.7;
}

/* Inputs y selects grises */
#fields.fields--disabled input,
#fields.fields--disabled select,
#fields.fields--disabled textarea {
  background: #f7f6f6 !important;
  color: #666 !important;
  border-color: #ccc !important;
}

/* Botones bloqueados */
button:disabled,
.iconbtn:disabled {
  opacity: 0.4 !important;
  pointer-events: none !important;
  filter: grayscale(60%);
  cursor: not-allowed;
}

.overlay-layer.drawing .bbox {
  cursor: pointer;
  /* aún en modo dibujo, se pueden clicar las cajas */
}

.proof-slot {
  width: 112px;
  height: 70px;
  background: #e2e8f0;
  border-radius: 9px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.proof-add {
  font-size: 26px;
  color: var(--muted);
  cursor: pointer;
}

.proof-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proof-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 50%;
  color: white;
  font-size: 16px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
}

.field--row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.field--75 {
  flex: 3;
}

.field--25 {
  flex: 1;
}

/* Toggle tipo iPhone */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}

input:checked+.slider {
  background-color: #007aff;
  /* azul tipo iPhone */
}

input:checked+.slider:before {
  transform: translateX(22px);
}


/* fila con 2 columnas: 75% / 25% */
.field--row {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 12px;
  align-items: end;
}

/* las dos subcolumnas heredan la estética */
.field-main,
.field-offensive {
  display: flex;
  flex-direction: column;
}

/* switch estilo iPhone */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 34px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

input:checked+.slider {
  background: #34c759;
}

input:checked+.slider::before {
  transform: translateX(22px);
}

/* Grid 2 columnas para la fila tags + ofensivo */
.fields .row-tags-offensive {
  display: grid;
  grid-template-columns: 5fr 1fr;
  /* 75% - 25% */
  gap: 16px;
  align-items: end;
  /* Alinea el switch verticalmente */
}

/* El campo de tags ocupa toda su celda */
.fields .row-tags-offensive .field--tags {
  width: 100%;
}

/* El switch ofensivo */
.fields .row-tags-offensive .field--offensive {
  display: flex;
  flex-direction: column;
  justify-content: end;
}

.offensive-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* <── AQUÍ EL FIX */
  justify-content: flex-end;
}

/* Campo principal + ofensivo en 2 columnas */
.field--tags {
  display: grid;
  grid-template-columns: 5fr 1fr;
  /* 5% - 25% */
  gap: 16px;
}

/* Asegura que el label del campo de texto esté arriba */
.field--tags .tags-wrap {
  display: flex;
  flex-direction: column;
}

/* SWITCH ACTIVADO */
.switch input:checked+.slider {
  background-color: var(--switch-on) !important;
}

/* Círculo cuando está activado */
.switch input:checked+.slider:before {
  background-color: white;
  /* Se mantiene blanco */
}

.photo-header {
  display: flex;
  align-items: center;
  gap: 24px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 14px;
  white-space: nowrap;
}

.meta-icon {
  width: 14px;
  height: 14px;
  filter: invert(100%);
  /* ⬅️ ICONOS BLANCOS */
  opacity: 0.9;
}

/* ============================================================
   ✅ NO-ANIM MODE while opening visor
   - disables transitions AND the active scale during 2 frames
   ============================================================ */
body.no-anim #gm-visor-carousel .v-thumb {
  transition: none !important;
}

body.no-anim #gm-visor-carousel .v-thumb[aria-current="true"] {
  transition: none !important;
  transform: none !important;
  /* <-- clave: evita el flash aunque aria-current esté mal 1 frame */
  box-shadow: none !important;
  /* opcional pero ayuda */
}

/* ============================================================
   🚫 Congelar completamente el visor cuando está abierto
   (evita scroll en visor, wheel, trackpad, overscroll, etc.)
   ============================================================ */
   body.visor-open #gm-visor-root,
   body.visor-open #gm-visor-modal {
     position: fixed !important;
     inset: 0 !important;
     width: 100vw !important;
     height: 100vh !important;
     overflow: hidden !important;
     overscroll-behavior: none !important;
     touch-action: none !important;
   }
   
