/* Main Modal/Container (Reset for full page view) */
.t888-compare-modal {
    background: #fff;
    /* Removed card styling to match "clean interface" request */
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    margin: 0;
    overflow: visible;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1f2937;
    animation: t888FadeIn 0.3s ease-out;
}

@keyframes t888FadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.t888-compare-header {
    padding: 0 0 40px 0; /* Clean adjustment */
    border-bottom: none;
    display: block;
}

.t888-compare-title {
    font-size: 42px; /* Bigger title like Image 1 */
    font-family: 'Georgia', serif; /* Elegant font matching image 4/1 style */
    font-weight: 400;
    color: #111;
    margin: 0;
    letter-spacing: -0.01em;
}

/* Close Interface Button */
/* Close Interface Button (Unified) */
.t888-modal-close,
.t888-close-interface {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    width: 40px !important; /* Slightly larger container */
    height: 40px !important;
    cursor: pointer;
    z-index: 2147483647 !important; /* Max Z-Index */
    color: #333;
    transition: transform 0.2s;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    box-shadow: none !important;
}
.t888-modal-close:hover,
.t888-close-interface:hover {
    transform: rotate(90deg);
    color: #000;
}
.t888-modal-close svg,
.t888-close-interface svg,
.t888-close-icon {
    width: 25px !important; /* Icon size 25px */
    height: 25px !important;
    stroke-width: 2px !important;
    display: block !important;
}


/* Table Structure */
.t888-compare-table-wrapper {
    overflow-x: auto;
    padding-bottom: 20px;
}

.t888-compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.t888-compare-table th, 
.t888-compare-table td {
    padding: 30px 40px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid #eee; /* Lighter border */
}

.t888-compare-table th {
    text-align: left;
    font-weight: 700;
    color: #000;
    white-space: nowrap;
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 10;
    width: 200px;
    font-size: 16px;
    border-right: 1px solid #f9f9f9; /* Subtle separator */
}

/* Product Info */
.t888-product-image-container {
    position: relative;
    width: 280px; /* Wider */
    height: 400px; /* Much taller vertical rectangle */
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: all 0.3s ease;
    /* No default bg, plain white usually */
}

.t888-product-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    z-index: 1;
    transition: transform 0.3s ease;
}

/* Overlay using pseudo-element to cover everything including the image */
.t888-product-image-container::after {
    content: '';
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: rgba(0,0,0,0.4); /* Dark grey overlay */
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5; /* Above image */
    pointer-events: none; /* Allow clicks to pass through if needed, though button handles click */
}

.t888-product-image-container:hover::after {
    opacity: 1;
}

/* Remove button - Bottom Right White Square */
.t888-remove-item {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: #fff;
    color: #000;
    width: 40px; /* Slightly larger button */
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s ease;
    text-decoration: none;
    z-index: 10; /* Above overlay */
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    top: auto;
}

.t888-product-image-container:hover .t888-remove-item {
    opacity: 1;
    transform: translateY(0);
}
.t888-remove-item:hover {
    background: #f0f0f0;
}

/* Product Titles & Meta */
.t888-product-title {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
}

.t888-price {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    color: #c08d5d; /* Brownish gold like Image 1/2 */
    font-weight: 700;
}
.t888-price del {
    color: #aaa;
    margin-right: 5px;
    font-weight: 400;
    font-size: 14px;
}

/* Scrollbar styling */
.t888-compare-table-wrapper::-webkit-scrollbar {
    height: 8px;
}
.t888-compare-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.t888-compare-table-wrapper::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
.t888-compare-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Compare Button in loop */
/* --- BẮT BUỘC NÚT NẰM NGANG (INLINE) --- */
.t888-compare-button-wrapper {
    display: inline-flex !important;
    vertical-align: middle !important;
    margin-left: 5px !important;  /* Khoảng cách với nút trái tim */
    margin-right: 5px !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    line-height: 1 !important;
}

.t888-compare-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;           /* Kích thước bằng nút trái tim */
    height: 40px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;    /* Bo góc nhẹ */
    color: #333;
    transition: all 0.3s;
    padding: 0;
}

.t888-compare-button:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

.t888-icon-container {
    width: 20px;
    height: 20px;
    line-height: 0;
}

/* Fix cho trang chi tiết: Ép form cart dàn ngang */
.woocommerce div.product form.cart, 
.product form.cart {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
}

/* --- FIX LỖI TỤT DÒNG DO NÚT WISHLIST "BLOCK" --- */
/* YITH Wishlist thường là thẻ DIV display: block, ta phải ép nó thành inline */
.yith-wcwl-add-to-wishlist, 
.wishlist_button, 
.tinv-wishlist {
    display: inline-block !important; /* Hoặc inline-flex */
    vertical-align: middle !important;
    margin-bottom: 0 !important;
    margin-right: 5px !important; /* Tạo khoảng cách với nút Compare */
    width: auto !important;
    line-height: normal !important;
}

/* Đảm bảo nút bên trong YITH cũng căn giữa */
.yith-wcwl-add-to-wishlist a,
.yith-wcwl-add-to-wishlist .yith-wcwl-add-button {
    display: inline-block !important;
    vertical-align: middle !important;
}

/* Fix chung cho container chứa các nút hành động nếu theme dùng flex */
.product-action-buttons,
.cart,
.summary .cart {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
}

/* Nếu theme dùng float */
.yith-wcwl-add-to-wishlist {
    float: none !important;
}

.t888-icon-container {
    width: 18px; /* Slightly smaller to match whitespace in image */
    height: 18px;
}

.t888-icon-container svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5; /* Thinner, cleaner lines */
}

/* Toggle visibility of icons */
.t888-icon-active {
    display: none;
}
.t888-added .t888-icon-default {
    display: none;
}
.t888-added .t888-icon-active {
    display: block;
}

/* --- MODAL POPUP (FULL SCREEN WHITE) --- */
#t888-compare-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 99999999;
    display: block;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* FIX: Only 1 Vertical Scrollbar for the whole modal */
    overflow-y: auto; 
    overflow-x: hidden;
}

#t888-compare-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Hide Body Scroll when Modal is Open */
body.t888-modal-open {
    overflow: hidden !important;
}

#t888-compare-modal-content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 40px;
    position: relative;
    /* No overflow here to prevent double scrollbar */
}

/* --- TOAST NOTIFICATION --- */
#t888-toast {
    visibility: hidden; 
    min-width: 250px;
    max-width: 350px;
    background-color: #333;
    color: #fff; 
    text-align: center;
    border-radius: 4px; 
    padding: 16px;
    position: fixed;
    z-index: 100000001; 
    left: 50%;
    bottom: 30px; 
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#t888-toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}
#t888-toast svg {
    width: 20px;
    height: 20px;
    stroke: #4CAF50; /* Green success color */
}

/* --- ADD TO CART STYLING FIXES --- */
/* Remove default "product loop" borders/padding added by shortcode */
.t888-compare-table td .woocommerce.add_to_cart_inline {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.t888-compare-table td .button.add_to_cart_button {
    background: #111 !important;
    color: #fff !important;
    border: none !important;
    padding: 10px 20px !important;
    font-weight: 500 !important;
    border-radius: 0 !important; /* Square/Sharp as per user image preference */
    transition: background 0.3s;
}
.t888-compare-table td .button.add_to_cart_button:hover {
    background: #333 !important;
}
/* Loading Spinner fix for button */
.t888-compare-table td .button.loading {
    opacity: 0.7;
    position: relative;
}
.t888-compare-table td .button.loading::after {
    top: 50%;
    margin-top: -8px; 
}

/* FIX: Table Scrolling - Only 1 Horizontal Scrollbar */
.t888-compare-table-wrapper {
    width: 100%;
    overflow-x: auto; /* This gives the horizontal scroll */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

/* Adjust button placement if theme differs - generic fix */
.woocommerce ul.products li.product .button {
    vertical-align: middle;
}

/* --- CSS CHO NÚT COMPARE Ở TRANG SINGLE PRODUCT --- */

/* 1. Đảm bảo khu vực chứa nút (Form Cart) dàn hàng ngang */
.woocommerce div.product form.cart {
    display: flex !important;
    align-items: center; /* Căn giữa theo chiều dọc */
    flex-wrap: wrap;
    gap: 10px; /* Khoảng cách giữa các nút */
}

/* 2. Style cho wrapper của nút Compare để nó nằm inline */
.single-product .t888-compare-button-wrapper {
    display: inline-flex !important;
    margin: 0 !important; /* Reset margin */
    vertical-align: middle;
}

/* 3. Style nút cho giống nút Wishlist (vuông/tròn tùy theme) */
.single-product .t888-compare-button {
    width: 40px;  /* Kích thước bằng nút Wishlist thường gặp */
    height: 40px;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px; /* Bo góc nhẹ */
    background: #fff;
    color: #333;
}

.single-product .t888-compare-button:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* --- ẨN TUYỆT ĐỐI Ở RELATED PRODUCTS (Lớp bảo vệ thứ 2) --- */
/* Đề phòng PHP lọt lưới, CSS này sẽ ẩn tiệt nút compare ở Related/Upsell */
.related.products .t888-compare-button-wrapper,
.up-sells.products .t888-compare-button-wrapper,

/* --- LINK STYLE OVERRIDES (Remove Box/Button styling) --- */
/* When 'Textual Link' is selected, remove all button-like styles */
.t888-style-link .t888-compare-button,
.single-product .t888-compare-button-wrapper.t888-style-link .t888-compare-button {
    width: auto !important;
    height: auto !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    text-decoration: underline !important; 
    color: inherit !important; /* Inherit form body or use #333 */
    display: inline !important;
    box-shadow: none !important;
}

.t888-style-link .t888-compare-button:hover,
.single-product .t888-compare-button-wrapper.t888-style-link .t888-compare-button:hover {
    background: transparent !important;
    color: #000 !important;
    text-decoration: none !important; /* Optional hover effect */
}


/* --- CHECKBOX STYLE OVERRIDES --- */
.t888-style-checkbox .t888-compare-button,
.single-product .t888-compare-button-wrapper.t888-style-checkbox .t888-compare-button {
    width: auto !important;
    height: auto !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    color: inherit !important;
    cursor: pointer;
    text-decoration: none !important;
}

/* Mock Checkbox Square */
.t888-checkbox-mock {
    width: 16px;
    height: 16px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 2px;
    display: inline-block;
    position: relative;
    margin-right: 6px;
    transition: all 0.2s;
}

/* Hover State */
.t888-style-checkbox .t888-compare-button:hover .t888-checkbox-mock {
    border-color: #333;
}

/* Checked/Added State */
.t888-style-checkbox .t888-compare-button.t888-added .t888-checkbox-mock {
    background: #333;
    border-color: #333;
}
.t888-style-checkbox .t888-compare-button.t888-added .t888-checkbox-mock::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
