/* =============================================
   APC Premium Widget Styles (Runnea Replica)
   ============================================= */
:root {
    --apc-primary: #106fdf;
    /* bright blue */
    --apc-primary-dark: #0050e0;
    --apc-text: #171717;
    /* very dark grey, almost black */
    --apc-text-light: #52525b;
    /* grey for labels */
    --apc-bg-light: #fafafa;
    /* very bright grey for hero */
    --apc-border: #e4e4e7;
    --apc-success: #10b981;
    --apc-danger: #ef4444;
}

.apc-premium-widget {
    background: #fff;
    border-radius: 12px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--apc-text);
    margin: 0 auto 10px auto !important;
    /* ELIMINADO MARGEN EXTERIOR SUPERIOR de 40px */
    max-width: 850px;
    padding: 10px !important;
    /* Reducido a 10px exactos por exigencia de diseño */
    border: 1px solid #f4f4f5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

/* --- HEADER --- */
.apc-pw-header {
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 10px !important;
    /* REDUCIDO DE 25px */
}

/* WP Autop Fix */
.apc-premium-widget p:empty,
.apc-premium-widget br {
    display: none !important;
}

/* FORZAR ESPECIFICIDAD CONTRA EL TEMA */
.apc-premium-widget h2.apc-pw-title,
.apc-premium-widget .apc-pw-title {
    font-size: 28px;
    font-weight: 900;
    margin-top: 0 !important;
    margin-bottom: 5px !important;
    padding-top: 0 !important;
    padding-left: 0 !important;
    /* MATA EL INDENTADO DEL TEMA */
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: -1px;
    color: var(--apc-text);
    border: none !important;
    /* Quitar bordes naranjas nativos del tema */
    background: transparent !important;
}

/* Matar los offset de anclaje de sticky headers o decoraciones del tema */
.apc-premium-widget h2.apc-pw-title::before,
.apc-premium-widget h2.apc-pw-title::after,
.apc-premium-widget h3.apc-pw-section-title::before,
.apc-premium-widget h3.apc-pw-section-title::after {
    display: none !important;
    content: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.apc-pw-brand-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--apc-primary);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0px;
    margin-bottom: 15px;
}

.apc-check-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: 12px;
}

.apc-pw-thumbs-row {
    display: flex;
    gap: 10px;
}

.apc-pw-thumb-wrap {
    width: 75px;
    height: 75px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f3f4f6;
    padding: 2px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apc-pw-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.apc-pw-thumb-wrap:hover {
    border-color: #d1d5db;
}

.apc-pw-thumb-wrap.active {
    border-color: var(--apc-primary);
}

.apc-pw-active-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--apc-primary);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 2;
}

/* --- HERO SECTION --- */
.apc-pw-hero {
    display: flex;
    gap: 20px;
    /* REDUCIDO ESPACIO HORIZONTAL/MIXTO */
    background: transparent;
    padding: 0 !important;
    /* Eliminado padding inferior extra */
    margin-bottom: 0 !important;
    /* CERO ESPACIO INFERIOR */
    align-items: center;
    border: none;
}

.apc-pw-hero-image {
    flex: 0 0 320px;
    max-width: 320px;
    position: relative;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 12px;
    padding: 20px;
}

.apc-pw-hero-image img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    mix-blend-mode: multiply;
    transition: opacity 0.2s;
    transform: scale(1.15);
}

.apc-pw-save-badge {
    position: absolute;
    top: 5px;
    right: -15px;
    background: var(--apc-primary);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    transform: rotate(5deg);
    box-shadow: 0 4px 10px rgba(16, 97, 255, 0.2);
    z-index: 2;
}

.apc-pw-hero-info {
    flex: 1;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.apc-pw-guarantee-badge {
    display: inline-flex;
    align-items: center;
    background: #d1fae5;
    color: #059669;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 20px;
    margin-bottom: 4px;
    /* EXTRAMADAMENTE REDUCIDO */
    text-transform: uppercase;
    align-self: flex-start;
}

.apc-pw-price-range-label {
    font-size: 14px;
    color: var(--apc-text-light);
    font-weight: 600;
    margin-bottom: 4px;
    /* Casi tocando */
    margin-top: 0px;
    /* Sin margen por encima */
}

.apc-pw-big-price-row {
    display: flex;
    align-items: center;
    margin-bottom: 0px;
}

.apc-pw-big-price {
    font-size: 44px;
    font-weight: 900;
    color: var(--apc-text);
    letter-spacing: -1.5px;
    line-height: 1;
}

.apc-pw-best-merchant {
    margin-left: 15px;
    display: flex;
    align-items: center;
}

.apc-pw-hero-logo {
    max-height: 20px;
    object-fit: contain;
}

.apc-pw-stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    /* Reducido al mínimo casi se tocan */
    font-size: 13px;
    color: var(--apc-text);
    font-weight: 700;
}

.apc-pw-stat-row .apc-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    opacity: 0.7;
}

.apc-pw-hero-btn {
    display: block;
    width: 100%;
    background: var(--apc-primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 14px;
    text-transform: uppercase;
    margin-top: 25px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
}

.apc-pw-hero-btn:hover {
    background: var(--apc-primary-dark);
}

/* --- STORE LIST --- */
.apc-pw-store-section {
    padding-top: 0;
}

.apc-premium-widget h3.apc-pw-section-title,
.apc-premium-widget .apc-pw-section-title {
    font-size: 17px;
    font-weight: 900;
    margin-top: 0 !important;
    /* OVERRIDE WORDPRESS H3 MARGIN */
    margin-bottom: 10px !important;
    /* Reducido para pegar a la tabla */
    padding-top: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform: uppercase;
    color: var(--apc-text);
    border: none !important;
}

.apc-pw-count-badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
}

.apc-pw-store-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apc-pw-store-row {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    /* Menos redondeado para ser compacto */
    padding: 10px 15px;
    /* DRASTICAMENTE REDUCIDO: De 15px/20px a 10px/15px */
    transition: transform 0.2s, box-shadow 0.2s;
}

.apc-pw-store-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border-color: #cbd5e1;
}

.apc-pw-col-store {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* UPDATED LOGO STYLES */
.apc-pw-store-logo-wrap {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 1px solid #f1f5f9;
    padding: 5px;
}

.apc-pw-store-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.apc-pw-store-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6;
    color: #fff;
    font-weight: bold;
    font-size: 1.2em;
    border-radius: 50%;
}

.apc-pw-store-name {
    font-weight: 900;
    color: var(--apc-text);
    font-size: 16px;
    margin-bottom: 2px;
}

.apc-pw-store-status {
    font-size: 11px;
    color: var(--apc-success);
    font-weight: 800;
    text-transform: uppercase;
}

.apc-pw-col-price {
    text-align: right;
    margin-right: 30px;
    min-width: 100px;
}

.apc-pw-final-price {
    font-size: 22px;
    font-weight: 900;
    color: var(--apc-text);
    line-height: 1;
}

.apc-pw-old-price {
    font-size: 16px;
    color: #94a3b8;
    text-decoration: line-through;
    margin-top: 4px;
}

.apc-pw-deal-label {
    display: inline-block;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.apc-pw-buy-btn {
    background: #eff6ff;
    color: var(--apc-primary);
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 800;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-block;
}

.apc-pw-buy-btn:hover {
    background: var(--apc-primary);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .apc-pw-hero {
        flex-direction: column;
        padding: 16px 12px;
        gap: 12px;
    }

    .apc-pw-hero-image {
        flex: 0 0 auto;
        max-width: 100%;
        width: 100%;
        max-height: 220px;
        padding: 12px;
    }

    .apc-pw-hero-image img {
        max-height: 180px;
        width: auto;
        margin: 0 auto;
    }

    .apc-pw-hero-info {
        padding-left: 0;
        width: 100%;
    }

    .apc-pw-big-price {
        font-size: 32px;
    }

    .apc-pw-save-badge {
        right: 5px;
        top: 5px;
    }

    /* Stack store rows vertically on small screens */
    .apc-pw-store-row {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }

    .apc-pw-col-store {
        flex: 1 1 100%;
        min-width: 0;
    }

    .apc-pw-col-price {
        margin-right: 0;
        min-width: auto;
        flex: 1;
        text-align: left;
    }

    .apc-pw-buy-btn {
        flex: 1 1 100%;
        text-align: center;
        padding: 12px 16px;
    }

    /* Prevent premium widget overflow */
    .apc-premium-widget {
        padding: 10px !important;
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .apc-pw-store-logo-wrap {
        width: 44px;
        height: 44px;
    }

    .apc-pw-store-name {
        font-size: 14px;
    }

    .apc-pw-final-price {
        font-size: 18px;
    }
}

/* =============================================
   NEW STYLES (Logos & Badges)
   ============================================= */

/* HERO LOGO */
.apc-pw-big-price-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
}

.apc-pw-hero-logo {
    height: 50px;
    max-width: 160px;
    object-fit: contain;
    vertical-align: middle;
}

.apc-pw-hero-merchant-text {
    font-size: 0.9em;
    color: #666;
}

.apc-pw-price-range-sub {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 12px;
}

/* OLD PRICE */
.apc-pw-old-price {
    font-size: 0.85em;
    color: #999;
    text-decoration: line-through;
    margin-top: 2px;
}

.apc-pw-deal-label {
    background: #ef4444;
    color: #fff;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

/* =============================================
   SEARCH SHORTCODE STYLES ([apc_search])
   ============================================= */

.apc-search-container {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    max-width: 1100px;
    margin: 30px auto;
    color: #1a1a1a;
}

/* --- Search Form --- */
.apc-search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 30px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
}

.apc-search-input {
    flex: 2 1 250px;
    min-width: 200px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: #1a1a1a;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.apc-search-input:focus {
    border-color: #1061ff;
}

.apc-filter-select {
    flex: 1 1 150px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a1a;
    background: white;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 32px;
}

.apc-search-button {
    flex: 1 1 150px;
    padding: 12px 24px;
    background: #1061ff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.2s;
}

.apc-search-button:hover {
    background: #0050e0;
}

/* --- Products Grid --- */
.apc-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.apc-product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    border: 1px solid #eee;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.apc-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.apc-product-image-wrapper {
    position: relative;
    background: #f8f9fa;
    padding-top: 75%;
    overflow: hidden;
}

.apc-product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    mix-blend-mode: multiply;
}

.apc-merchant-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(16, 97, 255, 0.9);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    z-index: 1;
}

.apc-product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.apc-product-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 10px 0;
    line-height: 1.4;
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apc-product-price {
    font-size: 20px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 14px;
}

.apc-buy-button {
    margin-top: auto;
    display: block;
    text-align: center;
    background: #1061ff;
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s;
}

.apc-buy-button:hover {
    background: #0050e0;
    color: white;
}

/* No results */
.apc-no-results {
    text-align: center;
    color: #666;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 12px;
    font-size: 15px;
}

/* --- Pagination --- */
.apc-pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.apc-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #1a1a1a;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.apc-pagination .page-numbers:hover,
.apc-pagination .page-numbers.current {
    background: #1061ff;
    color: white;
    border-color: #1061ff;
}

/* Responsive for grid */
@media (max-width: 600px) {
    .apc-search-form {
        flex-direction: column;
    }

    .apc-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}