/**
 * ระบบ Scale หน้าเว็บแบบปรับปรุงพิเศษ
 * ================================
 * วิธีการนี้ใช้ CSS Transform เพื่อย่อขยายทั้งหน้าเว็บและทำงานกับทุกหมวดหมู่สินค้า
 */

:root {
    --ui-scale: 0.85;
}

/* ระบบ Scale แบบปรับปรุง - ใช้ transform กับ body */
html.scaled-view body {
    transform: scale(var(--ui-scale)) !important;
    transform-origin: top center !important;
    width: calc(100% / var(--ui-scale)) !important;
    height: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-bottom: 50px !important;
    max-width: none !important;
}

/**
 * แก้ไขปัญหาสำหรับ SMART PHONE section
 */
html.scaled-view [id*="flash-sale"],
html.scaled-view [class*="flash-sale"],
html.scaled-view [id*="SMART_PHONE"],
html.scaled-view [class*="smart-phone"],
html.scaled-view [id*="smartphone"],
html.scaled-view [id*="TABLET"] {
    /* font-size controlled by global variables */
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

/* แก้ไขปัญหาสำหรับ product grid ในทุกหมวดหมู่ - เฉพาะเจาะจง */
html.scaled-view .home-product-grid,
html.scaled-view .product-grid,
html.scaled-view .products-list,
html.scaled-view div[class*="product-grid"],
html.scaled-view div[id*="products-grid"] {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 32px !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Responsive scale presets */
@media (max-width: 1200px) {
    :root { --ui-scale: 0.80; }
}
@media (max-width: 900px) {
    :root { --ui-scale: 0.75; }

    html.scaled-view .home-product-grid,
    html.scaled-view .product-grid,
    html.scaled-view .products-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}
@media (max-width: 600px) {
    :root { --ui-scale: 0.70; }

    html.scaled-view .home-product-grid,
    html.scaled-view .product-grid,
    html.scaled-view .products-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
/* Enhanced Product Cards Styling - Advice.co.th Style */

/* ========================================
   PRODUCT IMAGE CONTAINER - CENTER WITH SIDE BADGES
   ======================================== */
.product-card-new .product-image-container-new {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
    gap: 0;
    padding: 0;
    width: 100%;
    height: auto;
    min-height: 200px;
    aspect-ratio: 4 / 3;
    flex-wrap: nowrap;
}

/* Feature Badges - Bottom Layout 2-Column */
.product-badges-sidebar {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
    padding: 4px 0px 4px 0px;
    background: transparent;
    border-top: none;
    z-index: 5;
}

.product-badges-sidebar .feature-badges-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 3px !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

/* Compact feature badges - bottom layout */
.product-badges-sidebar .feature-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    padding: 3px 6px !important;
    font-size: 5px !important;
    line-height: 1 !important;
    color: white !important;
    border-radius: 50px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    width: auto !important;
    min-width: fit-content !important;
    max-width: 100% !important;
    height: 16px !important;
}

.product-badges-sidebar .feature-badge i {
    font-size: 4px !important;
    display: inline-block !important;
    margin-right: 2px !important;
}

/* Right Badges Column - NEW badge at top right, below brand logo */
.right-badges-column {
    position: absolute;
    top: 40px;
    right: 8px;
    left: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
    z-index: 10;
}

.right-badges-column .incoming-badge {
    display: none !important;
}

.right-badges-column .product-badge-top,
.right-badges-column .advice-badge-new {
    position: relative !important;
    margin: 0 !important;
    background: #ff3333 !important;
    color: white !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    padding: 5px 9px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 6px rgba(255, 51, 51, 0.4) !important;
}

/* Brand Logo Badge - Overlay on Image Area (Top-Right) - Transparent */
.product-image-container-new .brand-logo-badge-new {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 12 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.product-image-container-new .brand-logo-badge-new img.brand-logo-img-new {
    max-height: 22px !important;
    max-width: 70px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
}

/* Center Image - Overlay */
.product-card-new .product-card-image-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2 !important;
    pointer-events: none !important;
}

.product-card-new .product-image-new {
    max-width: 87.5%;
    max-height: 87.5%;
    height: auto;
    object-fit: contain;
    width: auto;
}
}

/* Hide feature badges in body section */
.product-card-new .card-body-new .feature-badges-container {
    display: none !important;
}

/* ========================================
   FEATURE BADGES - คุณสมบัติเด่น (Advice Style)
   ======================================== */
.feature-badges-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
    margin: 6px 0;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.feature-badge i {
    font-size: 8px;
}

/* Badge Colors - Advice.co.th Style */
.feature-badge--new {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.feature-badge--ai {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.feature-badge--ict {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.feature-badge--copilot {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.feature-badge--installment {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.feature-badge--express {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.feature-badge--freeship {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

/* Responsive - Mobile Adjustments */
@media (max-width: 576px) {
    .feature-badges-container {
        gap: 2px;
        margin: 4px 0;
    }

    .feature-badge {
        padding: 1px 4px;
        font-size: 8px;
    }

    .feature-badge i {
        font-size: 7px;
    }
}

/* Product Card Integration - จำกัดความสูงและจำนวน badges */
.product-card-new .feature-badges-container,
.card.product-card .feature-badges-container,
.category-card .feature-badges-container {
    margin-top: 4px;
    margin-bottom: 6px;
    max-height: 42px;
    overflow: hidden;
}

/* Flash Sale Card Integration */
.flash-product-card .feature-badges-container,
.flash-sale-slide .feature-badges-container {
    margin: 3px 0;
    max-height: 38px;
    overflow: hidden;
}

/* Carousel/Swiper Card Integration */
.swiper-slide .feature-badges-container,
.product-carousel-slider .feature-badges-container {
    margin: 4px 0;
    max-height: 40px;
    overflow: hidden;
}

/* ป้องกัน badges ล้นออกนอก card */
.card-body-new .feature-badges-container,
.fs-card-body .feature-badges-container {
    position: relative;
    width: 100%;
    max-height: 44px;
    overflow: hidden;
}

/* ========================================
   BUY NOW BUTTON - ปุ่มซื้อเลย (สีฟ้า) - FORCE BLUE
   ======================================== */

/* ========================================
   CATEGORY CARD IMAGE CLICKABLE
   ======================================== */
.category-card__visual {
    position: relative;
    overflow: hidden;
}

.category-card__visual > a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.category-card__visual > a:hover {
    opacity: 0.9 !important;
}

.category-card__visual > a:hover img {
    transform: scale(1.05) !important;
}

.category-card__visual img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    transition: transform 0.3s ease !important;
}

/* ========================================
   BUY NOW BUTTON - ปุ่มซื้อเลย (สีฟ้า) - FORCE BLUE (CONTINUED)
   ======================================== */
/* Wave Animation */
@keyframes waveAnimation {
    0% {
        background-position: 0% center;
    }
    50% {
        background-position: 100% center;
    }
    100% {
        background-position: 0% center;
    }
}

.buy-now-btn-new,
.product-card-new .buy-now-btn-new,
.swiper-slide .buy-now-btn-new,
a.buy-now-btn-new,
button.buy-now-btn-new {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: calc(100% - 4px) !important;
    padding: 8px 13px !important;
    margin: 10px 2px 0 2px !important;
    background: linear-gradient(90deg, #1d7ff2 0%, #18a7e3 48%, #16d0be 100%) !important;
    background-size: 200% 200% !important;
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    border: none !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 3px 8px rgba(22, 156, 203, 0.35) !important;
    animation: waveAnimation 2s ease-in-out infinite !important;
}

.buy-now-btn-new:hover,
.product-card-new .buy-now-btn-new:hover,
a.buy-now-btn-new:hover {
    background: linear-gradient(135deg, #186fe0 0%, #1498d7 52%, #12baa9 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 14px rgba(22, 156, 203, 0.42) !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.buy-now-btn-new:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(22, 156, 203, 0.35);
}

.buy-now-btn-new i {
    font-size: 18px;
    color: #f59e0b !important;
}

.buy-now-btn-new span {
    font-size: 14px;
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Responsive - Mobile */
@media (max-width: 576px) {
    .buy-now-btn-new {
        padding: 8px 12px;
        font-size: 12px;
        margin-top: 8px;
    }

    .buy-now-btn-new i,
    .buy-now-btn-new span {
        font-size: 12px;
    }
}

/* Product Card body layout adjustment */
.card-body-new {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 12px 12px 12px !important;
}

.card-body-new .price-section-new {
    margin-top: auto;
    text-align: center;
}

/* ========================================
   PRICE DISPLAY - ราคาและส่วนลดบรรทัดเดียวกัน
   ======================================== */
.price-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    width: 100%;
}

.price-col {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
    text-align: center;
    width: 100%;
}

/* ราคาเดิมขีดฆ่า */
.price-col .original-row {
    display: block;
    line-height: 1.2;
}

.price-col .card-price-original {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
}

/* ราคาปัจจุบัน + ส่วนลด อยู่บรรทัดเดียวกัน - INLINE FORCE */
.price-col .price-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}

.price-col .card-price-online {
    display: inline-block !important;
    font-size: 16px;
    font-weight: 700;
    color: #0ea5e9;
    white-space: nowrap;
    flex-shrink: 0;
}

.price-col .card-price {
    font-size: 17px;
    font-weight: 700;
    color: #0ea5e9;
}

/* Badge ส่วนลด - inline กับราคา */
.price-col .promo-badge-right {
    display: inline-flex !important;
    align-items: center;
    padding: 2px 6px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Meta col สำหรับ online only text */
.meta-col {
    margin-bottom: 2px;
}

.meta-col .meta-line.online-only {
    font-size: 10px;
    color: #f97316;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive - Mobile */
@media (max-width: 576px) {
    .price-col .card-price-online,
    .price-col .card-price {
        font-size: 15px;
    }

    .price-col .promo-badge-right {
        font-size: 9px;
        padding: 2px 5px;
    }

    .price-col .card-price-original {
        font-size: 11px;
    }
}

/* Product Card New - Full Height Display - EQUAL HEIGHT FIX */
.product-card-new {
    display: flex;
    flex-direction: column;
    height: auto;
    background: #ffffff;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.product-card-new:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Swiper slide height adjustment - AUTO HEIGHT */
.product-carousel-slider .swiper-slide,
.swiper-slide:has(.product-card-new) {
    height: auto !important;
    min-height: auto !important;
}

.product-carousel-slider .product-card-new,
.swiper-slide .product-card-new {
    height: auto;
    overflow: visible;
}

/* Card Body - Fixed Height Sections */
.product-card-new .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 6px;
    padding-bottom: 4px;
    overflow: visible;
}

/* Title - Fixed Height with Ellipsis */
.product-card-new .product-title-link {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 32px;
    max-height: 32px;
    margin-bottom: 6px;
}

/* Feature Badges - Fixed Height */
.product-card-new .feature-badges-container {
    min-height: auto;
    max-height: none;
    overflow: visible;
    margin-bottom: 4px;
}

/* Specs/Description - Fixed Height */
.product-card-new .product-specs,
.product-card-new .card-spec-line {
    display: block !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.5 !important;
    min-height: auto !important;
    max-height: none !important;
    margin-bottom: 6px !important;
    word-break: break-word !important;
    white-space: normal !important;
}

/* Price Section - Fixed at Bottom */
.product-card-new .price-col {
    margin-top: 4px;
    flex-shrink: 0;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
}
}

/* Price Row - FORCE INLINE */
.product-card-new .price-row,
.product-card-new .price-col .price-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.product-card-new .card-price {
    font-size: 16px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    text-align: center !important;
    display: block !important;
    width: 100% !important;
}

.product-card-new .promo-badge-right {
    font-size: 9px !important;
    padding: 2px 5px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* Ensure button is always visible - FIXED BOTTOM */
.product-card-new .buy-now-btn-new {
    margin-top: 2px;
    margin-bottom: 0;
    flex-shrink: 0;
    width: 100%;
}

/* Mobile Responsive - Equal Height Cards */
@media (max-width: 768px) {
    .product-carousel-slider .swiper-slide,
    .swiper-slide:has(.product-card-new) {
        height: auto !important;
        min-height: auto !important;
    }

    .product-card-new {
        height: auto;
    }

    .product-card-new .product-title-link {
        min-height: 28px;
        max-height: 28px;
        font-size: 11px !important;
    }

    .product-card-new .feature-badges-container {
        min-height: 24px;
        max-height: 24px;
    }

    .product-card-new .product-specs,
    .product-card-new .card-spec-line {
        display: block !important;
        min-height: auto !important;
        max-height: none !important;
        font-size: 10px !important;
        line-height: 1.5 !important;
        overflow: visible !important;
        white-space: normal !important;
    }

    .product-card-new .card-price {
        font-size: 14px !important;
    }

    .product-card-new .promo-badge-right {
        font-size: 8px !important;
        padding: 1px 4px !important;
    }
}

@media (max-width: 480px) {
    .product-carousel-slider .swiper-slide,
    .swiper-slide:has(.product-card-new) {
        height: 440px !important;
        min-height: 440px !important;
        max-height: 440px !important;
    }

    .product-card-new {
        min-height: 420px;
        max-height: 440px;
    }
}

/* ========================================
   SINGLE SOURCE OF TRUTH - แก้ที่เดียวได้ทั้งหน้า
   ======================================== */
:root {
    /* Font Sizes - ควบคุมขนาดตัวอักษรทั้งหมดที่นี่เท่านั้น */
    --product-title-size: 12px !important;
    --product-title-line-height: 1.25 !important;
    --product-title-color: #0066cc !important;
    --product-price-size: 18px !important;
    --product-spec-size: 12px !important;
    --product-badge-size: 8px !important;

    /* Design Tokens */
    --pcv2-color-bg:#ffffff;
    --pcv2-color-border:#d9e2ec;
    --pcv2-color-accent:#0ea5e9;
    --pcv2-skel-base:#eef2f6;
    --pcv2-skel-mid:#e2e8f0;
    --pcv2-skel-radius:6px;
    --pcv2-text-primary:#1d2734;
    --pcv2-text-secondary:#5f6c7b;
    --pcv2-text-faint:#64748b;
    --pcv2-price-current:#0c6fbf;
    --pcv2-price-old:#7a8896;
}
[data-theme="dark"], .dark {
    --pcv2-color-bg:#1e2530;
    --pcv2-color-border:#303a46;
    --pcv2-color-accent:#38bdf8;
    --pcv2-skel-base:#334155;
    --pcv2-skel-mid:#475569;
    --pcv2-text-primary:#e2e8f0;
    --pcv2-text-secondary:#cbd5e1;
    --pcv2-text-faint:#94a3b8;
    --pcv2-price-current:#38bdf8;
    --pcv2-price-old:#64748b;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --pcv2-color-bg:#1e2530;
        --pcv2-color-border:#303a46;
        --pcv2-color-accent:#38bdf8;
        --pcv2-skel-base:#334155;
        --pcv2-skel-mid:#475569;
        --pcv2-text-primary:#e2e8f0;
        --pcv2-text-secondary:#cbd5e1;
        --pcv2-text-faint:#94a3b8;
        --pcv2-price-current:#38bdf8;
        --pcv2-price-old:#64748b;
    }
}

/* Page layout - 90% width with centered content */
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

.page-wrapper,
.content-wrapper {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding-left: var(--page-edge-padding, 24px) !important;
    padding-right: var(--page-edge-padding, 24px) !important;
    box-sizing: border-box !important;
}

/* All main containers use full width */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: var(--page-edge-padding, 24px) !important;
    padding-right: var(--page-edge-padding, 24px) !important;
}

/* === CRITICAL FIX: REMOVE MAX-WIDTH CONSTRAINTS FOR PRODUCT GRIDS === */
.homepage-section[data-section-type="product_grid"] .container {
    max-width: 100% !important;
    width: 100% !important;
}

.section-content-area {
    max-width: 100% !important;
    width: 100% !important;
}

/* Ensure product grid spans full available width */
.homepage-section .product-grid {
    width: calc(100vw - 32px);
    max-width: calc(100% - 0px);
}

/* Category page responsive grid - Fixed responsive columns */
.category-products-page #products-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 16px;
    align-items: stretch;
}

.category-products-page #products-grid > * {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Responsive breakpoints */
@media (min-width: 1600px) {
    .category-products-page #products-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1680px;
        gap: 24px;
    }
}

@media (max-width: 1199px) {
    .category-products-page #products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .category-products-page #products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        padding: 0 10px;
    }
}

@media (max-width: 540px) {
    .category-products-page #products-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 12px;
    }
}

.category-products-page .category-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 480px;
    height: 100%;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    transition: all 0.25s ease;
    cursor: pointer;
}

.category-products-page .category-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    border-color: #0ea5e9;
}

.category-products-page .category-card__visual {
    position: relative;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 20px;
    min-height: 260px;
    height: 260px;
    max-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    border-bottom: 1px solid #e2e8f0;
}

.category-products-page .category-card__visual img {
    position: relative;
    display: block;
    max-width: 100%;
    max-height: 220px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center center;
    z-index: 1;
    transition: transform 0.35s ease;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
}

.category-products-page .category-card:hover .category-card__visual img {
    transform: scale(1.05);
}

.category-products-page .category-card__brand-logo {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 56px;
    height: 56px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    transition: all 0.3s ease;
    border: 1px solid rgba(13, 110, 253, 0.08);
}

.category-products-page .category-card__brand-logo:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.category-products-page .category-card__brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 576px) {
    .category-products-page .category-card__brand-logo {
        width: 46px;
        height: 46px;
        padding: 6px;
    }

    .category-products-page .category-card__brand-logo img {
        width: 100%;
        height: 100%;
    }
}

.category-products-page .category-card__badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 10;
    max-width: 60%;
}

.category-products-page .category-card__badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: #ffffff;
    background: #3b82f6;
    border-radius: 4px;
    padding: 3px 6px;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    white-space: nowrap;
}

.category-products-page .category-card__badge i {
    font-size: 0.6rem;
}

/* สี badges แต่ละประเภท */
.category-products-page .category-card__badge--stock {
    background: #22c55e;
}

.category-products-page .category-card__badge--shipping {
    background: #f59e0b;
}

.category-products-page .category-card__badge--ai {
    background: #8b5cf6;
}

.category-products-page .category-card__badge--ict {
    background: #06b6d4;
}

.category-products-page .category-card__badge--copilot {
    background: #6366f1;
}

.category-products-page .category-card__badge--new {
    background: #ef4444;
}

.category-products-page .category-card__badge--recommend {
    background: rgba(34, 197, 94, 0.95);
}

.category-products-page .category-card__badge--incoming {
    background: rgba(249, 115, 22, 0.95);
}

.category-products-page .category-card__content {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 1rem 1.25rem 1.25rem;
    flex: 1;
}

.category-products-page .category-card__title-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.category-products-page .category-card__brand-chip {
    align-self: flex-start;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #4338ca;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    text-transform: uppercase;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.category-products-page .category-card__title-link {
    text-decoration: none;
    color: inherit;
}

.category-products-page .category-card__title-link h3 {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.category-products-page .category-card__title-link:hover h3 {
    color: #0ea5e9;
}

.category-products-page .category-card__excerpt {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.45;
    max-height: 60px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.category-products-page .category-card__spec-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.78rem;
    color: #64748b;
    max-height: 56px;
    overflow: hidden;
}

.category-products-page .category-card__spec-list li {
    display: flex;
    gap: 0.3rem;
    align-items: flex-start;
    line-height: 1.3;
}

.category-products-page .category-card__spec-list li::before {
    content: '•';
    color: #0ea5e9;
    font-weight: 700;
    flex-shrink: 0;
}

.category-products-page .category-card__promo-ribbon {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 12;
}

.category-products-page .category-card__promo-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.category-products-page .category-card__promo-badge--deal {
    background: linear-gradient(135deg, #fb923c, #f97316);
}

.category-products-page .category-card__promo-badge--flash {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.category-products-page .category-card__promo-badge--new {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.category-products-page .category-card__promo-badge--top {
    background: linear-gradient(135deg, #10b981, #059669);
}

.category-products-page .category-card__price-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    margin-top: auto;
}

.category-products-page .category-card__price-left {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* ราคาและปุ่มอยู่บรรทัดเดียวกัน */
.category-products-page .category-card__price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding: 0.5rem 0;
}

.category-products-page .category-card__price-info {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.category-products-page .category-card__price-current {
    font-size: 1.2rem;
    font-weight: 800;
    color: #dc2626;
    line-height: 1.1;
}

.category-products-page .category-card__price-current--contact {
    display: inline-block;
    max-width: 100%;
    font-size: 0.88rem;
    line-height: 1.25;
    white-space: normal;
    word-break: keep-all;
}

.category-products-page .category-card__price-old {
    font-size: 0.72rem;
    color: #94a3b8;
    text-decoration: line-through;
    line-height: 1;
}

/* ปุ่มกด */
.category-products-page .category-card__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.category-products-page .category-card__cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #f1f5f9;
    color: #0284c7;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-products-page .category-card__cart-btn:hover {
    background: #0ea5e9;
    color: #fff;
    transform: scale(1.05);
}

.category-products-page .category-card__cart-btn i {
    font-size: 0.85rem;
}

.category-products-page .category-card__buy-btn {
    display: none;
}

/* ปุ่มซื้อเลยแบบใหม่ - เต็มความกว้าง สีน้ำเงินไล่ฟ้าทะเล */
.category-products-page .category-card__buy-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: calc(100% - 4px);
    padding: 10px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    text-decoration: none;
    transition: all 0.2s ease;
    margin: 10px 2px 0 2px;
    border: none;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}

.category-products-page .category-card__buy-box:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(14, 165, 233, 0.4);
}

.category-products-page .category-card__buy-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
}

.category-products-page .category-card__buy-main i {
    font-size: 1rem;
    color: #ffffff;
}

.category-products-page .category-card__buy-sub {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.category-products-page .category-card__price-saving {
    font-size: 0.75rem;
    font-weight: 600;
    color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    display: inline-block;
    width: fit-content;
}

.category-products-page .category-card__online-note {
    font-size: 0.72rem;
    color: #f59e0b;
    font-weight: 500;
    font-style: italic;
}

.category-products-page .category-card__pill-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    overflow: hidden;
}

.category-products-page .category-card__pill {
    background: #f1f5f9;
    color: #334155;
    border-radius: 4px;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-weight: 600;
    white-space: nowrap;
}

.category-products-page .category-card__pill i {
    font-size: 0.6rem;
}

/* ซ่อน footer เก่า */
.category-products-page .category-card__footer {
    display: none;
}

.category-products-page .category-card__shipping-note {
    display: none;
}

.category-products-page .category-card__actions {
    display: none;
}

.category-products-page .category-card__cart-btn {
    display: none;
}

/* ซ่อน cta-btn เก่า */
.category-products-page .category-card__cta-btn {
    display: none;
}

/* สี pills แต่ละประเภท - กะทัดรัด */
.category-products-page .category-card__pill--warranty {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.category-products-page .category-card__pill--stock {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
}

.category-products-page .category-card__pill--shipping {
    background: #fef3c7 !important;
    color: #92400e !important;
}

.category-products-page .category-card__pill--copilot {
    background: #ede9fe !important;
    color: #6d28d9 !important;
}

/* Responsive - การ์ดสินค้า */
@media (max-width: 768px) {
    .category-products-page .category-card {
        min-height: 420px;
    }

    .category-products-page .category-card__visual {
        min-height: 200px;
        height: 200px;
        padding: 16px;
    }

    .category-products-page .category-card__visual img {
        max-height: 170px;
    }

    .category-products-page .category-card__content {
        padding: 0.85rem 1rem 1rem;
    }

    .category-products-page .category-card__title-link h3 {
        font-size: 0.88rem;
    }

    .category-products-page .category-card__price-current {
        font-size: 1.1rem;
    }

    .category-products-page .category-card__buy-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .category-products-page .category-card__cart-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 576px) {
    .category-products-page .category-card {
        min-height: 360px;
    }

    .category-products-page .category-card__visual {
        min-height: 160px;
        height: 160px;
        padding: 12px;
    }

    .category-products-page .category-card__visual img {
        max-height: 140px;
    }

    .category-products-page .category-card__content {
        padding: 0.6rem 0.75rem 0.75rem;
        gap: 0.4rem;
    }

    .category-products-page .category-card__title-link h3 {
        font-size: 0.78rem;
    }

    .category-products-page .category-card__price-current {
        font-size: 1rem;
    }

    .category-products-page .category-card__price-row {
        gap: 0.3rem;
    }

    .category-products-page .category-card__buy-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }

    .category-products-page .category-card__cart-btn {
        width: 26px;
        height: 26px;
    }

    .category-products-page .category-card__cart-btn i {
        font-size: 0.75rem;
    }

    .category-products-page .category-card__shipping-note {
        font-size: 0.6rem;
    }

    .category-products-page .category-card__pill-item .category-card__pill i {
        font-size: 0.55rem;
    }
}

.category-products-page .category-card__pill i,
.category-products-page .category-card__stat i {
    color: inherit;
}

/* ซ่อนปุ่มซื้อเลยทั้งหมด */
.category-products-page .category-card__cta {
    display: none !important;
}

/* ปุ่มซื้อและตะกร้า - แสดงปกติ */
.category-products-page .category-card__buy-icon {
    display: none !important;
}

.category-products-page .category-card__stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #475569;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.6rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-products-page .category-card__stat {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.product-card {
    position: relative;
    border-radius: 16px !important;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #10b981 0%, #3b82f6 50%, #6366f1 100%) border-box !important;
    border: 2px solid transparent !important;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.1) !important;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* จำกัดความสูงเพื่อให้ปุ่มอยู่ในการ์ด */
    min-height: 520px !important;
    max-height: 580px !important;
    height: 100% !important;
}

/* Ensure card and wrapper don't clip badges */
.product-card,
.product-card-wrapper,
.card,
.card-body {
    overflow: visible !important;
}

.product-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    height: 0;
    width: 100%;
    pointer-events: none;
/* === SECTION CONTENT AREA OVERRIDE === */
.homepage-section {
    max-width: 100% !important;
    width: 100% !important;
}

.main-content-wrapper {
    max-width: 100% !important;
    width: 100% !important;
}
    transform: translateY(-8px);
    box-shadow: 0 16px 40px rgba(59, 130, 246, 0.2),
                0 8px 16px rgba(16, 185, 129, 0.15) !important;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #10b981 0%, #3b82f6 30%, #6366f1 100%) border-box !important;
}

/* Fixed card size (desktop): 313 x 584px as requested */
:root {
    --pc-fixed-card-width: 313px;
    --pc-fixed-card-height: 584px;
    --pc-fixed-image-height: 280px;
    --pc-fixed-grid-gap: 0.5rem;
}

/* Apply fixed sizing only to product grids so other cards aren’t affected */
.product-grid,
.category-products-page #products-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    justify-content: stretch !important;
    gap: 16px !important;
    width: 100% !important;
}

.product-grid .product-card-wrapper,
.category-products-page #products-grid > * {
    width: 100% !important;
    max-width: 100% !important;
}

.product-grid .product-card,
.category-products-page #products-grid .product-card {
    width: 100% !important;
    height: auto !important;
}

.product-grid .product-image-container,
.product-grid .card-img-top-wrapper,
.category-products-page #products-grid .product-image-container,
.category-products-page #products-grid .card-img-top-wrapper {
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 4 / 3 !important;
    padding: 16px !important;
}

.product-grid .product-card .card-body,
.category-products-page #products-grid .product-card .card-body {
    padding: 14px 16px 16px !important;
    gap: 10px;
    overflow: visible !important;
}

/* Very narrow screens (smaller than the fixed width): avoid horizontal overflow */
@media (max-width: 340px) {
    .product-grid,
    .category-products-page #products-grid {
        grid-template-columns: 1fr !important;
        justify-content: stretch;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .product-grid .product-card-wrapper,
    .category-products-page #products-grid > * {
        width: 100% !important;
        max-width: 100% !important;
    }

    .product-grid .product-card,
    .category-products-page #products-grid .product-card {
        width: 100% !important;
        height: auto !important;
    }
}

.product-card .card-body {
    flex: 1 1 auto;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px;
    padding: 14px 16px 16px !important;
    background: transparent;
    overflow: visible !important;
    /* เพิ่มความสูงเพื่อให้เนื้อหาแสดงครบ */
    min-height: 260px !important;
    max-height: 340px !important;
}

.product-card .card-body .brand-name,
.product-card .card-body .product-brand,
.product-card .card-body .card-brand {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #0284c7;
    text-transform: uppercase;
}

.product-card .card-body .card-title,
.product-card .card-body .product-name,
/* Font-size controlled by .product-title only */
.product-card .card-body .product-title {
    /* font-size: 11px !important; */
    /* font-weight: 600 !important; */
    color: #0f172a;
    margin: 0 0 2px 0 !important;
    line-height: 1.3;
    /* จำกัดความสูง */
    max-height: 28px !important;
    overflow: hidden !important;
    flex-shrink: 0 !important; /* ป้องกันไม่ให้ title ถูกบีบ */
}

.product-card .card-body .product-description,
.product-card .card-body .card-text,
.product-card .card-body .product-desc,
.product-card .card-body .product-meta {
    font-size: 11px !important;
    line-height: 1.35 !important;
    color: #6b7280 !important;
    margin: 0 !important;
    /* จำกัด 3 บรรทัด: 11px × 1.35 × 3 = 44.55px */
    max-height: 44.55px !important;
    overflow: hidden !important;
    word-wrap: break-word !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    flex-shrink: 0 !important; /* ป้องกันไม่ให้ description ถูกบีบ */
}

.product-card .card-body .price-block,
.product-card .card-body .price-row,
.product-card .card-body .pricing-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: center;
}

.product-card .card-body .price-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 4px 0 !important;
    align-items: center;
    text-align: center;
}

.product-card .card-body .card-price-original {
    color: #94a3b8;
    text-decoration: line-through;
    font-size: 13px;
    font-weight: 400;
    margin: 0;
}

.product-card .card-body .price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-card .card-body .card-price-online,
.product-card .card-body .card-price,
.product-card .card-body .price-strong,
.product-card .card-body .current-price,
.product-card .card-body .final-price {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0;
    line-height: 1.2 !important;
}

.product-card .card-body .discount-badge {
    background: #dc2626;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

.product-card .card-body .product-info-pills {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 12px 0;
}

.product-card .card-body .info-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #64748b;
    line-height: 1.4;
}

.product-card .card-body .info-pill i {
    color: #3b82f6;
    font-size: 11px;
}

.product-card .card-body .info-pill.warranty-pill i { color: #10b981; }
.product-card .card-body .info-pill.delivery-pill i { color: #f59e0b; }
.product-card .card-body .info-pill.installment-pill i { color: #ef4444; }

.product-card .card-body .price-note,
.product-card .card-body .installment-note,
.product-card .card-body .delivery-note,
.product-card .card-body .warranty-note,
.product-card .card-body .shipping-info {
    font-size: 10px !important;
    color: #64748b !important;
    display: block;
    line-height: 1.4 !important;
}

.product-card .card-body .btn-group {
    margin-top: auto !important; /* ดันไปด้านล่างสุด */
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 66px !important;
    padding: 8px 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important; /* ไม่ให้หดตัว */
}

.product-card .card-body .btn,
.product-card .card-body button,
.product-card .card-body .btn-group .btn,
.product-card .card-body .add-to-cart-btn,
.product-card .card-body .cta-primary {
    /* บังคับให้แสดง */
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    cursor: pointer !important;
    /* ปุ่มยาว สีฟ้าแบบไล่ระดับ */
    width: calc(100% - 4px) !important;
    height: auto !important;
    min-width: auto !important;
    min-height: 44px !important;
    border-radius: 12px !important;
    padding: 10px 16px !important;
    margin: 0 2px !important;
    font-weight: 600;
    font-size: 14px !important;
    line-height: 1.5 !important;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3) !important;
    transition: all 0.2s ease;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    position: relative;
    flex-shrink: 0 !important;
    z-index: 100 !important;
    text-align: center !important;
    text-decoration: none !important;
}

.product-card .card-body .btn::before,
.product-card .card-body .add-to-cart-btn::before {
    display: none !important;
}

.product-card .card-body .btn i,
.product-card .card-body .btn-group .btn i,
.product-card .card-body .add-to-cart-btn i {
    display: none !important;
}

.product-card .card-body .btn:hover,
.product-card .card-body button:hover,
.product-card .card-body .btn-group .btn:hover,
.product-card .card-body .add-to-cart-btn:hover,
.product-card .card-body .cta-primary:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(14, 165, 233, 0.4) !important;
}

.product-card .card-body .support-meta,
.product-card .card-body .view-count-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.product-card .card-body .view-count-footer i {
    color: #cbd5e1;
    font-size: 12px;
}

.product-card .card-body .assist-row,
.product-card .card-body .info-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: #64748b;
}

.product-image-container {
    position: relative;
    overflow: visible !important;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(180deg, #f8fbff 0%, #eef2f7 100%);
    flex-shrink: 0;
    width: 100%;
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 2.6vw, 24px);
    box-sizing: border-box;
}

/* ========== Feature Badges Container ========== */
.feature-badges-container {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 10;
    max-width: 120px;
    pointer-events: none;
}

/* Copilot+PC Badge */
.copilot-pc-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #0078D4 0%, #00BCF2 100%);
    border-radius: 4px;
    padding: 3px 6px;
    box-shadow: 0 2px 6px rgba(0,120,212,0.35);
    font-size: 9px !important;
    font-weight: 700 !important;
    color: white;
    line-height: 1;
    white-space: nowrap;
}

.copilot-pc-badge-overlay img {
    height: 14px;
    width: auto;
}

.copilot-pc-badge-overlay span {
    color: white;
    font-size: 9px !important;
    font-weight: 700 !important;
}

/* NEW Badge */
.new-arrival-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(34,197,94,0.35);
    line-height: 1;
    white-space: nowrap;
}

/* AI Feature Badge */
.ai-feature-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: white;
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(37,99,235,0.35);
    line-height: 1;
    white-space: nowrap;
}

/* ICT Badge */
.ict-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    color: #422006;
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(234,179,8,0.35);
    line-height: 1;
    white-space: nowrap;
}

/* Warranty Badge (ประกัน 3-3-3) */
.warranty-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(16,185,129,0.35);
    line-height: 1;
    white-space: nowrap;
}

/* Express Delivery Badge */
.express-delivery-badge-overlay {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: #f8fafc;
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(17,24,39,0.4);
    line-height: 1;
    white-space: nowrap;
}
/* ========== End Feature Badges Container ========== */

.product-card .card-img-top-wrapper {
    width: 100%;
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 2.6vw, 24px);
    background: transparent;
    margin: 0;
    position: relative;
    overflow: visible;
}

@media (max-width: 640px) {
    .product-card {
        border-radius: 14px !important;
        box-shadow: 0 10px 22px rgba(15, 76, 129, 0.14) !important;
    }

    .product-card .card-body {
        padding: 16px 16px 20px !important;
        gap: 10px;
    }

    .product-card .card-body .card-title,
    .product-card .card-body .product-name,
    .product-card .card-body .product-title {
        font-size: clamp(0.92rem, 3.4vw, 1rem);
    }

    .product-card .card-body .card-price-online,
    .product-card .card-body .card-price,
    .product-card .card-body .price-strong {
        font-size: clamp(1.15rem, 4vw, 1.28rem);
    }

    .product-card .card-body .price-note,
    .product-card .card-body .installment-note,
    .product-card .card-body .delivery-note {
        font-size: 0.7rem;
    }

    .product-card .card-body .btn,
    .product-card .card-body button,
    .product-card .card-body .cta-primary {
        padding: 0.5rem 0.9rem;
        font-size: 0.9rem;
    }

    .product-image-container,
    .product-card .card-img-top-wrapper {
        padding: 16px;
    }
}

.product-card figure {
    margin: 0;
    width: 100%;
}

.product-card figure figcaption,
.product-card .product-dimension,
.product-card .dimension-note {
    margin-top: clamp(6px, 1vw, 10px);
    text-align: center;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #6b7280;
}

/* เฉพาะหมวด SMART PHONE: ให้ภาพสินค้าแสดงเต็มพื้นที่ด้านบนของการ์ดสินค้า ไม่มีพื้นหลังสีเทา */
html.scaled-view [id*="SMART_PHONE"] .product-image-container,
html.scaled-view [class*="smart-phone"] .product-image-container,
html.scaled-view [id*="smartphone"] .product-image-container {
    background: #ffffff !important;
    aspect-ratio: 3 / 4 !important;
    height: auto !important;
    padding: clamp(16px, 3vw, 26px) !important;
    align-items: center !important;
    justify-content: center !important;
    border-bottom: none !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-image-container img,
html.scaled-view [id*="smartphone"] .product-image-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    background: transparent !important;
    margin: 0 !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

.product-card .card-img-top,
.product-card img.product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    background: transparent !important;
    margin: 0 !important;
    display: block !important;
}

/* Reduce gap between section header and product grid by 0.25rem for SMART PHONE sections */
html.scaled-view [id*="SMART_PHONE"] .section-header,
html.scaled-view [class*="smart-phone"] .section-header,
html.scaled-view [id*="smartphone"] .section-header {
    margin-bottom: calc(40px - 0.25rem) !important; /* original margin-bottom: 40px in content-section-balance.css */
}
html.scaled-view [id*="SMART_PHONE"] .product-grid,
html.scaled-view [class*="smart-phone"] .product-grid,
html.scaled-view [id*="smartphone"] .product-grid {
    padding-top: 0 !important; /* ensure grid doesn't add extra top padding */
    margin-top: 0 !important; /* nudge grid up slightly if needed */
}

/* SMART PHONE: full width layout with no gaps (cards stick together) */
html.scaled-view [id*="SMART_PHONE"] .product-grid,
html.scaled-view [class*="smart-phone"] .product-grid,
html.scaled-view [id*="smartphone"] .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(var(--sp-col-min), 1fr)) !important;
        gap: 0 !important;              /* no gaps at all */
        column-gap: 0 !important;       /* explicitly no column gap */
        row-gap: 0 !important;          /* explicitly no row gap */
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
}

/* SMART PHONE Layout System (no gaps, cards stick together) */
html.scaled-view [id*="SMART_PHONE"],
html.scaled-view [class*="smart-phone"],
html.scaled-view [id*="smartphone"] {
        --sp-col-min: 280px;           /* minimum card width (increased) */
        --sp-col-max: 1fr;             /* distribute remaining space */
        --sp-grid-gap-x: 0px;          /* no horizontal gap */
        --sp-grid-gap-y: 0px;          /* no vertical gap */
        --sp-card-max-width: none;     /* remove width restriction for full expansion */
        --sp-img-height: 240px;        /* consistent image stage */
        --sp-img-ratio: 3 / 4;         /* fallback aspect-ratio if needed */
        --sp-body-padding-x: 16px;     /* slightly reduced padding */
        --sp-body-padding-y: 12px;     /* slightly reduced padding */
        --sp-title-lines: 2;
        --sp-meta-lines: 3;
}
html.scaled-view [id*="SMART_PHONE"] .product-grid,
html.scaled-view [class*="smart-phone"] .product-grid,
html.scaled-view [id*="smartphone"] .product-grid {
        display:grid !important;
        grid-template-columns:repeat(auto-fit,minmax(var(--sp-col-min), var(--sp-col-max))) !important;
        gap: var(--sp-grid-gap-y) var(--sp-grid-gap-x) !important;
        align-items:start !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card,
html.scaled-view [class*="smart-phone"] .product-card,
html.scaled-view [id*="smartphone"] .product-card {
        max-width: var(--sp-card-max-width) !important;
        width: 100% !important;  /* Use full available width */
        padding: var(--sp-body-padding-y) var(--sp-body-padding-x) calc(var(--sp-body-padding-y) + 8px) var(--sp-body-padding-x) !important;
        box-sizing: border-box !important;
        margin: 0 !important;  /* Remove any margin that creates gaps */
}
/* Image zone exact sizing */
html.scaled-view [id*="SMART_PHONE"] .product-image-container,
html.scaled-view [class*="smart-phone"] .product-image-container,
html.scaled-view [id*="smartphone"] .product-image-container {
        height: var(--sp-img-height) !important;
        aspect-ratio: var(--sp-img-ratio) !important;
}
/* Enforce full cover by default, allow contain with helper class */
html.scaled-view [id*="SMART_PHONE"] .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-image-container img,
html.scaled-view [id*="smartphone"] .product-image-container img {
        object-fit: cover !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card.img-contain .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-card.img-contain .product-image-container img,
html.scaled-view [id*="smartphone"] .product-card.img-contain .product-image-container img { object-fit:contain !important; }

/* Unified line clamp (add standard property) */
html.scaled-view [id*="SMART_PHONE"] .product-card__title,
html.scaled-view [class*="smart-phone"] .product-card__title,
html.scaled-view [id*="smartphone"] .product-card__title { -webkit-line-clamp: var(--sp-title-lines) !important; line-clamp: var(--sp-title-lines) !important; }
html.scaled-view [id*="SMART_PHONE"] .product-card__meta,
html.scaled-view [class*="smart-phone"] .product-card__meta,
html.scaled-view [id*="smartphone"] .product-card__meta,
html.scaled-view [id*="SMART_PHONE"] .product-card__excerpt,
html.scaled-view [class*="smart-phone"] .product-card__excerpt,
html.scaled-view [id*="smartphone"] .product-card__excerpt { -webkit-line-clamp: var(--sp-meta-lines) !important; line-clamp: var(--sp-meta-lines) !important; }

@media (max-width:1400px){
    html.scaled-view [id*="SMART_PHONE"],
    html.scaled-view [class*="smart-phone"],
    html.scaled-view [id*="smartphone"] { --sp-col-min: 240px; }
}
@media (max-width:1100px){
    html.scaled-view [id*="SMART_PHONE"],
    html.scaled-view [class*="smart-phone"],
    html.scaled-view [id*="smartphone"] { --sp-img-height: 230px; }
}
@media (max-width:900px){
    html.scaled-view [id*="SMART_PHONE"],
    html.scaled-view [class*="smart-phone"],
    html.scaled-view [id*="smartphone"] { --sp-col-min: 220px; --sp-img-height:220px; }
}
@media (max-width:680px){
    html.scaled-view [id*="SMART_PHONE"],
    html.scaled-view [class*="smart-phone"],
    html.scaled-view [id*="smartphone"] { --sp-col-min: 100%; --sp-img-height:250px; }
}
@media (max-width: 1200px) {
  html.scaled-view [id*="SMART_PHONE"] .product-grid,
  html.scaled-view [class*="smart-phone"] .product-grid,
  html.scaled-view [id*="smartphone"] .product-grid {
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
  }
}
@media (max-width: 640px) {
  html.scaled-view [id*="SMART_PHONE"] .product-grid,
  html.scaled-view [class*="smart-phone"] .product-grid,
  html.scaled-view [id*="smartphone"] .product-grid {
      grid-template-columns: 1fr !important;
  }
}

/* Helper: add .tall-phone on product-card to preserve full tall device without cropping */
html.scaled-view [id*="SMART_PHONE"] .product-card.tall-phone .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-card.tall-phone .product-image-container img,
html.scaled-view [id*="smartphone"] .product-card.tall-phone .product-image-container img {
    object-fit: contain !important;
    padding: 8px !important;
}

/* Constrain individual card width so layout stays balanced with auto-fit */
html.scaled-view [id*="SMART_PHONE"] .product-card,
html.scaled-view [class*="smart-phone"] .product-card,
html.scaled-view [id*="smartphone"] .product-card {
    width: 100% !important;  /* Use full grid column width */
    margin: 0 !important;    /* Remove card margins for full space utilization */
}

/* เพิ่มขนาดภาพสินค้าในหมวด SMART PHONE ให้ใหญ่ขึ้น 30% */
html.scaled-view [id*="SMART_PHONE"] .product-image-container,
html.scaled-view [class*="smart-phone"] .product-image-container,
html.scaled-view [id*="smartphone"] .product-image-container {
    height: 286px !important; /* 220px + 30% = 286px */
    transition: height 0.3s;
}

/* MacBook specific enlargement (apply class .macbook on the card or container) */
.product-card.macbook .product-image-container {
        height: 600px; /* target visual height */
        aspect-ratio: 2 / 3; /* 400 x 600 ratio */
        max-width: 400px; /* constrain width near requested 400 */
        margin: 0 auto; /* center within card */
}
.product-card.landscape-600x400 .product-image-container {
        height: 400px; /* requested 600x400 landscape height */
        aspect-ratio: 3 / 2; /* 600 x 400 ratio */
        max-width: 600px; /* limit width to 600 */
        width: 100%;
        margin: 0 auto;
}
.product-card.landscape-600x400 .product-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
        transform: none;
        max-width: 100%;
        max-height: 100%;
}
.product-card.landscape-600x400:hover .product-image { transform: scale(1.04); }

/* Responsive downscale for landscape variant */
@media (max-width: 1400px) {
    .product-card.landscape-600x400 .product-image-container { height: 360px; max-width: 540px; }
}
@media (max-width: 1200px) {
    .product-card.landscape-600x400 .product-image-container { height: 330px; max-width: 500px; }
}
@media (max-width: 992px) {
    .product-card.landscape-600x400 .product-image-container { height: 300px; max-width: 460px; }
}
@media (max-width: 768px) {
    .product-card.landscape-600x400 .product-image-container { height: 260px; max-width: 400px; }
}
@media (max-width: 576px) {
    .product-card.landscape-600x400 .product-image-container { height: 220px; max-width: 340px; }
}
.product-card.macbook .product-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
        transform: none;
}
.product-card.macbook:hover .product-image { transform: scale(1.04); }

/* Responsive adjustments for MacBook */
@media (max-width: 1400px) {
    .product-card.macbook .product-image-container { height: 520px; }
}
@media (max-width: 1200px) {
    .product-card.macbook .product-image-container { height: 480px; }
}
@media (max-width: 992px) {
    .product-card.macbook .product-image-container { height: 420px; max-width: 360px; }
}
@media (max-width: 768px) {
    .product-card.macbook .product-image-container { height: 360px; max-width: 320px; }
}
@media (max-width: 576px) {
    .product-card.macbook .product-image-container { height: 300px; max-width: 280px; }
}

/* Base product image – enlarge visual footprint without changing container */
.product-image {
    max-width: 180%; /* allow image to exceed container natural width */
    max-height: 180%;
    height: auto;
    object-fit: contain; /* avoid cropping essential product edges */
    object-position: center;
    transition: transform 0.35s ease;
    padding: 0; /* remove inner whitespace */
    transform: scale(1); /* base scale */
    min-height: 340px; /* further reduce overall card height so bottom actions are visible */
    max-height: none;
    overflow: visible;

/* Optional helper class you can add to markup if some images still feel small */
.product-image.enlarge-2x { /* roughly +100% vs original contain fit */
    transform: scale(1.25); /* start slightly larger */
}

/* Hover: subtle lift without oversizing too much */
.product-card:hover .product-image {
    transform: scale(1.35); /* if enlarge-2x applied this multiplies visually ~1.7x */
}

/* If cropping is acceptable for specific categories, add class .crop-fit on container */
.product-image-container.crop-fit .product-image {
    object-fit: cover;
    max-width: 100%;
    max-height: 100%;
    transform: scale(1.05); /* slight enlarge when covering */
}

.product-card .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.35rem 0.5rem !important; /* sync reduced padding variant */
    min-height: 210px;
    max-height: none;
    overflow: visible;
}

.discount-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: linear-gradient(45deg, #ff4757, #ff3838);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
    z-index: 2;
}

/* ========================================
   PRODUCT TITLE - FORCE OVERRIDE ALL
   แก้ที่ตัวแปรด้านบน (:root) เท่านั้น!
   ======================================== */
* .card-title,
* .product-title,
* .product-name,
.product-card .card-title,
.product-card .product-title,
.product-card .product-name,
.product-card h3,
.product-card h5,
#products-grid .card-title,
#products-grid .product-title,
#products-grid h3,
#products-grid h5,
.card .card-title,
.card h3,
.card h5 {
    font-size: var(--product-title-size) !important;
    line-height: var(--product-title-line-height) !important;
    color: var(--product-title-color) !important;
    font-weight: 600 !important;
    margin: 0 0 12px 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important; /* title ควรเป็น 2 บรรทัด */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.product-card-new .product-card-title-shell {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.35rem !important;
    min-height: 56px !important;
    margin-bottom: 8px !important;
}

.product-card-new .product-card-title-link {
    display: block !important;
    min-height: auto !important;
    margin-bottom: 0 !important;
    color: #14b8c4 !important;
    text-decoration: none !important;
}

.product-card-new .product-card-title-link .product-title-rendered,
.product-card-new .product-card-title-link .product-title-new,
.product-card-new .card-title.product-title-new {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    margin: 0 !important;
    min-height: 2.7em !important;
    line-height: 1.35 !important;
    color: #14b8c4 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
}

.product-card-new .card-body-new {
    overflow: visible !important;
}

@media (max-width: 768px) {
    .product-card-new .product-card-title-shell {
        min-height: 48px !important;
    }
}

.price-section {
    margin: 10px 0 !important;
    display: block !important;
}

.original-price {
    font-size: 13px;
    margin-bottom: 2px;
}

.final-price {
    font-size: 18px !important;
    margin: 0;
    display: block !important;
    visibility: visible !important;
    color: #27ae60 !important;
    font-weight: bold !important;
}

.final-price.text-danger {
    color: #e74c3c !important;
}

.final-price.text-primary {
    color: #3498db !important;
}

.price-section .original-price {
    display: block !important;
    visibility: visible !important;
}

.price-section .final-price {
    display: block !important;
    visibility: visible !important;
}

.product-actions,
.product-cta-bar {
    margin-top: auto !important;
    display: flex !important;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    align-items: flex-start;
    visibility: visible !important;
}

.product-cta-bar .price-section {
    margin: 0 !important;
    flex: 1 1 100%;
    min-width: 0;
}

.buy-btn {
    background: linear-gradient(45deg, #3498db, #2980b9);
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100% !important;
    box-sizing: border-box;
    min-width: 0;
    visibility: visible !important;
}

@media (min-width: 768px) and (max-width: 1200px) {
    .product-cta-bar {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .product-cta-bar .price-section {
        flex: 1 1 150px;
        min-width: 0;
    }
    .product-cta-bar .buy-btn {
        flex: 1 1 200px;
        min-width: 160px;
        max-width: 100%;
    }
}

.buy-btn:hover {
    background: linear-gradient(45deg, #2980b9, #2471a3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.product-rating {
    border-top: 1px solid #ecf0f1;
    padding-top: 8px;
    display: block !important;
    visibility: visible !important;
}

.product-rating .fa-star {
    font-size: 12px;
}

/* =============================================
   Flash Sale Inspired Product Card Overrides
   Applied to general product cards to match the
   modern flash-sale visual style across sections.
============================================= */
.product-slider-5col-container {
    padding: 12px 0 18px;
}

.product-slider-5col-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
    align-items: stretch;
    width: 100%;
    margin: 0 auto;
}

.product-slider-5col-grid .product-card {
    height: 100%;
}

.product-card {
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08) !important;
    border: 1px solid #e2e8f0 !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex !important;
    flex-direction: column;
    position: relative;
    min-height: 340px; /* further reduce overall card height so bottom actions are visible */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14) !important;
}

.product-card__img {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    padding: 12px 12px; /* tighten padding so image area is smaller */
    min-height: 150px;
}

.product-card__img img {
    width: 100% !important;
    max-width: 100% !important;
    height: clamp(130px, 14vw, 180px) !important;
    max-height: 200px !important;
    object-fit: cover !important; /* ensure image fills area */
    object-position: center center !important; /* keep subject centered */
    transition: transform 0.3s ease;
    margin: 0 auto !important;
    display: block !important;
}

.product-card:hover .product-card__img img {
    transform: scale(1.05);
}

.product-card__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px; /* slightly less vertical gap between body elements */
    padding: 12px; /* reduce inner padding so bottom area moves up */
}

/* ลบออก - ใช้ universal rule ด้านบนแทน */

.product-card__price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ff4757;
    margin: 0;
}

.product-card__original-price {
    font-size: 0.95rem;
    color: #94a3b8;
    text-decoration: line-through;
    margin: -6px 0 10px;
}

.product-card__meta,
.product-card__excerpt {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* shorten excerpt to free vertical space */
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


.product-card__cta:hover,
.product-card .buy-btn:hover,
.product-card .product-card__button:hover,
.product-card button:hover,
.product-card a.button:hover,
.product-card a.btn-primary:hover {
    background: linear-gradient(45deg, #ee5a24, #ff6b6b);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
}

.product-card__footer,
.product-card__actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Lift buy button area slightly so it doesn't hug the card bottom and ensure spacing looks balanced */
.product-card__footer,
.product-card__actions,
.product-card .product-actions,
.product-card .price-section {
    margin-bottom: 8px !important;
}

.product-card .product-actions {
    margin-top: 8px !important; /* avoid using auto which pushes it to the very bottom */
}

/* Ensure image containers center their content across variants */
.product-image-container,
.product-card__img,
.card-img-top-wrapper,
.card-img-top {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.product-card__img img,
.product-image,
.product-card .product-image {
    object-position: center center !important;
}

/* SMART PHONE specific overrides -------------------------------------------------- */
html.scaled-view [id*="SMART_PHONE"] .product-card,
html.scaled-view [class*="smart-phone"] .product-card,
html.scaled-view [id*="smartphone"] .product-card {
    min-height: 300px !important; /* tuned smaller for SMART PHONE so buy button shows */
}
html.scaled-view [id*="SMART_PHONE"] .product-card__img,
html.scaled-view [class*="smart-phone"] .product-card__img,
html.scaled-view [id*="smartphone"] .product-card__img {
    padding: 10px 10px !important;
    min-height: 130px !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card__img img,
html.scaled-view [class*="smart-phone"] .product-card__img img,
html.scaled-view [id*="smartphone"] .product-card__img img {
    height: clamp(110px, 12vw, 150px) !important; /* slightly smaller clamp to reduce vertical footprint */
    max-height: 160px !important;
    object-fit: contain !important; /* show whole product without hard crop */
    object-position: center center !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card__body,
html.scaled-view [class*="smart-phone"] .product-card__body,
html.scaled-view [id*="smartphone"] .product-card__body {
    padding: 10px !important;
    gap: 6px !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card__meta,
html.scaled-view [class*="smart-phone"] .product-card__meta,
html.scaled-view [id*="smartphone"] .product-card__meta,
html.scaled-view [id*="SMART_PHONE"] .product-card__excerpt,
html.scaled-view [class*="smart-phone"] .product-card__excerpt,
html.scaled-view [id*="smartphone"] .product-card__excerpt {
    -webkit-line-clamp: 3 !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card__footer,
html.scaled-view [class*="smart-phone"] .product-card__footer,
html.scaled-view [id*="smartphone"] .product-card__footer,
html.scaled-view [id*="SMART_PHONE"] .product-card__actions,
html.scaled-view [class*="smart-phone"] .product-card__actions,
html.scaled-view [id*="smartphone"] .product-card__actions {
    margin-top: 12px !important; /* lift actions (buy button) visibly higher */
    gap: 6px !important;
}

/* end SMART PHONE specific overrides ------------------------------------------- */

.product-card__meta,
.product-card__excerpt {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .product-slider-5col-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 18px;
    }

    .product-card {
        min-height: 380px;
    }

    .product-card__img {
        min-height: 190px;
    }

    /* ไม่ต้อง override - ใช้ CSS Variables จาก :root */
}

@media (max-width: 480px) {
    .product-title,
    .card-title,
    .product-name,
    .product-card .card-title,
    .product-card .product-title,
    .product-card .product-name,
    .product-card h3,
    .product-card h5 {
        font-size: 11px !important;
    }

    .product-title,
    .card-title,
    .product-name,
    .product-card .card-title,
    .product-card .product-title,
    .product-card .product-name,
    .product-card h3,
    .product-card h5 {
        font-size: 11px !important;
    }

    .product-card {
        border-radius: 14px !important;
    }

    .product-card__body {
        padding: 18px 16px;
    }
}

/* Badges - Advice Style */
.badge {
    font-size: 10px;
    padding: 4px 8px;
    z-index: 3;
    border-radius: 4px !important;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.bg-success {
    background: linear-gradient(135deg, #fb923c, #f97316) !important;
    color: white !important;
}

.badge.bg-info {
    background: linear-gradient(45deg, #06b6d4, #0891b2) !important;
    color: white !important;
}

.badge.bg-danger {
    background: linear-gradient(45deg, #ef4444, #dc2626) !important;
}

.badge.bg-primary {
    background: linear-gradient(45deg, #3b82f6, #2563eb) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .product-card {
        margin-bottom: 15px;
        min-height: 420px;
        max-height: 480px;
    }

    .product-image {
        height: 160px;
        padding: 2px;
        object-fit: cover;
    }

    .product-title {
        font-size: 11px !important;
        line-height: 1.25 !important;
        min-height: calc(1.25em * 3) !important;
        max-height: calc(1.25em * 3.2) !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .product-specs {
        font-size: 11px !important;
        min-height: 55px !important;
        max-height: 75px !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
    }

    .final-price {
        font-size: 16px !important;
    }

    .product-card .card-body {
        padding: 0.35rem 0.5rem !important; /* reduced to match global minimal padding */
        min-height: 240px;
        max-height: 300px;
    }

    .buy-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
}

/* Loading animation */
.product-card-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Grid layout improvements */
#products-grid {
    gap: var(--pc-fixed-grid-gap, 0.5rem);
    padding: 0 8px;
    margin: 0;
}

/* Container improvements for better spacing - 90% width with 5% margins on each side */
.container-fluid {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0;
    padding-left: var(--page-edge-padding, 24px);
    padding-right: var(--page-edge-padding, 24px);
}

/* Main content area with 90% width */
main,
.main-content {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0;
    padding-left: var(--page-edge-padding, 24px) !important;
    padding-right: var(--page-edge-padding, 24px) !important;
}

/* Product listing page specific container */
.category-products-container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0;
    padding-left: var(--page-edge-padding, 24px) !important;
    padding-right: var(--page-edge-padding, 24px) !important;
}

/* ==========================================================
   TRUE 90% WIDTH (REMOVE INNER 5% PADDING) FOR NOTEBOOK PAGE
   Usage Options:
   1) Add class "page-notebook" to <body> (preferred)
      <body class="page-notebook"> ...
   2) Or add class "full-90-no-padding" to a specific container:
      <div class="category-products-container full-90-no-padding"> ...
   This keeps other pages unaffected.
   ========================================================== */
body.page-notebook .page-wrapper,
body.page-notebook .content-wrapper,
body.page-notebook main,
body.page-notebook .main-content,
body.page-notebook .category-products-container,
body.page-notebook .container-fluid,
.full-90-no-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: var(--global-content-width, 100%) !important;
    max-width: none !important; /* keep outer width constraint */
    margin-left: 0 !important;
    margin-right: 0 !important;
}
/* Breadcrumb & filter bar alignment (assumes .breadcrumb, .filters-bar, .filters-row classes if present) */
body.page-notebook .breadcrumb,
body.page-notebook .filters-bar,
body.page-notebook .filters-row,
.full-90-no-padding.breadcrumb,
.full-90-no-padding .filters-bar,
.full-90-no-padding .filters-row {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}

/* 100% WIDTH EXTENSION (third state) */
body.page-notebook.full-100 .page-wrapper,
body.page-notebook.full-100 .content-wrapper,
body.page-notebook.full-100 main,
body.page-notebook.full-100 .main-content,
body.page-notebook.full-100 .category-products-container,
body.page-notebook.full-100 .container-fluid,
body.page-notebook.full-100 .breadcrumb,
body.page-notebook.full-100 .filters-bar,
body.page-notebook.full-100 .filters-row {
    max-width:100% !important;
}

/* ==========================================================
   NOTEBOOK MODE: EXPAND PRODUCT GRID TO FULL HORIZONTAL SPACE
   Eliminates unused right white area by using CSS grid.
   Adjust breakpoints for card counts.
   ========================================================== */
/* ==========================================================
   SIMPLE LAYOUT - NO COMPLEX ZOOM BEHAVIOR
   ========================================================== */

/* ==========================================================
   RESPONSIVE PRODUCT GRID (GLOBAL)
   5 cols (>=1600), 4 cols (>=1200), 3 cols (>=900), 2 cols (>=600), 1 col (<600)
   Uses a shared class hook to minimize duplication.
   ========================================================== */
.product-grid,
#products-grid,
.home-product-grid,
.flash-product-grid {
    display:grid;
    gap: var(--pc-fixed-grid-gap, 0.5rem);
    grid-template-columns:repeat(2,minmax(0,1fr));
}
#products-grid.row > [class*="col-"],
.product-grid.row > [class*="col-"],
.home-product-grid.row > [class*="col-"],
.flash-product-grid.row > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
@media (min-width:600px){
    .product-grid,#products-grid,.home-product-grid,.flash-product-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (min-width:900px){
    .product-grid,#products-grid,.home-product-grid,.flash-product-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
@media (min-width:1200px){
    .product-grid,#products-grid,.home-product-grid,.flash-product-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
@media (min-width:1600px){
    .product-grid,#products-grid,.home-product-grid,.flash-product-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
}

/* ==========================================================
   NOTEBOOK LAYOUT - LOCK TO EXACTLY 4 COLUMNS ON DESKTOP
   (Keeps user request: always 4 columns, even on ultra-wide)
   ========================================================== */
/* Notebook scaling tokens (simulate 80% zoom visually without browser zoom) */
body.page-notebook {
    --nb-scale: 0.8;                 /* adjust here: 0.8 = 80% look */
    --nb-base-card: 260;             /* base width in px before scale */
    --nb-base-gap: 10;               /* base gap in px before scale (≈0.5rem visual after scale) */
    --nb-cols: 4;                    /* locked desktop columns */
    --nb-card-width: calc(var(--nb-base-card) * var(--nb-scale) * 1px);
    --nb-gap: calc(var(--nb-base-gap) * var(--nb-scale) * 1px);
    --nb-cluster-width: calc(var(--nb-cols) * var(--nb-card-width) + (var(--nb-cols) - 1) * var(--nb-gap));
}

/* Apply notebook fixed cluster ONLY to main products grid (and optional .nb-grid alias) */
body.page-notebook #products-grid,
body.page-notebook #products-grid.nb-grid,
body.page-notebook .home-product-grid.nb-grid {
    display:grid;
    grid-template-columns: repeat(var(--nb-cols), var(--nb-card-width)) !important; /* fixed tracks for stability */
    gap: var(--pc-fixed-grid-gap, var(--nb-gap)) !important;
    max-width: var(--nb-cluster-width);
    margin:0 auto;
    padding:0 16px;
    justify-content:center;
}
/* Responsive downsizing (unscaled logical breakpoints) */
@media (max-width:1199.98px){
    body.page-notebook { --nb-cols: 3; }
    body.page-notebook #products-grid,
    body.page-notebook #products-grid.nb-grid,
    body.page-notebook .home-product-grid.nb-grid {
        grid-template-columns: repeat(var(--nb-cols), var(--nb-card-width)) !important;
        max-width: calc(var(--nb-cols) * var(--nb-card-width) + (var(--nb-cols) - 1) * var(--nb-gap));
    }
}
@media (max-width:899.98px){
    body.page-notebook { --nb-cols: 2; }
    body.page-notebook #products-grid,
    body.page-notebook #products-grid.nb-grid,
    body.page-notebook .home-product-grid.nb-grid {
        grid-template-columns: repeat(var(--nb-cols), var(--nb-card-width)) !important;
        max-width: calc(var(--nb-cols) * var(--nb-card-width) + (var(--nb-cols) - 1) * var(--nb-gap));
    }
}
@media (max-width:599.98px){
    body.page-notebook { --nb-cols: 1; }
    body.page-notebook #products-grid,
    body.page-notebook #products-grid.nb-grid,
    body.page-notebook .home-product-grid.nb-grid {
        grid-template-columns: repeat(var(--nb-cols), minmax(0, 1fr)) !important;
        max-width: 420px;
    }
}

/* Cards should not stretch to fill entire width */
/* Scope card width limits only inside main products grid cluster */
body.page-notebook #products-grid .product-card,
body.page-notebook #products-grid .flash-product-card,
body.page-notebook #products-grid .product-card-v2,
body.page-notebook #products-grid .product-card-pro {
    width:100%;
    max-width:var(--nb-card-width);
    min-width:0; /* allow shrink within track */
    margin:0 auto;
    box-sizing:border-box;
}

/* Mobile sizing inside notebook still inherits global breakpoints */

/* =============================================================
     FLASH SALE CAROUSEL (Independent from notebook/product grids)
     - Uses horizontal flex + scroll-snap
     - Avoid adding .flash-product-grid to notebook selectors
     ============================================================= */
.flash-sale-section { --flash-card-width: 234px; --flash-gap: 14px; position:relative; overflow: visible !important; }
.flash-sale-track {
        display:flex;
        gap:var(--flash-gap);
        overflow-x:auto;
        overflow-y: visible;
        scroll-snap-type:x mandatory;
        -webkit-overflow-scrolling:touch;
        padding:8px 4px 50px;
        scrollbar-width:thin;
}
.flash-sale-track::-webkit-scrollbar { height:8px; }
.flash-sale-track::-webkit-scrollbar-thumb { background:#ccc; border-radius:4px; }
.flash-sale-slide { flex:0 0 var(--flash-card-width); scroll-snap-align:start; position:relative; min-height: 520px; }
.flash-sale-slide .product-card,
.flash-sale-slide .flash-product-card,
.flash-sale-slide .flash-sale-card { width:100%; max-width:var(--flash-card-width); margin:0; min-height: 500px; overflow: visible !important; }
.flash-sale-nav { position:absolute; top:50%; transform:translateY(-50%); width:42px; height:42px; border:none; background:rgba(0,0,0,.55); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; z-index:10; backdrop-filter:blur(4px); }
.flash-sale-nav:hover { background:rgba(0,0,0,.75); }
.flash-sale-nav.fs-prev { left:4px; }
.flash-sale-nav.fs-next { right:4px; }
@media (max-width:599.98px){
    .flash-sale-section { --flash-card-width: 180px; }
}
/* Optional compact density modifier */
.flash-sale-section.compact { --flash-card-width:198px; --flash-gap:11px; }

/* Autoplay progress bar */
.flash-sale-progress-wrapper { position:absolute; left:0; right:0; bottom:0; height:4px; background:rgba(255,255,255,.18); overflow:hidden; border-radius:2px; pointer-events:none; }
.flash-sale-progress { width:0%; height:100%; background:linear-gradient(90deg,#f59e0b,#ef4444); transition:width linear; }
.flash-sale-section.paused .flash-sale-progress { animation-play-state:paused; }

/* =============================================================
     FLASH SALE GRID MODE (NOTEBOOK ONLY) - 4 COLUMNS FIXED
     ใช้เมื่อไม่ต้องการ slider บนหน้าหมวด notebook
     เพิ่ม class: body.page-notebook .flash-sale-section.grid-4
     ============================================================= */
body.page-notebook .flash-sale-section.grid-4 {
    --flash-card-width: 234px;
    --flash-gap: 18px;
    position: relative;
    padding: 4px 0 12px;
}
body.page-notebook .flash-sale-section.grid-4 .flash-sale-track {
    display: grid;
    gap: var(--flash-gap);
    grid-template-columns: repeat(4, var(--flash-card-width));
    overflow: visible; /* ไม่ต้อง scroll แนวนอน */
    scroll-snap-type: none;
    justify-content: center;
    margin: 0 auto;
    max-width: calc(4 * var(--flash-card-width) + 3 * var(--flash-gap));
}
@media (max-width:1199.98px){
    body.page-notebook .flash-sale-section.grid-4 .flash-sale-track { grid-template-columns: repeat(3, var(--flash-card-width)); max-width: calc(3 * var(--flash-card-width) + 2 * var(--flash-gap)); }
}
@media (max-width:899.98px){
    body.page-notebook .flash-sale-section.grid-4 .flash-sale-track { grid-template-columns: repeat(2, var(--flash-card-width)); max-width: calc(2 * var(--flash-card-width) + 1 * var(--flash-gap)); }
}
@media (max-width:599.98px){
    body.page-notebook .flash-sale-section.grid-4 .flash-sale-track { grid-template-columns: minmax(0,1fr); max-width:420px; }
}
body.page-notebook .flash-sale-section.grid-4 .flash-sale-slide { flex: initial; width: auto; scroll-snap-align: initial; }
body.page-notebook .flash-sale-section.grid-4 .flash-sale-nav,
body.page-notebook .flash-sale-section.grid-4 .flash-sale-progress-wrapper { display: none !important; }
/* ป้องกัน override เก่าที่อาจ set width บน slide */
body.page-notebook .flash-sale-section.grid-4 .flash-sale-slide .product-card,
body.page-notebook .flash-sale-section.grid-4 .flash-sale-slide .flash-product-card { max-width: var(--flash-card-width); }

/* =============================================================
    FLASH SALE MODE TOGGLE + VIEW ALL LINK
    ============================================================= */
.flash-sale-controls { display:flex; align-items:center; gap:12px; margin:4px 0 8px; justify-content:flex-end; }
.flash-toggle-btn { cursor:pointer; background:linear-gradient(135deg,#6366f1,#0ea5e9); color:#fff; border:none; padding:6px 14px; border-radius:20px; font-size:13px; font-weight:600; letter-spacing:.3px; display:inline-flex; align-items:center; gap:6px; box-shadow:0 4px 10px rgba(0,0,0,.15); transition:.18s ease; }
.flash-toggle-btn:hover { filter:brightness(1.08); }
.flash-toggle-btn[data-mode="grid"] { background:linear-gradient(135deg,#f59e0b,#ef4444); }
.flash-view-all { font-size:13px; font-weight:600; color:#0ea5e9; text-decoration:none; position:relative; padding:4px 6px; }
.flash-view-all:hover { color:#0369a1; }
.flash-view-all::after { content:""; position:absolute; left:0; right:0; bottom:0; height:2px; background:currentColor; transform:scaleX(.4); transform-origin:left; transition:.25s ease; }
.flash-view-all:hover::after { transform:scaleX(1); }

/* When in grid mode hide nav buttons (already) but keep control layout consistent */
.flash-sale-section.grid-4 .flash-sale-controls .flash-toggle-btn[data-mode="grid"]::after { content:"(Grid)"; font-weight:400; font-size:11px; margin-left:4px; opacity:.8; }

/* FULL BLEED OVERRIDES (remove any residual side space) */
/* (Removed legacy .force-4cols full-width handling) */

/* Optional tighter on very large screens to pack more cards */
/* Remove previous auto-fill widening; maintain consistent 4 column rhythm for professional look */
/* If you want to allow 5+ columns on ultra-wide, create a new modifier class later. */

/* Reset legacy Bootstrap column paddings inside grid */
body.page-notebook #products-grid.row > [class*="col-"] { width:100% !important; max-width:100% !important; flex:none !important; padding-left:0 !important; padding-right:0 !important; }

/* Removed multiple legacy ultra-enforcement selectors (.notebook-4col, data-notebook-4col, zoom overrides)
   to reduce specificity wars. JS no longer needs to fight CSS. */

/* Card sizing safety: prevent overlap caused by transforms/margins inside grid context */
body.page-notebook #products-grid.row .product-card,
body.page-notebook #products-grid.row .flash-product-card,
body.page-notebook #products-grid.row .product-card-pro {
    width:100%;
    box-sizing:border-box;
    position:relative;
    /* Ensure hover scale doesn't create layout shift outside card */
    overflow:hidden;
}
body.page-notebook #products-grid.row .product-card .product-image,
body.page-notebook #products-grid.row .flash-product-card .product-image,
body.page-notebook #products-grid.row .product-card-pro .pcp-media img { max-width:100%; height:auto; }

/* =============================================================
   NOTEBOOK IMAGE STAGE NORMALIZATION (Prevent head cropping)
   - Provides a predictable image container height & aspect context
   - Default behaviour: contain (shows entire device) with proper centering
   - Variables allow quick tuning without selector duplication
   ============================================================= */
body.page-notebook {
    --nb-img-height: 336px;          /* base notebook image stage (20% larger) */
    --nb-img-height-md: 360px;       /* medium screens (20% larger) */
    --nb-img-height-sm: 384px;       /* small screens (20% larger) */
    --nb-img-ratio: 4 / 3;           /* many notebook images are wider; fallback ratio */
    --nb-title-lines: 2;             /* clamp lines for titles */
    --nb-meta-lines: 3;              /* clamp lines for meta/spec text */
    --nb-img-pad-contain: 12px;      /* increased inner padding for better spacing */
}
/* Core image container sizing */
body.page-notebook #products-grid .product-image-container,
body.page-notebook #products-grid .card-img-top-wrapper,
body.page-notebook #products-grid .card-img-top,
body.page-notebook #products-grid .product-card img.product-image {
    height: var(--nb-img-height) !important;
    aspect-ratio: var(--nb-img-ratio) !important;
    background: transparent !important;
    display: block !important;
    width: 100% !important;
    margin: 0 auto !important;
    position: relative;
    overflow: hidden;
}
/* Default contain fill to show entire notebook without cropping */
body.page-notebook #products-grid .product-image-container img,
body.page-notebook #products-grid .card-img-top-wrapper img,
body.page-notebook #products-grid .card-img-top img,
body.page-notebook #products-grid .product-card img.product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;  /* Show entire notebook */
    object-position: center center !important;
    background: transparent !important;
    border-radius: 6px 6px 0 0 !important;
    padding: var(--nb-img-pad-contain) !important;
}
/* Cover helper: add .nb-img-cover on the product-card to crop/fill if needed */
body.page-notebook #products-grid .product-card.nb-img-cover .product-image-container img {
    object-fit: cover !important;
    padding: 0 !important;
}
/* Taller device (very vertical / unusual aspect) helper: .nb-img-tall */
body.page-notebook #products-grid .product-card.nb-img-tall .product-image-container img {
    object-fit: contain !important;
    padding: calc(var(--nb-img-pad-contain) + 4px) !important;
}
/* Unified title/meta clamp using standard + webkit */
body.page-notebook #products-grid .product-card .product-card__title { -webkit-line-clamp: var(--nb-title-lines) !important; line-clamp: var(--nb-title-lines) !important; }
body.page-notebook #products-grid .product-card .product-card__meta,
body.page-notebook #products-grid .product-card .product-card__excerpt { -webkit-line-clamp: var(--nb-meta-lines) !important; line-clamp: var(--nb-meta-lines) !important; }

/* Responsive adjustments for notebook image stage */
@media (max-width: 1400px){ body.page-notebook { --nb-img-height: var(--nb-img-height-md); } }
@media (max-width: 900px){ body.page-notebook { --nb-img-height: var(--nb-img-height-sm); } }
@media (max-width: 680px){ body.page-notebook { --nb-img-height: 408px; --nb-img-pad-contain: 16px; } }

/* Safety: if legacy rules re-introduce unwanted padding/background */
body.page-notebook #products-grid .product-image-container,
body.page-notebook #products-grid .card-img-top-wrapper {
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

/* Optional: prevent layout shift on image load */
body.page-notebook #products-grid .product-image-container { overflow:hidden; }

/* If a specific notebook image still crops head, add class .nb-img-contain or .nb-img-tall in markup */


/* Neutralize excessive external margins that could cause vertical misalignment */
body.page-notebook #products-grid.row .product-card,
body.page-notebook #products-grid.row .flash-product-card,
body.page-notebook #products-grid.row .product-card-pro { margin:0; }

/* If any legacy animation sets translate that breaks stacking, confine with will-change inside only */
body.page-notebook #products-grid.row .product-card:hover,
body.page-notebook #products-grid.row .flash-product-card:hover,
body.page-notebook #products-grid.row .product-card-pro:hover { transform:translateY(-4px); }

/* Ensure product cards stretch uniformly */
body.page-notebook #products-grid .product-card,
body.page-notebook #products-grid .product-card-v2,
body.page-notebook #products-grid .flash-product-card { height:100%; }
/* Constrain individual card max width for consistent clustering */
body.page-notebook #products-grid .product-card,
body.page-notebook #products-grid .product-card-v2,
body.page-notebook #products-grid .flash-product-card { max-width: var(--nb-card-width); }

/* Toggle button icon + tooltip */
.width-toggle-btn { position:relative; }
.width-toggle-btn .wtb-icon { font-size:14px; line-height:1; }
.width-toggle-btn[data-state="normal"] .icon-normal { display:inline; }
.width-toggle-btn[data-state="normal"] .icon-90, .width-toggle-btn[data-state="normal"] .icon-100 { display:none; }
.width-toggle-btn[data-state="wide90"] .icon-90 { display:inline; }
.width-toggle-btn[data-state="wide90"] .icon-normal, .width-toggle-btn[data-state="wide90"] .icon-100 { display:none; }
.width-toggle-btn[data-state="wide100"] .icon-100 { display:inline; }
.width-toggle-btn[data-state="wide100"] .icon-normal, .width-toggle-btn[data-state="wide100"] .icon-90 { display:none; }

.width-toggle-btn .wtb-tooltip {
    position:absolute;
    bottom:calc(100% + 8px);
    left:50%;
    transform:translateX(-50%) scale(.85);
    background:#1e293b;
    color:#fff;
    padding:6px 10px;
    font-size:11px;
    border-radius:6px;
    white-space:nowrap;
    opacity:0;
    pointer-events:none;
    transition:.18s ease;
    box-shadow:0 4px 14px rgba(0,0,0,.15);
    z-index:20;
}
.width-toggle-btn:hover .wtb-tooltip { opacity:1; transform:translateX(-50%) scale(1); }
.width-toggle-btn .wtb-tooltip::after {
    content:"";
    position:absolute;
    top:100%;
    left:50%;
    transform:translateX(-50%);
    border:6px solid transparent;
    border-top-color:#1e293b;
}

/* Floating Action Button (FAB) for width toggle */
.width-fab {
    position:fixed;
    bottom:18px;
    right:18px;
    width:50px;
    height:50px;
    border-radius:50%;
    background:linear-gradient(135deg,#0284c7,#0ea5e9);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
    font-weight:600;
    box-shadow:0 4px 16px rgba(0,0,0,.25);
    cursor:pointer;
    z-index:999;
    border:none;
    transition:background .25s, transform .25s, box-shadow .25s;
}
.width-fab:hover { background:linear-gradient(135deg,#0369a1,#0ea5e9); transform:translateY(-3px); box-shadow:0 8px 20px rgba(0,0,0,.35); }
.width-fab:active { transform:scale(.92); }
.width-fab[data-state="wide90"] { background:linear-gradient(135deg,#0d9488,#14b8a6); }
.width-fab[data-state="wide100"] { background:linear-gradient(135deg,#7c3aed,#6366f1); }

/* Slide animation for grid transition */
.grid-animating #products-grid .product-card,
.grid-animating #products-grid .product-card-v2,
.grid-animating #products-grid .flash-product-card { opacity:0; transform:translateY(14px); }
.grid-animating-in #products-grid .product-card,
.grid-animating-in #products-grid .product-card-v2,
.grid-animating-in #products-grid .flash-product-card { animation:gridFadeSlide .45s ease forwards; }

@keyframes gridFadeSlide { 0% { opacity:0; transform:translateY(18px);} 100% {opacity:1; transform:translateY(0);} }

/* Stagger effect */
#products-grid .product-card,
#products-grid .product-card-v2,
#products-grid .flash-product-card { transition:transform .35s, box-shadow .35s; }
body.grid-animating-in #products-grid > *:nth-child(1) { animation-delay:0.02s; }
body.grid-animating-in #products-grid > *:nth-child(2) { animation-delay:0.06s; }
body.grid-animating-in #products-grid > *:nth-child(3) { animation-delay:0.10s; }
body.grid-animating-in #products-grid > *:nth-child(4) { animation-delay:0.14s; }
body.grid-animating-in #products-grid > *:nth-child(5) { animation-delay:0.18s; }
body.grid-animating-in #products-grid > *:nth-child(6) { animation-delay:0.22s; }
/* add more nth-child if grid bigger */


/* Small screens: ensure still centered */
@media (max-width: 575px) {
    body.page-notebook .category-products-container.full-90-no-padding,
    body.page-notebook .category-products-container,
    .full-90-no-padding {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Products container spacing */
.row {
    --bs-gutter-x: 0.75rem;
    --bs-gutter-y: 1rem;
    margin-left: 0;
    margin-right: 0;
}

/* Responsive padding adjustments for 90% width */
@media (min-width: 1400px) {
    #products-grid {
        padding: 0 12px;
        gap: 8px;
    }

    .container-fluid,
    main,
    .main-content,
    .category-products-container {
        width: var(--global-content-width, 100%) !important;
        max-width: none !important;
        padding-left: var(--page-edge-padding, 24px) !important;
        padding-right: var(--page-edge-padding, 24px) !important;
    }
}

@media (min-width: 1200px) {
    .container-fluid,
    main,
    .main-content,
    .category-products-container {
        width: var(--global-content-width, 100%) !important;
        max-width: none !important;
        padding-left: var(--page-edge-padding, 24px) !important;
        padding-right: var(--page-edge-padding, 24px) !important;
    }

    #products-grid {
        gap: 10px;
    }
}

@media (max-width: 991px) {
    #products-grid {
        padding: 0 4px;
        gap: 8px;
    }

    .container-fluid,
    main,
    .main-content,
    .category-products-container {
        width: var(--global-content-width, 100%) !important;
        max-width: none !important;
        padding-left: var(--page-edge-padding, 20px) !important;
        padding-right: var(--page-edge-padding, 20px) !important;
    }
}

/* Force visibility for all product card elements */
#products-grid .product-card .card-body * {
    display: block !important;
    visibility: visible !important;
}

/* ลบออก - ใช้ universal rule แทน */

/* ลบออก - ใช้ universal rule แทน */

#products-grid .product-card .product-specs {
    font-size: 12px !important;
    color: #64748b !important;
    line-height: 1.3 !important;
    min-height: 60px !important;
    max-height: 80px !important;
    overflow: hidden !important;
    display: block !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    hyphens: none !important;
}

#products-grid .product-card .price-section {
    margin: 0 !important;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

#products-grid .product-card .final-price {
    font-size: 18px !important;
    font-weight: 700 !important;
    margin-bottom: 0.25rem !important;
    color: #0ea5e9 !important;
    text-align: left;
}

#products-grid .product-card .original-price {
    color: #64748b !important;
    text-decoration: line-through !important;
    font-size: 11px !important;
    text-align: left;
}

#products-grid .product-card .product-actions {
    margin-top: auto !important;
    flex-shrink: 0;
    display: flex !important;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    align-items: flex-start;
}

#products-grid .product-card .buy-btn {
    width: 100% !important;
    padding: 10px 16px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    background: linear-gradient(135deg, #0ea5e9, #0284c7) !important;
    border: none !important;
    border-radius: 6px !important;
    color: white !important;
    text-transform: none !important;
    transition: all 0.3s ease !important;
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 0;
}

@media (min-width: 768px) and (max-width: 1200px) {
    #products-grid .product-card .product-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    #products-grid .product-card .product-actions .price-section {
        flex: 1 1 150px !important;
        min-width: 0;
    }
    #products-grid .product-card .buy-btn {
        flex: 1 1 200px !important;
        min-width: 160px;
        max-width: 100%;
    }
}

#products-grid .product-card .buy-btn:hover {
    background: linear-gradient(135deg, #0284c7, #0369a1) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3) !important;
}

/* Empty state styling */
.empty-state {
    padding: 60px 20px;
    text-align: center;
}

.empty-state i {
    color: #bdc3c7;
    margin-bottom: 20px;
}

.empty-state h4 {
    color: #7f8c8d;
    margin-bottom: 15px;
}

.empty-state p {
    color: #95a5a6;
    margin-bottom: 25px;
}

/* Responsive Grid Layout - Professional Breakpoints */
/* Desktop Large (≥1400px) - 5 columns */
@media (min-width: 1400px) {
    #products-grid .col-xxl-2 {
        flex: 0 0 19.5% !important;
        max-width: 19.5% !important;
        margin-bottom: 2rem;
    }

    .product-card {
        min-height: 500px;
        max-height: 540px;
    }

    .product-image {
        height: 220px;
        padding: 1px;
        object-fit: cover;
    }

    .product-card .card-body {
        min-height: 260px;
        max-height: 300px;
    }
}

/* Desktop/Laptop (992-1399px) - 4 columns */
@media (min-width: 992px) and (max-width: 1399px) {
    #products-grid .col-xl-3 {
        flex: 0 0 24.5% !important;
        max-width: 24.5% !important;
        margin-bottom: 2rem;
    }

    .product-card {
        min-height: 490px;
        max-height: 530px;
    }

    .product-image {
        height: 210px;
        padding: 1px;
        object-fit: cover;
    }

    .product-card .card-body {
        min-height: 260px;
        max-height: 300px;
    }
}

/* Tablet (768-1024px) - 2 columns for breathing room */
@media (min-width: 768px) and (max-width: 1024px) {
    #products-grid .col-lg-4 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
        margin-bottom: 2rem;
    }
    #products-grid {
        justify-content: center;
    }
}

@media (max-width: 1280px) {
    #products-grid .col-xxl-2,
    #products-grid .col-xl-3,
    #products-grid .col-lg-4 {
        flex: 0 0 48% !important;
        max-width: 48% !important;
        margin-bottom: 1.5rem !important;
    }
    #products-grid {
        justify-content: center;
        gap: 16px !important;
    }
    .product-card .card-body .product-description,
    .product-card .card-body .product-desc,
    #products-grid .product-card .product-description,
    #products-grid .product-card .product-desc {
        -webkit-line-clamp: 3;
        line-clamp: 3;
        max-height: 44.55px;
    }
    .product-image-container {
        height: 180px !important;
    }
    .product-card .card-body,
    #products-grid .product-card .card-body {
        padding: 0.5rem 0.75rem !important;
        gap: 0.3rem;
        display: grid !important;
        grid-template-rows: auto auto 1fr auto;
        align-content: stretch;
    }
    .product-card .product-title,
    #products-grid .product-card .product-title {
        font-size: 13px !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
    }
    .product-card .card-text,
    .product-card .product-desc,
    .product-card .product-description,
    #products-grid .product-card .card-text,
    #products-grid .product-card .product-desc,
    #products-grid .product-card .product-description {
        -webkit-line-clamp: 3 !important;
        line-clamp: 3 !important;
        max-height: 44.55px !important;
    }
    .product-actions,
    .product-cta-bar,
    #products-grid .product-card .product-actions {
        gap: 0.35rem !important;
        width: 100%;
    }
    .buy-btn,
    #products-grid .product-card .buy-btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
        border-radius: 18px !important;
        white-space: nowrap;
        flex: 1 1 160px !important;
    }
    #products-grid .product-card .price-section {
        order: 3;
    }
    #products-grid .product-card .product-actions {
        order: 4;
    }
}

@media (min-width: 768px) and (max-width: 991px) {

    .product-card {
        min-height: 480px;
        max-height: none;
        overflow: visible;
    }

    .product-image {
        height: 200px;
        padding: 2px;
        object-fit: cover;
    }

    .product-card .card-body {
        min-height: 260px;
        max-height: none;
    }
}

/* Mobile Large (576-767px) - 2 columns with 90% width */
@media (min-width: 576px) and (max-width: 767px) {
    #products-grid .col-md-6 {
        flex: 0 0 49.5% !important;
        max-width: 49.5% !important;
        margin-bottom: 2rem;
    }

    .product-card {
        min-height: 460px;
        max-height: none;
        overflow: visible;
    }

    .product-image {
        height: 180px;
        padding: 2px;
        object-fit: cover;
    }

    .product-card .card-body {
        min-height: 260px;
        max-height: none;
    }

    .container-fluid, main, .main-content, .category-products-container {
        width: var(--global-content-width, 100%) !important;
        max-width: none !important;
        padding-left: var(--page-edge-padding, 20px) !important;
        padding-right: var(--page-edge-padding, 20px) !important;
    }
}

/* Mobile Small (≤575px) - 1 column with 90% width */
@media (max-width: 575px) {
    #products-grid .col-sm-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 1.5rem;
    }

    .product-card {
        min-height: 400px;
        max-height: none;
        overflow: visible;
    }

    .product-image {
        height: 160px;
        padding: 2px;
        object-fit: cover;
    }

    .product-card .card-body {
        min-height: 220px;
        max-height: none;
    }


@media (max-width: 1200px) {
    #products-grid .product-card {
        max-height: none !important;
        overflow: visible !important;
    }
    #products-grid .product-card .card-body {
        max-height: none !important;
    }
}
    .container-fluid, main, .main-content, .category-products-container {
        width: var(--global-content-width, 100%) !important;
        max-width: none !important;
        padding-left: var(--page-edge-padding, 16px) !important;
        padding-right: var(--page-edge-padding, 16px) !important;
    }

    #products-grid {
        padding: 0 2px !important;
        gap: 6px !important;
    }
}

/* ==========================================================
   PRODUCT CARD VARIANT V2 (Based on target screenshot)
   Usage: wrap card with class .product-card-v2 (instead of .product-card)
   Keeps original styles intact. Add .has-discount if discount badge shown.
   ========================================================== */
.product-card-v2 {
    position: relative;
    background: var(--pcv2-color-bg);
    border: 1px solid var(--pcv2-color-border);
    border-radius: 14px;
    padding: 0; /* internal sections manage their own padding */
    display: flex;
    flex-direction: column;
    min-height: 560px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    transition: box-shadow .25s, transform .25s;
}
.product-card-v2:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.10); transform: translateY(-3px); }

/* Image zone */
.product-card-v2 .pcv2-image-wrapper {
    position: relative;
    height: 240px; /* adjust if want larger */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px 4px;
}
.product-card-v2 .pcv2-image-wrapper img { max-height: 100%; max-width: 100%; object-fit: contain; }

/* Brand small top text */
.product-card-v2 .pcv2-brand {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    color: #0ea5e9;
    text-transform: uppercase;
    margin: 0 0 6px;
}

/* Title */
.product-card-v2 .pcv2-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    color: #0066cc; /* กำหนดสีฟ้าเข้มโดยตรงแทน var(--pcv2-text-primary) */
    margin: 0 0 6px;
    max-height: calc(1.25em * 2.2);
    overflow: hidden;
}

/* Specs / description */
.product-card-v2 .pcv2-specs {
    font-size: 14px;
    line-height: 1.5;
    color: var(--pcv2-text-secondary);
    margin: 0 0 12px;
    max-height: calc(1.5em * 3);
    overflow: hidden;
}

/* Price block */
.product-card-v2 .pcv2-price-block { margin-bottom: 10px; }
.product-card-v2 .pcv2-price-old {
    font-size: 12px;
    text-decoration: line-through;
    color: var(--pcv2-price-old);
    margin: 0 0 2px;
}
.product-card-v2 .pcv2-price-current {
    font-size: 22px;
    font-weight: 700;
    color: var(--pcv2-price-current);
    margin: 0 0 8px;
}

/* Badges row */
.product-card-v2 .pcv2-badges { display:flex; flex-wrap:wrap; gap:6px; margin:0 0 10px; }
.product-card-v2 .pcv2-badge {
    background:#eef2f6;
    color:#334155;
    font-size:11px;
    padding:4px 10px;
    border-radius:20px;
    font-weight:600;
    white-space:nowrap;
}
.product-card-v2 .pcv2-badge--discount { background:#dc2626; color:#fff; }
.product-card-v2 .pcv2-badge--best { background:#f59e0b; color:#fff; }

/* Footnote */
.product-card-v2 .pcv2-footnote {
    font-size:10px;
    color:var(--pcv2-text-faint);
    margin: -4px 0 14px;
}

/* Buy button */
.product-card-v2 .pcv2-buy-area { margin-top:auto; }
.product-card-v2 .pcv2-buy-btn {
    width:100%;
    background: linear-gradient(90deg,#0284c7,#0ea5e9);
    border:none;
    color:#fff;
    font-weight:600;
    font-size:15px;
    padding:14px 12px;
    border-radius:28px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    cursor:pointer;
    transition:background .25s, transform .25s;
}
.product-card-v2 .pcv2-buy-btn:hover { background: linear-gradient(90deg,#0369a1,#0ea5e9); transform: translateY(-2px); }

/* Bottom meta */
.product-card-v2 .pcv2-bottom-meta {
    font-size:11px;
    color:#64748b;
    display:flex;
    align-items:center;
    gap:14px;
    padding:6px 12px 10px;
    border-top:1px solid #eef2f6;
    margin-top:10px;
}

/* Inner content wrapper */
.product-card-v2 .pcv2-body { padding: 0 18px 16px; display:flex; flex-direction:column; flex:1; }

/* Responsive tweaks */
@media (max-width: 992px) {
  .product-card-v2 { min-height: 520px; }
  .product-card-v2 .pcv2-image-wrapper { height: 210px; }
  .product-card-v2 .pcv2-price-current { font-size: 20px; }
}
@media (max-width: 576px) {
  .product-card-v2 { min-height: 500px; }
  .product-card-v2 .pcv2-image-wrapper { height: 200px; padding:10px 14px 2px; }
  .product-card-v2 .pcv2-title { font-size:12.5px; }
  .product-card-v2 .pcv2-buy-btn { font-size:14px; padding:12px 10px; }
}

/* Skeleton Loading State for V2 */
.product-card-v2.loading { pointer-events:none; }
.product-card-v2.loading .pcv2-image-wrapper,
.product-card-v2.loading .pcv2-title,
.product-card-v2.loading .pcv2-specs,
.product-card-v2.loading .pcv2-price-old,
.product-card-v2.loading .pcv2-price-current,
.product-card-v2.loading .pcv2-badge,
.product-card-v2.loading .pcv2-footnote,
.product-card-v2.loading .pcv2-buy-btn {
    position: relative;
    color: transparent !important;
    background: var(--pcv2-skel-base);
    overflow: hidden;
}
.product-card-v2.loading .pcv2-buy-btn { box-shadow:none; }
.product-card-v2.loading .pcv2-image-wrapper img { opacity:0; }

@keyframes pcv2-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}
.product-card-v2.loading .pcv2-image-wrapper,
.product-card-v2.loading .pcv2-title,
.product-card-v2.loading .pcv2-specs,
.product-card-v2.loading .pcv2-price-old,
.product-card-v2.loading .pcv2-price-current,
.product-card-v2.loading .pcv2-badge,
.product-card-v2.loading .pcv2-footnote,
.product-card-v2.loading .pcv2-buy-btn {
    background-image: linear-gradient(90deg,var(--pcv2-skel-base) 0%,var(--pcv2-skel-mid) 40%,var(--pcv2-skel-base) 80%);
    background-size: 400px 100%;
    animation: pcv2-shimmer 1.2s linear infinite;
    border-radius: var(--pcv2-skel-radius);
}
.product-card-v2.loading .pcv2-buy-btn { border-radius:28px; }

/* ==========================================================
     FLASH SALE CARD VARIANT
     Class: .flash-product-card  (independent of other variants)
     ========================================================== */
.flash-product-card {
    position: relative;
    background:#fff;
    border-radius:16px;
    padding:18px 18px 16px;
    display:flex;
    flex-direction:column;
    min-height:480px;
    box-shadow:0 2px 6px rgba(0,0,0,0.06);
    border:1px solid #f0f2f5;
    transition:box-shadow .25s, transform .25s;
}
.flash-product-card:hover { box-shadow:0 8px 22px rgba(0,0,0,0.12); transform:translateY(-4px); }

.flash-product-card .fsc-image-wrap { height:190px; display:flex; align-items:center; justify-content:center; margin-bottom:12px; }
.flash-product-card .fsc-image-wrap img { max-width:100%; max-height:100%; object-fit:contain; }

/* Flash badge */
.flash-product-card .fsc-badge {
    position:absolute;
    top:14px; left:14px;
    background:#ef4444;
    color:#fff;
    font-size:11px;
    padding:6px 14px;
    font-weight:700;
    border-radius:24px;
    letter-spacing:.5px;
    box-shadow:0 2px 6px rgba(239,68,68,.4);
}

/* Brand */
.flash-product-card .fsc-brand { font-size:11px; font-weight:600; letter-spacing:.5px; color:#6366f1; margin-bottom:6px; text-transform:uppercase; }

/* Title clamp (2 lines) */
.flash-product-card .fsc-title { font-size:13px; font-weight:700; line-height:1.35; color:#0066cc; margin:0 0 8px; display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

/* Specs clamp (3 lines) */
.flash-product-card .fsc-specs { font-size:11px; line-height:1.35; color:#64748b; margin:0 0 10px; display:-webkit-box; -webkit-line-clamp:3; line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }

/* Price area */
.flash-product-card .fsc-price-block { margin-top:auto; }
.flash-product-card .fsc-price-old { font-size:12px; text-decoration:line-through; color:#94a3b8; margin:0 0 4px; }
.flash-product-card .fsc-price-current { font-size:22px; font-weight:700; color:#dc2626; margin:0 0 10px; }

/* Discount badge inline (optional) */
.flash-product-card .fsc-discount-inline { display:inline-block; background:#dc2626; color:#fff; font-size:11px; font-weight:600; padding:4px 10px; border-radius:14px; margin-right:8px; }

/* Countdown chip (optional positioning) */
.flash-product-card .fsc-timer { position:absolute; top:14px; right:14px; background:#fef3c7; color:#b45309; font-size:12px; font-weight:600; padding:6px 14px; border-radius:24px; box-shadow:0 2px 5px rgba(250,204,21,.4); }

/* Buy button */
.flash-product-card .fsc-buy-btn { width:100%; background:linear-gradient(90deg,#38bdf8,#0ea5e9) !important; color:#fff; border:none; border-radius:28px; font-size:15px; font-weight:600; padding:14px 12px; display:flex; align-items:center; justify-content:center; gap:8px; cursor:pointer; transition:background .25s, transform .25s; }
.flash-product-card .fsc-buy-btn:hover { background:linear-gradient(90deg,#0ea5e9,#0284c7) !important; transform:translateY(-2px); }

/* -----------------------------------------------------------------
   Apply Flash-sale card layout to SMART PHONE category
   - Mirrors .flash-product-card visuals but scoped to SMART PHONE pages
   ----------------------------------------------------------------- */
html.scaled-view [id*="SMART_PHONE"] .product-card,
html.scaled-view [class*="smart-phone"] .product-card,
html.scaled-view [id*="smartphone"] .product-card {
    position: relative !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 18px 18px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 480px !important; /* match flash card height */
    box-shadow: 0 2px 6px rgba(0,0,0,0.06) !important;
    border: 1px solid #f0f2f5 !important;
    transition: box-shadow .25s, transform .25s !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card:hover,
html.scaled-view [class*="smart-phone"] .product-card:hover,
html.scaled-view [id*="smartphone"] .product-card:hover {
    box-shadow:0 8px 22px rgba(0,0,0,0.12) !important;
    transform: translateY(-4px) !important;
}

/* Image wrapper: match flash image canvas */
html.scaled-view [id*="SMART_PHONE"] .product-image-container,
html.scaled-view [class*="smart-phone"] .product-image-container,
html.scaled-view [id*="smartphone"] .product-image-container {
    height: 240px !important; /* enlarge visual image zone */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 12px !important;
    padding: 12px 12px 12px 12px !important; /* symmetric padding for visual balance */
    background: transparent !important;
    border-radius: 12px !important;
    overflow: hidden !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-image-container img,
html.scaled-view [id*="smartphone"] .product-image-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* fill area – no shrinking look */
    object-position: center center !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Strong override: ensure no cover stretching/cropping inside SMART PHONE cards */
html.scaled-view [id*="SMART_PHONE"] .product-card img.product-image,
html.scaled-view [class*="smart-phone"] .product-card img.product-image,
html.scaled-view [id*="smartphone"] .product-card img.product-image,
html.scaled-view [id*="SMART_PHONE"] .product-card .card-img-top,
html.scaled-view [class*="smart-phone"] .product-card .card-img-top,
html.scaled-view [id*="smartphone"] .product-card .card-img-top {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
    margin: 0 auto !important;
    display: block !important;
}

/* Optional helper: add class .img-contain on product-card to preserve full image (no crop) */
html.scaled-view [id*="SMART_PHONE"] .product-card.img-contain .product-image-container img,
html.scaled-view [class*="smart-phone"] .product-card.img-contain .product-image-container img,
html.scaled-view [id*="smartphone"] .product-card.img-contain .product-image-container img,
html.scaled-view [id*="SMART_PHONE"] .product-card.img-contain img.product-image,
html.scaled-view [class*="smart-phone"] .product-card.img-contain img.product-image,
html.scaled-view [id*="smartphone"] .product-card.img-contain img.product-image {
    object-fit: contain !important;
    padding: 4px !important;
}

/* ================= Reference Layout Emulation (SMART PHONE) ================= */
/* Card frame refinement */
html.scaled-view [id*="SMART_PHONE"] .product-card,
html.scaled-view [class*="smart-phone"] .product-card,
html.scaled-view [id*="smartphone"] .product-card {
    border: 1px solid #d9e2ec !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
    border-radius: 14px !important;
    padding: 16px 18px 14px !important;
    min-height: 520px !important; /* enough space for specs + button */
    background:#ffffff !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card:hover,
html.scaled-view [class*="smart-phone"] .product-card:hover,
html.scaled-view [id*="smartphone"] .product-card:hover {
    border-color:#0284c7 !important;
    box-shadow:0 4px 14px rgba(0,0,0,0.10) !important;
}

/* Discount badge (top-left) reuse existing .discount-badge if present */
html.scaled-view [id*="SMART_PHONE"] .product-card .discount-badge,
html.scaled-view [class*="smart-phone"] .product-card .discount-badge,
html.scaled-view [id*="smartphone"] .product-card .discount-badge {
    top: 12px !important;
    left: 12px !important;
    font-size: 11px !important;
    padding: 6px 12px !important;
    border-radius: 22px !important;
    letter-spacing:.4px !important;
    background: linear-gradient(90deg,#ef4444,#dc2626) !important;
}

/* Brand label small uppercase */
html.scaled-view [id*="SMART_PHONE"] .product-card__brand,
html.scaled-view [class*="smart-phone"] .product-card__brand,
html.scaled-view [id*="smartphone"] .product-card__brand {
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: .5px !important;
    color:#0f62fe !important;
    margin: 0 0 6px 0 !important;
    text-transform: uppercase !important;
}

/* Title tighten */
html.scaled-view [id*="SMART_PHONE"] .product-card__title,
html.scaled-view [class*="smart-phone"] .product-card__title,
html.scaled-view [id*="smartphone"] .product-card__title {
    font-size: 14px !important;
    font-weight: 700 !important;
    margin: 0 0 10px 0 !important;
    -webkit-line-clamp:2 !important; line-clamp:2 !important;
}

/* Specs / excerpt compact (3 lines) */
html.scaled-view [id*="SMART_PHONE"] .product-card__meta,
html.scaled-view [class*="smart-phone"] .product-card__meta,
html.scaled-view [id*="smartphone"] .product-card__meta,
html.scaled-view [id*="SMART_PHONE"] .product-card__excerpt,
html.scaled-view [class*="smart-phone"] .product-card__excerpt,
html.scaled-view [id*="smartphone"] .product-card__excerpt,
html.scaled-view [id*="SMART_PHONE"] .product-description,
html.scaled-view [class*="smart-phone"] .product-description,
html.scaled-view [id*="smartphone"] .product-description,
html.scaled-view [id*="SMART_PHONE"] .product-desc,
html.scaled-view [class*="smart-phone"] .product-desc,
html.scaled-view [id*="smartphone"] .product-desc,
html.scaled-view [id*="SMART_PHONE"] .card-text,
html.scaled-view [class*="smart-phone"] .card-text,
html.scaled-view [id*="smartphone"] .card-text {
    font-size: 12px !important;
    line-height: 1.4 !important;
    -webkit-line-clamp:3 !important; line-clamp:3 !important;
    max-height: 50.4px !important; /* 12px * 1.4 * 3 */
    margin: 0 0 12px 0 !important;
}

/* Size annotation (if a span.size-info exists) */
html.scaled-view [id*="SMART_PHONE"] .product-card .size-info,
html.scaled-view [class*="smart-phone"] .product-card .size-info,
html.scaled-view [id*="smartphone"] .product-card .size-info {
    display:block !important;
    font-size:11px !important;
    color:#475569 !important;
    text-align:center !important;
    margin:6px 0 4px 0 !important;
}

/* Price block: old (strikethrough), new (larger) */
html.scaled-view [id*="SMART_PHONE"] .price-section .old-price,
html.scaled-view [class*="smart-phone"] .price-section .old-price,
html.scaled-view [id*="smartphone"] .price-section .old-price {
    font-size:12px !important;
    text-decoration:line-through !important;
    color:#94a3b8 !important;
    margin:0 0 4px 0 !important;
    display:block !important;
    font-weight:500 !important;
}
html.scaled-view [id*="SMART_PHONE"] .price-section .current-price,
html.scaled-view [class*="smart-phone"] .price-section .current-price,
html.scaled-view [id*="smartphone"] .price-section .current-price {
    font-size:24px !important;
    font-weight:700 !important;
    color:#0f62fe !important;
    margin:0 0 8px 0 !important;
    line-height:1.1 !important;
}

/* Blue buy button variant (override earlier pink) */
html.scaled-view [id*="SMART_PHONE"] .buy-btn,
html.scaled-view [class*="smart-phone"] .buy-btn,
html.scaled-view [id*="smartphone"] .buy-btn {
    background: linear-gradient(90deg,#0f62fe,#1283ff) !important;
    font-size:16px !important;
    font-weight:700 !important;
    padding:14px 14px !important;
    border-radius: 40px !important;
    box-shadow:0 3px 8px rgba(15,98,254,0.35) !important;
}
html.scaled-view [id*="SMART_PHONE"] .buy-btn:hover,
html.scaled-view [class*="smart-phone"] .buy-btn:hover,
html.scaled-view [id*="smartphone"] .buy-btn:hover {
    background: linear-gradient(90deg,#0b5ad9,#0f62fe) !important;
}

/* Footer spacing ensure button separated */
html.scaled-view [id*="SMART_PHONE"] .product-card__footer,
html.scaled-view [class*="smart-phone"] .product-card__footer,
html.scaled-view [id*="smartphone"] .product-card__footer {
    margin-top: 10px !important;
    padding-top: 6px !important;
    border-top: 1px solid #eef2f6 !important;
}

/* Align price/button block visually at bottom */
html.scaled-view [id*="SMART_PHONE"] .price-section,
html.scaled-view [class*="smart-phone"] .price-section,
html.scaled-view [id*="smartphone"] .price-section {
    margin-top:auto !important;
}

/* =========================================================================== */

/* Brand / title / specs styling similar to flash variant */
html.scaled-view [id*="SMART_PHONE"] .product-card__brand,
html.scaled-view [class*="smart-phone"] .product-card__brand,
html.scaled-view [id*="smartphone"] .product-card__brand {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    color: #6366f1 !important;
    margin-bottom: 6px !important;
}
html.scaled-view [id*="SMART_PHONE"] .product-card__title,
html.scaled-view [class*="smart-phone"] .product-card__title,
html.scaled-view [id*="smartphone"] .product-card__title {
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    color: #0066cc !important;
    margin: 0 0 8px 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important; /* title ควรเป็น 2 บรรทัด */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

html.scaled-view [id*="SMART_PHONE"] .product-description,
html.scaled-view [class*="smart-phone"] .product-description,
html.scaled-view [id*="smartphone"] .product-description,
html.scaled-view [id*="SMART_PHONE"] .card-text,
html.scaled-view [class*="smart-phone"] .card-text,
html.scaled-view [id*="smartphone"] .card-text,
html.scaled-view [id*="SMART_PHONE"] .product-desc,
html.scaled-view [class*="smart-phone"] .product-desc,
html.scaled-view [id*="smartphone"] .product-desc {
    font-size: 11px !important;
    line-height: 1.35 !important; /* เปลี่ยนจาก 1.4 เป็น 1.35 */
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    max-height: 44.55px !important; /* 11px * 1.35 * 3 */
    margin: 0 0 10px 0 !important;
    flex-shrink: 0 !important;
}

/* Price block and buy button behavior */
html.scaled-view [id*="SMART_PHONE"] .price-section,
html.scaled-view [class*="smart-phone"] .price-section,
html.scaled-view [id*="smartphone"] .price-section {
    margin-top: auto !important; /* push price to bottom like flash cards */
}
html.scaled-view [id*="SMART_PHONE"] .buy-btn,
html.scaled-view [class*="smart-phone"] .buy-btn,
html.scaled-view [id*="smartphone"] .buy-btn {
    width: 100% !important;
    background: linear-gradient(90deg,#f43f5e,#fb7185) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 28px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    padding: 14px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: background .25s, transform .25s !important;
    position: relative !important;
    z-index: 6 !important; /* keep button above decorative overlays */
}
html.scaled-view [id*="SMART_PHONE"] .buy-btn:hover,
html.scaled-view [class*="smart-phone"] .buy-btn:hover,
html.scaled-view [id*="smartphone"] .buy-btn:hover {
    background: linear-gradient(90deg,#e11d48,#f43f5e) !important;
    transform: translateY(-2px) !important;
}


/* Bottom meta (optional) */
.flash-product-card .fsc-meta { font-size:11px; color:#94a3b8; display:flex; align-items:center; gap:12px; margin-top:12px; }

/* Progress bar (stocks left) */
.flash-product-card .fsc-progress { position:relative; height:6px; background:#f1f5f9; border-radius:4px; overflow:hidden; margin:6px 0 12px; }
.flash-product-card .fsc-progress > span { position:absolute; inset:0; background:linear-gradient(90deg,#f87171,#ef4444); width:50%; }

/* Responsive */
@media (max-width: 992px) {
    .flash-product-card { min-height:460px; }
    .flash-product-card .fsc-image-wrap { height:170px; }
    .flash-product-card .fsc-price-current { font-size:20px; }
}
@media (max-width: 576px) {
    .flash-product-card { min-height:440px; padding:16px 16px 14px; }
    .flash-product-card .fsc-image-wrap { height:160px; }
    .flash-product-card .fsc-buy-btn { font-size:14px; padding:12px 10px; }
}

/* Flash Sale + Landscape 600x400 hybrid variant */
.flash-product-card.landscape-600x400 .fsc-image-wrap {
        height:400px; /* requested height */
        aspect-ratio:3 / 2; /* 600 x 400 */
        max-width:600px;
        width:100%;
        margin:0 auto 14px;
}
.flash-product-card.landscape-600x400 .fsc-image-wrap img {
        max-width:100%;
        max-height:100%;
        object-fit:contain;
}
/* Downscale breakpoints */
@media (max-width:1400px){
    .flash-product-card.landscape-600x400 .fsc-image-wrap { height:360px; max-width:560px; }
}
@media (max-width:1200px){
    .flash-product-card.landscape-600x400 .fsc-image-wrap { height:330px; max-width:520px; }
}
@media (max-width:992px){
    .flash-product-card.landscape-600x400 .fsc-image-wrap { height:300px; max-width:480px; }
}
@media (max-width:768px){
    .flash-product-card.landscape-600x400 .fsc-image-wrap { height:260px; max-width:420px; }
}
@media (max-width:576px){
    .flash-product-card.landscape-600x400 .fsc-image-wrap { height:220px; max-width:360px; }
}

/* ==========================================================
     DYNAMIC LAYOUT MODES: UNIFORM HEIGHT + MASONRY + LAZY LOAD
     ----------------------------------------------------------
     Modes:
         1) Uniform (default) - rows visually aligned; JS sets equal min-height per visual row
         2) Masonry - variable heights; grid-auto-rows + span calculation for tight packing
     Activation:
         - Add data-mode="masonry" to #products-grid (or class .masonry-mode)
         - Use JS helper (product-layout-modes.js) to toggle
     Lazy Loading:
         - <img data-src="real.jpg" class="lazy-img" src="placeholder.jpg" />
         - Card should start with class .loading for skeleton until image loads
     ========================================================== */

/* Shared shimmer keyframes (reuse if needed elsewhere) */
@keyframes card-skeleton-shimmer { 0% { background-position:-200px 0;} 100% { background-position:200px 0;} }

/* Base skeleton styles for legacy .product-card & flash cards */
.product-card.loading .product-image-container,
.product-card.loading .product-image,
.flash-product-card.loading .fsc-image-wrap,
.flash-product-card.loading .fsc-image-wrap img,
.product-card.loading .card-body .skeleton-line,
.flash-product-card.loading .skeleton-line {
        position: relative;
        background: linear-gradient(90deg,#f1f5f9 0%,#e2e8f0 40%,#f1f5f9 80%);
        background-size:400px 100%;
        animation: card-skeleton-shimmer 1.25s linear infinite;
        color: transparent !important;
}
.product-card.loading .product-image { opacity:0; }
.flash-product-card.loading .fsc-image-wrap img { opacity:0; }

/* Optional simple skeleton lines inside body (add with JS if desired) */
.skeleton-line { height:12px; border-radius:6px; margin:6px 0; }
.skeleton-line.sm { height:8px; }
.skeleton-line.lg { height:18px; }

/* Lazy image fade-in */
.lazy-img { opacity:0; transition:opacity .5s ease; }
.lazy-img.loaded { opacity:1; }

/* MASONRY MODE (applies to #products-grid when .masonry-mode or data-mode="masonry") */
#products-grid.masonry-mode,
#products-grid[data-mode="masonry"] {
        display:grid !important; /* ensure grid (already grid in notebook mode) */
        grid-template-columns:repeat(auto-fill,minmax(250px,1fr));
        grid-auto-rows:8px; /* base row height unit for span calc */
        grid-auto-flow:dense;
}

/* Adjust column minimum for full-100 wide mode */
body.page-notebook.full-100 #products-grid.masonry-mode,
body.page-notebook.full-100 #products-grid[data-mode="masonry"] {
        grid-template-columns:repeat(auto-fill,minmax(280px,1fr));
}

/* Masonry items (any direct child) will receive inline grid-row-end:span N from JS */
#products-grid.masonry-mode > *,
#products-grid[data-mode="masonry"] > * { break-inside:avoid; }

/* UNIFORM MODE HOOK (JS applies equal heights per visual row) */
#products-grid.uniform-mode > * { /* JS sets --balanced-height dynamically */ min-height:var(--balanced-height, auto); }

/* When switching modes, clear transitions causing jank */
#products-grid.mode-transition > * { transition:none !important; }

/* Helper class for forcing a card's measured content wrapper */
.measure-target { display:block; }

/* Reduce animation during prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .grid-animating #products-grid .product-card,
    .grid-animating #products-grid .product-card-v2,
    .grid-animating #products-grid .flash-product-card,
    body.grid-animating-in #products-grid > * { animation:none !important; transform:none !important; }
    .lazy-img { transition:none; }
}

/* Optional toggle buttons styling (if you add masonry/uniform toggle UI) */
.layout-mode-toggle-group { display:flex; gap:6px; align-items:center; }
.layout-mode-btn { border:1px solid #cbd5e1; background:#fff; padding:6px 12px; border-radius:6px; font-size:12px; cursor:pointer; font-weight:600; color:#334155; transition:.2s; }
.layout-mode-btn.active { background:#0ea5e9; color:#fff; border-color:#0284c7; }
.layout-mode-btn:hover { background:#f1f5f9; }
.layout-mode-btn.active:hover { background:#0284c7; }

/* ==========================================================
    PROFESSIONAL PRODUCT CARD VARIANT (.product-card-pro)
    Inspired by reference screenshot (badges, promo ribbon, meta chips)
    Structure:
    <div class="product-card-pro loading">
      <div class="pcp-media">
          <div class="pcp-badge pcp-badge--green">Recommended</div>
          <img class="pcp-brand-logo" src="/brand/asus.svg" alt="ASUS" />
          <div class="pcp-icon-stack">
              <span class="pcp-icon pcp-icon-360">360°</span>
              <span class="pcp-icon pcp-icon-ict">ICT</span>
              <span class="pcp-icon pcp-icon-ai">AI</span>
          </div>
          <img class="pcp-image lazy-img" data-src="/images/product.jpg" src="/images/placeholder.png" alt="...">
      </div>
      <div class="pcp-promo-ribbon">ใช้โค้ดลดเพิ่ม 🎉 <span class="pcp-code">INTELMID15</span></div>
      <div class="pcp-body">
          <div class="pcp-brand">ASUS</div>
          <h3 class="pcp-title">Notebook Asus Vivobook 16 M1607KA-MB556W(A Quiet Blue)</h3>
          <div class="pcp-spec-box">
              <div class="pcp-spec-lines">16.0 inch / Intel Core i5 13420H / 16GB DDR4 / 512GB SSD / Integrated Graphics ...</div>
              <button class="pcp-spec-more" type="button">ดูเพิ่มเติม</button>
          </div>
          <div class="pcp-price-block">
              <div class="pcp-price-current">฿22,990</div>
              <div class="pcp-footnote">*ราคานี้เฉพาะออนไลน์เท่านั้น</div>
          </div>
          <div class="pcp-meta-row">
              <div class="pcp-chip">ประกัน 3-3-3</div>
              <div class="pcp-chip">จัดส่งฟรี 3-5 ชม.</div>
              <div class="pcp-chip pcp-chip-accent">ผ่อน 0%</div>
          </div>
          <div class="pcp-buy-area"><button class="pcp-buy-btn" type="button"><span class="pcp-buy-icon">🛒</span> ซื้อเลย</button></div>
          <div class="pcp-stats-row"><span class="pcp-stat">👁️ 1.2K</span></div>
      </div>
    </div>
    ========================================================== */
  :root {
     --pcp-radius:16px;
     --pcp-border:#dbe4ef;
     --pcp-border-active:#0ea5e9;
     --pcp-bg:#ffffff;
     --pcp-bg-alt:#f1f5f9;
     --pcp-text:#1e293b;
     --pcp-text-muted:#64748b;
     --pcp-accent:#0ea5e9;
     --pcp-accent-grad:linear-gradient(90deg,#0284c7,#0ea5e9);
     --pcp-badge-green:#10b981;
     --pcp-promo-bg:#015ea8;
     --pcp-promo-text:#ffffff;
     --pcp-spec-box-border:#cbd5e1;
     --pcp-chip-bg:#e2e8f0;
     --pcp-chip-accent-bg:#0ea5e9;
     --pcp-buy-text:#ffffff;
     --pcp-shadow:0 2px 6px rgba(0,0,0,.05);
     --pcp-shadow-hover:0 6px 18px rgba(0,0,0,.12);
     --pcp-skel-base:#e2e8f0;
     --pcp-skel-mid:#f1f5f9;
  }
  [data-theme="dark"], .dark {
     --pcp-border:#334155;
     --pcp-border-active:#38bdf8;
     --pcp-bg:#1e2530;
     --pcp-bg-alt:#27313d;
     --pcp-text:#e2e8f0;
     --pcp-text-muted:#94a3b8;
     --pcp-accent:#38bdf8;
     --pcp-accent-grad:linear-gradient(90deg,#0369a1,#0ea5e9);
     --pcp-promo-bg:#0f3d63;
     --pcp-spec-box-border:#3b4856;
     --pcp-chip-bg:#334155;
     --pcp-chip-accent-bg:#38bdf8;
     --pcp-shadow:0 2px 6px rgba(0,0,0,.6);
     --pcp-shadow-hover:0 6px 18px rgba(0,0,0,.65);
     --pcp-skel-base:#334155;
     --pcp-skel-mid:#475569;
  }

.product-card-pro {
    position:relative;
    display:flex; flex-direction:column;
    background:var(--pcp-bg);
    border:2px solid var(--pcp-border);
    border-radius:var(--pcp-radius);
    box-shadow:var(--pcp-shadow);
    transition:.25s border-color,.25s box-shadow,.25s transform;
    overflow:hidden;
    min-height:600px;
}
.product-card-pro:hover { border-color:var(--pcp-border-active); box-shadow:var(--pcp-shadow-hover); transform:translateY(-3px); }
.product-card-pro:focus-within { border-color:var(--pcp-border-active); outline:none; box-shadow:0 0 0 3px rgba(14,165,233,.35); }

.product-card-pro .pcp-media { position:relative; height:220px; padding:14px 16px 10px; display:flex; align-items:center; justify-content:center; background:var(--pcp-bg-alt); }
.product-card-pro .pcp-image { max-width:100%; max-height:100%; object-fit:contain; transition:transform .35s; }
.product-card-pro:hover .pcp-image { transform:scale(1.04); }

/* ==========================================================
     HOVER TITLE -> IMAGE ZOOM FEATURE
     ----------------------------------------------------------
     Goal: เมื่อเอาเมาส์ไปชื่่อสินค้า (title) ให้รูปสินค้าขยายเล็กน้อย
     Implementation:
         1) Modern CSS :has() selector (no extra JS req.)
                - Works in Chromium 105+, Safari 15.4+, Firefox 121+
         2) Fallback class .hover-zoom-title (add to parent card in templates)
         3) Optional JS (see doc) can add a helper class when :has() unsupported.
     Adjust scale via --title-hover-scale (default 1.12) per variant.
     ========================================================== */
/* Custom property for scale so each variant can override if needed */
.product-card, .product-card-v2, .flash-product-card, .product-card-pro { --title-hover-scale:1.12; }

/* Base safety: only transform image itself */
.product-card .product-image, .product-card-v2 .pcv2-image-wrapper img,
.flash-product-card .fsc-image-wrap img, .product-card-pro .pcp-image { will-change:transform; }

/* 1) Modern :has() usage – when TITLE hovered inside the card */
.product-card:has(.product-title:hover) .product-image,
.product-card-v2:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.flash-product-card:has(.fsc-title:hover) .fsc-image-wrap img,
.product-card-pro:has(.pcp-title:hover) .pcp-image { transform:scale(var(--title-hover-scale)); }

/* 2) Fallback: add .hover-zoom-title to card to enable simple sibling hover rule */
.hover-zoom-title .product-title:hover ~ .product-image-container .product-image { transform:scale(var(--title-hover-scale)); }
.hover-zoom-title.product-card-v2 .pcv2-title:hover ~ .pcv2-image-wrapper img { transform:scale(var(--title-hover-scale)); }
.hover-zoom-title.flash-product-card .fsc-title:hover ~ .fsc-image-wrap img { transform:scale(var(--title-hover-scale)); }
/* pro card: title is after image, so fallback needs JS to toggle a class on parent (.title-hovering) */
.product-card-pro.title-hovering .pcp-image { transform:scale(var(--title-hover-scale)); }

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce){
    .product-card:has(.product-title:hover) .product-image,
    .product-card-v2:has(.pcv2-title:hover) .pcv2-image-wrapper img,
    .flash-product-card:has(.fsc-title:hover) .fsc-image-wrap img,
    .product-card-pro:has(.pcp-title:hover) .pcp-image,
    .product-card-pro.title-hovering .pcp-image { transform:none; }
}

/* ==========================================================
     ADVANCED TITLE HOVER EFFECT UTILITIES
     Utilities (add to the card element):
         .title-hover-vertical  -> ซูมเฉพาะแนวตั้ง scaleY
         .title-hover-shine     -> แสงไฮไลท์สไลด์ผ่านรูปตอน hover title
         .title-hover-pan       -> ซูม + เลื่อน (pan) เล็กน้อย
     Custom Properties (override per card/variant):
         --title-hover-scale-x (default 1)  | --title-hover-scale-y (default uses --title-hover-scale)
         --title-hover-pan-x (default 0px)  | --title-hover-pan-y (default -6px)
         --title-hover-shine-duration (1.1s)
     Works with :has() (modern) + JS fallback class .title-hovering for pro card / legacy fallback.
     ========================================================== */
/* Axis scale defaults */
.product-card, .product-card-v2, .flash-product-card, .product-card-pro {
    --title-hover-scale-x: 1;
    --title-hover-scale-y: var(--title-hover-scale,1.12);
    --title-hover-pan-x: 0px;
    --title-hover-pan-y: -6px;
    --title-hover-shine-duration:1.1s;
}

/* Vertical-only utility simply sets scale-x to 1 & custom scale-y (can override) */
.title-hover-vertical { --title-hover-scale-x:1; }
/* When vertical utility present but user changed --title-hover-scale keep axis separation */
.title-hover-vertical { --title-hover-scale-y: var(--title-hover-scale,1.14); }

/* Core transform builder (applied when title hovered) using :has() */
.title-hover-vertical:has(.product-title:hover) .product-image,
.title-hover-vertical:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.title-hover-vertical:has(.fsc-title:hover) .fsc-image-wrap img,
.title-hover-vertical:has(.pcp-title:hover) .pcp-image,
.title-hover-pan:has(.product-title:hover) .product-image,
.title-hover-pan:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.title-hover-pan:has(.fsc-title:hover) .fsc-image-wrap img,
.title-hover-pan:has(.pcp-title:hover) .pcp-image {
    transform:scale(var(--title-hover-scale-x)) scaleY(var(--title-hover-scale-y)) translate(var(--title-hover-pan-x), var(--title-hover-pan-y));
}

/* Pan utility default stronger scale & pan (override easily) */
.title-hover-pan { --title-hover-scale:1.10; --title-hover-scale-y:1.10; --title-hover-pan-y:-10px; }

/* Shine effect: add pseudo overlay only during hover */
.title-hover-shine .product-image-container,
.title-hover-shine .pcv2-image-wrapper,
.title-hover-shine .fsc-image-wrap,
.title-hover-shine .pcp-media { position:relative; overflow:hidden; }

@keyframes titleHoverShineSweep { 0% { transform:translateX(-120%) skewX(-20deg);} 60% { transform:translateX(110%) skewX(-20deg);} 100% { transform:translateX(110%) skewX(-20deg);} }

/* Using :has() to trigger shine */
.title-hover-shine:has(.product-title:hover) .product-image-container::after,
.title-hover-shine:has(.pcv2-title:hover) .pcv2-image-wrapper::after,
.title-hover-shine:has(.fsc-title:hover) .fsc-image-wrap::after,
.title-hover-shine:has(.pcp-title:hover) .pcp-media::after,
/* JS fallback class .title-hovering added on hover */
.title-hover-shine.title-hovering .product-image-container::after,
.title-hover-shine.title-hovering .pcv2-image-wrapper::after,
.title-hover-shine.title-hovering .fsc-image-wrap::after,
.title-hover-shine.title-hovering .pcp-media::after {
    content:"";
    position:absolute; inset:0;
    background:linear-gradient(115deg,transparent 20%,rgba(255,255,255,.55) 45%,rgba(255,255,255,.15) 60%,transparent 75%);
    mix-blend-mode:screen;
    pointer-events:none;
    animation:titleHoverShineSweep var(--title-hover-shine-duration) ease;
}

/* Combine shine + zoom/pan (stack transforms) */
.title-hover-shine:has(.product-title:hover) .product-image,
.title-hover-shine:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.title-hover-shine:has(.fsc-title:hover) .fsc-image-wrap img,
.title-hover-shine:has(.pcp-title:hover) .pcp-image,
.title-hover-shine.title-hovering .product-image,
.title-hover-shine.title-hovering .pcv2-image-wrapper img,
.title-hover-shine.title-hovering .fsc-image-wrap img,
.title-hover-shine.title-hovering .pcp-image {
    transform:scale(var(--title-hover-scale-x)) scaleY(var(--title-hover-scale-y)) translate(var(--title-hover-pan-x), var(--title-hover-pan-y));
}

/* Reduced motion: disable movement & shine animation */
@media (prefers-reduced-motion: reduce){
    .title-hover-vertical:has(.product-title:hover) .product-image,
    .title-hover-pan:has(.product-title:hover) .product-image,
    .title-hover-shine:has(.product-title:hover) .product-image,
    .title-hover-vertical:has(.pcv2-title:hover) .pcv2-image-wrapper img,
    .title-hover-pan:has(.pcv2-title:hover) .pcv2-image-wrapper img,
    .title-hover-shine:has(.pcv2-title:hover) .pcv2-image-wrapper img,
    .title-hover-vertical:has(.fsc-title:hover) .fsc-image-wrap img,
    .title-hover-pan:has(.fsc-title:hover) .fsc-image-wrap img,
    .title-hover-shine:has(.fsc-title:hover) .fsc-image-wrap img,
    .title-hover-vertical:has(.pcp-title:hover) .pcp-image,
    .title-hover-pan:has(.pcp-title:hover) .pcp-image,
    .title-hover-shine:has(.pcp-title:hover) .pcp-image,
    .title-hover-shine.title-hovering .product-image,
    .title-hover-shine.title-hovering .pcv2-image-wrapper img,
    .title-hover-shine.title-hovering .fsc-image-wrap img,
    .title-hover-shine.title-hovering .pcp-image { transform:none !important; }
    .title-hover-shine:has(.product-title:hover) .product-image-container::after,
    .title-hover-shine:has(.pcv2-title:hover) .pcv2-image-wrapper::after,
    .title-hover-shine:has(.fsc-title:hover) .fsc-image-wrap::after,
    .title-hover-shine:has(.pcp-title:hover) .pcp-media::after,
    .title-hover-shine.title-hovering .product-image-container::after,
    .title-hover-shine.title-hovering .pcv2-image-wrapper::after,
    .title-hover-shine.title-hovering .fsc-image-wrap::after,
    .title-hover-shine.title-hovering .pcp-media::after { animation:none; }
}

/* ==========================================================
     OPTIONAL UTILITIES TO RESOLVE TITLE HOVER CONFLICT
     - ปัญหา: เดิมมี rule .product-card:hover .product-image (ซูมทั้งการ์ด)
                        ทำให้เอฟเฟกต์เฉพาะ hover ชื่อสินค้าแยกไม่ออก หรือ scale เล็กลง
     - แนวทาง: ใช้คลาส .use-title-hover-only บนการ์ดเพื่อ ปิดการซูมตอน hover การ์ด
                            ให้ซูมเฉพาะตอน hover ที่ชื่อเท่านั้น
                            เพิ่มตัวแปร --title-hover-scale-title (ต่างจาก --title-hover-scale ถ้าต้องการ)
     ========================================================== */
.use-title-hover-only { --title-hover-scale-title: var(--title-hover-scale,1.4); }
/* ปิดการ์ด hover zoom เดิม */
.use-title-hover-only:hover .product-image,
.use-title-hover-only:hover .pcv2-image-wrapper img,
.use-title-hover-only:hover .fsc-image-wrap img,
.use-title-hover-only:hover .pcp-image { transform:none !important; }
/* เปิดเฉพาะ title hover (modern :has()) */
.use-title-hover-only:has(.product-title:hover) .product-image,
.use-title-hover-only:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.use-title-hover-only:has(.fsc-title:hover) .fsc-image-wrap img,
.use-title-hover-only:has(.pcp-title:hover) .pcp-image { transform:scale(var(--title-hover-scale-title)) !important; }
/* JS fallback (เพิ่ม .title-hovering) */
.use-title-hover-only.title-hovering .product-image,
.use-title-hover-only.title-hovering .pcv2-image-wrapper img,
.use-title-hover-only.title-hovering .fsc-image-wrap img,
.use-title-hover-only.title-hovering .pcp-image { transform:scale(var(--title-hover-scale-title)) !important; }

/* ถ้าต้องการให้การ์ดยังซูม แต่ title ซูมเพิ่มอีก (incremental) */
.increment-title-zoom { --title-hover-extra-scale:1.05; }
.increment-title-zoom:has(.product-title:hover) .product-image,
.increment-title-zoom:has(.pcv2-title:hover) .pcv2-image-wrapper img,
.increment-title-zoom:has(.fsc-title:hover) .fsc-image-wrap img,
.increment-title-zoom:has(.pcp-title:hover) .pcp-image { transform:scale(calc(var(--title-hover-scale,1.12) * var(--title-hover-extra-scale,1.05))); }
.increment-title-zoom.title-hovering .product-image,
.increment-title-zoom.title-hovering .pcv2-image-wrapper img,
.increment-title-zoom.title-hovering .fsc-image-wrap img,
.increment-title-zoom.title-hovering .pcp-image { transform:scale(calc(var(--title-hover-scale,1.12) * var(--title-hover-extra-scale,1.05))); }

/* Brand logo top-right */
.product-card-pro .pcp-brand-logo { position:absolute; top:10px; right:12px; height:26px; width:auto; object-fit:contain; }

/* Badge top-left */
.product-card-pro .pcp-badge { position:absolute; top:10px; left:12px; background:var(--pcp-badge-green); color:#fff; font-size:12px; font-weight:600; padding:4px 12px; border-radius:20px; box-shadow:0 2px 6px rgba(0,0,0,.15); }
.product-card-pro .pcp-badge--green { background:var(--pcp-badge-green); }

/* Icon stack (lower left / right) */
.product-card-pro .pcp-icon-stack { position:absolute; bottom:8px; left:8px; display:flex; gap:4px; }
.product-card-pro .pcp-icon { background:#fff; color:#0f172a; font-size:11px; font-weight:600; padding:4px 6px; border-radius:6px; box-shadow:0 2px 4px rgba(0,0,0,.12); line-height:1; }
.dark .product-card-pro .pcp-icon { background:#1e293b; color:#e2e8f0; }
.product-card-pro .pcp-icon-ai { background:#1e3a8a; color:#fff; }
.product-card-pro .pcp-icon-ict { background:#0f766e; color:#fff; }

/* Promo ribbon (full width bar) */
.product-card-pro .pcp-promo-ribbon { background:var(--pcp-promo-bg); color:var(--pcp-promo-text); font-size:14px; font-weight:600; padding:6px 16px 7px; display:flex; align-items:center; gap:6px; letter-spacing:.3px; }
.product-card-pro .pcp-promo-ribbon .pcp-code { background:rgba(255,255,255,.15); padding:2px 10px 3px; border-radius:14px; font-size:12px; letter-spacing:.5px; }

.product-card-pro .pcp-body { display:flex; flex-direction:column; padding:14px 18px 16px; flex:1; }
.product-card-pro .pcp-brand { font-size:11px; font-weight:600; letter-spacing:.6px; color:var(--pcp-accent); margin-bottom:4px; text-transform:uppercase; }
.product-card-pro .pcp-title {
    font-size: 30px !important;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 10px;
    color: var(--pcp-text);
    max-height: 88px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Spec box with dashed border */
.product-card-pro .pcp-spec-box { border:1px dashed var(--pcp-spec-box-border); border-radius:8px; padding:8px 10px 10px; margin:0 0 12px; position:relative; }
.product-card-pro .pcp-spec-lines { font-size:11.5px; line-height:1.35; color:var(--pcp-text-muted); max-height:58px; overflow:hidden; }
.product-card-pro .pcp-spec-more { position:absolute; right:8px; bottom:6px; background:none; border:none; font-size:11px; font-weight:600; color:var(--pcp-accent); cursor:pointer; padding:2px 6px; border-radius:6px; }
.product-card-pro .pcp-spec-more:hover { background:var(--pcp-bg-alt); }

/* Price block */
.product-card-pro .pcp-price-block { margin:0 0 10px; }
.product-card-pro .pcp-price-current { font-size:26px; font-weight:700; color:var(--pcp-accent); margin:0 0 6px; }
.product-card-pro .pcp-footnote { font-size:11px; color:var(--pcp-text-muted); margin:-2px 0 6px; }

/* Discount + old price */
.product-card-pro .pcp-price-inline { display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; }
.product-card-pro .pcp-price-old { font-size:14px; color:var(--pcp-text-muted); text-decoration:line-through; font-weight:500; }
.product-card-pro .pcp-discount-badge { background:#dc2626; color:#fff; font-size:11px; font-weight:700; padding:4px 10px; border-radius:16px; letter-spacing:.5px; box-shadow:0 2px 4px rgba(220,38,38,.4); }
.dark .product-card-pro .pcp-discount-badge { background:#b91c1c; }

/* Rating stars */
.product-card-pro .pcp-rating { display:flex; align-items:center; gap:4px; font-size:12px; margin:0 0 8px; color:#f59e0b; }
.product-card-pro .pcp-rating .pcp-stars { display:inline-flex; gap:2px; }
.product-card-pro .pcp-rating .pcp-star { color:#f59e0b; font-size:14px; line-height:1; }
.product-card-pro .pcp-rating .pcp-rating-count { font-size:11px; color:var(--pcp-text-muted); margin-left:4px; }

/* Wishlist + Compare floating controls */
.product-card-pro .pcp-actions-float { position:absolute; top:10px; left:50%; transform:translateX(-50%); display:flex; gap:8px; z-index:6; }
.product-card-pro .pcp-action-btn { width:38px; height:38px; border-radius:50%; border:1px solid var(--pcp-border); background:#ffffffd9; backdrop-filter:blur(6px); display:flex; align-items:center; justify-content:center; cursor:pointer; transition:.25s background,.25s border-color,.25s transform; position:relative; }
.dark .product-card-pro .pcp-action-btn { background:#1e293bdd; }
.product-card-pro .pcp-action-btn:hover { border-color:var(--pcp-border-active); transform:translateY(-2px); }
.product-card-pro .pcp-action-btn:active { transform:scale(.9); }
.product-card-pro .pcp-action-btn .pcp-heart { font-size:16px; color:#dc2626; }
.product-card-pro .pcp-action-btn.active .pcp-heart { color:#ef4444; }
.product-card-pro .pcp-action-btn .pcp-compare { font-size:16px; color:var(--pcp-text-muted); }
.product-card-pro .pcp-action-btn.active .pcp-compare { color:var(--pcp-accent); }

/* Compare indicator dot */
.product-card-pro .pcp-action-btn.active::after { content:""; position:absolute; bottom:6px; right:6px; width:8px; height:8px; background:var(--pcp-accent); border-radius:50%; box-shadow:0 0 0 2px #fff; }

/* Tooltip (optional) */
.product-card-pro .pcp-action-btn[data-tip]::before { content:attr(data-tip); position:absolute; top:-34px; left:50%; transform:translateX(-50%) scale(.85); background:#1e293b; color:#fff; font-size:11px; padding:4px 8px; border-radius:6px; white-space:nowrap; opacity:0; pointer-events:none; transition:.18s; box-shadow:0 4px 12px rgba(0,0,0,.25); }
.product-card-pro .pcp-action-btn[data-tip]:hover::before { opacity:1; transform:translateX(-50%) scale(1); }

/* Integrate rating just under brand or after spec box (flexible) */

/* Meta chips */
.product-card-pro .pcp-meta-row { display:flex; flex-wrap:wrap; gap:6px; margin:0 0 12px; }
.product-card-pro .pcp-chip { background:var(--pcp-chip-bg); color:var(--pcp-text); font-size:11px; font-weight:600; padding:4px 10px; border-radius:16px; line-height:1; display:inline-flex; align-items:center; }
.product-card-pro .pcp-chip-accent { background:var(--pcp-chip-accent-bg); color:#fff; }

/* Buy area */
.product-card-pro .pcp-buy-area { margin-top:auto; }
.product-card-pro .pcp-buy-btn { width:100%; background:var(--pcp-accent-grad); color:var(--pcp-buy-text); font-weight:700; font-size:17px; padding:14px 16px; border:none; border-radius:36px; display:flex; align-items:center; justify-content:center; gap:10px; cursor:pointer; transition:.25s background,.25s transform,.25s box-shadow; box-shadow:0 4px 14px rgba(2,132,199,.35); }
.product-card-pro .pcp-buy-btn:hover { transform:translateY(-2px); }
.product-card-pro .pcp-buy-btn:active { transform:scale(.95); }

/* Stats row */
.product-card-pro .pcp-stats-row { margin-top:12px; font-size:11px; color:var(--pcp-text-muted); display:flex; gap:14px; }
.product-card-pro .pcp-stat { display:inline-flex; align-items:center; gap:4px; }

/* Loading skeleton */
.product-card-pro.loading .pcp-media,
.product-card-pro.loading .pcp-promo-ribbon,
.product-card-pro.loading .pcp-title,
.product-card-pro.loading .pcp-spec-lines,
.product-card-pro.loading .pcp-price-current,
.product-card-pro.loading .pcp-footnote,
.product-card-pro.loading .pcp-chip,
.product-card-pro.loading .pcp-buy-btn,
.product-card-pro.loading .pcp-stats-row { position:relative; color:transparent !important; background:var(--pcp-skel-base); overflow:hidden; }
.product-card-pro.loading .pcp-image { opacity:0; }
.product-card-pro.loading .pcp-media,
.product-card-pro.loading .pcp-promo-ribbon,
.product-card-pro.loading .pcp-title,
.product-card-pro.loading .pcp-spec-lines,
.product-card-pro.loading .pcp-price-current,
.product-card-pro.loading .pcp-footnote,
.product-card-pro.loading .pcp-chip,
.product-card-pro.loading .pcp-buy-btn,
.product-card-pro.loading .pcp-stats-row { background-image:linear-gradient(90deg,var(--pcp-skel-base) 0%,var(--pcp-skel-mid) 45%,var(--pcp-skel-base) 80%); background-size:400px 100%; animation:card-skeleton-shimmer 1.2s linear infinite; }

/* Responsive tweaks */
@media (max-width:992px){
  .product-card-pro { min-height:560px; }
  .product-card-pro .pcp-media { height:200px; }
  .product-card-pro .pcp-price-current { font-size:24px; }
}
@media (max-width:576px){
  .product-card-pro { min-height:540px; }
  .product-card-pro .pcp-media { height:190px; padding:12px 12px 8px; }
    .product-card-pro .pcp-title {
                        font-size: 30px !important;
                        line-height: 1.35;
    }
  .product-card-pro .pcp-buy-btn { font-size:16px; padding:12px 14px; }
}

/* ==========================================================
   FINAL OVERRIDE: FIXED PRODUCT CARD SIZE (313 x 584)
   Placed at end of file to beat earlier grid/card rules.
   ========================================================== */
:root {
    --pc-fixed-card-width: 280px;
    --pc-fixed-card-height: auto;
    --pc-fixed-image-aspect: 4 / 3;
    --pc-fixed-grid-gap: 0.5rem;
}

/* Grid containers that render standard product cards */
.product-grid,
#products-grid,
.home-product-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, var(--pc-fixed-card-width)) !important;
    justify-content: center !important;
    gap: var(--pc-fixed-grid-gap) !important;
}

/* Swiper carousels that render product cards */
.product-carousel-slider .swiper-slide {
    width: var(--pc-fixed-card-width) !important;
}

/* Wrapper width lock */
.product-grid .product-card-wrapper,
#products-grid .product-card-wrapper,
.home-product-grid .product-card-wrapper,
.product-carousel-slider .product-card-wrapper {
    width: var(--pc-fixed-card-width) !important;
    max-width: var(--pc-fixed-card-width) !important;
    margin-bottom: 0 !important;
}

/* Card size lock */
.product-grid .card.product-card,
#products-grid .card.product-card,
.home-product-grid .card.product-card,
.product-carousel-slider .card.product-card {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Product card new - ensure visible overflow */
.product-carousel-slider .product-card-new,
.swiper-wrapper .product-card-new {
    overflow: visible !important;
    height: auto !important;
    min-height: 440px !important;
}

/* Image stage lock - FORCE 4:3 ASPECT RATIO */
.product-grid .card-img-top-wrapper,
#products-grid .card-img-top-wrapper,
.home-product-grid .card-img-top-wrapper,
.product-carousel-slider .card-img-top-wrapper,
.product-grid .product-image-container,
#products-grid .product-image-container,
.home-product-grid .product-image-container,
.product-carousel-slider .product-image-container {
    width: 100% !important;
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f8fafc !important;
}

/* Image inside container */
.product-grid .card-img-top-wrapper img,
#products-grid .card-img-top-wrapper img,
.home-product-grid .card-img-top-wrapper img,
.product-carousel-slider .card-img-top-wrapper img,
.product-grid .product-image-container img,
#products-grid .product-image-container img,
.home-product-grid .product-image-container img,
.product-carousel-slider .product-image-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
}

/* Body takes remaining height; prevent content pushing card taller */
.product-grid .card.product-card .card-body,
#products-grid .card.product-card .card-body,
.home-product-grid .card.product-card .card-body,
.product-carousel-slider .card.product-card .card-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 10px 12px 12px !important;
}

/* Clamp title + description so height stays stable */
.product-grid .card.product-card .card-title,
#products-grid .card.product-card .card-title,
.home-product-grid .card.product-card .card-title,
.product-carousel-slider .card.product-card .card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0 0 6px 0;
    font-size: 13px !important;
    line-height: 1.3 !important;
}

.product-grid .card.product-card .product-desc,
.product-grid .card.product-card .card-text,
#products-grid .card.product-card .product-desc,
#products-grid .card.product-card .card-text,
.home-product-grid .card.product-card .product-desc,
.home-product-grid .card.product-card .card-text,
.product-carousel-slider .card.product-card .product-desc,
.product-carousel-slider .card.product-card .card-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 11px !important;
    line-height: 1.35 !important;
}

/* Keep pills from growing unlimited rows */
.product-grid .price-pills,
#products-grid .price-pills,
.home-product-grid .price-pills,
.product-carousel-slider .price-pills {
    max-height: 36px;
    overflow: hidden;
}

/* Ensure CTA stays visible */
.product-grid .btn-group .btn,
#products-grid .btn-group .btn,
.home-product-grid .btn-group .btn,
.product-carousel-slider .btn-group .btn {
    min-height: 36px;
    font-size: 12px !important;
}

/* ========================================
   PRODUCT CARD NEW - SWIPER FULL HEIGHT FIX
   ให้ปุ่มซื้อเลยแสดงครบไม่ถูกตัด
   ======================================== */

/* Swiper container overflow visible */
.product-carousel-slider,
.product-carousel-slider .swiper,
.product-carousel-slider .swiper-container {
    overflow: visible !important;
    padding-bottom: 20px !important;
}

.product-carousel-slider .swiper-wrapper {
    align-items: stretch !important;
}

.product-carousel-slider .swiper-slide {
    height: 540px !important;
    min-height: 540px !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Product card new layout fix */
.swiper-slide .product-card-new,
.product-carousel-slider .product-card-new {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 520px !important;
    max-height: 540px !important;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: visible !important;
}

/* Image container */
.product-card-new .product-image-container-new {
    flex-shrink: 0;
    position: relative;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

/* Card body flex grow */
.product-card-new .card-body-new {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 12px;
    padding-bottom: 16px;
}

/* Price section stays at position */
.product-card-new .price-section-new {
    margin-top: auto;
    padding-top: 8px;
}

/* Button always visible at bottom */
.product-card-new .buy-now-btn-new {
    flex-shrink: 0;
    margin-top: 10px;
}

/* ==========================================================
   MOBILE OVERRIDE: 2 COLUMNS - ADVICE STYLE
   MUST be at the very end to override all previous rules
   ========================================================== */
@media (max-width: 768px) {
    /* Override fixed width for mobile - use percentage instead */
    :root {
        --pc-fixed-card-width: calc(50% - 6px) !important;
    }

    /* Force 2 columns on product carousel */
    .product-carousel-slider .swiper-slide {
        width: calc(50% - 5px) !important;
        min-width: calc(50% - 5px) !important;
        max-width: calc(50% - 5px) !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
    }

    /* Remove min-height on mobile */
    .product-carousel-slider .product-card-new,
    .swiper-wrapper .product-card-new {
        min-height: auto !important;
        max-height: none !important;
        height: auto !important;
    }

    /* Grid also 2 columns */
    .product-grid,
    #products-grid,
    .home-product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Final height override for storefront product cards */
.product-carousel-slider .swiper-slide,
.swiper-slide:has(.product-card-new) {
    height: 600px !important;
    min-height: 600px !important;
}

.swiper-slide .product-card-new,
.product-carousel-slider .product-card-new,
.swiper-wrapper .product-card-new {
    height: 100% !important;
    min-height: 580px !important;
    max-height: none !important;
}

.product-card-new .card-body-new {
    padding-bottom: 22px !important;
}

@media (max-width: 768px) {
    .product-carousel-slider .swiper-slide,
    .swiper-slide:has(.product-card-new) {
        height: 560px !important;
        min-height: 560px !important;
    }

    .swiper-slide .product-card-new,
    .product-carousel-slider .product-card-new,
    .swiper-wrapper .product-card-new {
        min-height: 540px !important;
    }
}

@media (max-width: 480px) {
    .product-carousel-slider .swiper-slide,
    .swiper-slide:has(.product-card-new) {
        height: 520px !important;
        min-height: 520px !important;
    }

    .swiper-slide .product-card-new,
    .product-carousel-slider .product-card-new,
    .swiper-wrapper .product-card-new {
        min-height: 500px !important;
    }
}
