/* ==========================================================================
   ESTILOS DE LA TIENDA (SHOP) - Actualizado
   ========================================================================== */

/* Ajuste de Ancho: Más aire en escritorio (90%) */
.shop-container-wrapper.content-container {
    width: 90%;
    max-width: 1400px; /* Un poco más ancho que el home para que quepan 4 productos */
    margin: 0 auto;
}

.shop-header {
    text-align: center;
    padding: 40px 0 50px 0;
}
.shop-header h1 { font-size: 38px; color: #333; margin-bottom: 10px; }

/* Layout Principal */
.shop-layout {
    display: flex;
    gap: 50px; /* Más espacio entre sidebar y grid */
    margin-bottom: 80px;
    position: relative; /* Necesario para el sticky del hijo */
}

/* --- SIDEBAR STICKY --- */
.shop-sidebar {
    flex: 0 0 260px;
    height: fit-content; /* Importante para sticky */
    position: -webkit-sticky; /* Safari */
    position: sticky;
    top: 100px; /* Se pega al techo cuando haces scroll (dejando espacio para navbar) */
    z-index: 90;
}

.filter-box {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #eee;
}

/* Buscador con Autocomplete */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-wrapper input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}
.search-input-wrapper button {
    position: absolute;
    right: 5px;
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
}

/* Dropdown de Resultados en Vivo */
.live-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-top: 5px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    z-index: 100;
    display: none; /* Oculto por defecto */
    max-height: 300px;
    overflow-y: auto;
}
.live-results-dropdown.active { display: block; }

.live-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #f5f5f5;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}
.live-item:hover { background: #f0f8ff; }
.live-item img { width: 40px; height: 40px; object-fit: contain; }
.live-item-info { display: flex; flex-direction: column; }
.live-item-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.live-item-ref { font-size: 11px; color: #888; }

/* Filtro Precio */
.price-inputs {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-bottom: 10px;
}
.price-inputs input {
    width: 45%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}
.btn-filter-apply {
    width: 100%;
    background-color: #333;
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-filter-apply:hover { background-color: #007bff; }

/* --- GRID --- */
.shop-grid-container { flex: 1; }

.shop-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}
.sorting-box select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #555;
    cursor: pointer;
}

.products-grid {
    display: grid;
    /* Rejilla responsiva automática con mínimo de 240px */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 30px;
}

/* --- CARD PRODUCTO --- */
.product-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
    transform: translateY(-5px);
    border-color: #e0e0e0;
}
.product-image-wrapper {
    position: relative;
    width: 100%;
    /* Establece una altura fija o una relación de aspecto para uniformidad */
    padding-bottom: 100%; /* Crea un cuadrado perfecto para la imagen */
    overflow: hidden; /* Importante para recortar cualquier desbordamiento */
    background-color: #f9f9f9; /* Fondo claro para imágenes transparentes */
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #eee;
}

.product-image-wrapper img {
    position: absolute; /* Permite que la imagen ocupe el espacio */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* <--- ¡ESTO ES CLAVE! Ajusta la imagen dentro del contenedor sin recortarla, manteniendo su relación de aspecto. */
    object-position: center; /* Centra la imagen si hay espacio extra */
    transition: transform 0.3s ease;
}

.product-card:hover .product-image-wrapper img {
    transform: scale(1.05); /* Pequeño zoom al pasar el ratón */
}

.stock-badge {
    position: absolute;
    top: 10px; left: 10px;
    font-size: 10px; font-weight: 700;
    padding: 3px 8px; border-radius: 4px;
    text-transform: uppercase;
}
.stock-badge.in-stock { background: #e6fffa; color: #00b894; }
.stock-badge.no-stock { background: #fff5f5; color: #ff7675; }

.product-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; }
.product-ref { font-size: 11px; color: #999; text-transform: uppercase; font-weight: 600;}
.product-info h3 {
    font-size: 15px; margin: 5px 0 15px 0; color: #333;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; }
.price-amount { font-size: 18px; font-weight: 700; color: #007bff; display: block; }
.price-tax { font-size: 10px; color: #888; }
.add-cart-btn {
    width: 35px; height: 35px;
    border-radius: 50%; border: none;
    background: #f0f8ff; color: #007bff;
    cursor: pointer; transition: all 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.add-cart-btn:hover { background: #007bff; color: #fff; }

/* --- PAGINACIÓN --- */
.shop-pagination {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.page-link {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #555;
    transition: all 0.2s;
}
.page-link.active, .page-link:hover {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.category-list a.active {
    color: #007bff;
    font-weight: 700;
    padding-left: 5px;
    border-left: 2px solid #007bff;
}

/* Estilo para los puntos suspensivos de paginación */
.page-link.dots {
    border: none;
    background: none;
    cursor: default;
}

/* Estilos para la lista de categorías */
.category-list a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.3s, padding-left 0.3s;
    display: flex; /* Usamos flex para alinear el texto y el badge */
    justify-content: space-between; /* Separa texto a la izq y badge a la der */
    align-items: center;
}

/* Badge de conteo */
.cat-count-badge {
    background-color: #f1f3f5;
    color: #adb5bd;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Efecto Hover en la categoría */
.category-list a:hover {
    color: #007bff;
    padding-left: 5px;
}

/* Cuando hacemos hover, el badge también se ilumina */
.category-list a:hover .cat-count-badge,
.category-list a.active .cat-count-badge {
    background-color: #eaf6ff;
    color: #007bff;
}

/* Ajuste de Ancho y Espaciado Superior para evitar solapamiento con Navbar */
.shop-container-wrapper.content-container {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    /* Aumentamos el margin-top para compensar el navbar fixed (aprox 80px + espacio extra) */
    margin-top: 120px; 
}

.shop-header {
    text-align: center;
    padding: 0 0 60px 0; /* Quitamos padding top aquí porque lo manejamos con margin-top en el container */
}

/* Nuevo botón simple para la tarjeta en shop (reemplaza a add-cart-btn) */
.view-details-btn {
    display: inline-block;
    color: #007bff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #007bff;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.view-details-btn:hover {
    background-color: #007bff;
    color: #fff;
}

/* Ajustes de Product Info en Shop */
.product-info { 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
    justify-content: space-between; /* Empuja el footer abajo */
}

/* --- Árbol de Categorías (Sidebar) --- */
.category-accordion {
    font-size: 14px;
}
.cat-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}
.cat-item {
    margin-bottom: 5px;
}

.cat-header {
    display: flex;
    align-items: center;
    position: relative;
}

.cat-header a {
    text-decoration: none;
    color: #555;
    flex-grow: 1;
    padding: 5px 0;
    transition: color 0.2s;
    display: flex;
    justify-content: space-between;
}
.cat-header a:hover, .cat-header a.active {
    color: #007bff;
    font-weight: 600;
}
.cat-header .count {
    font-size: 11px;
    background: #f0f0f0;
    padding: 1px 6px;
    border-radius: 10px;
    color: #888;
}

/* Flecha Toggle */
.cat-toggle {
    width: 20px;
    min-width: 20px;
    height: 20px;
    cursor: pointer;
    margin-right: 5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s;
}
.cat-toggle.open {
    transform: rotate(90deg);
}

/* Hijos */
.cat-children {
    padding-left: 20px;
    display: none; /* JS lo maneja */
    border-left: 1px solid #eee;
    margin-left: 9px; /* Alinear con flecha */
}

/* --- RESPONSIVE --- */
@media (max-width: 992px) {
    .shop-layout { flex-direction: column; }
    .shop-sidebar { 
        position: static; /* En móvil deja de ser sticky para no estorbar */
        width: 100%; 
    }
    /* Filtros en fila en tablet/movil */
    .shop-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .search-filter { grid-column: span 2; }
}
@media (max-width: 600px) {
    .shop-sidebar { display: block; } /* Una columna en móvil */
    .products-grid { grid-template-columns: 1fr 1fr; gap: 15px; } /* 2 columnas apretadas en móvil */
    .shop-header h1 { font-size: 28px; }
    
    /* Ajuste fino para tarjetas pequeñas en móvil */
    .product-image-wrapper { height: 150px; padding: 10px; }
    .price-amount { font-size: 16px; }
    .product-info { padding: 10px; }
}