/* ==================== FUENTES ==================== */
@font-face {
  font-family: "Sans";
  src: url("./fonts/FreeSans.otf");
}

/* ==================== ESTILOS GLOBALES ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Sans";
  min-height: 100vh;
  background: #f8f9fa;
  overscroll-behavior: none; /* Prevenir scroll bounce en iOS */
}

/* Prevenir scroll mientras se arrastra */
body.dragging {
  overflow: hidden;
  touch-action: none;
}

a {
  text-decoration: none;
  color: #a4a4a4;
  font-size: 13px;
}

/* ==================== NAVEGACIÓN ==================== */
nav {
  position: fixed;
  display: flex;
  width: 100%;
  justify-content: space-between;
  top: 0;
  padding: 8px 16px;
  background-color: white;
  z-index: 6;
  color: black;
}

.title {
  color: black;
}

.item-wrapper {
  display: flex;
  align-items: center;
}

li {
  list-style: none;
  margin-left: 1rem;
}

.menuButton {
  display: none;
  padding: 0;
  border: none;
  cursor: pointer;
  background: none;
}

.hidden-menu {
  position: fixed;
  flex-direction: column;
  align-content: flex-end;
  width: 100%;
  z-index: 5;
  transition: 1s;
  display: none;
  top: 34px;
}

.hidden-menu .item {
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: var(--darkgray);
  padding: 8px 16px;
  margin-bottom: 2px;
  background-color: white;
}

/* ==================== BOTÓN DESCARGAR ==================== */
#downloadBtn {
  position: fixed;
  z-index: 10000;
  right: 20px;
  bottom: 20px;
  padding: 8px 16px;
  border: none;
  cursor: pointer;
  background: #a4a4a4;
  color: black;
  font-size: 14px;
  transition: all 0.3s;
  min-height: 44px; /* Mejor accesibilidad táctil */
}

#downloadBtn:hover {
  background: #8c8c8c;
  transform: translateY(-2px);
}

/* ==================== CONTENEDOR PRINCIPAL ==================== */
.container {
  margin: 0 auto;
  overflow: hidden;
  padding: 20px;
  margin-top: 50px;
}

/* ==================== HEADER CON DOS COLUMNAS ==================== */
.header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 30px;
  align-items: start;
}

.header-left img {
  height: 180px;
  max-width: 100%;
  display: block;
}

.header-right {
  padding: 16px;
  font-size: 13px;
  //border: 1px solid #090909ff;
  //filter: drop-shadow(0 2px 4px rgba(42, 42, 42, 0.2));
}

.header-right h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e5e5;
}

.header-right p {
  margin-bottom: 10px;
  font-size: 13px;
}

.header-right p:last-child {
  margin-bottom: 0;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

/* ==================== PANEL IZQUIERDO - GALERÍA ==================== */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gallery-section {
  background: #f8f9fa;
}

.gallery-grid {
  position: relative;
  width: 100%;
  aspect-ratio: 1280 / 910;
  background-image: url("/img/rejilla.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  max-height: 600px;
}

/* ==================== ELEMENTOS DE LA GALERÍA ==================== */
.grid-item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: all 0.3s ease;
  padding: 5px;
  touch-action: none; /* Prevenir gestos del navegador */
}

.grid-item:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 4px 8px rgba(43, 43, 43, 0.4));
  z-index: 10;
}

.grid-item:active {
  cursor: grabbing;
}

.grid-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Posiciones de elementos en la rejilla */
.item-1 {
  left: 3%;
  top: 9%;
  width: 10%;
  height: 21%;
}
.item-2 {
  left: 15%;
  top: 9%;
  width: 12%;
  height: 20%;
}
.item-3 {
  left: 28%;
  top: 9%;
  width: 12%;
  height: 20%;
}
.item-4 {
  left: 41%;
  top: 9%;
  width: 12%;
  height: 20%;
}
.item-5 {
  left: 51%;
  top: 3%;
  width: 14%;
  height: 34%;
}
.item-6 {
  left: 62%;
  top: 0;
  width: 22%;
  height: 34%;
}
.item-7 {
  left: 84%;
  top: 6%;
  width: 12%;
  height: 15%;
}
.item-8 {
  left: 2%;
  top: 30%;
  width: 13%;
  height: 16%;
}
.item-9 {
  left: 13%;
  top: 25%;
  width: 18%;
  height: 24%;
}
.item-10 {
  left: 28%;
  top: 19%;
  width: 31%;
  height: 41%;
}
.item-11 {
  left: 49%;
  top: 30%;
  width: 34%;
  height: 15%;
}
.item-12 {
  left: 3%;
  top: 44%;
  width: 10%;
  height: 15%;
}
.item-13 {
  left: 13%;
  top: 36%;
  width: 18%;
  height: 24%;
}
.item-14 {
  left: 28%;
  top: 41%;
  width: 24%;
  height: 23%;
}
.item-15 {
  left: 50%;
  top: 39%;
  width: 12%;
  height: 20%;
}
.item-16 {
  left: 65%;
  top: 27%;
  width: 22%;
  height: 18%;
}
.item-17 {
  left: 78%;
  top: 25%;
  width: 23%;
  height: 18%;
}
.item-18 {
  left: 2%;
  top: 54%;
  width: 15%;
  height: 26%;
}
.item-19 {
  left: 29%;
  top: 53%;
  width: 25%;
  height: 30%;
}
.item-20 {
  left: 51%;
  top: 58%;
  width: 13%;
  height: 20%;
}
.item-21 {
  left: 56%;
  top: 41%;
  width: 30%;
  height: 24%;
}
.item-22 {
  left: 15%;
  top: 42%;
  width: 14%;
  height: 28%;
}
.item-23 {
  left: 15%;
  top: 56%;
  width: 14%;
  height: 23%;
}
.item-24 {
  left: 77%;
  top: 40%;
  width: 25%;
  height: 18%;
}
.item-25 {
  left: 54%;
  top: 54%;
  width: 37%;
  height: 21%;
}
.item-26 {
  left: 76%;
  top: 53%;
  width: 28%;
  height: 20%;
}
.item-27 {
  left: 2%;
  top: 81%;
  width: 18%;
  height: 17%;
}
.item-28 {
  left: 21%;
  top: 81%;
  width: 14%;
  height: 17%;
}
.item-29 {
  left: 36%;
  top: 77%;
  width: 15%;
  height: 20%;
}
.item-30 {
  left: 50%;
  top: 75%;
  width: 11%;
  height: 24%;
}
.item-31 {
  left: 61%;
  top: 72%;
  width: 13%;
  height: 23%;
}
.item-32 {
  left: 71%;
  top: 72%;
  width: 13%;
  height: 22%;
}
.item-33 {
  left: 82%;
  top: 69%;
  width: 14%;
  height: 31%;
}

/* ==================== PANEL DERECHO - CANVAS ==================== */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.canvas-container {
  background: #f8f9fa;
  flex: 1;
}

.drop-zone {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 500px;
  background-image: url("/img/escena.jpg");
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  touch-action: none; /* Prevenir scroll en el canvas */
}

.drop-zone.drag-over {
  background-color: #ccc;
}

/* ==================== ELEMENTOS SOLTADOS ==================== */
.dropped-element {
  position: absolute;
  cursor: move;
  user-select: none;
  transition: box-shadow 0.2s;
  touch-action: none; /* Prevenir gestos del navegador */
}

.dropped-element:hover {
  box-shadow: 0 0 0 1px #ccc;
}

.dropped-element.selected {
  box-shadow: 0 0 0 1px #ccc;
}

.dropped-element img {
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(42, 42, 42, 0.2));
}

/* ==================== CONTROLES DE ELEMENTOS ==================== */
.delete-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: #ccc;
  color: white;
  border: 1px solid white;
  cursor: pointer;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.delete-btn:hover,
.resize-handle:hover {
  transform: scale(1.1);
}

.dropped-element:hover .delete-btn,
.dropped-element.selected .delete-btn {
  display: flex;
}

.resize-handle {
  position: absolute;
  color: white;
  border: 1px solid white;
  bottom: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #ccc;
  cursor: nwse-resize;
  display: none;
  z-index: 11;
}

.resize-handle::before {
  content: "↘";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.dropped-element:hover .resize-handle,
.dropped-element.selected .resize-handle {
  display: flex;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    max-height: 500px;
  }

  .drop-zone {
    min-height: 400px;
  }
}

@media (max-width: 1024px) {
  .item-wrapper {
    display: none;
  }

  .menuButton {
    display: block;
  }

  .header {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  #downloadBtn {
    bottom: 10px;
    right: 10px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .main-content {
    gap: 15px;
  }

  .gallery-grid {
    max-height: 400px;
  }

  .drop-zone {
    min-height: 350px;
  }

  .header-right {
    font-size: 12px;
    padding: 12px;
  }

  .header-right h2 {
    font-size: 13px;
  }

  .header-right p {
    font-size: 11px;
  }

  .delete-btn,
  .resize-handle {
    width: 22px;
    height: 22px;
  }

  .delete-btn {
    font-size: 20px;
    top: -12px;
    right: -12px;
  }

  .resize-handle {
    bottom: -12px;
    right: -12px;
  }

  .resize-handle::before {
    font-size: 14px;
  }
}

/* ==================== MOSTRAR CONTROLES EN MÓVIL ==================== */
@media (max-width: 768px) {
  .dropped-element.selected .delete-btn,
  .dropped-element.selected .resize-handle {
    display: flex !important;
  }
  
  .dropped-element .delete-btn,
  .dropped-element .resize-handle {
    display: none;
  }
}