/**
 * Article Carousel Loop Styles
 * เวอร์ชัน: 1.0.2
 * ธีม: Rosso Corsa (แดง) - ปรับปรุง Arrow UI
 */

/* ===== Variables ===== */
:root {
    --rosso-corsa: #D40000;
    --rosso-dark: #990000;
    --rosso-light: #FF3333;
    --rosso-very-light: #FFEEEE;
    --white: #FFFFFF;
    --black: #000000;
    --gray-100: #F8F9FA;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #6C757D;
    --gray-700: #495057;
    --gray-800: #343A40;
    --gray-900: #212529;
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

/* ===== Container ===== */
.article-carousel-container {
    position: relative;
    width: 100%;
    margin: 2rem auto;
    padding: 0 70px; /* เพิ่ม padding ซ้าย-ขวาเพื่อไม่ให้ Arrow ทับ CardItem */
    overflow: visible; /* เปลี่ยนจาก hidden เป็น visible */
    border-radius: var(--border-radius);
}

.article-carousel-inner {
    position: relative;
    width: 100%;
    overflow: hidden; /* ใช้ overflow hidden ที่นี่แทน */
    border-radius: var(--border-radius);
}

/* ===== Track ===== */
.article-carousel-track {
    display: flex;
    transition: transform 0.5s ease;
    min-height: 250px;
}

/* ===== Items ===== */
.article-carousel-item {
    flex: 0 0 auto;
    width: 33.333%; /* Default, will be overridden by JS */
    padding: 15px;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.article-carousel-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: var(--gray-800);
    background-color: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.article-carousel-link:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.article-carousel-link:focus {
    outline: 2px solid var(--rosso-corsa);
    outline-offset: 2px;
}

/* Thumbnail */
.article-carousel-thumbnail {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
    overflow: hidden;
    background-color: var(--gray-200);
}

.article-carousel-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}

.article-carousel-link:hover .article-carousel-thumbnail img {
    transform: scale(1.05);
}

/* Title */
.article-carousel-title {
    padding: 15px;
    position: relative;
}

.article-carousel-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--gray-800);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    max-height: 2.8em; /* 2 lines × line-height */
    transition: color var(--transition-speed);
}

.article-carousel-link:hover .article-carousel-title h3 {
    color: var(--rosso-corsa);
}

/* After title decorative line */
.article-carousel-title:after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background-color: var(--rosso-corsa);
    margin-top: 10px;
    transition: width var(--transition-speed);
}

.article-carousel-link:hover .article-carousel-title:after {
    width: 60px;
}

/* ===== Navigation Arrows - ปรับปรุงใหม่ ===== */
.article-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;          /* เพิ่มขนาดเป็น 50px */
    height: 50px;         /* เพิ่มขนาดเป็น 50px */
    border-radius: 50%;   /* ทำให้เป็นวงกลมสมบูรณ์ */
    background-color: var(--white);  /* พื้นหลังสีขาว */
    color: var(--rosso-corsa);       /* สีไอคอนเป็นสีแดง */
    border: 1px solid var(--gray-300); /* เพิ่ม border 1px */
    cursor: pointer;
    z-index: 15;          /* เพิ่ม z-index */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); /* เพิ่มเงาให้ชัดขึ้น */
    backdrop-filter: blur(10px); /* เพิ่มเอฟเฟกต์ blur */
}

.article-carousel-arrow:hover {
    background-color: var(--rosso-corsa);  /* เปลี่ยนพื้นหลังเป็นสีแดงตอน hover */
    color: var(--white);                   /* เปลี่ยนสีไอคอนเป็นสีขาวตอน hover */
    border-color: var(--rosso-corsa);      /* เปลี่ยนสี border ตอน hover */
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(212, 0, 0, 0.3); /* เงาสีแดงตอน hover */
}

.article-carousel-arrow:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 0, 0, 0.3);
}

.article-carousel-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.article-carousel-arrow svg {
    width: 24px;          /* เพิ่มขนาดไอคอน */
    height: 24px;         /* เพิ่มขนาดไอคอน */
    stroke-width: 2.5;    /* เพิ่มความหนาของเส้น */
}

.article-carousel-prev {
    left: 10px;           /* ปรับตำแหน่งจากขอบซ้าย */
}

.article-carousel-next {
    right: 10px;          /* ปรับตำแหน่งจากขอบขวา */
}

/* ===== Navigation Dots ===== */
.article-carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 10px;
    gap: 10px;
}

/* Hide dots when navigator_dot is set to "off" */
.article-carousel-container.no-dots .article-carousel-dots {
    display: none !important;
}

.article-carousel-dot {
    width: 13px; /* ขนาดปกติ +10% */
    height: 13px;
    border-radius: 50%;
    background-color: #C0C0C0; /* สีเทาเหมือนในรูป */
    border: none;
    margin: 0;
    padding: 0;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    position: relative;
}

.article-carousel-dot:hover {
    background-color: #A0A0A0;
    transform: scale(1.1);
}

.article-carousel-dot.active {
    width: 55px; /* ความยาวแบบ pill +10% */
    height: 13px;
    border-radius: 6.5px; /* ทำให้เป็น pill shape */
    background-color: var(--rosso-corsa); /* สีแดงเหมือนในรูป */
    transform: none;
}

.article-carousel-dot.active:hover {
    background-color: var(--rosso-dark);
    transform: none;
}

.article-carousel-dot:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 0, 0, 0.3);
}

.article-carousel-dot:active {
    transform: scale(0.95);
}

/* ===== Responsive Navigation Dots ===== */
@media screen and (max-width: 768px) {
    .article-carousel-dots {
        gap: 8px;
    }
    
    .article-carousel-dot {
        width: 11px;
        height: 11px;
    }
    
    .article-carousel-dot.active {
        width: 45px;
        height: 11px;
        border-radius: 5.5px;
    }
}

@media screen and (max-width: 576px) {
    .article-carousel-dots {
        margin-top: 15px;
        gap: 7px;
    }
    
    .article-carousel-dot {
        width: 10px;
        height: 10px;
    }
    
    .article-carousel-dot.active {
        width: 40px;
        height: 10px;
        border-radius: 5px;
    }
}

/* ===== Loading State ===== */
.article-carousel-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed);
}

.article-carousel-container.loading .article-carousel-loading {
    opacity: 1;
    visibility: visible;
}

.article-carousel-loader {
    width: 50px;
    height: 50px;
    border: 4px solid var(--gray-200);
    border-radius: 50%;
    border-top-color: var(--rosso-corsa);
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Skeleton Loading ===== */
.article-carousel-item.skeleton {
    background-color: transparent;
    box-shadow: none;
}

.skeleton-image {
    position: relative;
    background-color: var(--gray-200);
    overflow: hidden;
}

.skeleton-image:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    margin: 8px 0;
    background-color: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.skeleton-text:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== Error State ===== */
.article-carousel-error {
    width: 100%;
    padding: 2rem;
    text-align: center;
    color: var(--rosso-corsa);
    font-weight: bold;
    background-color: var(--rosso-very-light);
    border: 1px solid var(--rosso-light);
    border-radius: var(--border-radius);
}

/* ===== Responsive Styles ===== */
@media screen and (max-width: 992px) {
    .article-carousel-container {
        padding: 0 60px; /* ลด padding บน tablet */
    }
    
    .article-carousel-arrow {
        width: 45px;
        height: 45px;
    }
    
    .article-carousel-arrow svg {
        width: 22px;
        height: 22px;
    }
    
    .article-carousel-title h3 {
        font-size: 15px;
    }
}

@media screen and (max-width: 768px) {
    .article-carousel-container {
        margin: 1.5rem auto;
        padding: 0 50px; /* ลด padding บน mobile */
    }
    
    .article-carousel-item {
        padding: 10px;
    }
    
    .article-carousel-title {
        padding: 12px;
    }
    
    .article-carousel-arrow {
        width: 40px;
        height: 40px;
    }
    
    .article-carousel-arrow svg {
        width: 20px;
        height: 20px;
    }
}

@media screen and (max-width: 576px) {
    .article-carousel-container {
        margin: 1rem auto;
        padding: 0 45px; /* ลด padding บน small mobile */
    }
    
    .article-carousel-title h3 {
        font-size: 14px;
    }
    
    .article-carousel-dots {
        margin-top: 15px;
    }
    
    .article-carousel-arrow {
        width: 36px;
        height: 36px;
    }
    
    .article-carousel-arrow svg {
        width: 18px;
        height: 18px;
    }
    
    .article-carousel-prev {
        left: 5px;
    }
    
    .article-carousel-next {
        right: 5px;
    }
    
    .article-carousel-dot {
        width: 5px; /* ลดจาก 10px เหลือ 5px (50%) */
        height: 5px; /* ลดจาก 10px เหลือ 5px (50%) */
        margin: 0 4px;
    }
    
    .article-carousel-dot.active {
        width: 6px; /* ลดจาก 12px เหลือ 6px (50%) */
        height: 6px; /* ลดจาก 12px เหลือ 6px (50%) */
    }
}