/* === Base (lo que enviaste) === */
body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f1e8;
  color: #3e2723;
  overflow-x: hidden; /* Evitar scroll horizontal y asomo */
}

header {
  background: url('cafe.webp') center/cover no-repeat;
  color: white;
  text-align: center;
  padding: 50px 20px;
  font-size: 24px;
  font-weight: 600;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.5);
  letter-spacing: 1px;
}

nav {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #3b2b23;
  padding: 15px;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 18px;
  font-weight: 600;
  transition: color 0.3s ease;
}

nav a:hover {
  color: #ffb74d;
}

.cart-icon {
  font-size: 22px;
  color: white;
  cursor: pointer;
  transition: color 0.3s ease;
  position: relative;
}

.cart-icon:hover {
  color: #ffb74d;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ffb74d;
  color: white;
  font-size: 14px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 50%;
}

.cart-wrapper {
  position: relative;
  margin-left: 20px;
}

.container {
  padding: 40px 10%;
  text-align: center;
}

.carousel {
  max-width: 1100px;
  margin: auto;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  position: relative;
}

.carousel img {
  width: 100%;
  border-radius: 10px;
  height: auto;
  object-fit: cover;
  display: block;
}

.carousel-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  color: white;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.6);
  font-size: 36px;
  font-weight: 600;
  z-index: 1;
}

.products {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 30px;
  margin-top: 30px;
}

.product {
  background: white;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  width: 500px;
  max-width: 100%;
}

.product:hover {
  transform: translateY(-5px);
}

.product img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.product button {
  background-color: #6F4E37;
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 15px;
  transition: background 0.3s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.product button:hover {
  background-color: #8D6E63;
}

.about, .contact {
  margin-top: 50px;
  padding: 30px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

footer {
  background-color: #3b2b23;
  color: white;
  text-align: center;
  padding: 20px;
  margin-top: 50px;
  font-size: 16px;
}

.social-icons a {
  font-size: 28px;
  margin: 0 15px;
  color: #3b2b23;
}

.social-icons a:hover {
  color: #ffb74d;
}

/* Carrito lateral */
#cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background-color: #fff;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.25);
  padding: 20px 30px 20px 20px;
  transition: transform 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;

  /* Oculto por defecto con transform */
  transform: translateX(100%);
}

#cart-sidebar.open {
  transform: translateX(0);
}

#cart-sidebar h3 {
  margin-top: 0;
  color: #3e2723;
}

#cart-items {
  margin-top: 20px;
}

.cart-item {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  gap: 15px;
  padding: 10px;
  border-radius: 8px;
  background-color: #faf5f0;
  box-shadow: 0 2px 6px rgba(111, 78, 55, 0.15);
}

.cart-item img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.cart-item-details {
  flex: 1;
  text-align: left;
  font-size: 16px;
  line-height: 1.3;
  color: #3e2723;
  font-weight: 600;
}

.cart-item-details strong {
  font-size: 18px;
  display: block;
  margin-bottom: 6px;
}

#checkout-btn {
  background-color: #6F4E37;
  color: white;
  border: none;
  padding: 15px;
  width: 100%;
  border-radius: 5px;
  font-size: 18px;
  cursor: pointer;
  margin-top: 25px;
  font-weight: 600;
  transition: background 0.3s ease;
}

#checkout-btn:hover {
  background-color: #8D6E63;
}

#close-cart {
  background: transparent; 
  border: none; 
  font-size: 28px; 
  cursor: pointer; 
  position: absolute; 
  top: 10px; 
  right: 15px;
  color: #3e2723;
  font-weight: 700;
}

@media (max-width: 768px) {
  nav {
    flex-direction: column;
    align-items: center;
  }

  .nav-links {
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 10px;
  }

  nav a {
    margin: 10px 0;
    font-size: 18px;
  }

  .cart-wrapper {
    margin-top: 10px;
  }

  .container {
    padding: 20px 5%;
  }

  .carousel-text {
    font-size: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 0 10px;
  }

  .products {
    flex-direction: column;
    gap: 20px;
  }

  .product {
    width: 100%;
  }

  .about, .contact {
    padding: 20px 15px;
  }

  .social-icons a {
    font-size: 24px;
    margin: 0 10px;
  }

  /* Sidebar en móvil igual oculto por transform */
  #cart-sidebar {
    width: 100%;
    padding: 20px;
    transform: translateX(100%);
  }
  #cart-sidebar.open {
    transform: translateX(0);
  }
}
/* ===== Modal (popup) de pago / carrito ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background-color: white;
  padding: 24px;
  border-radius: 10px;
  max-width: 640px;
  width: 100%;
  text-align: left;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-top: 0;
}

.modal-cart-items .cart-item {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid #ddd;
  align-items: center;
}

.modal-cart-items .cart-item:last-child {
  border-bottom: none;
}

.modal-cart-items .cart-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
}

.modal-cart-items .cart-item-details {
  flex-grow: 1;
  padding: 0 12px;
  text-align: left;
}

.modal-cart-items .cart-item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.modal-cart-items .cart-item-actions input[type="number"] {
  width: 56px;
  padding: 6px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.remove-item {
  background-color: #ff4c4c;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
}

.remove-item:hover {
  background-color: #e04d46;
}

.form-group {
  margin-bottom: 16px;
  max-width: 420px;
}

.form-group input[type="text"],
.form-group input[type="date"] {
  margin-top: 8px;
  padding: 10px;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 16px;
  box-sizing: border-box;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.close-btn, .send-btn {
  background-color: #ff4c4c;
  color: white;
  border: none;
  padding: 10px 18px;
  font-size: 16px;
  border-radius: 5px;
  cursor: pointer;
}

.send-btn {
  background-color: #25d366;
}

.close-btn:hover {
  background-color: #e53935;
}

.send-btn:hover {
  background-color: #1ebe57;
}

@media (max-width: 480px) {
  .modal-content {
    padding: 16px;
  }
}

/* === Extras responsivos añadidos === */

/* Teléfonos muy pequeños (<=360px) */
@media (max-width: 360px) {
  header {
    padding: 36px 16px;
    font-size: 20px;
  }
  .carousel-text {
    font-size: 18px;
  }
  nav a {
    font-size: 16px;
  }
  .cart-item img {
    width: 64px;
    height: 64px;
  }
}

/* Tablet (481px–768px) – 2 columnas de producto, textos ajustados */
@media (min-width: 481px) and (max-width: 768px) {
  .container {
    padding: 28px 6%;
  }
  .carousel-text {
    font-size: 24px;
  }
  /* Cambiamos a grid para controlar columnas sin romper móvil */
  .products {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
  }
  .product {
    width: 100%;
  }
  #cart-sidebar {
    width: 85vw;
  }
}

/* Portátiles / pantallas medianas (769px–1024px) – 2/3 columnas según espacio */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 36px 8%;
  }
  .carousel {
    max-width: 1000px;
  }
  .carousel-text {
    font-size: 32px;
  }
  .products {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 26px;
  }
  #cart-sidebar {
    width: 360px;
  }
}

/* Escritorio (>=1025px) – 3 columnas, mayor respiro */
@media (min-width: 1025px) and (max-width: 1439px) {
  .container {
    padding: 44px 9%;
  }
  .products {
    display: grid;
    grid-template-columns: repeat(3, minmax(280px, 1fr));
    gap: 28px;
  }
  .carousel-text {
    font-size: 36px;
  }
  #cart-sidebar {
    width: 400px;
  }
}

/* Escritorio grande (>=1440px) – contenedores amplios y tipografía sutilmente mayor */
@media (min-width: 1440px) {
  .container {
    padding: 48px 12%;
  }
  .carousel {
    max-width: 1280px;
  }
  .carousel-text {
    font-size: 42px;
  }
  .products {
    display: grid;
    grid-template-columns: repeat(3, minmax(320px, 1fr));
    gap: 32px;
  }
  nav a {
    font-size: 19px;
  }
  #cart-sidebar {
    width: 420px;
  }
}

/* Mejoras de usabilidad en móvil: aumentar área táctil de botones */
@media (max-width: 768px) {
  .product button,
  #checkout-btn,
  .remove-item,
  .close-btn,
  .send-btn {
    padding: 14px 18px;
    font-size: 17px;
  }
}

/* Evitar header muy alto en landscape móvil */
@media (max-height: 420px) and (orientation: landscape) {
  header {
    padding: 28px 16px;
  }
  .carousel-text {
    font-size: 18px;
  }
}

/* Respeta preferencias de usuario: menos animación si lo piden */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
/* ===== BLOQUEO TOTAL DE SCROLL DEL FONDO MIENTRAS EL MODAL ESTÉ ABIERTO ===== */

/* Caso A: usando clase .modal-open en <body> o <html> */
html.modal-open,
body.modal-open {
  overflow: hidden !important;      /* Bloquea el scroll normal */
  position: fixed !important;       /* Fija la página (compatible con iOS) */
  inset: 0;                         /* top, right, bottom, left: 0 */
  width: 100%;
  touch-action: none;               /* Bloquea gestos táctiles (móvil/tablet) */
  -webkit-overflow-scrolling: auto; /* Quita el momentum en Safari */
  overscroll-behavior: contain;     /* Evita rebote al llegar al tope */
}

/* Evita que el contenido del fondo reciba clics o toques mientras el modal está abierto */
html.modal-open *:not(.modal):not(.modal *),
body.modal-open *:not(.modal):not(.modal *) {
  pointer-events: none;
}

/* Permite interacción SOLO dentro del modal */
html.modal-open .modal,
body.modal-open .modal,
html.modal-open .modal *,
body.modal-open .modal * {
  pointer-events: auto;
}

/* El modal ocupa toda la pantalla y puede tener su propio scroll interno */
.modal {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw;
  height: 100vh;
  overflow-y: auto;    /* Scroll interno solo dentro del modal */
  overflow-x: hidden;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  display: none;       /* Por defecto oculto */
}

/* Si se muestra con display:flex, fuerza su visibilidad */
.modal[style*="display: flex"] {
  display: flex !important;
}

/* Caso B (sin JS): bloquea fondo si el modal está visible usando :has() */
@supports selector(body:has(.modal)) {
  body:has(.modal[style*="display: flex"]),
  html:has(.modal[style*="display: flex"]) {
    overflow: hidden !important;
    position: fixed !important;
    inset: 0;
    width: 100%;
    touch-action: none;
    -webkit-overflow-scrolling: auto;
    overscroll-behavior: contain;
  }

  /* Evita eventos en el fondo */
  html:has(.modal[style*="display: flex"]) *:not(.modal):not(.modal *),
  body:has(.modal[style*="display: flex"]) *:not(.modal):not(.modal *) {
    pointer-events: none;
  }

  /* Mantiene interacción dentro del modal */
  html:has(.modal[style*="display: flex"]) .modal,
  body:has(.modal[style*="display: flex"]) .modal {
    pointer-events: auto;
  }
}

/* Evita que el sidebar del carrito mueva el fondo cuando hay modal */
html.modal-open #cart-sidebar,
body.modal-open #cart-sidebar,
html:has(.modal[style*="display: flex"]) #cart-sidebar,
body:has(.modal[style*="display: flex"]) #cart-sidebar {
  overflow: hidden !important;
}

/* Asegura compatibilidad total en móviles y tablets */
@media (max-width: 1024px) {
  html.modal-open,
  body.modal-open {
    position: fixed !important;
    overflow: hidden !important;
    width: 100%;
    height: 100%;
    touch-action: none;
  }
}
