/* ============================================================
   CATALOG.CSS — Product Catalog & Flash Sale Styles
   v2.1 — Nexus V2 Ultra | Fixed: accessibility, specificity, variables
   ============================================================ */

/* ─── Base Reset ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: var(--color-border, #e5e7eb);
    /* FIX: use variable */
}

/* ─── Catalog Layout ─── */
.catalog-wrapper-nexus {
    min-height: var(--catalog-min-height);
    padding-bottom: var(--catalog-padding-bottom);
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px 0 20px;
}

/* Tablet: 4 Columns */
@media (min-width: 768px) {
    .catalog-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

/* Desktop: 6 Columns */
@media (min-width: 1024px) {
    .catalog-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 14px;
    }
}

/* Responsive Wrapper */
@media (max-width: 768px) {
    .catalog-wrapper-nexus {
        min-height: auto;
        padding-bottom: 40px;
    }
}

/* ─── Cleanup Legacy Spacing ─── */
.catalog-layout-full {
    margin-top: 0;
    /* FIX: removed !important */
    padding-top: 0;
    /* FIX: removed !important */
}

/* ====================================================
   FLASH SALE SECTION
   ==================================================== */
.bl-flash-sale {
    margin: 10px 0 0;
}

.bl-fs-wrapper {
    background: var(--white, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--fs-border);
}

/* ── Header ── */
.bl-fs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--white, #ffffff);
    border-left: 3px solid var(--fs-orange);
    border-bottom: 1px solid var(--fs-border-light);
}

.bl-fs-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.bl-fs-tag {
    display: inline-block;
    font-size: var(--text-md);
    font-weight: 800;
    color: var(--fs-red);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--fs-red);
    padding-bottom: 1px;
}

/* ── Timer ── */
.bl-fs-timer-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bl-fs-ends-label {
    font-size: var(--text-sm);
    color: var(--fs-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

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

.bl-digit-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.bl-digit {
    background: #fff5f5;
    color: var(--fs-red);
    font-size: 14px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    padding: 3px 7px;
    border-radius: 4px;
    min-width: 30px;
    text-align: center;
    line-height: 1.3;
    letter-spacing: 1px;
    border: 1px solid #fecaca;
}

/* FIX: A11Y - bumped from 8px to 10px for readability */
.bl-digit-label {
    font-size: 10px;
    color: var(--fs-text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.bl-digit-sep {
    font-size: 14px;
    font-weight: 700;
    color: var(--fs-text-muted);
    margin-bottom: 10px;
    line-height: 1;
    padding: 0 1px;
}

/* ── See All ── */
.bl-fs-seeall {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--fs-orange);
    font-size: var(--text-base);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: gap 0.2s;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: 0 8px;
}

.bl-fs-seeall:hover {
    gap: 6px;
    color: var(--fs-orange-dark);
}

/* ── Scroll Container (Drag & Snap) ── */
.bl-fs-scroll {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 16px 20px 20px;
    background: var(--fs-surface);
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.bl-fs-scroll:active {
    cursor: grabbing;
}

.bl-fs-scroll::-webkit-scrollbar {
    display: none;
}

.bl-fs-products {
    display: flex;
    gap: 14px;
    width: max-content;
    scroll-snap-type: x mandatory;
}

/* ── Card ── */
.bl-fs-card {
    display: flex;
    flex-direction: column;
    background: var(--white, #ffffff);
    border: 1px solid #eeeeee;
    border-radius: 10px;
    overflow: hidden;
    width: 168px;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    scroll-snap-align: start;
}

.bl-fs-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(243, 112, 33, 0.18);
    border-color: var(--fs-orange);
}

/* Image */
.bl-fs-img-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--white, #ffffff);
    overflow: hidden;
}

.bl-fs-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    transition: transform 0.3s;
}

.bl-fs-card:hover .bl-fs-img {
    transform: scale(1.06);
}

/* Badge */
.bl-fs-badge {
    position: absolute;
    top: 8px;
    left: 0;
    z-index: 2;
}

/* Specific yellow styling from storefront */
.bl-fs-badge.yellow {
    left: 8px;
    background: var(--fs-yellow);
    color: #000;
    border-radius: 4px 12px 12px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bl-badge-pct {
    display: block;
    background: var(--fs-yellow-gradient);
    color: #7c2d12;
    font-size: var(--text-sm);
    font-weight: 900;
    padding: 3px 8px 3px 7px;
    border-radius: 0 100px 100px 0;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.3px;
}

/* Info */
.bl-fs-info {
    padding: 10px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 106px;
}

@media (min-width: 768px) {
    .bl-fs-info {
        min-height: 116px;
    }
}

.bl-fs-name {
    font-family: var(--font-body);
    font-size: var(--product-title-size);
    min-height: 28px;
    max-height: 28px;
    font-weight: 500;
    color: var(--fs-text);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 4px 0;
}

@media (min-width: 768px) {
    .bl-fs-name {
        font-size: var(--product-title-size-sm);
        min-height: 32px;
        max-height: 32px;
    }
}

.bl-fs-price-new {
    font-size: var(--product-price-size);
    font-weight: 800;
    color: var(--fs-orange);
    line-height: 1.2;
}

@media (min-width: 768px) {
    .bl-fs-price-new {
        font-size: var(--product-price-size-sm);
    }
}

.bl-fs-price-old {
    font-size: var(--text-xs);
    color: var(--fs-text-dim);
    text-decoration: line-through;
}

/* Stock bar */
.bl-fs-stock {
    margin-top: auto;
    padding-top: 8px;
}

.bl-stock-bar {
    height: 6px;
    background: var(--color-border, #e5e7eb);
    /* FIX: variable */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.bl-stock-fill {
    height: 100%;
    background: var(--fs-green-gradient);
    border-radius: 4px;
    /* FIX: use will-change for GPU performance optimization */
    will-change: width;
    transition: width 0.5s ease;
}

.bl-stock-fill.low {
    background: var(--fs-danger-gradient);
}

/* FIX: A11Y - bumped from 10px to 11px for readability */
.bl-stock-label {
    font-size: 11px;
    color: var(--fs-text-meta);
    font-weight: 600;
}

/* ── Flash Sale Empty State ── */
.bl-fs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    text-align: center;
    background: var(--fs-surface);
}

.bl-fs-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.bl-fs-empty-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fs-text);
    margin: 0 0 4px;
}

.bl-fs-empty-desc {
    font-size: 12px;
    color: var(--fs-text-muted);
    margin: 0;
}

/* ── Flash Sale Skeleton ── */
.bl-fs-skeleton {
    display: flex;
    gap: 14px;
    padding: 16px 20px 20px;
    background: var(--fs-surface);
    overflow: hidden;
}

.bl-fs-skel-card {
    flex-shrink: 0;
    width: 168px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--white, #fff);
    border: 1px solid #f1f5f9;
}

.bl-fs-skel-img {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
}

.bl-fs-skel-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bl-fs-skel-line {
    border-radius: 4px;
}

.bl-fs-skel-line.w85 {
    width: 85%;
    height: 12px;
}

.bl-fs-skel-line.w50 {
    width: 50%;
    height: 14px;
}

.bl-fs-skel-line.w35 {
    width: 35%;
    height: 10px;
}

/* ── Mobile Optimization ── */
@media (max-width: 768px) {
    .bl-fs-header {
        padding: 10px 16px;
        gap: 8px;
    }

    .bl-fs-title {
        font-size: 17px;
    }

    .bl-fs-tag {
        font-size: var(--text-lg);
    }

    .bl-fs-icon {
        font-size: 18px;
    }

    .bl-digit {
        font-size: var(--text-lg);
        padding: 3px 6px;
        min-width: 30px;
    }

    .bl-fs-seeall {
        font-size: var(--text-sm);
    }

    .bl-fs-card {
        width: 156px;
    }

    .bl-fs-ends-label {
        display: none;
    }

    .bl-fs-logo {
        display: none;
    }

    .bl-fs-skel-card {
        width: 156px;
    }
}

/* ============================================================
   PRODUCT GRID & CARD STANDARDIZATION (Nexus V2 Ultra)
   FIX: Reduced !important usage via higher specificity selectors
   ============================================================ */

/* Unified Grid Systems */
.catalog-grid,
.cart-recom-grid,
.related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px 0;
}

@media (min-width: 768px) {

    .catalog-grid,
    .cart-recom-grid,
    .related-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

@media (min-width: 1024px) {

    .catalog-grid,
    .related-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 16px;
    }

    .cart-recom-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Base Card Reset */
.product-card-nexus {
    text-decoration: none;
    color: inherit;
}

.product-card-nexus .line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

/* Product Name: Fixed height for row alignment */
.product-card-nexus .product-name-nexus {
    height: 2.6rem;
    line-height: 1.3rem;
    font-size: 13px;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

@media (min-width: 768px) {
    .product-card-nexus .product-name-nexus {
        height: 3rem;
        line-height: 1.5rem;
        font-size: 14px;
    }
}

/* Price section: fixed height for alignment */
.product-card-nexus .price-section-nexus {
    height: 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

@media (min-width: 768px) {
    .product-card-nexus .price-section-nexus {
        height: 56px;
    }
}

/* Discount row and spacer */
.product-card-nexus .discount-row-nexus,
.product-card-nexus .discount-spacer-nexus {
    height: 18px;
    display: flex;
    align-items: center;
}

@media (min-width: 768px) {

    .product-card-nexus .discount-row-nexus,
    .product-card-nexus .discount-spacer-nexus {
        height: 22px;
    }
}

/* Footer alignment */
.product-card-nexus .card-footer-nexus {
    height: 28px;
    display: flex;
    align-items: center;
    margin-top: auto;
}

/* ⚡ Flash Sale Specialized Card Tweaks */
.flash-sale-card {
    border-color: #fee2e2;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flash-sale-card:hover {
    /* FIX: replaced hardcoded #f97316 with CSS variable */
    border-color: var(--fs-orange);
    box-shadow: 0 12px 24px -8px rgba(249, 115, 22, 0.2);
}

.flash-sale-card .price-section-nexus {
    height: 48px;
}

@media (min-width: 768px) {
    .flash-sale-card .price-section-nexus {
        height: 52px;
    }
}

/* Flash Sale Stock Bar */
.fs-stock-container-nexus {
    width: 100%;
}

.fs-stock-container-nexus .h-2 {
    height: 6px;
    background-color: #f1f5f9;
}

/* FIX: animation performance — use opacity+transform only (GPU friendly) */
@keyframes pulse-soft {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.animate-pulse {
    animation: pulse-soft 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ─── Search Info Bar ─── */
.search-info-bar {
    margin: 0;
    padding-bottom: 20px;
}

.search-info-bar .info-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 12px;
}

.search-info-bar .info-text {
    font-size: var(--text-md);
    color: var(--fs-text-body);
}

.search-info-bar .result-count {
    color: var(--fs-text-muted);
    font-size: var(--text-sm);
}

/* FIX: A11Y - ensured 44x44px minimum touch target with explicit padding */
.btn-clear-search {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
}

/* ============================================================
   PREMIUM PROMOTION BADGES (Nexus V2 Ultra)
   ============================================================ */
.badge-container-nexus {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}

.promo-badge-nexus {
    font-size: 10px;
    font-weight: 800;
    padding: 3px 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Specific Badge Variants */
.badge-promo-nexus {
    background: rgba(30, 41, 59, 0.85);
    color: #f8fafc;
    border-radius: 2px 12px 2px 12px;
}

.badge-flash-nexus {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(185, 28, 28, 0.9));
    color: #ffffff;
    animation: flash-pulse 2s infinite;
    clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
    padding: 3px 14px;
    border-radius: 2px;
}

.badge-special-nexus {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
    color: #ffffff;
    border-radius: 12px 0px 12px 0px;
}

/* FIX: animation optimized to only use transform (no box-shadow) for GPU performance */
@keyframes flash-pulse {
    0% {
        transform: scale(1);
    }

    70% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);
    }
}

@media (max-width: 640px) {
    .promo-badge-nexus {
        font-size: 9px;
        padding: 2px 8px;
    }
}