:root {
   /* Variables de Colores */
  --color-primario: #102b5f;
  --color-secundario: #ee2b8c;
  --color-fondo: #f5f5f5;
  --color-blanco: white;
  
  /* Variables de Capas (Z-Index) para evitar conflictos */
  --z-whatsapp: 100;
  --z-nav-mobile: 900;
  --z-backdrop: 998;
  --z-sidebar: 999;
  --z-search-overlay: 1000;
}

/* =========================================
   1. GLOBALES Y ESTRUCTURA
   ========================================= */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--color-fondo);
  color: #333;
}

.contenedor-principal {
  min-width: 320px;
  width: 95%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Contenedor Flex para Sidebar + Contenido */
.contenedor {
  display: flex;
  gap: 20px;
  padding: 20px;
  align-items: flex-start;
  position: relative;
}

.main-content {
  width: 100%;
  flex-grow: 1;
  min-width: 0; /* Evita desbordes en flexbox */
}

/* Componente Card Genérico */
.card {
  border-radius: 8px;
  box-shadow: 0px 2px 5px rgba(0,0,0,0.1);
  background: var(--color-blanco);
  padding: 20px;
}

/* =========================================
   2. HEADER Y NAV
   ========================================= */
header {
  background: var(--color-blanco);
  color: var(--color-primario);
  padding: 15px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 50;
}

.logo-cont, .logo-cont a {
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.logo { height: 60px; width: auto; display: block; }
.palabra-logo { height: 45px; display: block; }

nav {
  display: flex;
  gap: 20px;
}

nav a {
  color: #0d548b;
  margin-left: 20px;
  text-decoration: none;
  font-weight: bold;
  transition: 0.3s;
}

nav a:hover { color: var(--color-secundario); }

/* Buscador Header Desktop */
.search-container {
  position: relative;
  margin: 10px 40px;
}

.search-container input {
  width: 100%;
  max-width: 300px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
}

#clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  display: none;
  color: #555;
  font-size: 18px;
}

.menu-toggle {
  display: none;
  font-size: 28px;
  color: #0d548b;
  cursor: pointer;
}

/* Responsive Header */
@media (max-width: 768px) {
  header {
    padding: 15px 25px;
  }
  nav {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 80px;
    right: 0;
    left: 0;
    bottom: 0;
    /* CORREGIDO: Espacios en calc */
    min-height: calc(100vh - 80px);
    background: var(--color-primario);
    padding: 20px;
    gap: 20px;
    justify-content: flex-start;
    align-items: flex-start;
    z-index: var(--z-nav-mobile);
    overflow-y: auto;
  }

  nav a {
    margin: 10px 0;
    font-size: 18px;
    display: block;
    color: rgb(234, 237, 240);
  }

  .menu-toggle { display: block; }
  nav.active { display: flex; }

  .logo { height: 50px;}
  .palabra-logo { height: 40px;}
}

/* =========================================
   3. BANNER Y SECCIONES HOME
   ========================================= */
.banner {
  height: 450px;
  width: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
  border-radius: 10px;
}

.banner h2 { font-size: 36px; margin-bottom: 10px; margin-left: 8px; }
.banner p { font-size: 20px; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9); }

@media (max-width: 768px) {
  .banner { height: 230px; }
  .banner h2 { font-size: 22px; }
  .banner p { font-size: 14px; margin-left: 5px; } 
}

.titulo-seccion {
  text-align: center;
  font-size: 30px;
  margin-top: 40px;
  margin-bottom: 20px;
  color: var(--color-primario);
}

/* Marcas */
.marcas {
  background: var(--color-blanco);
  padding: 30px 20px;
  text-align: center;
}

.logos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 30px;
}

.logos img {
  max-height: 40px;
  object-fit: contain;
  transition: 0.3s;
}

.logos img:hover { transform: scale(1.1); }

@media (max-width: 768px) {
 .logos img { max-height: 25px; }
}

/* Categorías (Tarjetas Home) */
.categorias {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 60px 40px;
  background: var(--color-blanco);
}

.categoria {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  height: 250px;
  cursor: pointer;
  transition: 0.3s;
}

.categorias a {
  display: block; /* <--- ESTA ES LA CLAVE */
  text-decoration: none;
  color: inherit;
  height: 100%; /* Asegura que el enlace cubra toda la tarjeta */
}

.categoria:hover { transform: scale(1.03); }

.categoria img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.categoria h4 {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 10px;
  color: var(--color-blanco);
  font-size: 18px;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.4);
  text-align: center;
}

@media (max-width: 768px) {
    .categorias {
        grid-template-columns: repeat(2, 1fr);
        padding: 20px;
    } 
    .categoria { height: 150px; }
    .categoria h4 { font-size: 14px; padding: 8px; }  
}

/* =========================================
   4. SIDEBAR Y FILTROS (Optimizado para JS)
   ========================================= */
.filtro-lateral {
  flex-basis: 250px;
  flex-shrink: 0;
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  font-size: 14px;
}

.filtro-lateral h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.2rem;
  color: #333;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

/* Lista de Categorías */
.lista-filtros {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lista-filtros li {
  list-style: none;
  margin-bottom: 2px;
}

.lista-filtros a {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  color: #555;
  border-radius: 4px;
  transition: all 0.2s ease;
  /* El padding-left lo maneja el JS */
}

.lista-filtros a:hover {
  background-color: #f0f4f8;
  color: #007bff;
}

.lista-filtros a.filtro-activo {
  background-color: #e6f0ff;
  color: #0056b3;
  font-weight: bold;
  border-left: 3px solid #007bff;
}

/* Subcategorías (UL Anidado) */
.subcategorias {
  list-style: none;
  padding: 0; /* IMPORTANTE: 0 para evitar doble indentación con JS */
  margin: 0;
  display: none; /* JS controla el display block */
}

.subcategorias a {
  font-size: 0.95em;
  color: #666;
}

/* Filtros Marcas (Checkboxes) */
#contenedor-filtros-marcas {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

#contenedor-filtros-marcas h5 {
  font-size: 1em;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

#contenedor-filtros-marcas div {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

#contenedor-filtros-marcas input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

#contenedor-filtros-marcas label {
  cursor: pointer;
  color: #555;
  font-size: 14px;
  user-select: none;
}

/* Controles Móviles Sidebar */
.mobile-controls {
  display: none;
  padding: 10px 20px;
  background-color: #fff;
  border-bottom: 1px solid #eee;
}

#toggle-filtros-btn {
  background-color: var(--color-primario);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filtro-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-backdrop);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.filtro-backdrop.is-open {
  display: block;
  opacity: 1;
}

/* Por defecto oculto en escritorio */
.mobile-only {
    display: none;
}

/* Estilos para el botón de aplicar filtros */
.btn-aplicar {
    width: 100%;
    background-color: #007bff; /* Tu color principal */
    color: white;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
}

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

/* Mostrar solo en móvil (ajusta 768px a tu breakpoint) */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    /* Opcional: Hacer que el botón quede fijo abajo del todo si el menú es muy largo */
    .filtro-lateral {
        display: flex;
        flex-direction: column;
        height: 100vh; /* Ocupar toda la altura */
        overflow-y: auto;
        padding-bottom: 80px; /* Espacio para el botón si lo haces fijo */
        position: relative;
    }

    .filtro-actions {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 15px;
        border-top: 1px solid #eee;
        margin-top: auto; /* Empuja el botón al final */
        z-index: 10;
    }
}

/* =========================================
   5. PRODUCTOS Y GRILLA
   ========================================= */
.orden-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.orden-container label {
  margin-right: 10px;
  font-weight: 500;
  color: #555;
}

.orden-container select {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: white;
  cursor: pointer;
}

.productos  {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 240px));
  gap: 20px;
  padding: 20px 40px;
  justify-content: center;
}

.producto {
  background: var(--color-blanco);
  /* Hereda padding de .card o se define aquí si es necesario */
}

.producto:hover {
  transform: translateY(-5px);
  box-shadow: 0px 4px 15px rgba(0,0,0,0.15);
}

.imagen-producto-wrapper {
  width: 100%;
  height: 180px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  background-color: white;
  border-radius: 4px;
}

.imagen-producto-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.producto h4 {
  word-wrap: break-word;
  min-height: 3em;
}

.producto-precio {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--color-primario);
  margin: 10px 0;
}

.ver-detalles-btn {
  background: var(--color-secundario);
  color: var(--color-blanco);
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
  text-decoration: none;
  display: inline-block;
}

.ver-detalles-btn:hover { background: #132a55; }

.paginacion-container {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  gap: 5px;
  align-items: center;
}

.paginacion-btn {
  padding: 8px 12px;
  border: 1px solid #ccc;
  background-color: white;
  cursor: pointer;
  border-radius: 4px;
}

.paginacion-btn:disabled { cursor: not-allowed; opacity: 0.5; }
.pagina-actual { font-weight: bold; }

/* Responsive Productos y Contenedor */
@media (max-width: 768px) { 
    .contenedor {
        flex-direction: column;
        padding: 0;
    }

    .mobile-controls { display: block; }

    .orden-container {
        justify-content: space-between;
        padding: 15px 20px;
    }
    
    .contenedor-grid-productos {
         padding: 0 15px;
    }

    /* Sidebar móvil deslizante */
    .filtro-lateral {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        z-index: var(--z-sidebar);
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-radius: 0;
        overflow-y: auto;
    }

    .filtro-lateral.is-open {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }

    .productos {
        grid-template-columns: repeat(2, 1fr);
        padding: 10px 10px; 
        gap: 10px;
    }
    
    .producto h4 { margin: 5px 0; font-size: 14px; }
    .imagen-producto-wrapper { height: 120px; }
    .card { padding: 15px; }
    .ver-detalles-btn { padding: 6px 12px; font-size: 12px; } 
}

/* =========================================
   6. DETALLE DE PRODUCTO Y PÁGINAS
   ========================================= */
.detalle-producto {
  padding: 40px;
  background: white;
  margin: 40px auto;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  max-width: 800px;
}

.detalle-producto h1 {
  color: var(--color-primario);
  margin-bottom: 10px;
}

.detalle-precio {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--color-secundario);
  margin: 15px 0;
}

.detalle-producto #producto-descripcion {
  line-height: 1.6;
  font-size: 1.1em;
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
}

#imagen-principal-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  background-color: white;
}

#imagen-principal {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#galeria-thumbnails {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

#galeria-thumbnails .thumbnail {
  width: 80px;
  height: 80px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 8px;
  opacity: 0.6;
  transition: opacity 0.2s, border-color 0.2s;
}

#galeria-thumbnails .thumbnail-active {
  opacity: 1;
  border-color: var(--color-primario);
}

@media (min-width: 768px) {
  .detalle-producto {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    text-align: left;
  }
  .columna-imagen, .columna-info { flex: 1; }
}

.cta-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 25px;
  background-color: #25D366;
  color: white;
  text-decoration: none;
  font-weight: bold;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.cta-btn:hover { background-color: #1DAE5A; }

/* Variaciones */
.variaciones-botones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.variacion-btn {
    padding: 8px 16px;
    border: 2px solid #ccc;
    border-radius: 20px;
    background-color: #f9f9f9;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.variacion-btn:hover { border-color: #888; }

.variacion-btn.active {
    border-color: #0d1a33;
    background-color: #0d1a33;
    color: white;
}

/* Quiénes Somos */
main {
  padding: 40px;
  background: white;
  margin: 20px auto;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  max-width: 800px;
}
main h1 {
  color: var(--color-primario);
  text-align: center;
  margin-bottom: 30px;
  font-size: 2.5em;
}
main p {
  line-height: 1.8;
  margin-bottom: 20px;
  font-size: 1.1em;
}

/* =========================================
   7. SEARCH OVERLAY & EXTRAS
   ========================================= */
.search-overlay {
  position: fixed;
  top: 0; 
  right: 0;
  width: 350px;
  max-width: 90%;
  height: 100%;
  background-color: white;
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  padding: 20px;
  z-index: var(--z-search-overlay);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
} 

.search-overlay.is-active { transform: translateX(0); } 
 
.search-overlay input[type="search"]:focus {
  border-color: #1885d8;
  box-shadow: 0 0 5px rgba(24, 133, 216, 0.5);
  outline: none;
}

#overlay-search-input {
  width: 100%;
  padding: 10px;
  font-size: 18px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
#search-form { margin-top: 30px; }

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
  color: #555;
  cursor: pointer;
  z-index: 10;
}

#overlay-results-container { margin-top: 20px; }

#overlay-results-container div {
  padding: 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

#overlay-results-container img {
  width: 50px;
  height: 50px;
  margin-right: 10px;
}

.search-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
}

.search-icon-btn i {
  font-size: 20px;
  color: var(--color-primario);
  transition: transform 0.2s;
}

.search-icon-btn:hover i { transform: scale(1.1); color: var(--color-secundario);}

/* Buscador en menú móvil */
#nav #search-form { display: none; }

@media (max-width: 768px) {
    #open-search-btn { display: none; }
    #nav #search-form {
        display: block;
        margin-bottom: 20px;
    }
    #nav #overlay-search-input {
        background-color: #132a55;
        color: white;
        border: 1px solid #3d4a66;
    }
}

.mobile-search-trigger {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #132a55;
    border: 1px solid #3d4a66;
    border-radius: 5px;
    color: #ccc !important;
    margin-bottom: 20px !important;
}

@media (max-width: 768px) {
    nav.active .mobile-search-trigger { display: flex; }
}

/* Page Backdrop */
.page-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.page-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

/* =========================================
   8. FOOTER Y SOCIAL
   ========================================= */
footer {
  background: var(--color-primario);
  color: var(--color-blanco);
  text-align: center;
  padding: 20px 10px;
  margin-top: 40px;
}

footer p { margin: 8px 0; }

.social-links {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 10px 0;
}

.social-links img {
  width: 30px;
  height: 30px;
  transition: transform 0.3s;
}

.social-links img:hover { transform: scale(1.1); }

/* WhatsApp */
.whatsapp-float {
  position: fixed;
  width: 60px;
  height: 60px;
  bottom: 20px;
  right: 20px;
  background-color: #25d366; /* Color corregido */
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0px 2px 10px rgba(0,0,0,0.3);
  z-index: var(--z-whatsapp);
  transition: transform 0.3s;
}

.whatsapp-float:hover { transform: scale(1.1); }

.whatsapp-float img { width: 35px; height: 35px; }