/**
 * Product Term Carousel Styles
 * โค้ดสมบูรณ์พร้อมใช้งาน - อัปเดตล่าสุด
 */

 :root {
    --term-list-primary: #D40000; /* Rosso Corsa Red */
    --term-list-primary-light: #ff3333;
    --term-list-primary-dark: #a20000;
    --term-list-text: #333333;
    --term-list-text-light: #666666;
    --term-list-gray-light: #f5f5f5;
    --term-list-gray: #e0e0e0;
    --term-list-gray-dark: #999999;
    --term-list-white: #ffffff;
    --term-list-transition: all 0.3s ease;
    --term-list-navy: #192A56; /* สีน้ำเงินเข้มสำหรับลูกศร */
}

/* ส่วนหลักของ Carousel */
.product-term-carousel {
    position: relative;
    margin-bottom: 30px;
    padding-bottom: 40px; /* ให้มีพื้นที่สำหรับ pagination dots */
}

/* Container ด้านนอกเพื่อควบคุมขนาดและการวางตำแหน่ง */
.product-term-carousel-outer {
    position: relative;
    width: 100%;
    padding: 0 50px; /* พื้นที่สำหรับปุ่มเลื่อน */
    box-sizing: border-box;
    margin: 0 auto;
}

.product-term-carousel-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    padding: 0 2.5px;
}

/* Track และ Item */
.product-term-carousel-track {
    display: flex;
    transition: transform 0.5s ease;
    padding: 10px 0;
    margin: 0;
    will-change: transform;
}

.product-term-carousel-item {
    margin: 0 2.5px; /* ระยะห่างระหว่าง CardItem */
    box-sizing: border-box;
    transition: all 0.3s ease;
}

/* Card Layout - ปรับตามภาพตัวอย่างใหม่ */
.product-term-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background-color: var(--term-list-white);
    border: none; /* ลบเส้นกรอบออก */
    border-radius: 0; /* ลบมุมโค้ง */
    overflow: visible;
    height: 100%;
    transition: all 0.3s ease;
    box-shadow: none;
    padding: 10px;
    text-align: center;
}

.product-term-card:hover {
    transform: translateY(-3px);
    box-shadow: none; /* ลบเงาเมื่อ hover */
    background-color: #f8f8f8; /* พื้นหลังสีอ่อนเมื่อ hover */
}

.product-term-carousel-item.active .product-term-card {
    border: none; /* ลบเส้นกรอบเมื่อ active */
    background-color: #FFF5F5; /* พื้นหลังสีอ่อนเมื่อ active */
    box-shadow: none;
}

/* รูปภาพ/ไอคอน - เพิ่มขนาด */
.product-term-card-image {
    position: relative;
    height: 120px; /* ขนาดภาพบน Desktop */
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
    background-color: transparent; /* ลบพื้นหลังสีเทา */
}

.product-term-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0;
    transition: transform 0.3s ease;
}

.product-term-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background-color: transparent; /* ลบพื้นหลังสีเทา */
    color: #999;
}

.product-term-card-placeholder .dashicons {
    font-size: 48px; /* เพิ่มขนาดไอคอน */
    width: 48px;
    height: 48px;
}

/* เนื้อหาใน Card */
.product-term-card-content {
    padding: 5px 0 0;
    text-align: center;
    position: relative;
}

.product-term-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--term-list-text);
    transition: color 0.3s ease;
}

.product-term-card:hover .product-term-card-title {
    color: var(--term-list-primary);
}

.product-term-carousel-item.active .product-term-card-title {
    color: var(--term-list-primary);
    font-weight: 600;
}

.term-count {
    color: #666; /* สีเทาสำหรับตัวเลขใน () */
    font-weight: normal;
}

/* ปุ่มเลื่อน Next/Prev */
.product-term-carousel-prev,
.product-term-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background-color: white;
    border-radius: 50%; /* ทำเป็นวงกลม */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    opacity: 1;
    border: 1px solid #E0E0E0; /* ขอบบางๆ */
    color: var(--term-list-navy); /* สีน้ำเงินเข้ม */
    pointer-events: auto !important;
}

.product-term-carousel-prev {
    left: 0;
}

.product-term-carousel-next {
    right: 0;
}

.product-term-carousel-prev:hover,
.product-term-carousel-next:hover {
    background-color: var(--term-list-navy);
    color: white;
    transform: translateY(-50%) scale(1.05);
}

.product-term-carousel-prev:focus,
.product-term-carousel-next:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(25, 42, 86, 0.2);
}

.product-term-carousel-prev svg,
.product-term-carousel-next svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ===== Pagination Dots - อัปเดตใหม่ตามแบบ Article Carousel ===== */
.product-term-carousel-pagination {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.product-term-carousel-dot {
    width: 13px; /* ขนาดปกติ +10% */
    height: 13px;
    border-radius: 50%;
    background-color: #C0C0C0; /* สีเทาเหมือนในรูป */
    border: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.product-term-carousel-dot:hover {
    background-color: #A0A0A0;
    transform: scale(1.1);
}

.product-term-carousel-dot.active {
    width: 55px; /* ความยาวแบบ pill +10% */
    height: 13px;
    border-radius: 6.5px; /* ทำให้เป็น pill shape */
    background-color: var(--term-list-primary); /* สีแดงเหมือนในรูป */
    transform: none;
}

.product-term-carousel-dot.active:hover {
    background-color: var(--term-list-primary-dark);
    transform: none;
}

.product-term-carousel-dot:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 0, 0, 0.3);
}

.product-term-carousel-dot:active {
    transform: scale(0.95);
}

/* Responsive ตาม breakpoints - ปรับขนาดภาพและจำนวน items */
@media (max-width: 1200px) {
    .product-term-carousel-item {
        /* กำหนดไว้แล้วโดย JavaScript - ไม่ต้องกำหนดซ้ำ */
    }
}

@media (max-width: 992px) {
    .product-term-carousel-item {
        /* กำหนดไว้แล้วโดย JavaScript - ไม่ต้องกำหนดซ้ำ */
    }
}

@media (max-width: 768px) {
    .product-term-carousel-outer {
        padding: 0 40px;
    }
    
    .product-term-card-image {
        height: 90px; /* เพิ่มขนาดภาพให้ใหญ่ขึ้น */
        width: 90px; 
    }
    
    .product-term-card-placeholder .dashicons {
        font-size: 36px;
        width: 36px;
        height: 36px;
    }
    
    .product-term-carousel-prev,
    .product-term-carousel-next {
        width: 30px;
        height: 30px;
    }
    
    .product-term-carousel-prev svg,
    .product-term-carousel-next svg {
        width: 14px;
        height: 14px;
    }
    
    /* เพิ่มพื้นที่ให้กับ card เพื่อรองรับภาพใหญ่ขึ้น */
    .product-term-card {
        padding: 12px 8px;
    }
    
    /* ===== Responsive Pagination Dots ===== */
    .product-term-carousel-pagination {
        gap: 8px;
    }
    
    .product-term-carousel-dot {
        width: 11px;
        height: 11px;
    }
    
    .product-term-carousel-dot.active {
        width: 45px;
        height: 11px;
        border-radius: 5.5px;
    }
}

@media (max-width: 576px) {
    .product-term-carousel-outer {
        padding: 0 30px;
    }
    
    .product-term-card-image {
        height: 80px; /* เพิ่มขนาดภาพให้ใหญ่ขึ้นสำหรับ Mobile */
        width: 80px;
    }
    
    /* แก้ไขการซ่อนไอเทมที่เกินกว่า 2 รายการ */
    .product-term-carousel-item {
        flex: 0 0 calc(50% - 5px) !important; /* บังคับให้แสดง 2 รายการต่อแถวเสมอ */
        min-width: calc(50% - 5px) !important;
    }
    
    .product-term-card-title {
        font-size: 13px; /* ลดขนาดตัวหนังสือเล็กน้อย */
    }
    
    .product-term-card-placeholder .dashicons {
        font-size: 32px;
        width: 32px;
        height: 32px;
    }
    
    /* ===== Mobile Pagination Dots ===== */
    .product-term-carousel-pagination {
        gap: 7px;
    }
    
    .product-term-carousel-dot {
        width: 10px;
        height: 10px;
    }
    
    .product-term-carousel-dot.active {
        width: 40px;
        height: 10px;
        border-radius: 5px;
    }
}

/* อนิเมชั่นสำหรับ Loading */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.product-term-carousel.loading {
    opacity: 0.7;
}

.product-term-carousel.loaded {
    animation: fadeIn 0.5s ease forwards;
}