/*! Flickity v2.3.0
https://flickity.metafizzy.co
---------------------------------------------- */

.flickity-enabled {
  position: relative;
}

.flickity-enabled:focus { outline: none; }

.flickity-viewport {
  overflow: hidden;
  position: relative;
  height: 100%;
}

.flickity-slider {
  position: absolute;
  width: 100%;
  height: 100%;
}

/* draggable */

.flickity-enabled.is-draggable {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.flickity-enabled.is-draggable .flickity-viewport {
  cursor: move;
  cursor: -webkit-grab;
  cursor: grab;
}

.flickity-enabled.is-draggable .flickity-viewport.is-pointer-down {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

/* ---- flickity-button ---- */

.flickity-button {
  position: absolute;
  background: hsla(0, 0%, 100%, 0.75);
  border: none;
  color: #333;
}

.flickity-button:hover {
  background: white;
  cursor: pointer;
}

.flickity-button:focus {
  outline: none;
  box-shadow: 0 0 0 5px #19F;
}

.flickity-button:active {
  opacity: 0.6;
}

.flickity-button:disabled {
  opacity: 0.3;
  cursor: auto;
  pointer-events: none;
}

.flickity-button-icon {
  fill: currentColor;
}

/* ---- previous/next buttons ---- */

.flickity-prev-next-button {
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translateY(-50%);
}

.flickity-prev-next-button.previous { left: 10px; }
.flickity-prev-next-button.next { right: 10px; }

.flickity-rtl .flickity-prev-next-button.previous {
  left: auto;
  right: 10px;
}
.flickity-rtl .flickity-prev-next-button.next {
  right: auto;
  left: 10px;
}

.flickity-prev-next-button .flickity-button-icon {
  position: absolute;
  left: 20%;
  top: 20%;
  width: 60%;
  height: 60%;
}

/* ---- page dots ---- */

.flickity-page-dots {
  position: absolute;
  width: 100%;
  bottom: -25px;
  padding: 0;
  margin: 0;
  list-style: none;
  text-align: center;
  line-height: 1;
}

.flickity-rtl .flickity-page-dots { direction: rtl; }

.flickity-page-dots .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 8px;
  background: #333;
  border-radius: 50%;
  opacity: 0.25;
  cursor: pointer;
}

.flickity-page-dots .dot.is-selected {
  opacity: 1;
}

/* ===========================================
   CUSTOM PRODUCT DISPLAY STYLES
   =========================================== */

.cpd-section-container {
    margin-bottom: 20px;
    position: relative;
    background-color: #fff;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* === FIX: Header Layout - Title bên trái, Links bên phải === */
.cpd-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: nowrap; /* <-- THAY ĐỔI: Ép nằm trên 1 hàng */
    gap: 15px;
}

.cpd-section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    text-transform: uppercase;
    flex: 1 1 auto; /* <-- THAY ĐỔI: Cho phép co giãn */
    min-width: 0; /* <-- THÊM: Đảm bảo co lại được */
    white-space: nowrap; /* <-- THÊM: Giữ title trên 1 hàng */
    overflow: hidden; /* <-- THÊM: Ẩn phần bị tràn */
    text-overflow: ellipsis; /* <-- THÊM: Hiển thị '...' */
}

.cpd-category-links {
    margin: 0;
    padding: 0;
    border: none;
    text-align: right;
    display: flex;
    align-items: center;
    flex-wrap: nowrap; /* <-- THAY ĐỔI: Giữ các link trên 1 hàng */
    gap: 15px;
    flex-shrink: 0; /* <-- THÊM: Không cho khối này co lại */
}

.cpd-category-links a {
    display: inline-block;
    margin: 0;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.cpd-category-links a:hover {
    color: var(--primary-color, #01a4ef);
}

.cpd-category-links a.cpd-view-more {
    font-weight: 600;
    color: var(--primary-color, #01a4ef);
}

.cpd-product-row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -10px;
    margin-right: -10px;
}

/* --- Featured Product --- */
.cpd-featured-product {
    width: 33.333%;
    padding: 0 10px;
    box-sizing: border-box;
    position: relative;
}

.cpd-featured-details {
    margin-bottom: 15px;
    border: 1px solid #eee;
    padding: 10px;
    background: #f9f9f9;
}

.cpd-attr-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #555;
}

.cpd-attr-item:last-child {
    margin-bottom: 0;
}

.cpd-attr-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
}

/* Example Icons - Replace with your actual paths */
.cpd-attr-cpu .cpd-attr-icon { 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="4" y="4" width="16" height="16" rx="2"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="1" x2="9" y2="4"/><line x1="15" y1="1" x2="15" y2="4"/><line x1="9" y1="20" x2="9" y2="23"/><line x1="15" y1="20" x2="15" y2="23"/><line x1="20" y1="9" x2="23" y2="9"/><line x1="20" y1="14" x2="23" y2="14"/><line x1="1" y1="9" x2="4" y2="9"/><line x1="1" y1="14" x2="4" y2="14"/></svg>'); 
}

.cpd-attr-pin .cpd-attr-icon { 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="1" y="6" width="18" height="12" rx="2" ry="2"/><line x1="23" y1="13" x2="19" y2="13"/></svg>'); 
}

.cpd-attr-screen .cpd-attr-icon { 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>'); 
}

.cpd-featured-image {
    margin-bottom: 10px;
    position: relative;
}

.cpd-featured-product img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Slider Container --- */
.cpd-slider-container {
    width: 66.666%;
    padding: 0 10px;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

/* === FIX: Full width slider when no featured product is selected === */
.cpd-product-row.cpd-no-featured-product .cpd-slider-container {
    width: 100%;
}

.cpd-product-slider {

}

/* === NEW: Tăng khoảng cách giữa các sản phẩm trong slider === */
.cpd-slider-item {
    padding: 15px; /* Tăng từ 10px lên 15px */
    box-sizing: border-box;
    text-align: center;
    position: relative;
}

.cpd-slider-item .cpd-slider-image {
    position: relative;
    margin-bottom: 10px;
    padding: 10px; /* Thêm padding để hình nhỏ lại */
    background: #fff;
}

.cpd-slider-item img {
    max-width: 85%; /* Giảm kích thước hình từ 100% xuống 85% */
    height: auto;
    display: block;
    margin: 0 auto;
}

/* --- General Product Styles --- */
.cpd-product-title {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 5px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: calc(1.3em * 2);
}

.cpd-featured-product .cpd-product-title {
    font-size: 16px;
}

.cpd-featured-product a,
.cpd-slider-item a {
    text-decoration: none;
    color: inherit;
}

.cpd-featured-product a:hover .cpd-product-title,
.cpd-slider-item a:hover .cpd-product-title {
     color: var(--primary-color, #01a4ef);
}

.cpd-price, 
.woocommerce ul.products li.product .price {
    color: red;
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 5px;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    justify-content: center;
}

.cpd-featured-product .cpd-price {
    justify-content: flex-start;
    font-size: 18px;
}

.cpd-price del, 
.woocommerce ul.products li.product .price del {
    order: 2;
    font-size: 12px;
    color: #888;
    font-weight: 400;
    margin-left: 10px;
    text-decoration: line-through;
    opacity: 0.8;
}

.cpd-price ins, 
.woocommerce ul.products li.product .price ins {
    order: 1;
    text-decoration: none;
    background: none;
}

/* Discount Badge */
.cpd-discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #ffcc00;
    color: #333;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    z-index: 2;
    line-height: 1.2;
}

/* ===========================================
   === NAVIGATION BUTTONS - GIỐNG HÌNH MẪU ===
   =========================================== */

.cpd-product-slider .flickity-prev-next-button {
    width: 48px;
    height: 80px; /* Hình chữ nhật cao */
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px; /* Bo góc nhẹ, không phải hình tròn */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    top: 50%;
    transform: translateY(-50%); /* Căn giữa theo chiều dọc */
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: background 0.2s ease, border-color 0.2s ease; /* Chỉ transition màu, KHÔNG transform */
    z-index: 10;
}

.cpd-product-slider .flickity-prev-next-button:hover {
    background: #fafafa;
    border-color: #d0d0d0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    /* KHÔNG scale, KHÔNG translateY thêm - giữ nguyên vị trí */
}

/* Vị trí cố định bên ngoài slider */
.cpd-product-slider .flickity-prev-next-button.previous {
    left: -30px; /* Nằm bên ngoài slider, bên trái */
}

.cpd-product-slider .flickity-prev-next-button.next {
    right: -30px; /* Nằm bên ngoài slider, bên phải */
}

/* Arrow icon styling - Màu xám nhạt */
.cpd-product-slider .flickity-prev-next-button .flickity-button-icon {
    position: absolute; 
    fill: #999;
    width: 40px;
    height: 40px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%); 
}

.cpd-product-slider .flickity-prev-next-button:hover .flickity-button-icon {
    fill: #666; /* Đậm hơn khi hover */
}

/* Ẩn hoàn toàn nút khi bị vô hiệu hóa */
.cpd-product-slider .flickity-button:disabled {
    display: none !important;
}

/* Ẩn hoàn toàn page dots */
.cpd-product-slider .flickity-page-dots {
    display: none !important;
}

/* --- Responsive Styles --- */
@media (max-width: 991px) {
    /* Header responsive - giữ nguyên layout nhưng có thể xuống dòng */
    .cpd-section-header {
        gap: 10px;
    }
    
    /* Adjust arrow position for tablet - vẫn giữ hình chữ nhật */
    .cpd-product-slider .flickity-prev-next-button {
        width: 44px;
        height: 70px;
    }
    
    .cpd-product-slider .flickity-prev-next-button.previous {
        left: -20px;
    }
    
    .cpd-product-slider .flickity-prev-next-button.next {
        right: -20px;
    }
}

@media (max-width: 767px) {
    /* === MOBILE: Ẩn category links, chỉ hiển thị title và "Xem thêm" === */
    .cpd-section-header {
        justify-content: space-between;
    }
    
    .cpd-category-links a:not(.cpd-view-more) {
        display: none; /* Ẩn tất cả category links trừ "Xem thêm" */
    }
    
    .cpd-category-links {
        gap: 0;
    }
    
    .cpd-featured-product {
        width: 100%;
        margin-bottom: 20px;
        padding: 0 10px;
    }
    
    .cpd-slider-container {
        width: 100%;
        padding: 0 10px;
    }
    
    /* JS will handle width, but ensure minimum */
    .cpd-slider-item {
        min-width: 45%;
        padding: 10px; /* Giảm padding trên mobile */
    }
    
    /* Smaller arrows on mobile - nằm BÊN TRONG slider */
    .cpd-product-slider .flickity-prev-next-button {
        width: 40px;
        height: 60px;
    }
    
    .cpd-product-slider .flickity-prev-next-button.previous {
        left: -20px; /* Bên trong slider */
    }
    
    .cpd-product-slider .flickity-prev-next-button.next {
        right: -20px; /* Bên trong slider */
    }
    
    .cpd-product-slider .flickity-prev-next-button .flickity-button-icon {
        width: 30px;
        height: 30px;
    }
    
    .cpd-section-container {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .cpd-section-title {
        font-size: 18px;
    }
    
    .cpd-product-title {
        font-size: 14px;
    }
    
    .cpd-price {
        font-size: 15px;
    }
    
    /* Even smaller arrows on very small screens */
    .cpd-product-slider .flickity-prev-next-button {
        width: 36px;
        height: 56px;
    }
}

/* Fix for slider initialization on mobile */
.cpd-product-slider:not(.flickity-enabled) .cpd-slider-item {
    display: inline-block;
    width: 50%;
    vertical-align: top;
}

@media (max-width: 767px) {
    .cpd-product-slider:not(.flickity-enabled) .cpd-slider-item {
        width: 100%;
        display: block;
    }
}

/* Ensure slider items are properly contained */
.cpd-product-slider {
    white-space: nowrap;
}

.cpd-product-slider.flickity-enabled {
    white-space: normal;
}

.cpd-slider-item {
    white-space: normal;
    vertical-align: top;
}