/* FASE 4 - Ofertas Relámpago (tienda pública)
   Variables CSS friendly con dark-mode. */
:root {
    --flash-offer-bg-from: #dc2626;
    --flash-offer-bg-to: #f97316;
    --flash-offer-fg: #ffffff;
    --flash-offer-shadow: 0 10px 26px rgba(220, 38, 38, 0.24);
    --flash-offer-accent: #fff7ed;
    --flash-offer-countdown-bg: #1f2937;
    --flash-offer-countdown-fg: #ffffff;
    --flash-offer-price-old: #94a3b8;
    --flash-offer-price-new: #dc2626;
    --flash-offer-panel-bg: linear-gradient(135deg, rgba(255, 237, 213, 0.98), rgba(254, 226, 226, 0.98));
    --flash-offer-panel-border: rgba(249, 115, 22, 0.38);
    --flash-offer-panel-text: #9a3412;
}

@media (prefers-color-scheme: dark) {
    :root {
        --flash-offer-shadow: 0 6px 18px rgba(220, 38, 38, 0.55);
        --flash-offer-countdown-bg: rgba(0, 0, 0, 0.85);
        --flash-offer-price-old: #64748b;
        --flash-offer-panel-bg: linear-gradient(135deg, rgba(127, 29, 29, 0.30), rgba(124, 45, 18, 0.24));
        --flash-offer-panel-border: rgba(251, 146, 60, 0.28);
        --flash-offer-panel-text: #fed7aa;
    }
}

.flash-offer {
    position: relative;
}

html body[class*="theme-"] .product-image,
html body[class*="theme-"] .cl-card-img,
html body .product-image,
html body .cl-card-img {
    position: relative;
}

html body[class*="theme-"] .product-badges-wrap,
html body .product-badges-wrap {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 12;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    pointer-events: none;
}

html body[class*="theme-"] .product-badges-wrap > *,
html body .product-badges-wrap > * {
    pointer-events: auto;
}

/* Badges dentro del wrap: flujo flex (temas como bold/modern/voyage usan .product-badge absolute). */
html body[class*="theme-"] .product-badges-wrap .product-badge,
html body[class*="theme-"] .cl-card-badges .cl-card-badge,
html body .product-badges-wrap .product-badge,
html body .cl-card-badges .cl-card-badge {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex-shrink: 0;
}

html body[class*="theme-"] .cl-card-badges,
html body .cl-card-badges {
    z-index: 12;
}

html body[class*="theme-"] .main-image-frame .product-badges-wrap,
html body .main-image-frame .product-badges-wrap {
    z-index: 15;
}

html body[class*="theme-"] .main-image-frame > img,
html body .main-image-frame > img {
    position: relative;
    z-index: 1;
}

.flash-offer-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    background: linear-gradient(135deg, var(--flash-offer-bg-from), var(--flash-offer-bg-to));
    color: var(--flash-offer-fg);
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.35px;
    text-transform: uppercase;
    border-radius: 999px;
    box-shadow: var(--flash-offer-shadow);
    pointer-events: none;
    animation: flashOfferGlow 2.8s ease-in-out infinite;
}

.flash-offer-badge::before {
    content: "\f0e7"; /* fa-bolt */
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome", sans-serif;
    font-weight: 900;
    font-size: 11px;
    color: var(--flash-offer-accent);
}

/* Variante inline cuando el badge va dentro de un contenedor de badges
   (listings/cards) donde ya hay position:relative/absolute en el wrap.
   Incluye product-badges-wrap (themes base/urban/minimal) y cl-card-badges (classic-light). */
.product-badges-wrap .flash-offer-badge,
.cl-card-badges .flash-offer-badge,
.flash-offer-badge.flash-offer-badge--inline,
.products-grid-card .flash-offer-badge,
.dp-product-card .flash-offer-badge,
html body[class*="theme-"] .product-badges-wrap .flash-offer-badge {
    position: static;
    top: auto;
    left: auto;
    pointer-events: auto;
}

/* Countdown inline en cards (sin bloque absoluto). El wrap pierde su absolute
   y el countdown interno queda alineado con el flujo flex-wrap del contenedor. */
.product-badges-wrap .flash-offer-countdown-wrap,
.cl-card-badges .flash-offer-countdown-wrap,
html body[class*="theme-"] .product-badges-wrap .flash-offer-countdown-wrap {
    position: static;
    top: auto;
    left: auto;
    pointer-events: auto;
    flex-basis: 100%;
    margin-top: 0;
}
.product-badges-wrap .flash-offer-countdown,
.cl-card-badges .flash-offer-countdown,
.products-grid-card .flash-offer-countdown,
html body[class*="theme-"] .product-badges-wrap .flash-offer-countdown {
    margin-top: 0;
    font-size: 11px;
    padding: 3px 8px;
}

html body[class*="theme-"] .product-shipping-badge-wrap,
html body[class*="theme-"] .cl-card-shipping-badge,
html body .product-shipping-badge-wrap,
html body .cl-card-shipping-badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 11;
    pointer-events: none;
}

html body[class*="theme-"] .product-badge-free-shipping,
html body[class*="theme-"] .cl-card-badge-free-shipping,
html body[class*="theme-"] .product-free-shipping-pill,
html body .product-badge-free-shipping,
html body .cl-card-badge-free-shipping,
html body .product-free-shipping-pill {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    box-sizing: border-box !important;
    padding: 6px 11px !important;
    color: #ffffff !important;
    background: #059669 !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    line-height: 1.2 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    white-space: nowrap;
}

html body[class*="theme-"] .product-free-shipping-pill,
html body .product-free-shipping-pill {
    gap: 8px !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    font-size: 0.92rem !important;
}

html body[class*="theme-"] .product-badge-free-shipping i,
html body[class*="theme-"] .cl-card-badge-free-shipping i,
html body[class*="theme-"] .product-free-shipping-pill i,
html body .product-badge-free-shipping i,
html body .cl-card-badge-free-shipping i,
html body .product-free-shipping-pill i {
    font-size: 0.85em !important;
    color: #ffffff !important;
}

html body[class*="theme-"] .product-free-shipping-pill i,
html body .product-free-shipping-pill i {
    font-size: 1em !important;
}

/* Tarjetas / catálogo / home / búsqueda: contenido dentro de la imagen */
html body[class*="theme-"] .product-card .product-shipping-badge-wrap,
html body .product-card .product-shipping-badge-wrap,
html body[class*="theme-"] .cl-card-img .cl-card-shipping-badge,
html body .cl-card-img .cl-card-shipping-badge {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
}

html body[class*="theme-"] .product-card .product-badge-free-shipping,
html body .product-card .product-badge-free-shipping,
html body[class*="theme-"] .cl-card-img .cl-card-badge-free-shipping,
html body .cl-card-img .cl-card-badge-free-shipping {
    max-width: 100% !important;
    width: fit-content !important;
    min-width: 0 !important;
    padding: 5px 9px !important;
    font-size: 0.66rem !important;
    gap: 4px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
    text-align: left !important;
    overflow-wrap: anywhere;
}

html body[class*="theme-"] .product-card .product-badge-free-shipping i,
html body .product-card .product-badge-free-shipping i,
html body[class*="theme-"] .cl-card-img .cl-card-badge-free-shipping i,
html body .cl-card-img .cl-card-badge-free-shipping i {
    flex-shrink: 0 !important;
    font-size: 0.78em !important;
}

@media (max-width: 480px) {
    html body[class*="theme-"] .product-card .product-badge-free-shipping,
    html body .product-card .product-badge-free-shipping,
    html body[class*="theme-"] .cl-card-img .cl-card-badge-free-shipping,
    html body .cl-card-img .cl-card-badge-free-shipping {
        padding: 4px 8px !important;
        font-size: 0.62rem !important;
        letter-spacing: 0 !important;
    }
}

/* Etiqueta «Nuevo» — legible en todos los temas (no compite con descuento/promo/flash). */
html body[class*="theme-"] .product-badge.badge-new,
html body[class*="theme-"] .cl-card-badges .badge-new,
html body[class*="theme-"] .cl-card-badge.badge-new,
html body .product-badge.badge-new,
html body .cl-card-badges .badge-new,
html body .cl-card-badge.badge-new {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    box-sizing: border-box !important;
    padding: 4px 10px !important;
    color: #ffffff !important;
    /* Azul fijo: distinto de promo verde (#059669) y oferta roja; legible en temas claros/oscuros */
    background: #2563eb !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18) !important;
    text-shadow: none !important;
    white-space: nowrap;
    z-index: 13;
}

html body[class*="theme-"] .cl-card-badges .badge-new,
html body[class*="theme-"] .cl-card-badge.badge-new,
html body .cl-card-badges .badge-new,
html body .cl-card-badge.badge-new {
    font-size: 0.62rem !important;
    padding: 2px 7px !important;
}

body.theme-neon .product-badge.badge-new,
body.theme-neon .cl-card-badge.badge-new {
    background: #22d3ee !important;
    color: #0f172a !important;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.45) !important;
}

body.theme-urban .product-badge.badge-new,
body.theme-urban .cl-card-badge.badge-new {
    background: #111827 !important;
    color: #ffee00 !important;
    border: 1px solid #ffee00 !important;
}

.flash-offer-countdown {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 5px 10px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.35px;
    color: var(--flash-offer-countdown-fg);
    background: var(--flash-offer-countdown-bg);
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
}

.flash-offer-countdown.flash-offer-countdown-inline {
    position: static;
    margin: 0;
}

.flash-offer-countdown-wrap {
    position: absolute;
    top: 42px;
    left: 10px;
    z-index: 5;
    pointer-events: none;
}

.flash-offer-price-wrap {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.flash-offer-price-original {
    color: var(--flash-offer-price-old);
    text-decoration: line-through;
    font-weight: 500;
    font-size: 0.9em;
}

.flash-offer-price-final {
    color: var(--flash-offer-price-new);
    font-weight: 800;
    font-size: 1.05em;
}

.product-detail-content-col .product-detail-title--in-col + .flash-offer-detail-banner {
    margin-top: 6px;
}

.product-detail-content-col .product-detail-title--in-col:has(+ .flash-offer-detail-banner) {
    margin-bottom: 8px;
    padding-bottom: 0;
    border-bottom: none;
}

.flash-offer-detail-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0 0 10px;
    padding: 9px 14px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--flash-offer-bg-from), var(--flash-offer-bg-to));
    border: none;
    border-radius: 12px;
    box-shadow: var(--flash-offer-shadow);
    animation: flashOfferGlow 2.8s ease-in-out infinite;
}

.flash-offer-detail-banner::after {
    content: none;
}

.flash-offer-detail-banner > * {
    position: relative;
    z-index: 1;
}

.flash-offer-detail-banner .flash-offer-badge--detail {
    position: static;
    top: auto;
    left: auto;
    pointer-events: auto;
    background: transparent;
    box-shadow: none;
    animation: none;
    padding: 0;
    margin: 0;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.flash-offer-detail-banner .flash-offer-badge--detail::before {
    font-size: 0.88rem;
    color: var(--flash-offer-accent);
}

.flash-offer-detail-banner .flash-offer-countdown,
.flash-offer-detail-banner .flash-offer-countdown-inline {
    margin: 0;
    padding: 5px 10px;
    font-size: 0.76rem;
    font-weight: 800;
    color: #ffffff;
    background: rgba(15, 23, 42, 0.42);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    white-space: nowrap;
    flex: 0 0 auto;
}

.flash-offer-detail-name {
    color: var(--flash-offer-panel-text);
    font-size: 0.92rem;
    font-weight: 700;
}

body.theme-neon .flash-offer-detail-banner,
body.theme-urban .flash-offer-detail-banner {
    background: linear-gradient(135deg, #dc2626, #f97316);
    box-shadow: 0 14px 34px rgba(220, 38, 38, 0.35);
}

@keyframes flashOfferGlow {
    0%, 100% {
        transform: translateY(0);
        filter: brightness(1);
    }
    50% {
        transform: translateY(-1px);
        filter: brightness(1.06);
    }
}

@media (max-width: 600px) {
    .flash-offer-badge {
        font-size: 10px;
        padding: 5px 9px;
        top: 8px;
        left: 8px;
    }
    .flash-offer-countdown {
        font-size: 11px;
        padding: 3px 8px;
    }
    .flash-offer-countdown-wrap {
        top: 36px;
        left: 8px;
    }
    .product-detail-content-col .product-detail-title--in-col + .flash-offer-detail-banner {
        margin-top: 4px;
    }
    .product-detail-content-col .product-detail-title--in-col:has(+ .flash-offer-detail-banner) {
        margin-bottom: 4px;
        padding-bottom: 0;
        border-bottom: none;
    }
    .flash-offer-detail-banner {
        gap: 8px;
        padding: 8px 12px;
        border-radius: 11px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .flash-offer-detail-banner::-webkit-scrollbar {
        display: none;
    }
    .flash-offer-detail-banner .flash-offer-badge--detail {
        font-size: 0.72rem;
        letter-spacing: 0.32px;
    }
    .flash-offer-detail-banner .flash-offer-countdown,
    .flash-offer-detail-banner .flash-offer-countdown-inline {
        min-height: 0;
        padding: 5px 9px;
        font-size: 0.72rem;
    }
}

@media (max-width: 768px) {
    html body[class*="theme-"] .product-detail-image-col .product-shipping-badge-wrap,
    html body .product-detail-image-col .product-shipping-badge-wrap {
        display: block !important;
        left: 12px;
        bottom: 12px;
        z-index: 14;
    }
    html body[class*="theme-"] .product-free-shipping-pill--detail-desktop,
    html body .product-free-shipping-pill--detail-desktop {
        display: none !important;
    }
    html body[class*="theme-"] .product-detail-image-col .product-badge-free-shipping,
    html body .product-detail-image-col .product-badge-free-shipping {
        padding: 7px 12px !important;
        font-size: 0.78rem !important;
        max-width: calc(100vw - 56px);
        color: #ffffff !important;
        background: #059669 !important;
        border: none !important;
        border-radius: 6px !important;
        box-shadow: none !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    html body[class*="theme-"] .product-detail-image-col .product-badge-free-shipping i,
    html body .product-detail-image-col .product-badge-free-shipping i {
        color: #ffffff !important;
        font-size: 0.9em !important;
    }
    html body[class*="theme-"] .product-detail-price-block.price-block,
    html body .product-detail-price-block.price-block {
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
        padding-bottom: 12px !important;
    }
    html body[class*="theme-"] .product-detail-price-block .product-detail-price,
    html body .product-detail-price-block .product-detail-price {
        display: inline-flex;
        align-items: center;
        min-height: 30px;
        font-size: clamp(1.45rem, 6vw, 1.7rem) !important;
        line-height: 1 !important;
        white-space: nowrap;
    }
    html body[class*="theme-"] .product-detail-price-block .product-price-promo,
    html body .product-detail-price-block .product-price-promo {
        display: inline-flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        min-width: 0;
    }
    html body[class*="theme-"] .product-detail-price-block .discount-badge,
    html body .product-detail-price-block .discount-badge {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 30px !important;
        padding: 0 10px !important;
        border-radius: 6px !important;
        font-size: 0.86rem !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }
    html body[class*="theme-"] .product-detail-price-block .product-compare-price-old,
    html body .product-detail-price-block .product-compare-price-old {
        display: inline-flex !important;
        align-items: center !important;
        min-height: 30px !important;
        font-size: clamp(1rem, 4.2vw, 1.12rem) !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    .flash-offer-badge,
    .flash-offer-detail-banner {
        animation: none;
    }
}
