/* ==================== 
   1. IMPORTACIÓN Y VARIABLES 
   ==================== */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&family=Playfair+Display&display=swap');

:root {
  --bg: #ffffff;
  --card: #2c5530;
  --accent: #4a7c59;
  --text: #2c3e50;
  --muted: #ffffff;
  --border: #e8f5e8;
  --shadow: rgba(0, 0, 0, 0.1);
  --menu-bg-hover: #1e3a21;
  --product-hover: #f8fdf8;
}

/* ==================== 
   2. TIPOGRAFÍA Y LAYOUT 
   ==================== */
body {
  margin: 0;
  font-family: "Open Sans", "Segoe UI", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ==================== 
   3. HEADER Y NAVEGACIÓN 
   ==================== */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #e8f5e8;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 4px 20px var(--shadow);
}

.container.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 30px;
  gap: 15px;
  flex-wrap: wrap;
  background: #e3f1e3;
  border-radius: 8px;
}

/* Logo y marca */
.brand {
  display: flex;
  align-items: center;
  gap: 2.4rem;
  text-decoration: none;
  font-weight: 700;
  color: #050505;
}

.brand span {
  font-size: 1.4rem;
  font-weight: bold;
}

.logo-img {
  height: 120px;
  width: auto;
  border-radius: 4px;
  padding: 4px;
}

/* Menú principal */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex-grow: 1;
}

.menu-item {
  display: inline-block;
  background: white;
  color: #212121;
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: 25px;
  padding: 0.45rem 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.menu-item:hover,
.menu-item.active {
  background: var(--menu-bg-hover);
  color: var(--muted);
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.2);
  transform: translateY(-2px);
}

/* ==================== 
   4. MENÚS DESPLEGABLES (scroll interno) - CORREGIDO
   ==================== */
.categories-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;

  /* ✅ Scroll principal del menú */
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}

.categories-menu.active {
  opacity: 1;
  visibility: visible;
}

/* Contenido del menú (listas o grid) - SIN max-height redundante */
.categories-menu ul,
.categories-menu .areas-grid {
  list-style: none;
  margin: 0;
  padding: 10px 0;
  /* ✅ No aplicamos max-height aquí para evitar scroll anidado */
}

.categories-menu li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.categories-menu li:last-child {
  border-bottom: none;
}

.categories-menu li a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  display: block;
  transition: all 0.3s ease;
}

.categories-menu li a:hover {
  color: #388e3c;
  background: var(--product-hover);
  border-radius: 6px;
  padding: 0.5rem 1rem;
}

/* Menú de ÁREAS TERAPÉUTICAS (grid) */
.areas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 10px;
}

.area-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.area-column a {
  color: #212121;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.5rem 0;
  transition: all 0.3s ease;
}

.area-column a:hover {
  color: var(--accent);
  background: var(--product-hover);
  border-radius: 6px;
  padding: 0.5rem 0.5rem;
}

/* Botón de cierre (móviles) */
.close-menu {
  display: none;
  position: sticky;
  top: 10px;
  right: 10px;
  background: #f5f5f5;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 10;
  align-self: flex-end;
  margin: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.close-menu::before {
  content: "×";
  font-weight: bold;
  color: #333;
}

/* ==================== 
   5. BUSCADOR 
   ==================== */
.buscador-container {
  position: relative;
  min-width: 200px;
  flex-shrink: 0;
}

#buscador {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px;
  border: 2px solid #ffffff;
  border-radius: 25px;
  outline: none;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

#buscador:focus {
  border-color: #28a745;
}

#resultados {
  position: absolute;
  top: 48px;
  width: 100%;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 1000;
  list-style: none;
  padding: 0;
  margin: 0;
}

#resultados li {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

#resultados li:hover {
  background: var(--product-hover);
  color: var(--accent);
}

/* ==================== 
   6. DETALLE DEL PRODUCTO 
   ==================== */
.page-wrapper {
  background: #e3f1e3;
  min-height: 100vh;
  padding: 2rem 0;
}

.producto-detalle {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  color: #2c5530;
}

.producto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.producto-info h1 {
  font-size: 3rem;
  color: var(--card);
  margin-bottom: 1.5rem;
}

.descripcion-corta {
  color: var(--card);
  opacity: 0.9;
}

/* Beneficios */
.beneficios li {
  color: var(--card);
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaf-icon {
  width: 18px;
  height: 18px;
  fill: #7cffd9;
}

/* Botones */
.btn-comprar {
  background: #28a745;
  color: white;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
  transition: all 0.3s ease;
}

.btn-comprar:hover {
  background: #218838;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

/* ==================== 
   7. ACORDEÓN 
   ==================== */
.accordion-header {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 14px 20px;
  font-weight: 600;
  color: var(--card);
  background: white;
  border: 1px solid var(--card);
  border-radius: 0;
}

.accordion-header .leaf-icon {
  fill: #28a745;
  margin-right: 10px;
}

.arrow {
  width: 10px;
  height: 10px;
  border: 2px solid;
  border-color: transparent #28a745 #28a745 transparent;
  transform: rotate(45deg);
  transition: transform 0.3s ease;
  margin-left: auto;
}

.accordion-item.active .arrow {
  transform: rotate(-135deg);
}

.accordion-content {
  max-height: 0;
  padding: 0 20px;
  overflow: hidden;
  transition: max-height 0.35s ease;
  background: white;
}

.accordion-content.open {
  padding: 14px 20px;
  max-height: 500px;
}

/* ==================== 
   8. FOOTER 
   ==================== */
footer {
  background: var(--card);
  color: var(--muted);
  padding: 1rem 0;
  text-align: center;
}

.footer-extra {
  background: #2c5530;
  color: var(--muted);
  padding: 2rem 0;
  font-size: 0.9rem;
}

.footer-container {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-section h4 {
  color: var(--muted);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  margin: 0.5rem 0;
}

.footer-section a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ==================== 
   9. RESPONSIVE (móviles) 
   ==================== */
@media (max-width: 768px) {
  .container.nav {
    flex-direction: column;
    padding: 15px;
  }

  .brand {
    flex-direction: column;
    gap: 0.5rem;
  }

  .logo-img {
    height: 60px;
  }

  .menu {
    width: 100%;
    justify-content: center;
  }

  .producto-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .producto-info h1 {
    font-size: 2.5rem;
  }

  /* Menú desplegable en móvil */
  .categories-menu {
    left: 5%;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .areas-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    padding: 10px 15px;
  }

  .area-column a {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .close-menu {
    display: block;
  }

  .buscador-container {
    width: 100%;
    margin-top: 10px;
  }

  #buscador {
    width: 100%;
  }
}

/* Carrusel responsivo */
.carousel {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 12px;
}

.carousel-images {
  display: flex;
  transition: transform 0.5s ease-in-out;
  width: 100%;
}

.carousel-images img {
  width: 100%;
  height: auto;
  object-fit: cover;
  flex-shrink: 0;
}

/* Botones de navegación */
.carousel-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 10px;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 0.3s;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-button:hover,
.carousel-button:focus {
  opacity: 1;
}

.prev {
  left: 10px;
}

.next {
  right: 10px;
}

/* Ocultar botones en móviles si se prefiere */
@media (max-width: 480px) {
  .carousel-button {
    opacity: 0.5;
  }
  .carousel-button:hover {
    opacity: 0.8;
  }
}

/* Estilos para resultados del buscador */
.resultados-busqueda {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  list-style: none;
  margin: 0;
  padding: 0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: none;
}

.resultados-busqueda li:hover,
.resultados-busqueda li:focus {
  background-color: #f5f5f5;
}

/* Menú áreas terapéuticas responsive (opcional, si usas esta clase) */
.areas-menu {
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.areas-menu::-webkit-scrollbar {
  width: 6px;
}

.areas-menu::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.areas-menu::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* ===== Footer 100% responsive y sin cortes ===== */
html, body {
  max-width: 100%;
  overflow-x: hidden;           /* evita scroll horizontal en móviles */
}

footer {
  width: 100%;
  padding: 24px 16px;
  box-sizing: border-box;       /* asegura que los paddings no “rompan” el ancho */
}

.footer-container {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)); /* 4 columnas desktop */
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Permite que el texto largo no saque la columna del grid */
.footer-col {
  min-width: 0;
}

.footer-col h3 {
  margin: 0 0 10px 0;
  line-height: 1.2;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-col a {
  text-decoration: none;
  word-break: break-word;       /* rompe palabras muy largas si hace falta */
}

/* Iconos fijos y que no empujen el layout */
.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-social .social-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

/* Copyright / aviso final centrado y legible */
.footer-bottom {
  text-align: center;
  padding: 12px 8px;
  font-size: 0.95rem;
}

/* ===== Breakpoints: 4 → 3 → 2 → 1 columnas ===== */
@media (max-width: 1024px) {
  .footer-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .footer-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { padding: 20px 14px; }
}
@media (max-width: 520px) {
  .footer-container { grid-template-columns: 1fr; }
  .footer-bottom { font-size: 0.9rem; }
}

/* (Opcional) si ves que el texto se pasa, baja un poco el tamaño en móviles */
@media (max-width: 400px) {
  footer { font-size: 0.96rem; }
}

/* ===== Botón: Regresar a la página anterior (móviles y desktop) ===== */
.btn-regresar,
.boton-regresar,
.regresar-anterior,
a.back-btn {
  display: block;                 /* evita deformaciones y solapamientos */
  width: 92%;                     /* se adapta al ancho del teléfono */
  max-width: 360px;               /* límite en pantallas grandes */
  margin: 18px auto 28px;         /* centrado y separación del footer */
  padding: 12px 16px;
  background: #2bb24a;            /* mismo verde de tu paleta */
  color: #fff !important;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(43,178,74,.25);
  line-height: 1.35;              /* permite que el texto haga salto limpio */
  white-space: normal;            /* el texto puede partirse en varias líneas */
  word-break: break-word;         /* evita que palabras largas “rompan” el botón */
  overflow: hidden;               /* no se sale el contenido */
}

.btn-regresar:hover,
.boton-regresar:hover,
.regresar-anterior:hover,
a.back-btn:hover {
  background: #249a3f;
  transform: translateY(-1px);
}

/* Ajustes finos en móviles */
@media (max-width: 480px) {
  .btn-regresar,
  .boton-regresar,
  .regresar-anterior,
  a.back-btn {
    font-size: .95rem;
    padding: 12px 14px;
    width: 94%;
    max-width: 340px;
  }
}
