* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #111;
  color: #eee;
  overflow: hidden;
}

.oculto { display: none !important; }

/* ── MAPA ── */
#map {
  width: 100vw;
  height: 100vh;
  background: #111111;
}

/* ── BARRA DE SESIÓN ── */
#barra-sesion {
  position: fixed;
  bottom: 26px; right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(22, 33, 62, 0.92);
  border: 1px solid #0f3460;
  border-radius: 22px;
  padding: 7px 16px;
  backdrop-filter: blur(6px);
}

#info-usuario { font-size: 0.82rem; color: #aaa; }

#btn-login {
  background: #4285F4;
  color: white;
  border: none;
  padding: 7px 15px;
  border-radius: 16px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: bold;
}
#btn-login:hover { background: #3367d6; }

#btn-logout {
  background: transparent;
  border: 1px solid #444;
  color: #888;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.78rem;
  cursor: pointer;
}
#btn-logout:hover { border-color: #e94560; color: #e94560; }

/* ── PANEL LATERAL ── */
#panel {
  position: fixed;
  top: 90px;
  left: 20px;
  width: 544px;
  max-height: calc(100vh - 110px);
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 16px;
  overflow: hidden;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  min-width: 260px;
  max-width: 860px;
}

#panel-scroll {
  height: 100%;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 24px;
  box-sizing: border-box;
  padding-right: 12px;
}

#panel-scroll::-webkit-scrollbar { width: 4px; }
#panel-scroll::-webkit-scrollbar-track {
  background: rgba(15, 52, 96, 0.3);
  border-radius: 0 14px 14px 0;
  margin: 2px 0;
}
#panel-scroll::-webkit-scrollbar-thumb {
  background: #4285F4;
  border-radius: 10px;
}
#panel-scroll::-webkit-scrollbar-thumb:hover { background: #6aa3f8; }
#panel-scroll { scrollbar-width: thin; scrollbar-color: #4285F4 transparent; }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── ASA DE REDIMENSIÓN ── */
#panel-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  border-radius: 0 16px 16px 0;
  background: transparent;
  transition: background 0.2s;
  z-index: 10;
}

#panel-resize-handle:hover,
#panel-resize-handle:active {
  background: rgba(66, 133, 244, 0.25);
}

/* Pequeña línea visual indicativa */
#panel-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  background: rgba(66, 133, 244, 0.4);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}
#panel-resize-handle:hover::after { opacity: 1; }

.btn-cerrar {
  position: absolute;
  top: 14px; right: 14px;
  background: #0f3460;
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}
.btn-cerrar:hover { background: #e94560; }

#panel-contenido h2 { font-size: 1.4rem; color: #ffffff; margin-bottom: 6px; padding-right: 40px; }
#panel-contenido .categoria { font-size: 0.82rem; color: #4285F4; margin-bottom: 12px; letter-spacing: 0.03em; }
#panel-contenido .descripcion {
  color: #bbb;
  line-height: 1.7;
  margin-bottom: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}
#panel-contenido .fecha { font-size: 0.78rem; color: #555; margin-bottom: 8px; }
#panel-contenido .autor { font-size: 0.8rem; color: #4285F4; margin-top: 20px; padding-top: 14px; border-top: 1px solid #0f3460; }

.fotos-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.fotos-grid img {
  width: 100%;
  object-fit: cover;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.15s;
}
.fotos-grid img:hover { transform: scale(1.01); }

/* ── BOTONES DE ACCIÓN ── */
.btns-accion {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-editar {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid #4285F4;
  color: #4285F4;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 0.80rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-editar:hover { background: #4285F4; color: #fff; }

.btn-borrar {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid #e94560;
  color: #e94560;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 0.80rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-borrar:hover { background: #e94560; color: #fff; }

.btn-mover {
  flex: 1.5;
  min-width: 0;
  background: transparent;
  border: 1px solid #f0a500;
  color: #f0a500;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 0.80rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-mover:hover { background: #f0a500; color: #fff; }

.btn-tamaño {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid #a259f7;
  color: #a259f7;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 0.80rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-tamaño:hover { background: #a259f7; color: #fff; }

/* ── BOTÓN AÑADIR PIN ── */
#btn-añadir {
  position: fixed;
  bottom: 78px; right: 12px;
  background: #e94560;
  color: #fff; border: none;
  padding: 13px 28px; border-radius: 30px;
  font-size: 0.95rem; font-weight: bold;
  cursor: pointer; z-index: 1000;
  box-shadow: 0 4px 18px rgba(233,69,96,0.45);
  transition: all 0.2s;
}
#btn-añadir:hover { background: #c73652; transform: scale(1.05); }

/* ── INSTRUCCIÓN ── */
#instruccion {
  position: fixed;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  background: #0f3460; color: #fff;
  padding: 11px 22px; border-radius: 20px;
  z-index: 1000; display: flex;
  align-items: center; gap: 14px;
  font-size: 0.9rem;
  box-shadow: 0 3px 12px rgba(0,0,0,0.4);
}
#instruccion button {
  background: #e94560; border: none; color: #fff;
  padding: 5px 13px; border-radius: 13px;
  cursor: pointer; font-size: 0.85rem;
}

/* ── EDITOR DE TEXTO ENRIQUECIDO ── */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #0a2240;
  border: 1px solid #1a4a8a;
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  padding: 5px 8px;
  flex-wrap: nowrap;
}

.editor-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  color: #bbb;
  width: 28px; height: 26px;
  border-radius: 5px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  flex-shrink: 0;
}
.editor-toolbar button:hover {
  background: #1a4a8a;
  border-color: #4285F4;
  color: #fff;
}

.editor-toolbar button.activo {
  background: #1a4a8a;
  border-color: #4285F4;
  color: #fff;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: #1a4a8a;
  margin: 0 4px;
  flex-shrink: 0;
}

.editor-toolbar select {
  background: transparent;
  border: 1px solid transparent;
  color: #bbb;
  font-size: 0.72rem;
  border-radius: 5px;
  padding: 2px 2px;
  cursor: pointer;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
  max-width: 105px;
}
.editor-toolbar select:hover,
.editor-toolbar select:focus {
  background: #1a4a8a;
  border-color: #4285F4;
  color: #fff;
}
.editor-toolbar select option {
  background: #16213e;
  color: #eee;
}

.editor-content {
  width: 100%;
  min-height: 90px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 0 0 7px 7px;
  color: #fff;
  padding: 9px 11px;
  font-size: 0.92rem;
  outline: none;
  line-height: 1.6;
  word-break: break-word;
  overflow-y: auto;
  max-height: 200px;
  /* Estilos internos del rich text */
}

/* Placeholder para contenteditable */
.editor-content:empty::before {
  content: attr(data-placeholder);
  color: #555;
  pointer-events: none;
}

/* Estilos que el execCommand genera dentro del editor */
.editor-content b, .editor-content strong { font-weight: bold; }
.editor-content i, .editor-content em     { font-style: italic; }
.editor-content u                         { text-decoration: underline; }

/* ── MODAL NUEVA MARCA ── */
#modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 2000; display: flex;
  align-items: center; justify-content: center;
}

#modal-caja {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 14px; padding: 28px;
  width: 90%; max-width: 460px;
  max-height: 88vh; overflow-y: auto;
}

#modal-caja h2 { color: #e94560; margin-bottom: 18px; font-size: 1.3rem; }

#modal-caja label {
  display: block; margin: 12px 0 5px;
  color: #999; font-size: 0.85rem;
}

#modal-caja input[type="text"] {
  width: 100%; background: #0f3460;
  border: 1px solid #1a4a8a; border-radius: 7px;
  color: #fff; padding: 9px 11px;
  font-size: 0.92rem; outline: none;
}
#modal-caja select {
  width: 100%; background: #0f3460;
  border: 1px solid #1a4a8a; border-radius: 7px;
  color: #fff; padding: 9px 11px;
  font-size: 0.92rem; outline: none; cursor: pointer;
}
#modal-caja select option { background: #16213e; }
#modal-caja input[type="file"] { margin-top: 4px; color: #888; font-size: 0.85rem; }

#preview-fotos { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
#preview-fotos img { width: 65px; height: 65px; object-fit: cover; border-radius: 5px; }

#progreso-caja {
  margin-top: 12px; background: #0f3460;
  border-radius: 8px; overflow: hidden;
}
#progreso-barra { height: 7px; background: #e94560; width: 0%; transition: width 0.3s; }
#progreso-texto { display: block; text-align: center; font-size: 0.78rem; color: #888; padding: 5px; }

#btn-guardar {
  background: #e94560; color: #fff; border: none;
  padding: 12px; border-radius: 9px;
  font-size: 0.95rem; font-weight: bold;
  cursor: pointer; margin-top: 18px; width: 100%;
}
#btn-guardar:hover { background: #c73652; }
#btn-guardar:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secundario {
  background: transparent; border: 1px solid #333;
  color: #888; padding: 9px; border-radius: 9px;
  font-size: 0.88rem; cursor: pointer;
  margin-top: 8px; width: 100%;
}
.btn-secundario:hover { border-color: #555; color: #aaa; }

/* ── MODAL EDICIÓN MARCA ── */
#modal-edicion {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 2000; display: flex;
  align-items: center; justify-content: center;
}

#modal-edicion-caja {
  background: #16213e;
  border: 2px solid #4285F4;
  border-radius: 14px; padding: 28px;
  width: 90%; max-width: 460px;
  max-height: 88vh; overflow-y: auto;
}

#modal-edicion-caja h2 { color: #4285F4; margin-bottom: 18px; font-size: 1.3rem; }

#modal-edicion-caja label {
  display: block; margin: 12px 0 5px;
  color: #999; font-size: 0.85rem;
}

#modal-edicion-caja input[type="text"] {
  width: 100%; background: #0f3460;
  border: 1px solid #1a4a8a; border-radius: 7px;
  color: #fff; padding: 9px 11px;
  font-size: 0.92rem; outline: none;
}
#modal-edicion-caja select {
  width: 100%; background: #0f3460;
  border: 1px solid #1a4a8a; border-radius: 7px;
  color: #fff; padding: 9px 11px;
  font-size: 0.92rem; outline: none; cursor: pointer;
}
#modal-edicion-caja select option { background: #16213e; }
#modal-edicion-caja input[type="file"] { margin-top: 4px; color: #888; font-size: 0.85rem; }

/* ── FOTOS EXISTENTES (edición) ── */
#edit-fotos-existentes {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 5px;
}

.foto-existente {
  position: relative;
  width: 65px;
  height: 65px;
}
.foto-existente img {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 5px;
}
.btn-quitar-foto {
  position: absolute;
  top: -5px; right: -5px;
  background: #e94560; border: none; color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}
.btn-quitar-foto:hover { background: #c73652; }

#edit-preview-nuevas { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
#edit-preview-nuevas img { width: 65px; height: 65px; object-fit: cover; border-radius: 5px; }

#edit-progreso-caja {
  margin-top: 12px; background: #0f3460;
  border-radius: 8px; overflow: hidden;
}
#edit-progreso-barra { height: 7px; background: #4285F4; width: 0%; transition: width 0.3s; }
#edit-progreso-texto { display: block; text-align: center; font-size: 0.78rem; color: #888; padding: 5px; }

#btn-guardar-edicion {
  background: #4285F4; color: #fff; border: none;
  padding: 12px; border-radius: 9px;
  font-size: 0.95rem; font-weight: bold;
  cursor: pointer; margin-top: 18px; width: 100%;
}
#btn-guardar-edicion:hover { background: #3367d6; }
#btn-guardar-edicion:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── IMÁGENES INLINE EN EDITOR ── */

/* Wrapper no editable que contiene controles + imagen */
.img-inline {
  display: block;
  margin: 10px 0;
  border-radius: 8px;
  border: 1.5px dashed transparent;
  padding: 2px;
  transition: border-color 0.15s;
  /* Evita que el cursor de texto entre en él */
  user-select: none;
}

/* Resaltar al pasar el ratón (solo dentro del editor) */
.editor-content .img-inline:hover {
  border-color: #4285F4;
}

/* Barra de controles */
.img-inline-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #0a2240;
  border: 1px solid #1a4a8a;
  border-radius: 6px 6px 0 0;
  padding: 4px 7px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

/* Botones de la barra */
.iic-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #bbb;
  min-width: 26px;
  height: 24px;
  border-radius: 4px;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
}
.iic-btn:hover {
  background: #1a4a8a;
  border-color: #4285F4;
  color: #fff;
}
.iic-btn.activo {
  background: #1a4a8a;
  border-color: #4285F4;
  color: #fff;
}
.iic-btn.iic-del { color: #e94560; }
.iic-btn.iic-del:hover { background: #e94560; border-color: #e94560; color: #fff; }

/* Separador vertical en la barra */
.iic-sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: #1a4a8a;
  margin: 0 3px;
  flex-shrink: 0;
}

/* Etiqueta de porcentaje */
.img-size-label {
  font-size: 0.75rem;
  color: #aaa;
  min-width: 34px;
  text-align: center;
  flex-shrink: 0;
}

/* Imagen dentro del wrapper — dentro del editor */
.editor-content .img-inline img {
  border-radius: 0 0 6px 6px;
  display: block;
  max-width: 100%;
}

/* En el panel de visualización: sin controles, imagen limpia */
.descripcion .img-inline {
  border: none;
  padding: 0;
  margin: 10px 0;
}
.descripcion .img-inline-controls { display: none !important; }
.descripcion .img-inline img {
  border-radius: 6px;
  max-width: 100%;
  display: block;
}

/* ── LIGHTBOX ── */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  z-index: 3000; display: flex;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 7px; }
#lightbox-cerrar {
  position: absolute; top: 18px; right: 18px;
  background: #e94560; border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 17px; cursor: pointer;
}

/* ── OCULTAR ATRIBUCIÓN LEAFLET ── */
.leaflet-control-attribution { display: none !important; }

/* ── PANEL DE CAPAS ── */
#capas-control {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 195px;
}

.capa-fila {
  display: flex;
  align-items: center;
  gap: 4px;
}

.capa-fila .btn-capa { flex: 1; }

.capas-sep {
  border: none;
  border-top: 1px solid #1a3060;
  margin: 5px 0;
}

.btn-capa {
  background: transparent;
  border: 1px solid #1a3060;
  color: #ccc;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.87rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  text-align: left;
  white-space: nowrap;
}
.btn-capa:hover  { border-color: #4285F4; color: #fff; background: rgba(66,133,244,0.1); }
.btn-capa.activo { background: rgba(15,52,96,0.8); border-color: #4285F4; color: #fff; }
.btn-capa.inactivo { opacity: 0.4; }

/* Botón ▾ categorías */
.btn-expandir-cats {
  background: transparent;
  border: 1px solid #1a3060;
  color: #888;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  padding: 0;
}
.btn-expandir-cats:hover { border-color: #4285F4; color: #4285F4; }

/* Dropdown de categorías */
#categorias-dropdown {
  background: rgba(8, 16, 38, 0.97);
  border: 1px solid #1a3060;
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: min(340px, calc(100vh - 320px));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #4285F4 transparent;
}

#categorias-dropdown::-webkit-scrollbar { width: 4px; }
#categorias-dropdown::-webkit-scrollbar-track {
  background: rgba(15, 52, 96, 0.3);
  border-radius: 10px;
}
#categorias-dropdown::-webkit-scrollbar-thumb {
  background: #4285F4;
  border-radius: 10px;
}
#categorias-dropdown::-webkit-scrollbar-thumb:hover { background: #6aa3f8; }

.cat-fila {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cat-fila input[type="checkbox"] {
  accent-color: #4285F4;
  cursor: pointer;
  width: 13px; height: 13px;
  flex-shrink: 0;
}

.cat-fila label {
  flex: 1;
  font-size: 0.81rem;
  color: #bbb;
  cursor: pointer;
  user-select: none;
}

.btn-isolate {
  background: transparent;
  border: 1px solid #1a3060;
  color: #555;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
}
.btn-isolate:hover { border-color: #4285F4; color: #4285F4; background: rgba(66,133,244,0.12); }
.btn-isolate.activo { border-color: #4285F4; color: #4285F4; background: rgba(66,133,244,0.22); }

/* ── OVERRIDES MODAL NUEVA MARCA ── */
#modal #modal-caja {
  max-width: 736px;
}
#modal .editor-content {
  min-height: 180px;
  max-height: 400px;
}

/* ── OVERRIDES MODAL EDICIÓN MARCA ── */
#modal-edicion #modal-edicion-caja {
  max-width: 736px;
}
#modal-edicion .editor-content {
  min-height: 180px;
  max-height: 400px;
}

/* ── MODAL TAMAÑO DE ICONO ── */
#modal-tamaño {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 2100; display: flex;
  align-items: center; justify-content: center;
}

#modal-tamaño-caja {
  background: #16213e;
  border: 2px solid #a259f7;
  border-radius: 14px;
  padding: 28px 32px;
  width: 90%; max-width: 360px;
  display: flex; flex-direction: column; gap: 18px;
}

#modal-tamaño-caja h2 {
  color: #a259f7;
  font-size: 1.2rem;
  margin: 0;
}

.tamaño-slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

#tamaño-slider {
  flex: 1;
  accent-color: #a259f7;
  cursor: pointer;
  height: 6px;
}

#tamaño-valor {
  font-size: 1.1rem;
  font-weight: bold;
  color: #a259f7;
  min-width: 38px;
  text-align: right;
}

.tamaño-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #555;
  margin-top: -10px;
}

#btn-guardar-tamaño {
  background: #a259f7; color: #fff; border: none;
  padding: 11px; border-radius: 9px;
  font-size: 0.95rem; font-weight: bold;
  cursor: pointer; width: 100%;
}
#btn-guardar-tamaño:hover { background: #8b3ee8; }
#btn-guardar-tamaño:disabled { opacity: 0.5; cursor: not-allowed; }
