:root {
  --bg:#0f1217;
  --panel:#161a21;
  --card:#1c2028;
  --accent:#4c8bf5;
  --muted:#e8edf5;
  --line:#333;
}

/* BASE */
html, body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, Arial;
  background: var(--bg);
  color: var(--muted);
}

/* HEADER */
#headerTop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
  box-sizing: border-box;
  padding: 8px 10px;

  /* Fondo GIF repetido en todo el ancho */
  background-image: url("binario.webp");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: center;
}

.bannerWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  height: 18vh;
  max-height: 160px;
  position: relative;
  z-index: 2;
}

.bannerCentral {
  flex: 2;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 2;
}

.gifLateral {
  flex: 1;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 2;
}

.headerLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  position: relative;
  z-index: 2;
}

.headerLine h2 {
  margin: 0;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.categorySelectors {
  display: flex;
  gap: 8px;
}

.searchCart {
  display: flex;
  gap: 8px;
}

/* MAIN */
main {
  padding: 20px;
  margin-top: calc(18vh + 60px);
}

/* PRODUCTOS */
#products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px;
}

.card {
  background: var(--card);
  padding: 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
}

.card h4 {
  margin: 10px 0 6px 0;
  font-size: 1rem;
}

.card p {
  margin: 0 0 8px 0;
  color: #bfc7d9;
  font-size: 0.95rem;
  white-space: pre-line;
}

.promoTag {
  background: #d9534f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 6px;
  position: absolute;
  top: 10px;
  left: 10px;
}

/* BOTONES */
button {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button.secondary {
  background: #2f3640;
}

#cartBadge {
  font-weight: 600;
  background: var(--accent);
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  color: #fff;
  cursor: pointer;
}

/* CANTIDAD */
.qtyWrap {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.qtyInput {
  width: 64px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #333;
  background: #12151b;
  color: #e8edf5;
}

/* MODALES */
.modalOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #0009;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modalBox {
  background: var(--panel);
  padding: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 12px;
  color: var(--muted);
}

.galleryWrap {
  text-align: center;
  overflow-x: hidden;
}

#galleryImg {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.galleryDesc {
  margin-top: 16px;
  white-space: pre-line;
  line-height: 1.4;
}

/* SCROLLBAR */
.modalBox::-webkit-scrollbar { width: 8px; }
.modalBox::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
.modalBox::-webkit-scrollbar-track { background: var(--card); }

.card p strong,
.modalBox strong {
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

/* TABLAS */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

td, th {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.hidden { display: none; }

/* RESPONSIVE */
@media (max-width:480px){
  .card img { height: 120px; }
  .qtyInput { width: 56px; }
}

.card p.description {
  white-space: pre-line;
  line-height: 1.4;
  max-height: calc(1.4em * 5);
  overflow: hidden;
}

@media (max-width:600px){
  .modalBox {
    width: 95%;
    max-width: none;
    padding: 12px;
  }
  .card {
    width: 100%;
    margin-bottom: 16px;
  }
  #galleryImg {
    max-height: 60vh;
  }
}

/* Modal gestión imágenes */
#manageImagesModal .modalBox {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

#imagesGrid {
  height: 300px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px;
  justify-content: flex-start;
  border: 1px solid var(--line);
}

#imagesGrid img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

#imageControls {
  margin-top: 16px;
  flex-shrink: 0;
  text-align: center;
}

@media (max-width: 1024px) {
  #imagesGrid img { width: 100px; height: 100px; }
}
@media (max-width: 768px) {
  #imagesGrid img { width: 90px; height: 90px; }
}
@media (max-width: 480px) {
  #imagesGrid img { width: 80px; height: 80px; }
}

/* Adaptativo para pantallas chicas */
@media (max-width: 768px) {
  .headerLine {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .headerLine h2 {
    flex-basis: 100%;
    text-align: center;
    font-size: 1rem;
  }

  .categorySelectors,
  .searchCart {
    flex-basis: 100%;
    justify-content: center;
  }

  #searchBox, #cartBadge, select {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .headerLine {
    flex-direction: column;
    align-items: stretch;
  }

  .headerLine h2 {
    font-size: 0.95rem;
  }

  #searchBox {
    width: 100%;
  }

  .categorySelectors,
  .searchCart {
    width: 100%;
    justify-content: center;
  }
}
/* Modal Overlay por encima del header */
#galleryModal.modalOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #0009;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

/* Caja del modal */
#galleryModal .modalBox {
  background: var(--panel);
  padding: 20px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;   /* scroll vertical para descripción */
  border-radius: 12px;
  color: var(--muted);
  position: relative;
}

/* Bloque de galería */
.galleryWrap {
  margin-bottom: 16px;
  position: relative;
}

/* Contenedor de imágenes */
.galleryImageContainer {
  position: relative;
  width: 100%;
  height: 60vh; /* altura fija */
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Imagen principal centrada */
.mainImg {
  width: 65%;          /* ocupa 65% del ancho */
  height: auto;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
  border-radius: 6px;
  z-index: 2;
}

/* Previews laterales más grandes y difuminadas */
.previewImg {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 35%;          /* más ancho para que se note */
  height: auto;
  max-height: 100%;
  object-fit: contain;
  opacity: 0.4;
  filter: blur(6px);   /* blur más intenso */
  z-index: 1;
}

.previewImg.left { left: 0; }
.previewImg.right { right: 0; }

/* Flechas superpuestas sobre la imagen principal */
#prevImg, #nextImg {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  cursor: pointer;
}

#prevImg { left: 10px; }
#nextImg { right: 10px; }

/* Texto de descripción */
.galleryDesc {
  margin-top: 16px;
  white-space: pre-line;
  line-height: 1.4;
}
