body {
  font-family: "Nunito Sans", sans-serif;
  padding: 10px;
  background-color: #f8f9fa;
  color: #212529;
  box-sizing: border-box;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

/* --- Estilos para la sección de usuario --- */
#user-section {
  text-align: right;
  margin-bottom: 20px;
}

#user-section button {
  background-color: #343a40; /* Color oscuro sólido */
}

main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#tienda,
#resumen-carrito {
  width: 100%;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

#filtro-busqueda {
  width: 100%;
  padding: 10px;
  margin-bottom: 20px;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  font-size: 1em;
  box-sizing: border-box;
  font-family: "Nunito Sans", sans-serif;
}

h1,
h2,
h3 {
  color: #343a40;
}

.producto {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f3f5;
  padding: 15px 5px;
  transition: background-color 0.2s ease-in-out;
  border-radius: 4px;
  gap: 15px;
}

.producto-imagen {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  flex-shrink: 0; /* Evita que la imagen se encoja */
}

.producto-contenido {
  flex-grow: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.producto:hover {
  background-color: #f8f9fa;
}

.producto.sin-stock {
  opacity: 0.6;
  background-color: #e9ecef;
}

.producto.sin-stock:hover {
  /* Evita que el producto agotado cambie de color al pasar el ratón */
  background-color: #e9ecef;
}

.producto:last-child {
  border-bottom: none;
}

.producto-info {
  flex-grow: 1;
  font-size: 1.1em;
}

button {
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  font-weight: bold;
}

button:hover {
  transform: translateY(-1px);
}

.btn-agregar {
  background-color: #007bff;
}

.btn-agregar:hover {
  background-color: #0056b3;
}

button:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
  transform: none;
}

#carrito-acciones {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
  margin-top: 10px;
}

#carrito-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style-type: none;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f3f5;
  gap: 10px;
}

.btn-eliminar {
  background-color: #dc3545;
  padding: 5px 10px;
  font-size: 0.9em;
}

.btn-eliminar:hover {
  background-color: #c82333;
}

#total-container {
  text-align: right;
  font-size: 1.3em;
  font-weight: bold;
  margin-top: 20px;
}

#btn-pagar {
  width: 100%;
  padding: 15px;
  font-size: 1.1em;
  margin-top: 15px;
  background-color: #28a745;
}

#btn-pagar:hover {
  background-color: #218838;
}

#btn-pagar:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
  transform: none;
}

/* --- Media Queries para Diseño Responsivo (Desktop) --- */
@media (min-width: 800px) {
  body {
    padding: 20px;
  }

  main {
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-start;
    gap: 30px;
  }

  #tienda,
  #resumen-carrito {
    width: 48%;
  }

  #historial-compras {
    width: 98%;
  }
}

/* --- Animación para agregar al carrito --- */
@keyframes flash-producto {
  0% {
    background-color: #f8f9fa; /* Color de fondo inicial/hover */
  }
  50% {
    background-color: #cce5ff; /* Color del destello (azul claro) */
    transform: scale(1.01); /* Un ligero escalado para más impacto */
  }
  100% {
    background-color: #f8f9fa; /* Vuelve al color inicial */
  }
}

.producto-agregado-animacion {
  animation: flash-producto 0.7s ease-out;
}

/* --- Estilos para el historial --- */
#historial-compras {
  width: 100%;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

.compra-historial {
  border: 1px solid #e9ecef;
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
}

.compra-historial ul {
  padding-left: 20px;
}
