/* Enterprise Flash Sales V2 — presentation tokens from --ag-fs-*
   Phase 4A.8: compact composition; overflow no longer clips carousel/arrows. */

.ag-fs-section {
    --ag-fs-local-gap: var(--ag-fs-carousel-gap, var(--ag-fs-card-gap, 12px));
    margin-block: var(--ag-fs-section-margin-y, 16px);
    padding: var(--ag-fs-section-pad, 8px);
    border-radius: var(--ag-fs-section-radius, 12px);
    background: var(--ag-fs-section-bg, #ffffff);
    border: 1px solid var(--ag-fs-section-border, #f1f5f9);
    box-shadow: var(--ag-fs-section-shadow, none);
    /* visible so hover-lift + arrows are not clipped; track still scrolls */
    overflow: visible;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Nested wrap from product-module must not re-introduce a full-bleed white band */
.ag-dh-flash-section-inner > .ag-dh-wrap,
.ag-dh-flash-section-inner > [data-ag-hsd].ag-dh-wrap {
    max-width: 100% !important;
    margin-inline: 0 !important;
    background: transparent !important;
    padding-inline: 0 !important;
    box-shadow: none !important;
}

/* On Homepage Background canvas, keep a readable white surface without a heavy frame */
html.ag-hbg-on .ag-fs-section:not([data-ag-hbg-override]) {
    background: var(--ag-fs-section-bg, var(--ag-surface, #ffffff));
}

.ag-fs-section .ag-dh-product-card,
.ag-fs-section [data-product-card] {
    border-radius: var(--ag-fs-card-radius, 10px);
    box-shadow: var(--ag-fs-card-shadow, 0 2px 8px rgba(15, 23, 42, 0.05));
    transition: transform var(--ag-fs-card-transition, 220ms) ease, box-shadow var(--ag-fs-card-transition, 220ms) ease;
    padding: var(--ag-fs-card-pad, 8px);
}

.ag-fs-section .ag-dh-product-card:hover,
.ag-fs-section [data-product-card]:hover {
    transform: translateY(calc(var(--ag-fs-card-lift, 2px) * -1));
    box-shadow: var(--ag-fs-card-hover-shadow, 0 8px 18px rgba(15, 23, 42, 0.1));
}

.ag-fs-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--ag-fs-header-gap, 10px);
    min-height: var(--ag-fs-header-height, 48px);
    padding: var(--ag-fs-header-pad-y, 8px) var(--ag-fs-header-pad-x, 12px);
    border-radius: var(--ag-fs-header-radius, 10px);
    /* Owned exclusively by Flash Sales Design (--ag-fs-*); not Section Header Design */
    background: linear-gradient(
        135deg,
        var(--ag-fs-header-bg, #be123c),
        var(--ag-fs-header-bg-end, #e11d48)
    ) !important;
    color: var(--ag-fs-header-text, #fff) !important;
    margin-bottom: var(--ag-fs-local-gap);
    border: 0;
    box-shadow: none;
    overflow: visible;
}

.ag-fs-header-main {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    justify-self: start;
}

.ag-fs-header-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: color-mix(in srgb, #fff 18%, transparent);
    color: var(--ag-fs-header-icon, #ffffff) !important;
    font-size: 1.1rem;
    flex: 0 0 auto;
}

.ag-fs-header-copy {
    min-width: 0;
}

.ag-fs-header-kicker {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: .9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ag-fs-header-title {
    margin: 0;
    font-size: var(--ag-fs-header-title-size, 16px);
    font-weight: var(--ag-fs-header-title-weight, 800);
    line-height: 1.2;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ag-fs-header-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex: 0 1 auto;
    flex-wrap: wrap;
    max-width: 100%;
}

.ag-fs-countdown {
    display: inline-flex;
    align-items: center;
    gap: var(--ag-fs-cd-gap, 6px);
    padding: var(--ag-fs-cd-pad-y, 4px) var(--ag-fs-cd-pad-x, 8px);
    border-radius: var(--ag-fs-cd-radius, 8px);
    background: var(--ag-fs-cd-bg, #7f1d1d) !important;
    color: var(--ag-fs-cd-text, #fff) !important;
    font-size: var(--ag-fs-cd-size, 12px);
    font-weight: var(--ag-fs-cd-weight, 800);
    justify-self: center;
}

.ag-fs-countdown-label {
    white-space: nowrap;
    opacity: .92;
}

.ag-fs-countdown-digits {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.ag-fs-countdown-unit {
    display: inline-grid;
    place-items: center;
    min-width: 1.85em;
    padding: .15em .35em;
    border-radius: calc(var(--ag-fs-cd-radius, 8px) - 2px);
    background: var(--ag-fs-cd-digit-bg, #111827);
    color: var(--ag-fs-cd-digit-text, #fff);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.ag-fs-countdown-sep {
    opacity: .8;
}

.ag-fs-view-more {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: var(--ag-fs-vm-pad-y, 6px) var(--ag-fs-vm-pad-x, 12px);
    border-radius: var(--ag-fs-vm-radius, 8px);
    background: var(--ag-fs-vm-bg, #fff) !important;
    color: var(--ag-fs-vm-text, #be123c) !important;
    font-size: var(--ag-fs-vm-size, 13px);
    font-weight: var(--ag-fs-vm-weight, 700);
    text-decoration: none;
    white-space: nowrap;
    flex: 0 0 auto;
    justify-self: end;
    transition: background var(--ag-fs-card-transition, 220ms) ease, color var(--ag-fs-card-transition, 220ms) ease, transform var(--ag-fs-card-transition, 220ms) ease;
}

.ag-fs-view-more:hover,
.ag-fs-view-more:focus-visible {
    background: var(--ag-fs-vm-hover-bg, #fff7ed);
    color: var(--ag-fs-vm-hover-text, #9f1239);
    transform: translateY(-1px);
}

.ag-fs-carousel {
    position: relative;
    /* Reserve gutters so arrows sit beside cards, not over titles/prices */
    padding-inline: calc(var(--ag-fs-arrow-size, 36px) * 0.55);
}

.ag-fs-track {
    display: grid;
    grid-auto-flow: column;
    --ag-fs-visible-cols: var(--ag-product-desktop-columns, 6);
    grid-auto-columns: calc((100% - (var(--ag-fs-visible-cols) - 1) * var(--ag-fs-carousel-gap, var(--ag-fs-card-gap, 12px))) / var(--ag-fs-visible-cols));
    justify-content: start;
    gap: var(--ag-fs-carousel-gap, var(--ag-fs-card-gap, 12px));
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-inline-end: var(--ag-fs-carousel-peek, 24px);
    padding-block: calc(var(--ag-fs-card-lift, 2px) + 6px);
    margin-block: calc((var(--ag-fs-card-lift, 2px) + 6px) * -1);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: stretch;
}

.ag-fs-track::-webkit-scrollbar {
    display: none;
}

.ag-fs-track:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--ag-fs-header-bg, #be123c) 55%, transparent);
    outline-offset: 2px;
}

.ag-fs-track > * {
    scroll-snap-align: start;
    min-width: 0;
    height: 100%;
    display: flex;
}

.ag-fs-section .ag-dh-product-card {
    width: 100%;
    background: var(--ag-fs-card-bg, #fff) !important;
    border-color: var(--ag-fs-card-border, #e2e8f0) !important;
    border-radius: var(--ag-fs-card-radius, 10px) !important;
    box-shadow: var(--ag-fs-card-shadow, none) !important;
    transition: transform var(--ag-fs-card-transition, 220ms) ease, box-shadow var(--ag-fs-card-transition, 220ms) ease;
}

.ag-fs-section .ag-dh-product-card:hover {
    transform: translateY(calc(var(--ag-fs-card-lift, 2px) * -1));
    box-shadow: var(--ag-fs-card-hover-shadow, none) !important;
}

.ag-fs-section .ag-dh-product-media-wrap,
.ag-fs-section .ag-dh-product-media {
    height: var(--ag-fs-card-image-height, 160px);
    max-height: var(--ag-fs-card-image-height, 160px);
    aspect-ratio: auto;
}

.ag-fs-section .ag-dh-product-media img {
    width: 100%;
    height: 100%;
    max-height: var(--ag-fs-card-image-height, 160px);
    object-fit: contain;
    object-position: center;
}

.ag-fs-section .ag-dh-product-title {
    color: var(--ag-fs-title-color, #0f172a) !important;
    font-size: var(--ag-fs-title-size, 13px) !important;
}

.ag-fs-section .ag-dh-price-row strong {
    color: var(--ag-fs-price-color, #be123c) !important;
}

.ag-fs-section .ag-dh-price-row del {
    color: var(--ag-fs-old-price-color, #94a3b8) !important;
}

.ag-fs-section .ag-dh-product-seller {
    color: var(--ag-fs-vendor-color, #475569) !important;
    font-size: var(--ag-fs-vendor-size, 12px) !important;
}

.ag-fs-section .ag-dh-product-shipping {
    color: var(--ag-fs-delivery-color, #64748b) !important;
    font-size: var(--ag-fs-delivery-size, 12px) !important;
}

.ag-fs-section .ag-dh-product-stock-label,
.ag-fs-section .ag-stock-progress__label,
.ag-fs-section .ag-stock-progress__stats {
    color: var(--ag-fs-stock-color, #0f172a);
    font-size: var(--ag-fs-stock-size, 12px);
}

.ag-fs-section .ag-dh-cart-btn {
    height: var(--ag-fs-btn-height, 40px) !important;
    min-height: var(--ag-fs-btn-height, 40px) !important;
    border-radius: var(--ag-fs-btn-radius, 10px) !important;
    background: var(--ag-fs-btn-bg, #0e7490) !important;
    color: var(--ag-fs-btn-text, #fff) !important;
    font-size: var(--ag-fs-btn-size, 13px) !important;
    font-weight: var(--ag-fs-btn-weight, 700) !important;
    transition: background var(--ag-fs-card-transition, 220ms) ease, color var(--ag-fs-card-transition, 220ms) ease, transform var(--ag-fs-card-transition, 220ms) ease;
}

.ag-fs-section .ag-dh-cart-btn:hover:not(:disabled) {
    background: var(--ag-fs-btn-hover-bg, #0f766e) !important;
    color: var(--ag-fs-btn-hover-text, #fff) !important;
    transform: translateY(-1px);
}

.ag-fs-nav {
    position: absolute;
    top: 50%;
    z-index: var(--ag-z-card, 3);
    translate: 0 -50%;
    width: var(--ag-fs-arrow-size, 36px);
    height: var(--ag-fs-arrow-size, 36px);
    border-radius: 999px;
    border: 1px solid var(--ag-fs-arrow-border, #e2e8f0);
    background: var(--ag-fs-arrow-bg, #fff);
    color: var(--ag-fs-arrow-text, #0f172a);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .12);
    cursor: pointer;
    transition: transform var(--ag-fs-card-transition, 220ms) ease, opacity .2s ease;
}

.ag-fs-nav:hover,
.ag-fs-nav:focus-visible {
    transform: scale(1.05);
    outline: 2px solid color-mix(in srgb, var(--ag-fs-header-bg, #be123c) 55%, transparent);
    outline-offset: 2px;
}

.ag-fs-nav:disabled {
    opacity: .35;
    cursor: default;
    transform: none;
    pointer-events: none;
}

.ag-fs-nav[hidden],
.ag-fs-nav[aria-hidden="true"] {
    display: none !important;
}

.ag-fs-nav--prev { inset-inline-start: 0; }
.ag-fs-nav--next { inset-inline-end: 0; }

@media (max-width: 991.98px) {
    .ag-fs-header {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "main view"
            "countdown countdown";
        min-height: 0;
    }

    .ag-fs-header-main { grid-area: main; }
    .ag-fs-countdown { grid-area: countdown; justify-self: start; }
    .ag-fs-view-more { grid-area: view; }

    .ag-fs-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .ag-fs-track {
        --ag-fs-visible-cols: var(--ag-product-tablet-columns, 4);
    }
}

@media (max-width: 575.98px) {
    .ag-fs-section {
        padding: var(--ag-fs-section-pad, 8px);
        margin-block: var(--ag-fs-section-margin-y, 16px);
    }

    .ag-fs-carousel {
        padding-inline: 0;
    }

    .ag-fs-header-title {
        font-size: max(1rem, var(--ag-fs-header-title-size, 16px));
        white-space: normal;
    }

    .ag-fs-countdown-label {
        display: none;
    }

    .ag-fs-track {
        --ag-fs-visible-cols: var(--ag-product-mobile-columns, 2);
    }

    .ag-fs-nav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ag-fs-track,
    .ag-fs-section .ag-dh-product-card,
    .ag-fs-view-more,
    .ag-fs-section .ag-dh-cart-btn,
    .ag-fs-nav {
        scroll-behavior: auto;
        transition: none !important;
    }
}

body.ag-theme-dark .ag-fs-section,
html.ag-theme-dark .ag-fs-section {
    /* keep token-driven surfaces; dark portal themes still honor --ag-fs-* */
}

/* ==========================================================================
   Flash Sales V1-R3 — Header Visual Parity
   Flush red bar at top of the white Flash surface; plain countdown + View All.
   Scoped to [data-ag-flash-header-r3] only — does not affect Recommended / Deals / Collections.
   ========================================================================== */

.ag-fs-section[data-ag-flash-header-r3] {
    /* Remove white cap: header owns the top edge; product body owns padding below. */
    padding-block-start: 0 !important;
    padding-inline: 0 !important;
    padding-block-end: 0 !important;
    margin-block: 0 !important;
    border-radius: 4px;
    /* Keep arrows/hover visible (product rails); header uses its own top radii. */
    overflow: visible;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    grid-template-columns: none !important;
    grid-template-areas: none !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    padding: 0 16px !important;
    margin: 0 !important;
    gap: 12px !important;
    /* Match section top corners; bottom square into white product body */
    border-start-start-radius: 4px !important;
    border-start-end-radius: 4px !important;
    border-end-start-radius: 0 !important;
    border-end-end-radius: 0 !important;
    background: #be1d3e !important;
    background-image: none !important;
    color: #ffffff !important;
    width: 100%;
    box-sizing: border-box;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-main {
    justify-self: unset;
    flex: 0 1 auto;
    min-width: 0;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-icon {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 4px;
    background: #facc15;
    color: #be1d3e !important;
    font-size: 0.875rem;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-kicker {
    display: none !important;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    font-size: 16px;
    font-weight: 800;
    color: #ffffff !important;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown,
.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown[data-ag-fs-countdown-plain] {
    justify-self: unset;
    flex: 0 0 auto;
    gap: 0.35rem !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-image: none !important;
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 700;
    box-shadow: none !important;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown-label {
    display: inline !important;
    opacity: 1;
    color: #ffffff !important;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown-digits {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown-unit {
    display: inline !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-image: none !important;
    color: #ffffff !important;
    font-variant-numeric: tabular-nums;
    box-shadow: none !important;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown-sep {
    opacity: 1;
    color: #ffffff !important;
    margin-inline: 0.1rem;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-view-more,
.ag-fs-section[data-ag-flash-header-r3] .ag-fs-view-more[data-ag-fs-view-plain] {
    justify-self: unset;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-image: none !important;
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: none !important;
    border: 0 !important;
    white-space: nowrap;
}

.ag-fs-section[data-ag-flash-header-r3] .ag-fs-view-more:hover,
.ag-fs-section[data-ag-flash-header-r3] .ag-fs-view-more:focus-visible {
    background: transparent !important;
    color: #ffffff !important;
    text-decoration: underline;
    outline-offset: 2px;
}

/* Product body keeps white surface + internal padding; header stays flush above. */
.ag-fs-section[data-ag-flash-header-r3] .ag-fs-carousel {
    padding-block: 8px 10px;
    background: var(--ag-fs-section-bg, #ffffff);
}

@media (max-width: 991.98px) {
    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-header {
        display: flex !important;
        flex-wrap: nowrap;
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        grid-template-areas: none !important;
    }

    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-main,
    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown,
    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-view-more {
        grid-area: unset !important;
    }
}

@media (max-width: 575.98px) {
    .ag-fs-section[data-ag-flash-header-r3] {
        padding: 0 !important;
        margin-block: 0 !important;
    }

    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-header {
        height: auto !important;
        min-height: 48px !important;
        max-height: none !important;
        flex-wrap: wrap;
        row-gap: 6px;
        padding: 8px 12px !important;
    }

    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-countdown-label {
        display: inline !important;
    }

    .ag-fs-section[data-ag-flash-header-r3] .ag-fs-header-title {
        white-space: nowrap;
        font-size: 15px;
    }
}

