/**
 * Flash Sale Countdown — Frontend CSS.
 */

/* ==========================================================================
   CSS Custom Properties (defaults)
   ========================================================================== */

.fs-shortcode-wrapper {
    --fs-columns: 4;
    --fs-columns-tablet: 3;
    --fs-columns-mobile: 1;
    margin: 30px 0;
}

/* ==========================================================================
   Single Product Countdown
   ========================================================================== */

.fs-countdown-wrapper {
    background: #e53935;
    color: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

/* Row 1: title (left) + timer (right) on a single line */
.fs-single-countdown {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "header timer"
        "progress progress";
    gap: 6px 16px;
    align-items: center;
}

.fs-single-countdown .fs-countdown-header {
    grid-area: header;
    font-size: 16px;
    font-weight: 800;
    font-style: italic;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    justify-content: flex-start;
}

.fs-single-countdown .fs-countdown-title {
    text-transform: uppercase;
}

.fs-flash-icon {
    font-size: 16px;
    animation: fs-flash-pulse 1.5s ease-in-out infinite;
}

@keyframes fs-flash-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

/* Timer — compact boxes on same row */
.fs-single-countdown .fs-timer-row {
    grid-area: timer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    justify-content: flex-end;
}

.fs-single-countdown .fs-timer-label {
    font-size: 13px;
    font-weight: 500;
    opacity: 1;
    white-space: nowrap;
}

.fs-single-countdown .fs-timer {
    display: flex;
    align-items: center;
    gap: 2px;
}

.fs-single-countdown .fs-timer-box {
    background: #fff;
    border-radius: 4px;
    padding: 2px 6px;
    min-width: 28px;
    text-align: center;
}

.fs-single-countdown .fs-timer-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    color: #e53935;
}

.fs-single-countdown .fs-timer-unit {
    display: none;
}

.fs-single-countdown .fs-timer-sep {
    font-size: 14px;
    font-weight: 700;
    animation: fs-blink 1s step-end infinite;
    color: #fff;
}

@keyframes fs-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Progress bar row 2 — full width, with "X/Y suất" at bottom-right */
.fs-single-countdown .fs-progress-row {
    grid-area: progress;
    margin: 0;
    position: relative;
}

.fs-single-countdown .fs-progress-bar {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

.fs-single-countdown .fs-progress-fill {
    background: linear-gradient(90deg, #fdd835, #ff9800);
    height: 100%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 1s ease-out;
    min-width: 0;
}

/* Hide the "Đã bán X" text baked inside the fill (kept for a11y only) */
.fs-single-countdown .fs-progress-text {
    position: absolute !important;
    clip: rect(0 0 0 0);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.fs-single-countdown .fs-progress-info {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    opacity: 1;
    text-align: right;
}

/* Variation discount badge */
.fs-variation-discount-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Shop Loop Countdown (compact)
   ========================================================================== */

.fs-loop-countdown {
    background: #e53935;
    color: #fff;
    border-radius: 4px;
    padding: 4px 8px;
    margin-top: 6px;
    font-size: 12px;
    text-align: center;
}

.fs-loop-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.fs-flash-icon-sm {
    font-size: 14px;
}

.fs-loop-progress {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    height: 6px;
    margin-top: 4px;
    overflow: hidden;
}

.fs-loop-progress-fill {
    background: linear-gradient(90deg, #fdd835, #ff9800);
    height: 100%;
    border-radius: 10px;
    transition: width 1s ease-out;
}

/* ==========================================================================
   Flash Sale Badge
   ========================================================================== */

.fs-badge {
    background: #e53935 !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 13px;
}

/* ==========================================================================
   Shortcode — Header
   ========================================================================== */

.fs-shortcode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #e53935, #ff5722);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px 8px 0 0;
}

.fs-shortcode-title {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fs-shortcode-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.fs-shortcode-timer .fs-timer-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    min-width: 36px;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
}

/* ==========================================================================
   Shortcode — Grid layout (responsive via CSS variables)
   ========================================================================== */

.fs-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--fs-columns, 4), 1fr);
    gap: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #eee;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

/* ==========================================================================
   Shortcode — Slider layout (responsive via CSS variables)
   ========================================================================== */

.fs-slider-container {
    position: relative;
    background: #fff;
    border: 1px solid #eee;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px;
}

.fs-slider-viewport {
    overflow: hidden;
}

.fs-slider {
    display: flex;
    gap: 16px;
    will-change: transform;
    touch-action: pan-y;
}

.fs-slider .fs-product-card {
    flex-shrink: 0;
    /* Width set dynamically by JS */
}

.fs-slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}

.fs-slider-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.fs-slider-prev {
    left: 4px;
}

.fs-slider-next {
    right: 4px;
}

/* ==========================================================================
   Product Card
   ========================================================================== */

.fs-product-card {
    position: relative;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s;
}

.fs-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fs-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #e53935;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 2;
}

.fs-card-image {
    display: block;
}

.fs-card-image img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.fs-card-info {
    padding: 10px 12px;
}

.fs-card-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    margin-bottom: 6px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-card-title:hover {
    color: #e53935;
}

.fs-card-prices-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 0;
}

.fs-card-prices {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.fs-card-price-sale {
    font-size: 16px;
    font-weight: 700;
    color: #e53935;
    line-height: 1.2;
}

.fs-card-price-regular {
    font-size: 13px;
    color: #999;
    line-height: 1.2;
}

/* Wishlist icon (top-right) */
.fs-card-wishlist {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s, background 0.15s;
}

.fs-card-wishlist:hover {
    background: #fff;
    transform: scale(1.05);
}

.fs-card-wishlist .yith-wcwl-add-to-wishlist,
.fs-card-wishlist .yith-wcwl-add-button {
    margin: 0 !important;
    line-height: 1;
    font-size: 14px;
    display: inline-flex !important;
}

.fs-card-wishlist a {
    color: #666 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
}

.fs-card-wishlist a:hover,
.fs-card-wishlist a.exists {
    color: #e53935 !important;
}

.fs-card-wishlist i {
    font-size: 16px;
}

.fs-card-wishlist .yith-wcwl-icon {
    font-size: 16px !important;
    margin: 0 !important;
}

/* Cart icon button (bottom-right of price row) */
.fs-card-cart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e53935;
    color: #fff !important;
    text-decoration: none !important;
    transition: background 0.15s, transform 0.15s;
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.25);
    border: 0;
    cursor: pointer;
}

.fs-card-cart-btn:hover {
    background: #c62828;
    color: #fff !important;
    transform: scale(1.06);
}

.fs-card-cart-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.fs-card-cart-btn.added::after {
    display: none;
}

.fs-card-cart-btn svg {
    display: block;
    stroke: currentColor;
}

/* Added-to-cart state visual */
.fs-card-cart-btn.added-to-cart {
    background: #2e7d32;
    box-shadow: 0 2px 6px rgba(46, 125, 50, 0.3);
}

/* Responsive */
@media (max-width: 549px) {
    .fs-card-wishlist {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
    .fs-card-cart-btn {
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
    }
    .fs-card-cart-btn svg {
        width: 15px;
        height: 15px;
    }
    .fs-card-price-sale {
        font-size: 14px;
    }
}

/* Card progress */
.fs-card-progress {
    margin-bottom: 6px;
}

.fs-card-progress-bar {
    background: #f0f0f0;
    border-radius: 10px;
    height: 16px;
    overflow: hidden;
}

.fs-card-progress-fill {
    background: linear-gradient(90deg, #fdd835, #ff9800);
    height: 100%;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 1s ease-out;
}

.fs-card-progress-fill span {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.fs-card-remaining {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
    display: block;
}

/* Card timer */
.fs-card-timer {
    background: #e53935;
    color: #fff;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Responsive — Tablet (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    .fs-countdown-wrapper {
        padding: 12px 16px;
    }

    .fs-countdown-header {
        font-size: 15px;
    }

    .fs-timer-value {
        font-size: 18px;
    }

    .fs-timer-box {
        min-width: 40px;
        padding: 4px 6px;
    }

    .fs-timer-row {
        flex-direction: column;
        gap: 6px;
    }

    .fs-shortcode-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    /* Tablet: use --fs-columns-tablet */
    .fs-products-grid {
        grid-template-columns: repeat(var(--fs-columns-tablet, 3), 1fr);
    }
}

/* ==========================================================================
   Responsive — Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    /* Mobile: use --fs-columns-mobile */
    .fs-products-grid {
        grid-template-columns: repeat(var(--fs-columns-mobile, 1), 1fr);
    }

    .fs-shortcode-title {
        font-size: 16px;
    }

    .fs-shortcode-timer .fs-timer-box {
        font-size: 14px;
        min-width: 30px;
        padding: 3px 6px;
    }
}
