/* --- TIENDA MIXCOCO: 6 COLUMNAS, CONTROLES DUALES, BÚSQUEDA NATIVA Y AJAX --- */

.mx-tienda-wrapper { 
    max-width: 1440px; 
    margin: 0 auto; 
    padding: 3rem 1rem; 
    font-family: 'Jost', sans-serif; 
}

.mx-tienda-contexto {
    width: 100%;
    margin: 0 auto 1.5rem;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    background: #f9fafb;
    color: #111827;
    border: 1px solid #f3f4f6;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
}

/* Contenedores de Botones y Paneles */
.mx-controles-tienda { 
    position: relative; 
    margin-bottom: 2.5rem; 
}
.mx-botones-header { 
    display: flex; 
    gap: 1rem; 
    flex-wrap: wrap; 
    justify-content: center; 
}

.mx-btn-desplegar {
    background-color: #111827; 
    color: #ffffff; 
    border: none; 
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem; 
    font-size: 0.95rem; 
    font-weight: 500; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    transition: background 0.3s;
}
.mx-btn-desplegar:hover { background-color: #374151; }
.mx-btn-desplegar * { pointer-events: none; } /* Clic en el botón completo */

.mx-panel-dropdown {
    display: none; 
    position: absolute; 
    top: 100%; 
    left: 0; 
    background: #ffffff;
    border-radius: 1rem; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 1.5rem; 
    margin-top: 1rem; 
    z-index: 50; 
    border: 1px solid #f3f4f6;
}
.mx-panel-dropdown.activo { display: grid; }

/* Panel Categorías */
.mx-panel-filtros { width: 100%; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (min-width: 768px) { .mx-panel-filtros { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .mx-panel-filtros { grid-template-columns: repeat(8, 1fr); } }

.mx-cat-item { text-decoration: none; text-align: center; display: block; cursor: pointer; transition: transform 0.3s ease; }
.mx-cat-item:hover, .mx-cat-item.seleccionado { transform: translateY(-5px); }
.mx-cat-img-wrapper { width: 100%; aspect-ratio: 1 / 1; border-radius: 0.75rem; overflow: hidden; margin-bottom: 0.5rem; border: 2px solid transparent; transition: border-color 0.3s; }
.mx-cat-item:hover .mx-cat-img-wrapper, .mx-cat-item.seleccionado .mx-cat-img-wrapper { border-color: #ec4899; }
.mx-cat-img-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.mx-cat-nombre { font-size: 0.85rem; font-weight: 500; color: #111827; }
.mx-cat-img-todos { background:#f3f4f6; display:flex; align-items:center; justify-content:center; }
.mx-cat-img-todos i { font-size:2.5rem; color:#d1d5db; }


/* Panel Orden */
.mx-panel-orden { width: 100%; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; padding: 1rem; left: auto; }
@media (max-width: 768px) { .mx-panel-orden { grid-template-columns: 1fr; } }

.mx-orden-item { padding: 0.75rem 1rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; color: #4b5563; transition: all 0.2s; }
.mx-orden-item:hover, .mx-orden-item.seleccionado { background-color: #f3f4f6; color: #111827; font-weight: 600; }

/* Transición AJAX */
.mx-ajax-wrapper { transition: opacity 0.3s ease; }

/* Grid de 6 Columnas */
.mx-grid-productos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (min-width: 768px) { .mx-grid-productos { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }
@media (min-width: 1200px) { .mx-grid-productos { grid-template-columns: repeat(6, 1fr); gap: 1.5rem; } }

.mx-productos-vacios { grid-column: 1 / -1; text-align: center; padding: 2rem; color: #4b5563; font-size: 1rem; }

/* Tarjetas */
.mx-card { background-color: #ffffff; border-radius: 1rem; overflow: hidden; border: 1px solid #f3f4f6; display: flex; flex-direction: column; transition: all 0.4s; height: 100%; }
.mx-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.08); }
.mx-card-image-wrapper {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: #f9fafb;
}

.mx-card-image-wrapper .mx-card-img,
.mx-card-image-wrapper img.mx-card-img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: opacity 0.45s ease, transform 0.6s ease !important;
}

.mx-card-image-wrapper .mx-card-img-principal {
    z-index: 1;
    opacity: 1;
    transform: scale(1);
}

.mx-card-image-wrapper .mx-card-img-hover {
    z-index: 2;
    opacity: 0;
    transform: scale(1.03);
}

.mx-card:hover .mx-card-image-wrapper.mx-tiene-hover-img .mx-card-img-principal {
    opacity: 0;
    transform: scale(1.04);
}

.mx-card:hover .mx-card-image-wrapper.mx-tiene-hover-img .mx-card-img-hover {
    opacity: 1;
    transform: scale(1.04);
}

.mx-card:hover .mx-card-image-wrapper.mx-sin-hover-img .mx-card-img-principal {
    transform: scale(1.05);
}

.mx-card-badge { position: absolute; top: 0.75rem; left: 0.75rem; z-index: 10; background-color: #ffffff; color: #111827; font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.5rem; border-radius: 0.375rem; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }

.mx-card-content { padding: 1.25rem; display: flex; flex-direction: column; flex-grow: 1; }
.mx-card-category { font-size: 0.65rem; color: #9ca3af; text-transform: uppercase; margin-bottom: 0.25rem; }
.mx-card-title { font-size: 0.95rem; font-weight: 500; color: #111827; margin: 0 0 0.75rem 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mx-card-title a { color: inherit; text-decoration: none; transition: color 0.3s; }
.mx-card-title a:hover { color: #ec4899; }
.mx-card-footer { margin-top: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.mx-card-price { font-size: 1.1rem; font-weight: 600; color: #111827; }
.mx-card-price del { font-size: 0.85rem; color: #9ca3af; margin-right: 5px; font-weight: normal; }

/* --- DISEÑO DEL BOTÓN "AGREGAR" LIMPIO Y BLINDADO --- */

/* El contenedor también debe tener ancho real; si no, el botón se comprime y el SVG termina pegado al texto. */
.mx-tienda-wrapper .mx-card-add-to-cart {
    width: 100% !important;
    min-width: 0 !important;
}

/* Ocultar el enlace de "Ver carrito" que WooCommerce agrega después del AJAX. */
.mx-tienda-wrapper .mx-card-add-to-cart .added_to_cart {
    display: none !important;
}

/*
 * Matamos pseudo-elementos del botón principal.
 * El spinner ahora vive dentro del contenedor del icono, no en ::after del enlace.
 */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio::before,
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio::after {
    content: none !important;
    display: none !important;
}

/* Botón base */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 40px !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.62rem 0.72rem !important;
    background: transparent !important;
    color: #111827 !important;
    border: 1.5px solid #111827 !important;
    border-radius: 0.5rem !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    text-align: center !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    white-space: normal !important;
    overflow: hidden !important;
    cursor: pointer !important;
    transition: all 0.25s ease !important;
}

/* División padre interna: aquí se separa de verdad el icono del texto. */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-contenido {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;

    line-height: 1 !important;
    pointer-events: none !important;
}

/* División del icono: nunca se encoge, así el SVG no se monta encima del texto. */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-icono {
    position: relative !important;
    display: inline-flex !important;
    flex: 0 0 16px !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 0 !important;
    margin: 0 !important;
}

/* SVG limpio, sin heredar tamaños raros del tema. */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-svg,
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-icono svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;

    color: currentColor !important;
    stroke: currentColor !important;
    fill: none !important;
    overflow: visible !important;
    transform: none !important;
}

/* División del texto: puede ocupar el espacio restante sin invadir el SVG. */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-texto {
    display: block !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: calc(100% - 23px) !important;

    color: currentColor !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: 1.12 !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}

/* Hover */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio:hover {
    background: #111827 !important;
    color: #ffffff !important;
    border-color: #111827 !important;
}

/* Estados AJAX de WooCommerce */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio.loading,
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio.added {
    background: transparent !important;
    color: #111827 !important;
    border-color: #111827 !important;
    opacity: 0.65 !important;
    cursor: wait !important;
}

/* Spinner dentro del espacio del icono, sin empujar ni amontonar el texto. */
.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio.loading .mx-btn-icono svg {
    opacity: 0 !important;
}

.mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio.loading .mx-btn-icono::before {
    content: "\f110" !important;
    position: absolute !important;
    inset: 0 !important;

    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    color: currentColor !important;

    animation: mx-spin 1s linear infinite !important;
}

@keyframes mx-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Ajustes para móvil y tarjetas estrechas */
@media (max-width: 767px) {
    .mx-card-content {
        padding: 0.95rem !important;
    }

    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio {
        min-height: 38px !important;
        padding: 0.52rem 0.5rem !important;
        font-size: 0.73rem !important;
        border-width: 1px !important;
    }

    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-contenido {
        gap: 5px !important;
    }

    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-icono,
    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-svg,
    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-icono svg {
        flex-basis: 15px !important;
        width: 15px !important;
        height: 15px !important;
        min-width: 15px !important;
        max-width: 15px !important;
    }

    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-limpio .mx-btn-texto {
        max-width: calc(100% - 20px) !important;
        line-height: 1.08 !important;
    }
}

/* En pantallas muy angostas, el texto variable necesita respirar. */
@media (max-width: 420px) {
    .mx-tienda-wrapper .mx-card-add-to-cart a.mx-btn-variable {
        font-size: 0.68rem !important;
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }
}

/* --- PAGINACIÓN --- */
.mx-paginacion { display: flex; justify-content: center; align-items: center; margin-top: 3rem; gap: 0.5rem; }
.mx-paginacion .page-numbers { display: flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border-radius: 0.5rem; border: 1px solid #e5e7eb; color: #4b5563; font-weight: 500; text-decoration: none; transition: all 0.3s ease; }
.mx-paginacion .page-numbers:hover, .mx-paginacion .page-numbers.current { background-color: #111827; color: #ffffff; border-color: #111827; }

/* ==============================
   SALES & DESCUENTOS MIXCOCO
   Extensión visual para [bloque_sales_mixcoco]
   ============================== */

.mx-sales-wrapper {
    padding-top: 2.4rem;
}

.mx-sales-hero {
    position: relative;
    overflow: hidden;
    max-width: 1180px;
    margin: 0 auto 2rem;
    padding: 2.2rem 1.5rem;
    border-radius: 1.4rem;
    background:
        radial-gradient(circle at top left, rgba(199, 0, 0, 0.11), transparent 34%),
        linear-gradient(135deg, #111111, #050505);
    color: #ffffff;
    text-align: center;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.14);
}

.mx-sales-hero::after {
    content: "";
    position: absolute;
    inset: auto 18% 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.42), transparent);
}

.mx-sales-kicker {
    display: inline-flex;
    margin-bottom: 0.7rem;
    color: #ffb4b4;
    font-family: 'Jost', sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.mx-sales-hero h2 {
    margin: 0;
    color: #ffffff;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 0.95;
    font-weight: 900;
    letter-spacing: -0.06em;
}

.mx-sales-hero p {
    max-width: 680px;
    margin: 1rem auto 0;
    color: rgba(255,255,255,0.72);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.55;
}

.mx-sales-wrapper .mx-btn-desplegar {
    background-color: #c70000;
}

.mx-sales-wrapper .mx-btn-desplegar:hover {
    background-color: #a00000;
}

.mx-sales-wrapper .mx-cat-item:hover .mx-cat-img-wrapper,
.mx-sales-wrapper .mx-cat-item.seleccionado .mx-cat-img-wrapper {
    border-color: #c70000;
}

.mx-sales-wrapper .mx-card-title a:hover {
    color: #c70000;
}

.mx-sale-card {
    position: relative;
}

.mx-sale-badge {
    background: #c70000 !important;
    color: #ffffff !important;
    border-radius: 999px !important;
    font-weight: 800 !important;
    box-shadow: 0 8px 18px rgba(199, 0, 0, 0.26) !important;
}

.mx-sales-wrapper .mx-card-price ins {
    color: #c70000;
    text-decoration: none;
    font-weight: 800;
}

.mx-sales-wrapper .mx-card-add-to-cart a.mx-btn-limpio {
    border-color: #c70000 !important;
    color: #c70000 !important;
}

.mx-sales-wrapper .mx-card-add-to-cart a.mx-btn-limpio:hover {
    background: #c70000 !important;
    border-color: #c70000 !important;
    color: #ffffff !important;
}

.mx-sales-wrapper .mx-card-add-to-cart a.mx-btn-limpio.loading,
.mx-sales-wrapper .mx-card-add-to-cart a.mx-btn-limpio.added {
    color: #c70000 !important;
    border-color: #c70000 !important;
}

.mx-sales-wrapper .mx-paginacion .page-numbers:hover,
.mx-sales-wrapper .mx-paginacion .page-numbers.current {
    background-color: #c70000;
    color: #ffffff;
    border-color: #c70000;
}

@media (max-width: 767px) {
    .mx-sales-hero {
        padding: 1.7rem 1rem;
        border-radius: 1rem;
    }

    .mx-sales-hero p {
        font-size: 0.9rem;
    }
}


/* ==============================
   FIX DROPDOWNS SALES
   Asegura que los filtros abran como panel/modal
   ============================== */

.mx-sales-wrapper .mx-controles-tienda {
    position: relative !important;
    z-index: 9990 !important;
    overflow: visible !important;
}

.mx-sales-wrapper .mx-panel-dropdown {
    z-index: 99999 !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.mx-sales-wrapper .mx-panel-dropdown.activo {
    display: grid !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.mx-sales-wrapper .mx-panel-filtros.activo {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

.mx-sales-wrapper .mx-panel-orden.activo {
    left: 50% !important;
    right: auto !important;
    width: min(100%, 760px) !important;
    transform: translateX(-50%) !important;
}

.mx-sales-wrapper .mx-toggle-filtros,
.mx-sales-wrapper .mx-toggle-orden {
    position: relative !important;
    z-index: 2 !important;
}
/* ==============================
   FIX PANEL FILTROS SALES
   Evita conflicto con tienda normal
   ============================== */

.mx-sales-wrapper .mx-controles-tienda {
    position: relative !important;
    z-index: 20 !important;
}

.mx-sales-wrapper .mx-panel-dropdown {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.mx-sales-wrapper .mx-panel-dropdown.activo {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: absolute !important;
    top: calc(100% + 1rem) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999 !important;
}

.mx-sales-wrapper .mx-panel-filtros.activo {
    grid-template-columns: repeat(2, 1fr) !important;
}

.mx-sales-wrapper .mx-panel-orden.activo {
    grid-template-columns: repeat(2, 1fr) !important;
}

@media (min-width: 768px) {
    .mx-sales-wrapper .mx-panel-filtros.activo {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .mx-sales-wrapper .mx-panel-filtros.activo {
        grid-template-columns: repeat(8, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .mx-sales-wrapper .mx-panel-orden.activo {
        grid-template-columns: 1fr !important;
    }
}

/* ==============================
   FIX MÓVIL - ORDENAR POR CENTRADO
   Sales & Descuentos
   ============================== */

@media (max-width: 768px) {
    .mx-sales-wrapper .mx-controles-tienda {
        position: relative !important;
    }

    .mx-sales-wrapper .mx-panel-orden.activo {
        position: absolute !important;
        top: calc(100% + 1rem) !important;
        left: 50% !important;
        right: auto !important;

        width: min(92vw, 420px) !important;
        max-width: 420px !important;

        transform: translateX(-50%) !important;

        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;

        padding: 1rem !important;
        margin-top: 0 !important;

        border-radius: 1rem !important;
        background: #ffffff !important;
        z-index: 99999 !important;
    }

    .mx-sales-wrapper .mx-panel-orden.activo .mx-orden-item {
        width: 100% !important;
        text-align: left !important;
    }
}