/* ==========================================================================
   Sección: Reconstrucción del Área de Productos (Filtros y Layout)
   ========================================================================= */
.catalog-products-area {
    flex: 1;
    min-width: 0;
}

/* --- Título Principal --- */
.catalog-main-title {
    font-size: 32px;
    font-weight: 700;
    color: #666; /* Gris oscuro del diseño */
    margin: 0 0 20px 0;
    letter-spacing: -0.5px;
}

/* --- Barras de Controles Superiores --- */
.catalog-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    margin-bottom: 30px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* --- Botón Verde "Ordenar por" (Fusión exacto) --- */
.ordering-wrapper {
    display: flex;
    align-items: stretch;
    background: #ffffff;
    border-radius: 30px; /* Borde súper redondeado de píldora */
    overflow: hidden; /* Corta lo que se salga para mantener la forma */
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); /* Sombra muy sutil */
}

.ordering-label {
    background-color: #00b912;
    color: #fff;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Selector de WooCommerce modificado */
.ordering-wrapper .woocommerce-ordering {
    margin: 0 !important;
    
}

.ordering-wrapper .woocommerce-ordering select {
    border: none;
    background: transparent;
    padding: 8px 35px 8px 15px; /* Espacio extra a la derecha para la flecha */
    font-size: 14px;
    color: #555;
    outline: none;
    cursor: pointer;
    box-shadow: none;
    appearance: none; /* Quita estilos por defecto del navegador */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23555" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    
}

/* Mostrando resultados */
.results-count-wrapper p {
    margin: 0 !important;
    font-size: 13px;
    color: #888;
}

/* --- Paginación Circular Perfectamente Centrada (Paso Clave) --- */
/* --- Paginación Circular Perfectamente Centrada --- */
.catalog-pagination-wrapper .woocommerce-pagination {
    margin: 0 !important;
    border: none !important;
}

.woocommerce nav.woocommerce-pagination ul {
    border: none !important;
}

.woocommerce-pagination ul {
    display: flex !important;
    gap: 12px !important; /* Separación clara para que no se peguen como en tu imagen */
    align-items: center !important;
    justify-content: center !important; /* Centrado horizontal */
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Resetear márgenes traicioneros de WooCommerce en los elementos de la lista */
.woocommerce-pagination ul li {
    border: none !important;
    margin: 0 !important; 
    padding: 0 !important;
}

/* Círculos base para enlaces y span current */
.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span.current {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important; /* Centrado interno del número */
    width: 40px !important; /* Medida exacta de tu Figma */
    height: 40px !important; /* Medida exacta de tu Figma */
    border-radius: 50% !important; /* Círculos perfectos */
    font-size: 16px !important; /* Medida exacta de tu Figma */
    font-weight: 600 !important; /* Semibold */
    line-height: 1 !important; /* CLAVE: Evita que el número se hunda */
    text-decoration: none !important;
    border: none !important;
    transition: all 0.3s ease !important;
    padding: 0 !important; 
    box-sizing: border-box !important;
}

/* Estado Inactivo (Círculo verde clarito) */
.woocommerce-pagination ul li a {
    background: #eaf4ea !important;
    color: #005a1e !important; /* Verde oscuro para hacer contraste como en Figma */
}

.woocommerce-pagination ul li a:hover {
    background: #d4ebd4 !important;
    color: #00b912 !important;
}

/* Estado Activo (Círculo verde oscuro sólido) */
.woocommerce-pagination ul li span.current {
    background: #00b912 !important;
    color: #ffffff !important;
}

/* Flechas (Next/Prev) */
.woocommerce-pagination ul li a.next,
.woocommerce-pagination ul li a.prev {
    font-size: 22px !important; /* Hacemos la flecha un poco más grande */
}

/* Paginación inferior */
.catalog-pagination-bottom {
    display: flex;
    justify-content: center;
    margin-top: 50px;
}
/* ==========================================================================
   Grilla y Tarjetas de Productos (Diseño Final)
   ========================================================================= */

.catalog-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columnas en desktop */
    gap: 20px;
}

/* --- Estructura Principal de la Card --- */
.custom-catalog-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Max-width ayuda a mantener la proporción si la pantalla es muy grande */
    max-width: 229px; 
    margin: 0 auto;
    box-sizing: border-box;
}

/* --- Contenedor de la Imagen --- */
.card-image-wrapper {
    position: relative;
    background-color: #f8f9fc; /* Fondo gris/azulado suave */
    border-radius: 20px;
    
    /* CAMBIO CLAVE: Quitamos la altura fija de 220px y usamos un aspect-ratio */
    width: 100%;
    aspect-ratio: 1 / 1; /* Esto crea un contenedor perfectamente cuadrado, reduciendo padding */
    
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden; /* Corta cualquier parte de la imagen que se salga */
    padding: 0 !important;
    box-sizing: border-box;
}

.custom-catalog-card:hover .card-image-wrapper {
    transform: translateY(-5px); /* Pequeño salto al pasar el mouse */
}

.card-image-link {
    width: 100%;
    height: 100%;
display: block;
}

.card-image-link img {
    /* CAMBIO CLAVE: Quitamos max-width y max-height, y usamos width y height 100% */
    width: 100%;
    height: 100%;
    
    /* CAMBIO CLAVE: Usamos 'cover' para que la imagen cubra todo el box, escalándose */
    object-fit: cover; 
    
    border-radius: 20px; /* Pequeño redondeado interno */
}
/* --- Badges / Etiquetas Flotantes --- */
.card-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 2;
}

.badge {
    font-size: 10px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
}

.badge i {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Colores específicos por etiqueta */
.badge-personalizable { background-color: #a855f7; } /* Morado */
.badge-nuevo { background-color: #ef4444; } /* Rojo */
.badge-darc { background-color: #374151; } /* Gris oscuro */

/* --- Información del Producto --- */
.card-info-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-meta {
    font-size: 11px;
    color: #9ca3af; /* Gris claro */
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.meta-divider {
    color: #d1d5db;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    margin: 0 0 15px 0;
}

.card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.card-title a:hover {
    color: #00b912;
}

/* --- Botones --- */
.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto; /* Empuja los botones al fondo siempre */
}

.btn-quote {
    flex: 1; /* Toma todo el espacio disponible */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: #00b912;
    color: #ffffff;
    padding: 10px;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.3s;
    border: none;
    cursor: pointer;
}

.btn-quote i {
    font-size: 15px;
}

.btn-quote:hover {
    background-color: #00990f;
    color: #ffffff;
}

.btn-wishlist {
    width: 38px;
    height: 38px;
    flex-shrink: 0; /* Evita que se aplaste */
    background-color: #eaf4ea;
    color: #00b912;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-wishlist i {
    font-size: 16px;
}

.btn-wishlist:hover {
    background-color: #00b912;
    color: #ffffff;
}

/* --- Ocultar el botón "View Cart" inyectado por WooCommerce --- */
.added_to_cart.wc-forward {
    display: none !important;
}
/* ==========================================================================
   Responsive (Adaptación a Móvil - 167x298)
   ========================================================================= */

@media screen and (max-width: 1024px) {
    .catalog-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   Responsive (Adaptación a Móvil - 2 Columnas Perfectas)
   ========================================================================= */

@media screen and (max-width: 1024px) {
    .catalog-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .catalog-products-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* Forzamos 2 columnas sí o sí */
        gap: 12px; /* Reducimos un poco el espacio entre tarjetas */
    }
    
    .custom-catalog-card {
        max-width: none; /* Quitamos restricciones, la grilla manda */
        width: 100%;
    }

    .card-image-wrapper {
        height: auto; /* Quitamos la altura fija que rompía la imagen */
        aspect-ratio: 1 / 1; /* Mantenemos el cuadro perfecto */
        padding: 0px !important;
    }

    .card-image-link img {
        object-fit: contain !important; /* Asegura que el producto se vea 100% completo, sin recortes */
    }

    .card-meta {
        font-size: 10px; /* Reducimos la letra */
        flex-wrap: wrap; /* Si el texto es muy largo (ej: Alimentos / Abarroteria), bajará de línea sin romper todo */
    }

    .card-title {
        font-size: 13px;
        margin: 0 0 10px 0;
    }

    /* Ajuste de Botones para Móvil */
    .btn-quote {
        font-size: 11px;
        padding: 8px 5px;
        gap: 4px;
    }

    .btn-quote i {
        font-size: 14px;
    }

    .btn-wishlist {
        width: 32px;
        height: 32px;
    }

    /* 1. La barra principal pasa de fila a columna */
    .catalog-controls-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px; /* Separación entre el filtro, los resultados y la paginación */
        margin-bottom: 25px;
    }

    /* 2. El contenedor izquierdo también a columna */
    .controls-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        width: 100%;
    }

    /* 3. El botón verde y su select toman el 100% del ancho */
    .ordering-wrapper {
        width: 100%;
    }

    /* Forzamos al select a que ocupe todo el espacio sobrante a la derecha */
    .ordering-wrapper .woocommerce-ordering {
        flex: 1; 
    }
    
    .ordering-wrapper .woocommerce-ordering select {
        width: 100%; 
    }

    /* 4. Alineamos la paginación a la izquierda (por defecto estaba centrada) */
    .catalog-controls-bar .woocommerce-pagination ul {
        justify-content: flex-start !important;
    }
}

/* Regla extra para móviles súper pequeños (ej. iPhone SE) */
@media screen and (max-width: 390px) {
    .card-actions {
        flex-wrap: wrap; /* Si no caben los botones lado a lado, se apilan ordenadamente */
    }
    .btn-wishlist {
        width: 100%; /* El corazón toma su propia fila */
        border-radius: 8px; /* Lo hacemos cuadradito para que se vea bien como botón inferior */
    }
}