/* ----------------------------------
   1. REGLAS GLOBALES Y BARRAS
------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: #f9f9f9;
  scroll-behavior: smooth;
}

/* Redes Sociales */
.redes-sociales {
  background-color: #007BFF;
  display: flex;
  justify-content: center;
  padding: 10px 0;
}
.redes-sociales img {
  width: 30px;
  height: 30px;
  margin: 0 15px;
}

/* Barra Desktop Contenedora */
.barra-desktop {
  display: block;
}

/* Barra Superior Desktop */
.barra-superior-desktop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: white;
  border-bottom: 2px solid #ddd;
}
.barra-superior-desktop .logo img {
  width: 160px;
  height: auto;
}
.barra-superior-desktop .buscador input {
  padding: 7px;
  border-radius: 15px;
  border: 1px solid #ccc;
  width: 500px;
}
.barra-superior-desktop .carrito img {
  width: 35px;
  height: 35px;
}
.barra-superior-desktop .carrito {
  display: flex;
  align-items: center;
  gap: 10px;
}
.barra-superior-desktop .carrito span {
  display: flex;
  align-items: center;
}

/* Categorías (solo escritorio) */
.categorias {
  display: flex;
  justify-content: space-around;
  background-color: #f9f9f9;
  padding: 10px 0;
  font-weight: bold;
  border-bottom: 2px solid #ddd;
}
.categorias a {
  text-decoration: none;
  color: black;
  transition: color 0.3s ease, transform 0.3s ease;
}
.categorias a:hover {
  color: #00FFFF;
  transform: scale(1.1);
}

/* Barra Móvil */
.barra-movil {
  display: none; /* Oculto en escritorio */
}

/* Barra Superior Móvil */
.barra-superior-movil {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: white;
  border-bottom: 1px solid #ddd;
}
.barra-superior-movil .logo img {
  max-height: 40px;
  object-fit: contain;
}
.barra-superior-movil .buscador {
  flex-grow: 0; /* Evita que el buscador ocupe todo el espacio disponible */
  margin-left: auto; /* Empuja el buscador hacia la derecha */
}
.barra-superior-movil .buscador input {
  width: 100%;
  max-width: 250px;
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 15px;
  font-size: 14px;
  outline: none;
}

/* Barra Menú-Carrito Móvil */
.barra-menu-carrito-movil {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  background-color: white;
}
.barra-menu-carrito-movil .boton-menu {
  background-color: transparent;
  border: none;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='40' height='40' rx='8' fill='%23007BFF'/%3E%3Crect x='10' y='12' width='20' height='2' rx='1' fill='%23ffffff'/%3E%3Crect x='10' y='19' width='20' height='2' rx='1' fill='%23ffffff'/%3E%3Crect x='10' y='26' width='20' height='2' rx='1' fill='%23ffffff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 40px 40px;
}
.barra-menu-carrito-movil .boton-menu:hover {
  background-color: transparent;
}
.barra-menu-carrito-movil .carrito {
  display: flex;
  align-items: center;
  gap: 10px;
}
.barra-menu-carrito-movil .carrito img {
  width: 35px;
  height: 35px;
  display: block;
}
.barra-menu-carrito-movil .carrito span {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  color: #333;
}
.carrito:hover {
  transform: scale(1.1);
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

/* Secciones, productos, etc. */
.seccion {
  margin: 40px auto;
  width: 90%;
}
.titulo-seccion {
  text-align: left;
  font-size: 2rem;
  margin: 10px 0 20px 10px;
  color: #000000;
}
.productos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.producto {
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 15px;
  background-color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between; /* Por defecto, en escritorio */
  text-align: center;
  gap: 5px;
}
.producto img {
  width: 100%;
  height: 250px;
  object-fit: contain;
  border-radius: 5px;
}
.producto h3 {
  margin: 10px 0;
  font-size: 1.6rem;
  font-weight: bold;
}
.producto p {
  font-size: 1.4rem;
  color: #333333;
}
.producto:hover {
  transform: translateY(-5px);
}
.btn-carrito {
  display: inline-block;
  padding: 15px 25px;
  font-size: 1.2rem;
  background-color: #007BFF;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.btn-carrito:hover {
  background-color: #00FFFF;
}

/* ----------------------------------
   2. CARRUSEL DE ESCRITORIO
------------------------------------- */
.carrusel-desktop {
  /* Por defecto, se muestra en escritorio */
  display: block;
}
.carrusel {
  width: 100%;
  max-width: 1200px;
  height: 400px; 
  margin: 20px auto;
  overflow: hidden;
  position: relative;
  border-radius: 10px;
  border: 2px solid #ccc; /* Solo para ver el contenedor */
}
.carrusel-inner {
  display: flex;
  width: 400%; /* 4 imágenes = 4x100% */
  animation: slideInfinite 15s linear infinite;
}
.carrusel img {
  width: 100%;
  height: 400px;
  object-fit: cover;
}
@keyframes slideInfinite {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* =====================
   CARRUSEL MÓVIL
===================== */
.carrusel-movil {
  /* El resto de propiedades se mantienen tal cual en tu código */
  display: none;               /* Oculto en escritorio */
  width: 100%;
  max-width: 1200px;
  margin: 20px auto;
  overflow: hidden;            /* Oculta lo que salga del contenedor */
  position: relative;
  border-radius: 10px;
  border: 2px solid #ccc;
}
.carrusel-movil-inner {
  display: flex;
  width: 200%;
  animation: autoSlideMovil 16s linear infinite;
}
.carrusel-movil-inner img {
  width: 50%;
  object-fit: contain;
}
@keyframes autoSlideMovil {
  0%, 49.999% {
    transform: translateX(0);
  }
  50%, 99.999% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}

/* ----------------------------------
   4. VENTANAS EMERGENTES Y OTROS
------------------------------------- */
.ventana-carrito {
  display: none;
  position: fixed;
  top: 20%;
  right: 20px;
  width: 300px;
  background-color: white;
  padding: 15px;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  z-index: 1000;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s ease;
}
.ventana-carrito.mostrar {
  display: block;
  transform: translateY(0);
  opacity: 1;
}
.ventana-carrito h2 {
  text-align: center;
}
.ventana-carrito ul {
  list-style: none;
  padding: 0;
}
.ventana-carrito li {
  margin: 10px 0;
}
.ventana-carrito button {
  margin-top: 10px;
  display: block;
  width: 100%;
  padding: 10px;
  background-color: #007BFF ;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.ventana-carrito button:hover {
  background-color: #00FFFF;
}

.cantidad-controles {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.cantidad-controles button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background-color: #007BFF;
  color: white;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}
.cantidad-controles button:hover {
  background-color: #00FFFF;
}
.cantidad-controles span {
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  min-width: 20px;
}
.producto-carrito {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 10px;
}

/* Detalle del producto */
.ventana-producto {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: 80%;
  max-width: 500px;
  background-color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
  max-height: 80%;
}
.ventana-producto img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 10px;
}
.ventana-producto h2 {
  font-size: 1.5rem;
  margin: 10px 0;
}
.ventana-producto p {
  margin: 10px 0;
  text-align: justify;
  line-height: 1.5;
}
.ventana-producto button {
  background-color: #007BFF;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 15px;
}
.ventana-producto button:hover {
  background-color: #00FFFF;
}
.cerrar {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  cursor: pointer;
  color: #333;
}
.cerrar:hover {
  color: red;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* Menú móvil desplegable */
.ventana-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(19, 21, 44, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 2000;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.ventana-menu a {
  color: white;
  font-size: 1.5rem;
  text-decoration: none;
  text-align: center;
  transition: color 0.3s ease, transform 0.3s ease;
}
.ventana-menu a:hover {
  color: #00FFFF;
  transform: scale(1.1);
}
.cerrar-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: transparent;
  color: white;
  font-size: 20px;
  border: none;
  cursor: pointer;
}
.cerrar-menu:hover {
  color: red;
}
.ocultar {
  display: none; /* Oculta el menú */
}

/* ----------------------------------
   5. MEDIA QUERIES GLOBALES
------------------------------------- */

/* Móviles y tablets hasta 768px */
@media (max-width: 768px) {
  /* Ocultar escritorio, mostrar móvil */
  .barra-desktop {
    display: none;
  }
  .barra-movil {
    display: block;
  }

  /* El carrusel de escritorio se oculta */
  .carrusel-desktop {
    display: none;
  }
  /* El carrusel de móvil se muestra */
  .carrusel-movil {
    display: block;
  }

  /* Dos productos por fila */
  .productos {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    align-items: stretch; /* Para alinear todas las tarjetas a la misma altura */
  }

  /* Ajustamos la imagen un poco más pequeña en móvil */
  .producto img {
    height: 200px;
  }

  /* Para que el botón se quede al fondo y centrado en X */
  .producto {
    justify-content: flex-start;
    align-items: stretch; /* Ocupa todo el alto para que margin-top: auto funcione */
  }
  .btn-carrito {
    margin-top: auto;
    align-self: center;
  }

  .ventana-carrito {
    right: 10px;
    width: 90%;
  }
  .ventana-producto {
    width: 90%;
  }
}

/* Móviles muy pequeños (por debajo de 480px) */
@media (max-width: 480px) {
  /* Mantenemos ocultas las categorías en el menú superior */
  .categorias {
    display: none; 
  }

  /*
    ¡IMPORTANTE!
    Removemos la regla anterior que forzaba 1 columna:
    .productos { grid-template-columns: 1fr; }
    Para que siga habiendo 2 productos por fila en cualquier móvil.
  */

  .titulo-seccion {
    text-align: center;
    font-size: 1.8rem;
  }
  .btn-carrito {
    padding: 10px;
    font-size: 1rem;
  }
}
