/* ===================================================================
   Biopompas — estilos propios (complemento de Bootstrap 5)
   =================================================================== */
:root {
  --bp-green: #2e7d32;
  --bp-green-dark: #1b5e20;
  --bp-light: #f6f9f6;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1e2a1e;
}

/* Accesibilidad: contorno visible al navegar con teclado */
a:focus-visible,
button:focus-visible,
.nav-link:focus-visible,
.btn:focus-visible {
  outline: 3px solid rgba(46, 107, 79, .45);
  outline-offset: 2px;
  border-radius: .25rem;
}

/* Transición suave en botones */
.btn {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

/* Hero */
.hero {
  background: linear-gradient(180deg, var(--bp-light), #fff);
}
.hero h1 {
  color: var(--bp-green-dark);
}

/* Botones */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--bp-green);
  border-color: var(--bp-green);
}
.btn-outline-primary {
  color: var(--bp-green);
  border-color: var(--bp-green);
}
.btn-outline-primary:hover {
  background-color: var(--bp-green);
  border-color: var(--bp-green);
  color: #fff;
}

/* Navbar */
.navbar-brand img {
  display: block;
}

/* Contenido legal / html desde Sheets */
.legal-content h1, .legal-content h2, .legal-content h3 {
  margin-top: 1.5rem;
  color: var(--bp-green-dark);
}
.legal-content p {
  line-height: 1.7;
}

/* Contenido de páginas editoriales (sobre-biopompas, etc.) — color eco */
.page-content h2 {
  color: var(--bp-teal-dark);
  font-weight: 600;
}
.page-content h3 {
  color: var(--bp-teal);
}
.page-content p {
  line-height: 1.75;
}
.page-content .card {
  border-radius: 1.15rem;
}

/* Chat widget */
.chat-widget {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1050;
}
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--bp-teal-dark);
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 340px;
  max-height: 460px;
  background: #fff;
  border-radius: .75rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  background: var(--bp-teal-dark);
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-area {
  padding: .75rem;
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 320px;
}
.chat-msg {
  max-width: 85%;
  padding: .5rem .75rem;
  border-radius: .75rem;
  font-size: .875rem;
}
.chat-msg.bot {
  background: var(--bp-soft2);
  align-self: flex-start;
}
.chat-input {
  display: flex;
  gap: .5rem;
  padding: .75rem;
  border-top: 1px solid #eee;
}

/* Sidebar de categorías (2 niveles) — diseño de árbol mejorado */
.category-tree {}
.sidebar-title {
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--bp-green-dark);
  font-weight: 700;
  margin-bottom: 1rem;
}
.category-tree-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.category-tree-item {
  margin-bottom: .15rem;
}
.category-tree-root {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem .7rem;
  border-radius: .5rem;
  color: var(--bp-green-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s ease, color .15s ease;
}
.category-tree-root:hover {
  background: var(--bp-soft2);
  color: var(--bp-teal);
}
.category-tree-root.active {
  background: var(--bp-teal-dark);
  color: #fff;
  box-shadow: 0 2px 6px rgba(20,53,42,.25);
}
.category-tree-icon {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--bp-teal);
  flex: 0 0 auto;
  opacity: .5;
}
.category-tree-root.active .category-tree-icon {
  background: #fff;
  opacity: 1;
}
.category-tree-sub {
  list-style: none;
  padding: 0 0 0 1.4rem;
  margin: 0 0 .25rem;
  border-left: 2px solid var(--bp-soft2);
  margin-left: .85rem;
}
.category-tree-subitem {
  display: block;
  padding: .35rem .55rem;
  margin-left: .2rem;
  border-radius: .4rem;
  color: var(--bp-ink-soft);
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s ease, color .15s ease;
}
.category-tree-subitem:hover {
  background: var(--bp-soft2);
  color: var(--bp-teal);
}
.category-tree-subitem.active {
  background: var(--bp-teal-dark);
  color: #fff;
  font-weight: 600;
}

/* Tarjeta de producto */
.product-card {
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 .6rem 1.2rem rgba(0,0,0,.12) !important;
}
.product-card-link {
  display: block;
}
.product-card-link img {
  transition: transform .25s ease;
}
.product-card:hover .product-card-link img {
  transform: scale(1.04);
}
.product-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background: var(--bp-soft2);
  color: var(--bp-teal-dark);
  font-weight: 600;
  text-align: center;
  padding: 1rem;
}

/* Paginador */
.pagination {
  gap: .25rem;
}
.page-link {
  border: 0;
  border-radius: .5rem;
  color: var(--bp-green-dark);
  padding: .5rem .8rem;
  transition: background .15s ease, color .15s ease;
}
.page-link:hover {
  background: var(--bp-soft2);
  color: var(--bp-teal);
}
.page-item.active .page-link {
  background-color: var(--bp-teal-dark);
  color: #fff;
}
.page-item.disabled .page-link {
  color: #9cb0a0;
  background: transparent;
}

/* Fieldset de motivos (formulario) accesible */
fieldset legend {
  font-size: .9rem;
  color: var(--bp-green-dark);
  float: none;
  width: auto;
}

/* ---- Responsive / móvil ---- */
@media (max-width: 575.98px) {
  body {
    overflow-x: visible;
  }
  .display-5 {
    font-size: 2rem;
  }
  .display-md-4 {
    font-size: 2.25rem;
  }
  .fs-2 {
    font-size: 1.6rem !important;
  }
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  #store-list {
    max-height: 320px;
    overflow: auto;
  }
  .navbar-brand img {
    height: 32px;
  }
  .sidebar-list.category-tree-list {
    font-size: .9rem;
  }
  .category-tree-root {
    padding: .7rem .75rem; /* mayor área táctil en móvil */
  }
  fieldset {
    padding: .75rem !important;
  }
}

@media (max-width: 767.98px) {
  .breadcrumb {
    flex-wrap: wrap;
  }
  .legal-content, .page-content {
    font-size: .95rem;
  }
}

/* ---- Sticky Megamenu (header) ---- */
/* El header DEBE ser sticky y fijarse arriba. Bootstrap .sticky-top necesita que
   ningún ancestro tenga overflow distinto de 'visible'; por eso movemos el
   overflow-x del body a html en móvil. */
html {
  overflow-x: hidden;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: #fff;
}
.site-header .sticky-top {
  position: relative; /* el header ya es sticky; quitar el sticky-top anidado que anula */
}
.sticky-top {
  z-index: 1030;
}
.navbar-nav .nav-link {
  font-weight: 500;
  color: var(--bp-green-dark);
}
.dropdown-menu.mega-menu {
  min-width: 0;
  padding: 1.25rem 0;
  border: 0;
  border-radius: 0 0 1rem 1rem;
  box-shadow: 0 1rem 2rem rgba(20,53,42,.16);
}
/* Desktop (≥992px): el menú se ancla a la NAVBAR (position:static en el <li>)
   y ocupa el ancho completo del viewport; el .container interior centra el
   contenido, así SIEMPRE cabe en pantalla (no depende del ancho del <li>). */
@media (min-width: 992px) {
  .nav-item.dropdown-mega {
    position: static;
  }
  .dropdown-menu.mega-menu {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    transform: none;
  }
}

/* En móvil, el mega menú se muestra en el flujo (lista expandible) sin cortes */
@media (max-width: 991.98px) {
  .dropdown-menu.mega-menu {
    position: static;
    min-width: 100%;
    width: 100%;
    float: none;
    padding: .5rem 0;
    box-shadow: none;
    border-top: 1px solid #eef4ee;
  }
  .dropdown-menu.mega-menu .container,
  .dropdown-menu.mega-menu .row {
    padding-left: 0;
    padding-right: 0;
  }
}
.mega-title {
  display: block;
  font-weight: 700;
  color: var(--bp-green-dark);
  text-decoration: none;
  margin-bottom: .5rem;
  padding-bottom: .25rem;
  border-bottom: 2px solid #eef4ee;
}
.mega-title:hover {
  color: var(--bp-green);
}
.mega-sub {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mega-sub li a {
  display: block;
  padding: .35rem 0;
  color: #46684a;
  text-decoration: none;
  font-size: .9rem;
}
.mega-sub li a:hover {
  color: var(--bp-green);
  text-decoration: underline;
}

/* Aviso de consentimiento de cookies (RGPD / LSSI-CE) */
.cookie-consent {
  background: rgba(33, 37, 41, .97);
  color: #fff;
  padding: .9rem 0;
  z-index: 1040;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .3);
}
.cookie-consent[hidden] {
  display: none !important;
}
.cookie-consent a {
  color: #fff;
  text-decoration: underline;
}
.cookie-consent a:hover {
  color: var(--bp-green, #8fbc8f);
}

