/* =========================================
   VARIABLES Y ESTILOS GENERALES
   ========================================= */
/* Asumo que tienes estas variables definidas en otro lado o en :root, 
   pero las mantengo usadas como en tu código original */

main {
  padding: 30px;
  max-width: 1100px;
  margin: auto;
  /* Espacio extra abajo para que el carrito no tape el último producto */
  padding-bottom: 80px; 
}

h2 {
  color: var(--rojo);
  border-bottom: 2px solid var(--naranja);
  padding-bottom: 5px;
  margin-top: 40px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  align-items: stretch;
}

/* =========================================
   TARJETAS DE PRODUCTO
   ========================================= */
.card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  justify-content: space-between; 
  flex-direction: column;
  transition: transform 0.2s;
}

.card:hover {
  transform: scale(1.02);
}

.card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.card-content {
  padding: 15px;
  flex-grow: 1;
}

.card h4 {
  margin: 0;
  color: var(--rojo);
}

.price {
  font-weight: bold;
  color: var(--naranja);
}

.quantity-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.quantity-controls button {
  background: var(--naranja);
  border: none;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

.quantity {
  font-weight: bold;
  font-size: 1.1em;
}

/* =========================================
   🔥 CARRITO FLOTANTE (CORREGIDO)
   ========================================= */
#cart {
  position: fixed;
  bottom: 0;
  right: 20px; /* Un poco separado del borde derecho se ve mejor */
  width: 350px;
  max-height: 70vh; /* Altura máxima del 70% de la pantalla */
  background: white;
  border-radius: 15px 15px 0 0;
  box-shadow: 0 -3px 12px rgba(0,0,0,0.2);
  
  /* LÓGICA DEL CAMBIO:
     100% baja todo el carrito (escondido).
     -50px sube solo la cabecera (que definimos abajo con 50px de alto).
     Así, no importa cuántos productos metas, solo se verá la cabecera. */
  transform: translateY(calc(100% - 50px)); 
  
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* Animación más suave */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

/* Estado abierto: se muestra entero */
#cart.open {
  transform: translateY(0);
}

#cart-header {
  background: var(--naranja);
  color: white;
  /* Definimos altura fija para que coincida con el cálculo del transform */
  height: 50px; 
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 1.1em;
}

/* Flechita visual opcional para indicar que se puede abrir */
#cart-header::after {
  content: ' ▲';
  font-size: 0.8em;
  margin-left: 8px;
  transition: transform 0.3s;
}
/* Cuando está abierto, girar la flechita */
#cart.open #cart-header::after {
  transform: rotate(180deg);
}

#cart ul {
  list-style: none;
  padding: 10px;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto; /* Scroll solo en la lista si hay muchos items */
}

#cart li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
  font-size: 0.9em;
}

.remove-btn {
  background: var(--rojo);
  border: none;
  color: white;
  font-size: 0.8em;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}

#cart-total {
  padding: 15px;
  font-weight: bold;
  border-top: 2px solid #eee;
  background-color: #fafafa;
  text-align: right;
  font-size: 1.1em;
}

.submit-btn {
  background: var(--naranja);
  color: white;
  text-align: center;
  font-weight: bold;
  padding: 12px;
  border-radius: 10px;
  margin: 10px 15px 15px 15px; /* Márgenes ajustados */
  text-decoration: none;
  display: block;
  border: none;
  cursor: pointer;
  width: auto; /* Ajuste automático dentro del flex */
}

.submit-btn:hover {
  background: var(--rojo);
}

/* =========================================
   FOOTER
   ========================================= */
footer {
  background-color: var(--rojo);
  color: white;
  text-align: center;
  padding: 20px 10px;
  margin-top: 50px;
}

footer a {
  color: var(--naranja);
  text-decoration: none;
}
