/* ===============================================
   CONTENT SECTION BALANCE SYSTEM V2
   - จัดขอบซ้าย-ขวาของเนื้อหาทุกส่วนให้เท่ากัน
   - สอดคล้องกับ Hero Slider และ Category Bar
   - ใช้ max-width 1400px เป็นมาตรฐาน
   - แก้ไขให้ขอบซ้าย-ขวาตรงกันแน่นอน
   =============================================== */

/* ===============================================
   GLOBAL CONTENT CONTAINER SYSTEM
   =============================================== */

/* Main Content Container - ใช้กับทุกส่วนเนื้อหา */
.content-balanced-container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 var(--page-edge-padding, 30px) !important;
    box-sizing: border-box !important;
    position: relative;
}

/* Container สำหรับ sections ทั่วไป */
.section-balanced-wrapper {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 20px var(--page-edge-padding, 30px) !important;
    box-sizing: border-box !important;
}

/* ===============================================
   VENDOR SUPPORT SECTION - แก้ไขให้ตรงกัน
   =============================================== */

/* Vendor Support Section - จัดขอบให้เท่ากัน */
.vendor-support-section {
    width: 100% !important;
    background: transparent;
    padding: 30px 0 !important;
    margin: 20px 0 !important;
    overflow: hidden;
    position: relative;
}

.vendor-support-section .vendor-support-container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 30px var(--page-edge-padding, 60px) !important; /* เพิ่ม padding ซ้าย-ขวาให้เท่ากัน */
    box-sizing: border-box !important;
}

.vendor-support-section h2 {
    color: #333;
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 30px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    padding: 15px 0;
}

.vendor-support-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%);
    border-radius: 2px;
}

/* Logo Grid - จัดโลโก้ให้เป็นระเบียบ */
.vendor-logos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 25px;
    align-items: center;
    justify-items: center;
    width: 100%;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.vendor-logo-item {
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.9) 100%);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    width: 100%;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.vendor-logo-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.6s ease;
}

.vendor-logo-item:hover::before {
    left: 100%;
}

.vendor-logo-item:hover {
    background: linear-gradient(135deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 107, 157, 0.3);
}

.vendor-logo-item img {
    max-width: 100%;
    max-height: 60px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: brightness(1.1) contrast(1.1);
    transition: all 0.3s ease;
}

.vendor-logo-item:hover img {
    filter: brightness(1.2) contrast(1.2);
    transform: scale(1.1);
}

/* ===============================================
   FLASH SELL SECTION - จัดขอบให้เท่ากันกับ VENDOR
   =============================================== */

.flash-sell-section,
.section-flash-sell,
[class*="flash-sell"] {
    width: 100% !important;
    /* Do not force background here to avoid nuking header artwork set via theme/CMS */
    padding: 24px 0 !important; /* slight vertical padding for breathing room */
    margin: 20px 0 !important;
    /* Allow header artwork and decorative elements to overflow the section safely */
    overflow: visible;
    position: relative;
}

.flash-sell-section .container,
.section-flash-sell .container,
[class*="flash-sell"] .container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 var(--page-edge-padding, 24px) !important;
    box-sizing: border-box !important;
    /* Ensure inner container doesn't clip header art */
    overflow: visible;
}

.flash-sell-section h2,
.section-flash-sell h2,
[class*="flash-sell"] h2 {
    color: #333;
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 30px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    padding: 15px 0;
}

.flash-sell-section h2::after,
.section-flash-sell h2::after,
[class*="flash-sell"] h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%);
    border-radius: 2px;
}

/* ===============================================
   PRODUCT SECTIONS - แก้ไขให้ตรงกัน
   =============================================== */

/* Product Section Wrapper */
.product-section {
    width: 100% !important;
    padding: 40px 0 !important;
    background: #f8fafc;
    margin: 0 !important;
    overflow: hidden;
}

.product-section-container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 var(--page-edge-padding, 30px) !important;
    box-sizing: border-box !important;
}

/* Section Header */
.section-header {
    text-align: center;
    margin-bottom: 40px;
    width: 100%;
    max-width: none !important;
    padding: 0 !important;
}

.section-title {
    font-size: 32px !important;
    font-weight: 700 !important;
    color: #333 !important;
    margin-bottom: 15px !important;
    position: relative !important;
}

#dynamic-content-wrapper .homepage-section.section-wrapper .section-title {
    margin-bottom: 22px !important;
}

/* Ensure there is breathing room between section headers and the first row of cards */
#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area {
    padding-top: 18px !important;
    position: relative;
}

#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area::before {
    content: '';
    display: block;
    height: 20px;
    width: 100%;
}

#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area .product-grid,
#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area .product-grid-balanced,
#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area .product-carousel,
#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area .product-carousel-slider {
    margin-top: 24px !important;
}

#dynamic-content-wrapper .homepage-section.section-wrapper .section-content-area > *:first-child {
    margin-top: 0 !important;
}

#dynamic-content-wrapper .homepage-section.section-wrapper .product-card,
#dynamic-content-wrapper .homepage-section.section-wrapper .card.product-card,
#dynamic-content-wrapper .homepage-section.section-wrapper .product-card-balanced,
#dynamic-content-wrapper .homepage-section.section-wrapper .product-grid .product-card-wrapper > .card,
#dynamic-content-wrapper .homepage-section.section-wrapper .product-grid .product-card-wrapper > .product-card {
    transform: scale(0.85);
    transform-origin: top center;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Section title underline removed for cleaner look */

.section-subtitle {
    font-size: 16px;
    color: #64748b;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Product Grid */
.product-grid-balanced {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin: 20px 0 0 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

.product-card-balanced {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    width: 100%;
    margin: 0 !important;
}

.product-card-balanced:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.product-image-balanced {
    width: 100%;
    height: 160px;
    overflow: hidden;
    position: relative;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.product-image-balanced img {
    width: auto;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-card-balanced:hover .product-image-balanced img {
    transform: scale(1.05);
}

.product-info-balanced {
    padding: 14px 18px 18px;
}

.product-name-balanced {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price-balanced {
    font-size: 18px;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 15px;
}

.product-button-balanced {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-button-balanced:hover {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    transform: translateY(-1px);
}

/* ===============================================
   PROMOTIONAL SECTIONS - แก้ไขให้ตรงกัน
   =============================================== */

/* Promotional Banner */
.promo-section {
    width: 100% !important;
    padding: 30px 0 !important;
    background: white;
    margin: 0 !important;
    overflow: hidden;
}

.promo-container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 var(--page-edge-padding, 30px) !important;
    box-sizing: border-box !important;
}

.promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    align-items: center;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

.promo-banner-balanced {
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    width: 100%;
    margin: 0 !important;
}

.promo-banner-balanced:hover {
    transform: translateY(-3px);
}

.promo-banner-balanced img {
    width: 100%;
    height: auto;
    display: block;
}

/* ===============================================
   MAIN CONTENT WRAPPER OVERRIDE
   =============================================== */

/* แก้ไข main content wrapper ให้ตรงกันแน่นอน */
.main-content-wrapper {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
}

/* Dynamic content wrapper override */
#dynamic-content-wrapper {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: visible; /* allow section header artwork to overflow safely */
}

/* Override any Bootstrap container classes */
.container, 
.container-fluid,
.container-lg,
.container-md,
.container-sm,
.container-xl,
.container-xxl {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding-left: var(--page-edge-padding, 30px) !important;
    padding-right: var(--page-edge-padding, 30px) !important;
    box-sizing: border-box !important;
}

/* ===============================================
   SECTION HEADERS - จัดขอบให้เท่ากันทุก SECTION
   =============================================== */

.section-header,
.content-section,
.logo-strip-section,
.product-grid-section,
.product-carousel-section,
.banner-grid-section,
.advertisement-banner-section {
    width: 100% !important;
    padding: 30px 0 !important;
    margin: 20px 0 !important;
    overflow: hidden;
    position: relative;
}

.section-header .container,
.content-section .container,
.logo-strip-section .container,
.product-grid-section .container,
.product-carousel-section .container,
.banner-grid-section .container,
.advertisement-banner-section .container {
    width: var(--global-content-width, 100%) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 30px var(--page-edge-padding, 60px) !important; /* ขอบซ้าย-ขวาเท่ากันทุก section */
    box-sizing: border-box !important;
}

/* Exceptions: keep header and nav containers full-width */
.top-bar .container.top-bar-full-width,
.main-nav .container.main-nav-full-width,
.main-header-wrapper .container {
    width: 100% !important;
    max-width: 1400px !important;
}

/* Mobile fallback: use full width on small screens */
@media (max-width: 768px) {
    .content-balanced-container,
    .section-balanced-wrapper,
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .product-section-container,
    .promo-container,
    .container,
    .container-fluid,
    .container-lg,
    .container-md,
    .container-sm,
    .container-xl,
    .container-xxl,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        width: 100% !important;
    }
}

/* ===============================================
   SECTION TITLES - รูปแบบเดียวกันทุก SECTION
   =============================================== */

.section-title,
h2.section-title,
.content-section h2,
.product-grid-section h2,
.product-carousel-section h2,
.banner-grid-section h2 {
    color: #333 !important;
    font-size: 32px !important;
    font-weight: 700 !important;
    margin: 0 0 30px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 2px !important;
    text-align: center !important;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    position: relative !important;
    padding: 15px 0 !important;
}

.section-title::after,
h2.section-title::after,
.content-section h2::after,
.product-grid-section h2::after,
.product-carousel-section h2::after,
.banner-grid-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(135deg, #ff6b9d 0%, #4fc3f7 100%);
    border-radius: 2px;
}

/* ===============================================
   RESPONSIVE DESIGN - รักษาขอบให้เท่ากันทุกขนาดหน้าจอ
   =============================================== */

/* Desktop Large (>1400px) */
@media (min-width: 1401px) {
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        padding: 40px 80px !important; /* เพิ่ม padding สำหรับหน้าจอใหญ่ */
    }
}

/* Desktop Medium (1200px - 1400px) */
@media (max-width: 1400px) and (min-width: 1201px) {
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        padding: 35px 70px !important;
    }
}

/* Tablet (768px - 1200px) */
@media (max-width: 1200px) and (min-width: 769px) {
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        padding: 30px 50px !important;
    }
}

/* Mobile Large (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        padding: 25px 30px !important;
    }
    
    .section-title,
    h2.section-title,
    .vendor-support-section h2,
    .flash-sell-section h2,
    .section-flash-sell h2,
    [class*="flash-sell"] h2 {
        font-size: 24px !important;
        letter-spacing: 1px !important;
    }
}

/* Mobile Small (≤480px) */
@media (max-width: 480px) {
    .vendor-support-section .vendor-support-container,
    .flash-sell-section .container,
    .section-flash-sell .container,
    [class*="flash-sell"] .container,
    .section-header .container,
    .content-section .container,
    .logo-strip-section .container,
    .product-grid-section .container,
    .product-carousel-section .container,
    .banner-grid-section .container,
    .advertisement-banner-section .container {
        padding: 20px 20px !important; /* ขอบเท่ากันแม้บน mobile */
    }
    
    .section-title,
    h2.section-title,
    .vendor-support-section h2,
    .flash-sell-section h2,
    .section-flash-sell h2,
    [class*="flash-sell"] h2 {
        font-size: 20px !important;
        letter-spacing: 1px !important;
        margin-bottom: 20px !important;
    }
    
    .vendor-logos-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 15px;
    }
    
    .vendor-logo-item {
        min-height: 80px;
        padding: 15px;
    }
}

/* ===============================================
   FORCE OVERRIDE FOR EXISTING ELEMENTS
   =============================================== */

/* แก้ไขทุก element ที่อาจไม่เป็นไปตาม balance system */
.row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
.col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, 
.col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, 
.col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto,
.col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, 
.col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, 
.col-md-10, .col-md-11, .col-md-12, .col-md-auto,
.col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, 
.col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, 
.col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ===============================================
   UTILITY CLASSES - แก้ไข
   =============================================== */

/* Quick Balance Classes */
.balance-container {
    max-width: 1400px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 30px !important;
    box-sizing: border-box !important;
}

.balance-section {
    width: 100% !important;
    padding: 30px 0 !important;
    margin: 0 !important;
}

.balance-wrapper {
    max-width: 1400px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 30px !important;
    box-sizing: border-box !important;
}

/* Text Alignment */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

/* Spacing */
.mb-20 { margin-bottom: 20px !important; }
.mb-30 { margin-bottom: 30px !important; }
.mb-40 { margin-bottom: 40px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-30 { margin-top: 30px !important; }
.mt-40 { margin-top: 40px !important; }

/* ===============================================
   PRINT STYLES
   =============================================== */

@media print {
    .content-balanced-container,
    .section-balanced-wrapper,
    .vendor-support-container,
    .product-section-container,
    .promo-container {
        max-width: 100% !important;
        padding: 0 20px !important;
    }
    
    .vendor-support-section {
        background: transparent !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
} 