/* ============================================
   Best Selling Products Section - ปัญหาการ์ดซ้อนทับ Fix
   ============================================ */

/* Reset และ cleanup สำหรับส่วนสินค้าขายดี */
section[data-category="สินค้าขายดี"],
section[data-section-id="best-selling"],
.best-selling-section {
    position: relative;
    margin: 20px auto;
    padding: 20px 15px;
    box-sizing: border-box;
    clear: both;
}

/* ป้องกัน multiple grid systems ทำงานซ้อนกัน */
.best-selling-section .row {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

/* Best Selling Clean Grid Layout */
.best-selling-clean-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 32px !important;
    padding: 20px 0 !important;
    margin: 0 auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Card wrapper สำหรับ clean grid */
.best-selling-clean-grid > div {
    display: flex !important;
    justify-content: center !important;
    align-items: stretch !important;
}

.best-selling-clean-grid .card,
.best-selling-clean-grid .product-card {
    width: 100% !important;
    max-width: 280px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    overflow: hidden !important;
}

.best-selling-clean-grid .card:hover,
.best-selling-clean-grid .product-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
}

/* Image container ใน clean grid */
.best-selling-clean-grid .card-img-top,
.best-selling-clean-grid .product-image {
    width: 100% !important;
    height: 180px !important;
    object-fit: cover !important;
    border-radius: 12px 12px 0 0 !important;
}

/* Card body styling */
.best-selling-clean-grid .card-body {
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.best-selling-clean-grid .card-title,
.best-selling-clean-grid .product-title {
    font-size: 10px !important;
    font-weight: 700 !important;
    color: #0066cc !important; /* เปลี่ยนเป็นสีฟ้าเข้มแทน #1b365d */
    line-height: 1.35 !important;
    margin: 0 0 10px 0 !important;
    display: -webkit-box !important;
    line-clamp: 2 !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    letter-spacing: 0.01em !important;
    text-align: center !important;
    padding: 0 12px !important;
}

.best-selling-clean-grid .card-text,
.best-selling-clean-grid .product-description {
    font-size: 12px !important;
    color: #6b7280 !important;
    line-height: 1.3 !important;
    margin: 0 0 12px 0 !important;
    display: -webkit-box !important;
    line-clamp: 3 !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    padding: 0 12px !important;
}

.best-selling-clean-grid .card-price,
.best-selling-clean-grid .product-price {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #dc2626 !important;
    margin: 8px 0 0 0 !important;
}

/* Responsive breakpoints for clean grid */
@media (max-width: 576px) {
    .best-selling-clean-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 15px 10px !important;
    }
    
    .best-selling-clean-grid .card,
    .best-selling-clean-grid .product-card {
        max-width: none !important;
    }
    
    .best-selling-clean-grid .card-img-top,
    .best-selling-clean-grid .product-image {
        height: 120px !important;
    }
    
    .best-selling-clean-grid .card-body {
        padding: 12px !important;
        gap: 6px !important;
    }
    
    .best-selling-clean-grid .card-title,
    .best-selling-clean-grid .product-title {
        font-size: 10px !important;
    }
    
    .best-selling-clean-grid .card-text,
    .best-selling-clean-grid .product-description {
        font-size: 10px !important;
    }
    
    .best-selling-clean-grid .card-price,
    .best-selling-clean-grid .product-price {
        font-size: 14px !important;
    }
}

@media (min-width: 577px) and (max-width: 768px) {
    .best-selling-clean-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .best-selling-clean-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 18px !important;
    }
}

@media (min-width: 993px) {
    .best-selling-clean-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 20px !important;
        max-width: 1200px !important;
        margin: 0 auto !important;
    }
}

/* Override any carousel styles that might conflict */
section[data-category="สินค้าขายดี"] .swiper-container,
section[data-category="สินค้าขายดี"] .swiper-wrapper,
section[data-category="สินค้าขายดี"] .swiper-slide {
    display: none !important;
}

/* Force grid mode - disable slider */
section[data-category="สินค้าขายดี"][data-best-selling-mode="grid"] .swiper-container,
section[data-category="สินค้าขายดี"][data-best-selling-mode="grid"] .product-carousel-slider {
    display: none !important;
}

/* Title styling for section */
section[data-category="สินค้าขายดี"] h2,
section[data-category="สินค้าขายดี"] .section-title,
section[data-category="สินค้าขายดี"] .homepage-section-title {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 30px 0;
    padding-bottom: 10px;
    position: relative;
}

section[data-category="สินค้าขายดี"] h2::after,
section[data-category="สินค้าขายดี"] .section-title::after,
section[data-category="สินค้าขายดี"] .homepage-section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #dc2626, #f59e0b);
    border-radius: 2px;
}

/* Loading state */
.best-selling-clean-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.best-selling-clean-grid.loading::after {
    content: 'กำลังโหลดสินค้าขายดี...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #6b7280;
    z-index: 10;
}