/* ═══════════════════════════════════════════════════════════════════════════
   Alottech Product Recommendations — Frontend Styles (FIXED FOR FLATSOME)
   ═══════════════════════════════════════════════════════════════════════════ */

/* 1. บังคับให้คอลัมน์ขวาของ Flatsome ไม่ขยายตามเนื้อหาภายใน (สำคัญที่สุด) */
.product-info.col-fit,
.entry-summary {
    min-width: 0 !important;
    max-width: 100% !important;
}

/* 2. กล่องหลักของ Plugin */
.alottech-rec-section {
    display: block !important;
    clear: both !important;
    margin-top: 24px !important;
    margin-bottom: 20px !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ─── Header Bar ───────────────────────────────────────────────────────── */

.alottech-rec-header {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 16px !important;
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%) !important;
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 700 !important;
}

.alottech-rec-icon-svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
    stroke: #fff !important;
}

.alottech-rec-title {
    font-size: 15px !important;
    line-height: 1.4 !important;
}

/* 3. ส่วน Wrapper ที่ทำหน้าที่ Scroll (หัวใจหลัก) */

.alottech-rec-products-wrapper {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
    padding-bottom: 5px !important;
}

.alottech-rec-products-wrapper::-webkit-scrollbar {
    height: 6px;
}

.alottech-rec-products-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.alottech-rec-products-wrapper::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 4px;
}

/* 4. กล่องรวมสินค้าด้านใน */

.alottech-rec-products {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 12px !important;
    padding: 16px !important;
    width: auto !important;
    box-sizing: border-box !important;
}

/* ─── Product Card ─────────────────────────────────────────────────────── */

.alottech-rec-product-card {
    flex: 0 0 140px !important;
    width: 140px !important;
    min-width: 140px !important;
    background: #fff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
}

.alottech-rec-product-card:hover {
    border-color: #d1d5db !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

/* ─── Product Link ─────────────────────────────────────────────────────── */

.alottech-rec-product-link {
    text-decoration: none !important;
    color: inherit !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
}

/* ─── Product Image ────────────────────────────────────────────────────── */

.alottech-rec-product-image {
    width: 100% !important;
    height: 140px !important;
    overflow: hidden !important;
    background: #f9fafb !important;
    position: relative !important;
}

.alottech-rec-product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    margin: 0 !important;
    padding: 0 !important;
    transition: transform 0.3s ease !important;
}

.alottech-rec-product-card:hover .alottech-rec-product-image img {
    transform: scale(1.05) !important;
}

/* ─── Product Info ─────────────────────────────────────────────────────── */

.alottech-rec-product-info {
    padding: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
}

.alottech-rec-product-name {
    font-size: 13px !important;
    /* ปรับขนาดให้อ่านง่ายขึ้นนิดนึง */
    line-height: 1.4 !important;
    /* ความสูงต่อบรรทัด (13px * 1.4 = 18.2px) */

    /* ความสูงรวมต้องเท่ากับ Line-height * 2 บรรทัด */
    height: 38px !important;
    /* 18.2 * 2 = 36.4 (เผื่อเป็น 38px ให้สระลอยไม่ขาด) */
    max-height: 38px !important;
    /* ห้ามสูงเกินนี้เด็ดขาด */

    overflow: hidden !important;
    /* ส่วนเกินซ่อน */
    display: -webkit-box !important;
    /* ใช้ Box model แบบเก่าเพื่อตัดคำ */
    -webkit-line-clamp: 2 !important;
    /* ตัดที่ 2 บรรทัด */
    -webkit-box-orient: vertical !important;

    white-space: normal !important;
    /* บังคับให้ขึ้นบรรทัดใหม่ได้ (สำคัญมาก) */
    text-overflow: ellipsis !important;
    /* ใส่ ... */
    margin: 0 0 4px 0 !important;
    /* เว้นระยะด้านล่างนิดหน่อย */
    color: #333 !important;
    /* สีเทาเข้ม */
}

.alottech-rec-product-price {
    font-size: 28px !important;
    font-weight: bold !important;
    color: #dc2626 !important;
    line-height: 1.2 !important;
    display: block !important;
}

.alottech-rec-product-price .woocommerce-Price-amount {
    font-size: 28px !important;
    font-weight: bold !important;
    color: #dc2626 !important;
    display: block !important;
}

.alottech-rec-product-price del {
    font-size: 11px !important;
    color: #9ca3af !important;
    font-weight: 400 !important;
}

.alottech-rec-product-price del .woocommerce-Price-amount {
    font-size: 11px !important;
    color: #9ca3af !important;
    font-weight: 400 !important;
}

.alottech-rec-product-price ins {
    text-decoration: none !important;
}

/* ─── Product Actions (Add to Cart Button) ─────────────────────────────── */

.alottech-rec-product-actions {
    padding: 0 8px 8px !important;
    margin-top: auto !important;
}

.alottech-rec-section .alottech-rec-add-to-cart {
    display: block !important;
    width: 100% !important;
    padding: 6px 0 !important;
    background-color: #dc3545 !important;
    color: #fff !important;
    border-radius: 4px !important;
    text-align: center !important;
    font-size: 12px !important;
    font-weight: bold !important;
    border: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.2s ease-in-out !important;
    line-height: 1.3 !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    height: auto !important;
    min-height: 36px !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    float: none !important;
    position: relative !important;
    letter-spacing: 0 !important;
}

.alottech-rec-section .alottech-rec-add-to-cart:hover {
    background-color: #b02a37 !important;
    color: white !important;
    text-decoration: none !important;
    opacity: 1 !important;
}

.alottech-rec-section .alottech-rec-add-to-cart:active {
    transform: scale(0.96) !important;
}

.alottech-rec-section .alottech-rec-add-to-cart.added {
    background-color: #16a34a !important;
    border-color: #16a34a !important;
    color: white !important;
}

.alottech-rec-section .alottech-rec-add-to-cart.loading {
    background-color: #b02a37 !important;
    border-color: #b02a37 !important;
    color: transparent !important;
    opacity: 1 !important;
    pointer-events: none !important;
}

/* ─── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .alottech-rec-section {
        margin-top: 16px !important;
        margin-bottom: 16px !important;
        border-radius: 6px !important;
    }

    .alottech-rec-header {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    .alottech-rec-icon-svg {
        width: 16px !important;
        height: 16px !important;
    }

    .alottech-rec-products {
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    .alottech-rec-product-card {
        flex: 0 0 130px !important;
        width: 130px !important;
        min-width: 130px !important;
    }

    .alottech-rec-product-image {
        height: 130px !important;
    }

    .alottech-rec-product-info {
        padding: 6px !important;
    }

    .alottech-rec-product-name {
        font-size: 12px !important;
        height: 34px !important;
        max-height: 34px !important;
        line-height: 1.4 !important;
    }

    .alottech-rec-product-price {
        font-size: 20px !important;
    }

    .alottech-rec-product-price .woocommerce-Price-amount {
        font-size: 20px !important;
    }

    .alottech-rec-product-actions {
        padding: 0 6px 6px !important;
    }

    .alottech-rec-section .alottech-rec-add-to-cart {
        font-size: 11px !important;
        padding: 5px 0 !important;
        min-height: 32px !important;
    }
}