/* === Style cho nút yêu thích === */
.my-wishlist-button {
    cursor: pointer;
    margin-top: 15px;
    padding: 10px 15px;
    border: 1px solid #dcdcdc;
    background-color: #f9f9f9;
    color: #333;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.my-wishlist-button:hover {
    background-color: #f0f0f0;
    border-color: #c0c0c0;
}
.my-wishlist-button.in-wishlist {
    background-color: #d90429;
    color: #fff;
    border-color: #d90429;
    cursor: default;
}
.my-wishlist-button.loading {
    opacity: 0.7;
    cursor: wait;
}

/* === Icon Yêu thích trên Header === */
.menu-item-wishlist {
    display: flex;
    align-items: center;
}
.my-wishlist-icon {
    position: relative;
    display: inline-flex;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    fill: none; /* Mặc định icon header không tô màu */
}
.my-wishlist-icon .wishlist-item-count {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: #d90429;
    color: #fff;
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
/*
.my-wishlist-icon.is-empty .wishlist-item-count {
    display: none;
}
*/

/* === Popup Container === */
.wishlist-popup {
    position: absolute;
    width: 376px;
    z-index: 100000;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.2s, opacity 0.2s, transform 0.2s;
    transform: translateY(10px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.wishlist-popup.is-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}
.wishlist-popup__content {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 80vh;
}
.wishlist-popup__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.wishlist-popup__header h3 {
    margin: 0;
    font-size: 1em;
}
.wishlist-close {
    background: none !important;
    border: none !important;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
    color: #555;
    transition: color 0.2s;
}
.wishlist-close:hover {
    color: #111;
}
.wishlist-popup__body {
    overflow-y: auto;
    padding: 10px 20px;
    max-height: 380px;
    flex-grow: 1;
}
.wishlist-popup__footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background-color: #f9f9f9;
    flex-shrink: 0;
}
.wishlist-popup__footer .button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    background-color: #d90429;
    color: #fff;
    text-decoration: none;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
}

/* === Items bên trong Popup & Trang Yêu thích === */
.wishlist-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}
.wishlist-item:last-child {
    border-bottom: none;
}
.wishlist-item__image {
    flex-shrink: 0;
}
.wishlist-item__image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 1px solid #eee;
}
.wishlist-item__details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* Quan trọng: Cho phép text-overflow hoạt động đúng trong flexbox */
}
.wishlist-item__name {
    font-weight: bold;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.wishlist-item__name:hover {
    color: #d90429;
}
.wishlist-item__price {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 10px;
    font-weight: 600;
    font-size: 12px;
    color: #000000;
}
.wishlist-item__actions {
    margin-top: 4px;
    font-size: 11px;
}
.wishlist-item__actions .wishlist-item__remove {
    color: #0073aa;
    text-decoration: underline;
    cursor: pointer;
}
.wishlist-item__actions .wishlist-item__remove:hover {
    color: #d90429;
}

/* CSS cho mô tả ngắn */
.wishlist-item__short-desc {
    font-size: 12px;
    color: #555;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Reset margin của thẻ <p> nếu có trong mô tả ngắn */
.wishlist-item__short-desc p {
    margin: 0;
}


.wishlist-empty {
    text-align: center;
    padding: 40px 20px;
    color: #777;
    font-size: 14px;
}

/* === Loader Spinner === */
.wishlist-popup__loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px; /* Để bo tròn theo content */
}
@keyframes spin { to { transform: rotate(360deg); } }
.wishlist-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #d90429;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* === Style cho icon trái tim trên trang sản phẩm === */
.single-product-wishlist-icon {
    display: inline-block;
    cursor: pointer;
    color: #333; /* Màu mặc định cho viền (stroke) */
    transition: all 0.2s ease;
    margin-top: 15px;
    line-height: 1;
    fill: none; /* Mặc định không tô màu (nền trong suốt) */
    border: none;
    background-color: transparent;
    padding: 0;
}

.single-product-wishlist-icon:hover {
    color: #d90429; /* Màu khi di chuột qua */
    background-color: transparent; /* Đảm bảo nền không đổi màu khi hover */
}

/* Quan trọng: Tô màu đầy cho icon khi được yêu thích */
.single-product-wishlist-icon.in-wishlist {
    color: #d90429; /* Màu đỏ cho viền */
    fill: #d90429;   /* Màu đỏ để tô đầy */
    background-color: transparent; /* Đảm bảo nền không đổi màu */
    border: none;
}

/* Style khi đang tải */
.single-product-wishlist-icon.loading {
    opacity: 0.5;
    cursor: wait;
}

/* === Style cho trang Yêu thích (/wishlist) === */
#my-wishlist-page {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    /* NÂNG CẤP: Thay đổi padding để thêm khoảng cách lề trái/phải */
    padding: 2em 15px; 
}

#my-wishlist-page .woocommerce-products-header {
    margin-bottom: 2em;
}

#my-wishlist-page .wishlist-items-container .wishlist-item {
    padding: 20px 0;
}

/* Hiệu ứng khi xóa item trên trang wishlist */
.wishlist-item.removing {
    transition: opacity 0.3s ease-out;
}

/*
==========================================================================
 BỔ SUNG: Tinh chỉnh bố cục trang Yêu thích theo yêu cầu
==========================================================================
*/

/* Áp dụng riêng cho các sản phẩm trên trang /wishlist */
#my-wishlist-page .wishlist-item {
    /* Căn các thành phần (ảnh, chi tiết, giá) ở trên cùng */
    align-items: flex-start; 
}

#my-wishlist-page .wishlist-item__details {
    /* Bỏ thiết lập mặc định để nó không tự động giãn ra */
    flex-grow: 0;
    
    /* Thiết lập chiều rộng chiếm khoảng 45% container */
    flex-basis: 45%; 
    
    /* Đặt giới hạn chiều rộng tối đa để không quá dài trên màn hình lớn */
    max-width: 450px; 
}

#my-wishlist-page .wishlist-item__price {
    /* Tự động đẩy phần giá về cuối dòng */
    margin-left: auto;
    
    /* Căn phải cho giá tiền */
    text-align: right;

    /* Thêm khoảng cách bên trái để không dính vào phần mô tả */
    padding-left: 20px;
}

/*
==========================================================================
 SỬA: Thêm và định dạng nút "Thêm vào giỏ hàng"
==========================================================================
*/
#my-wishlist-page .wishlist-item__actions {
    /* SỬA: Xếp các nút theo chiều dọc và căn trái */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px; /* Khoảng cách giữa 2 nút */
    margin-top: 10px;
}

/* Định dạng chung cho nút của WooCommerce */
#my-wishlist-page .wishlist-item__actions .button {
    /* Reset lề mặc định */
    margin: 0 !important;

    /* SỬA: Tùy chỉnh giao diện theo yêu cầu */
    background-color: #d90429; /* Màu đỏ */
    color: #fff !important;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 11px; /* Sửa kích thước font */
    line-height: 1.5;
    border: none;
}

#my-wishlist-page .wishlist-item__actions .button:hover {
    background-color: #b80021; /* Sửa thành màu đỏ sẫm hơn */
    color: #fff !important;
}

/* Trạng thái loading và đã thêm của nút AJAX */
#my-wishlist-page .wishlist-item__actions .button.loading {
    opacity: 0.7;
    background-color: #d90429; /* Sửa thành màu đỏ */
}

#my-wishlist-page .wishlist-item__actions .added_to_cart {
   display: none !important; /* Luôn ẩn link "Xem giỏ hàng" sau khi thêm */
}

/*
==========================================================================
 MỚI: Ẩn nút "Thêm vào giỏ" & "Lựa chọn tùy chọn" khỏi POPUP
==========================================================================
*/
#wishlist-popup .wishlist-item__actions .button {
    display: none !important;
}

/* Căn chỉnh lại link "Xóa" trong popup cho đẹp */
#wishlist-popup .wishlist-item__actions {
    display: block;
    margin-top: 4px;
}

/*
==========================================================================
 MỚI: Giảm kích thước font-size cho tiêu đề "Danh sách Yêu thích"
==========================================================================
*/

/* Tiêu đề trên trang /wishlist */
#my-wishlist-page .woocommerce-products-header__title {
    font-size: 20px;
}

/* Tiêu đề trong popup */
#wishlist-popup .wishlist-popup__header h3 {
    font-size: 16px;
}

/*
==========================================================================
 MỚI: Thêm khoảng cách cho khu vực đăng nhập của khách trong popup
==========================================================================
*/
.wishlist-guest-prompt {
    padding: 45px 0px; /* Thêm đệm trên/dưới 25px, trái/phải 20px */
    text-align: center;
}

/*
==========================================================================
 MỚI: Căn giữa khu vực đăng nhập của khách trên trang Yêu thích
==========================================================================
*/
.wishlist-guest-prompt-page {
    text-align: center;
    padding: 2em 0; /* Thêm một chút khoảng đệm trên dưới cho đẹp hơn */
}