/* ============================================================
 * MP MARKETPLACE — FRONTEND CSS v1.2.1
 * - Grid base con !important (fallback ante fallos del CSS dinámico)
 * - Buscador 100% aislado con --mpws-sb-* variables
 * ============================================================ */

/* WRAPPER */
.mpws-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 24px 0;
    box-sizing: border-box;
}
.mpws-wrapper *,
.mpws-wrapper *::before,
.mpws-wrapper *::after {
    box-sizing: border-box;
}

/* ============================================================
 * GRID — Layout base BLINDADO
 * Aunque el CSS dinámico falle, el grid responsivo sigue activo.
 * Mobile: 2 columnas · Tablet: 3 · Desktop: 4
 * ============================================================ */
.mpws-wrapper .mpws-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    column-gap: 16px;
    row-gap: 16px;
    width: 100%;
}
@media (min-width: 600px) {
    .mpws-wrapper .mpws-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}
@media (min-width: 1024px) {
    .mpws-wrapper .mpws-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

.mpws-wrapper .mpws-list {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* ============================================================
 * TARJETA
 * ============================================================ */
.mpws-wrapper .mpws-card {
    display: flex;
    flex-direction: column;
    background: var(--mpws-bg, #fff);
    border-radius: var(--mpws-radius, 12px);
    overflow: hidden;
    text-decoration: none !important;
    color: var(--mpws-dark, #1A1A1A);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    height: 100%;
    position: relative;
    width: 100%;
    min-width: 0;
}
.mpws-wrapper .mpws-card:focus-visible {
    outline: 2px solid var(--mpws-accent, #FF6B35);
    outline-offset: 2px;
}

.mpws-wrapper .mpws-card-media {
    position: relative;
    overflow: hidden;
    background: #F9FAFB;
    flex-shrink: 0;
    width: 100%;
}
.mpws-wrapper .mpws-card-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transition: transform .5s cubic-bezier(.4, 0, .2, 1);
    display: block;
}

/* BADGES */
.mpws-wrapper .mpws-badge {
    position: absolute;
    z-index: 2;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    border-radius: 6px;
    text-transform: uppercase;
    line-height: 1;
    letter-spacing: .3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.mpws-wrapper .mpws-badge-discount {
    top: 12px; right: 12px;
    background: var(--mpws-disc, #E63946);
    font-size: 13px;
    padding: 6px 11px;
}
.mpws-wrapper .mpws-badge-sale  { top: 12px; left: 12px; background: var(--mpws-sale, #FF6B35); }
.mpws-wrapper .mpws-badge-new   { top: 12px; left: 12px; background: var(--mpws-new, #06A77D); }
.mpws-wrapper .mpws-badge-stock {
    top: 12px; left: 12px;
    background: var(--mpws-stock, #FFB400);
    color: var(--mpws-dark, #1A1A1A);
    animation: mpws-pulse 2s infinite;
}
@keyframes mpws-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* BODY */
.mpws-wrapper .mpws-card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.mpws-wrapper .mpws-card-cat {
    font-size: 11px;
    color: var(--mpws-muted, #6B7280);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 500;
}
.mpws-wrapper .mpws-card-title {
    font-weight: 600;
    line-height: 1.4;
    color: var(--mpws-dark, #1A1A1A);
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* RATING */
.mpws-wrapper .mpws-card-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--mpws-muted, #6B7280);
}
.mpws-wrapper .mpws-stars {
    --rating: 0;
    display: inline-block;
    font-size: 13px;
    line-height: 1;
    background: linear-gradient(90deg, #FBBF24 calc(var(--rating)/5*100%), #E5E7EB calc(var(--rating)/5*100%));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 2px;
}
.mpws-wrapper .mpws-stars::before { content: "★★★★★"; }

/* PRECIO */
.mpws-wrapper .mpws-card-price {
    font-weight: 700;
    color: var(--mpws-price, #1A1A1A);
    line-height: 1.2;
}
.mpws-wrapper .mpws-card-price del {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--mpws-muted, #6B7280);
    margin-top: 2px;
    opacity: .85;
}
.mpws-wrapper .mpws-card-price del .woocommerce-Price-amount { color: var(--mpws-muted, #6B7280) !important; }
.mpws-wrapper .mpws-card-price ins {
    text-decoration: none;
    background: transparent;
    color: var(--mpws-price-sale, #E63946);
    font-weight: 700;
}
.mpws-wrapper .mpws-card-price ins .woocommerce-Price-amount { color: var(--mpws-price-sale, #E63946) !important; }

/* CARRUSEL */
.mpws-wrapper.mpws-tipo-carrusel { position: relative; padding: 0 0 40px; }
.mpws-wrapper .mpws-swiper        { overflow: hidden; padding: 8px 4px; }
.mpws-wrapper .mpws-swiper .swiper-slide { height: auto; display: flex; }
.mpws-wrapper .mpws-swiper .swiper-slide .mpws-card { width: 100%; }

.mpws-wrapper .mpws-nav-btn {
    width: 42px !important;
    height: 42px !important;
    background: #fff !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    color: var(--mpws-dark, #1A1A1A) !important;
    margin-top: -21px !important;
    transition: all .2s;
}
.mpws-wrapper .mpws-nav-btn:hover {
    background: var(--mpws-primary, #2D3277) !important;
    color: #fff !important;
}
.mpws-wrapper .mpws-nav-btn::after { font-size: 16px !important; font-weight: 700; }
.mpws-wrapper .mpws-swiper .swiper-pagination-bullet { background: var(--mpws-muted, #6B7280); opacity: .4; }
.mpws-wrapper .mpws-swiper .swiper-pagination-bullet-active {
    background: var(--mpws-primary, #2D3277);
    opacity: 1;
    width: 24px;
    border-radius: 4px;
}

/* ESTADOS */
.mpws-no-products {
    text-align: center;
    color: var(--mpws-muted, #6B7280);
    padding: 40px;
    font-style: italic;
}

@media (max-width: 599px) {
    .mpws-wrapper .mpws-badge { font-size: 10px; padding: 4px 8px; }
    .mpws-wrapper .mpws-nav-btn { display: none !important; }
}

/* ============================================================
 * BOTÓN CTA dentro de la tarjeta
 * Como va dentro del <a class="mpws-card">, debe ser un <span> estilizado
 * con clase .mpws-card-btn (no es un botón real, sino visual)
 * ============================================================ */
.mpws-wrapper .mpws-card-btn-wrap {
    width: 100%;
    margin-top: auto;
}

/* ============================================================
 * BUSCADOR — totalmente aislado con .mpws-search
 * ============================================================ */
.mpws-search {
    position: relative;
    width: 100%;
    font-family: inherit;
}
.mpws-search * { box-sizing: border-box; }

.mpws-search .mpws-search-form {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--mpws-sb-bg, #fff);
    border: 1.5px solid var(--mpws-sb-border, #E5E7EB);
    border-radius: var(--mpws-sb-radius, 10px);
    height: var(--mpws-sb-height, 46px);
    padding: 0 var(--mpws-sb-pad, 14px);
    transition: border-color .15s, box-shadow .15s;
}
.mpws-search .mpws-search-form:focus-within {
    border-color: var(--mpws-sb-primary, #2D3277);
    box-shadow: 0 0 0 4px rgba(45, 50, 119, .08);
}
.mpws-search .mpws-search-icon {
    color: var(--mpws-sb-phold, #9CA3AF);
    flex-shrink: 0;
    margin-right: 10px;
    display: flex;
}
.mpws-search .mpws-search-input {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--mpws-sb-text, #1A1A1A);
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0;
}
.mpws-search .mpws-search-input::placeholder { color: var(--mpws-sb-phold, #9CA3AF); }
.mpws-search .mpws-search-input::-webkit-search-cancel-button { display: none; }

.mpws-search .mpws-search-clear {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--mpws-sb-phold, #9CA3AF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mpws-search .mpws-search-clear:hover {
    background: rgba(0, 0, 0, .05);
    color: var(--mpws-sb-text, #1A1A1A);
}

/* DROPDOWN */
.mpws-search .mpws-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--mpws-sb-dd-bg, #fff);
    border: 1px solid var(--mpws-sb-border, #E5E7EB);
    border-radius: var(--mpws-sb-radius, 10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    z-index: 9999;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
}
.mpws-search .mpws-search-status {
    padding: 12px 16px;
    color: var(--mpws-sb-muted, #6B7280);
    font-size: 13px;
}
.mpws-search .mpws-search-status:empty { display: none; }
.mpws-search .mpws-search-status .mpws-no-match strong { color: var(--mpws-sb-text, #1A1A1A); }

.mpws-search .mpws-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none !important;
    color: var(--mpws-sb-text, #1A1A1A);
    border-bottom: 1px solid #F3F4F6;
    transition: background .12s;
    position: relative;
}
.mpws-search .mpws-search-item:last-child { border-bottom: none; }
.mpws-search .mpws-search-item:hover,
.mpws-search .mpws-search-item:focus {
    background: var(--mpws-sb-dd-hov, #F3F4F6);
    outline: none;
}
.mpws-search .mpws-search-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #F9FAFB;
}
.mpws-search .mpws-search-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mpws-search .mpws-search-cat {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--mpws-sb-muted, #6B7280);
    letter-spacing: .4px;
    font-weight: 500;
}
.mpws-search .mpws-search-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--mpws-sb-text, #1A1A1A);
}
.mpws-search .mpws-search-title mark {
    background: rgba(255, 193, 7, .35);
    color: inherit;
    padding: 0;
    border-radius: 2px;
}
.mpws-search .mpws-search-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--mpws-sb-price, #1A1A1A);
}
.mpws-search .mpws-search-price del {
    font-size: 11px;
    font-weight: 400;
    color: var(--mpws-sb-muted, #6B7280);
    margin-right: 4px;
    display: inline;
}
.mpws-search .mpws-search-price ins {
    text-decoration: none;
    color: var(--mpws-sb-price-sale, #E63946);
    background: transparent;
}
.mpws-search .mpws-search-badge {
    width: 22px;
    height: 22px;
    background: var(--mpws-sb-disc, #E63946);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.mpws-search .mpws-search-see-all {
    display: block;
    text-align: center;
    padding: 12px 16px;
    background: var(--mpws-sb-dd-hov, #F3F4F6);
    color: var(--mpws-sb-primary, #2D3277);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    border-top: 1px solid var(--mpws-sb-border, #E5E7EB);
    transition: background .12s;
}
.mpws-search .mpws-search-see-all:hover {
    background: var(--mpws-sb-primary, #2D3277);
    color: #fff;
}

/* ============================================================
 * SEARCH SHORTCODES — CHIPS (v3.0)
 * ============================================================ */
.mpws-search-chips-wrap { margin: 20px 0; }
.mpws-chips-title {
    font-size: 15px; font-weight: 700; color: var(--mpws-dark, #1A1A1A);
    margin: 0 0 12px; padding: 0;
}
.mpws-search-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.mpws-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #F1F5F9; color: #374151;
    border: 1px solid #E2E8F0; border-radius: 30px;
    padding: 7px 16px; font-size: 13px; font-weight: 500;
    text-decoration: none !important;
    transition: all .18s;
    white-space: nowrap;
}
.mpws-chip:hover {
    background: var(--mpws-primary, #2D3277);
    color: #fff; border-color: transparent;
}
.mpws-chip-count {
    background: rgba(0,0,0,.08); border-radius: 20px;
    padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.mpws-chip:hover .mpws-chip-count { background: rgba(255,255,255,.2); }
.mpws-chip-trending { background: #FFF7ED; border-color: #FED7AA; color: #C2410C; }
.mpws-chip-trending:hover { background: #EA580C; color: #fff; }
.mpws-chip-growth {
    background: #DCFCE7; color: #15803D; border-radius: 20px;
    padding: 1px 6px; font-size: 10px; font-weight: 700;
}
.mpws-chip-recent { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.mpws-chip-recent:hover { background: #1D4ED8; color: #fff; }

/* Sugerencias de autocomplete */
.mpws-search-suggestions {
    padding: 8px 0;
}
.mpws-search-suggestion {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; font-size: 13px; font-weight: 500;
    color: var(--mpws-sb-text, #1A1A1A);
    text-decoration: none !important;
    transition: background .12s;
    cursor: pointer;
}
.mpws-search-suggestion:hover {
    background: var(--mpws-sb-dd-hov, #F3F4F6);
}
