/* Custom Comparison CSS - Thế Giới Di Động style */

/* --- FLOATING COMPARE BAR --- */
#custom-compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 99999;
    padding: 15px 0;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-top: 1px solid #eaeaea;
    display: none; /* Controlled by JS */
}

#custom-compare-bar.collapsed {
    transform: translateY(100%);
}

.compare-bar-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    position: relative;
}

.compare-bar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compare-bar-products {
    display: flex;
    gap: 15px;
    flex-grow: 1;
}

.compare-bar-item {
    position: relative;
    width: 200px;
    height: 90px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}

.compare-bar-item img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    flex-shrink: 0;
}

.compare-bar-item .item-info {
    flex-grow: 1;
    min-width: 0;
}

.compare-bar-item .item-title {
    font-size: 12px;
    color: #333333;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-bar-item .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #888888;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1.5px solid #fff;
    line-height: 1;
}

.compare-bar-item .remove-btn:hover {
    background: #d93939;
}

.compare-bar-empty {
    width: 200px;
    height: 90px;
    border: 1.5px dashed #ccc;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666666;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    box-sizing: border-box;
}

.compare-bar-empty:hover {
    border-color: #2f80ed;
    background: #f7faff;
    color: #2f80ed;
}

.compare-bar-empty .plus-icon {
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    margin-bottom: 4px;
}

.compare-bar-empty span {
    font-size: 12px;
}

.compare-bar-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
    flex-shrink: 0;
}

.compare-bar-actions .btn-so-sanh {
    background: #2f80ed;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    padding: 10px 24px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-transform: uppercase;
    text-decoration: none;
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(47, 128, 237, 0.2);
}

.compare-bar-actions .btn-so-sanh:hover {
    background: #1b66ca;
}

.compare-bar-actions .btn-xoa-tat-ca {
    font-size: 13px;
    color: #2f80ed;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.compare-bar-actions .btn-xoa-tat-ca:hover {
    text-decoration: underline;
}

.compare-bar-toggle {
    position: absolute;
    top: -44px;
    right: 30px;
    background: #ffffff;
    border: 1px solid #e4e9f0;
    border-radius: 50px;
    padding: 7px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #2f80ed;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: background 0.2s ease, box-shadow 0.2s ease;
    z-index: 1;
}

.compare-bar-toggle:hover {
    background: #f2f7ff;
    box-shadow: 0 3px 12px rgba(47, 128, 237, 0.18);
}

/* Khi thanh thu gọn: ẩn nút Thu gọn (đã có pill "So sánh" nổi thay thế) */
#custom-compare-bar.collapsed .compare-bar-toggle {
    display: none;
}

.compare-bar-toggle svg {
    width: 10px;
    height: 10px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

#custom-compare-bar.collapsed .compare-bar-toggle svg {
    transform: rotate(180deg);
}

/* Nút pill nổi "So sánh (N)" khi thanh so sánh thu gọn */
#compare-collapsed-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 99998;
    display: none;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    color: #2f80ed;
    border: 1px solid #cfe0fb;
    border-radius: 50px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

#compare-collapsed-btn.visible {
    display: inline-flex;
}

#compare-collapsed-btn:hover {
    background: #f2f7ff;
    box-shadow: 0 2px 6px rgba(47, 128, 237, 0.18);
}

#compare-collapsed-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
}

/* --- CUSTOM COMPARE PAGE --- */
.wd-custom-compare-page {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
    font-family: inherit;
}

.compare-page-header {
    margin-bottom: 25px;
}

.compare-page-header h1 {
    font-size: 22px;
    font-weight: bold;
    color: #333333;
    margin-bottom: 15px;
    line-height: 1.4;
}

.compare-diff-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-diff-toggle-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.compare-diff-toggle-wrap label {
    font-size: 14px;
    color: #666666;
    cursor: pointer;
    user-select: none;
}

/* --- COMPARE TABLE STYLE --- */
.compare-table-custom-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #cfcfcf;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.compare-table-custom {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 800px;
}

.compare-table-custom th,
.compare-table-custom td {
    padding: 15px;
    border-bottom: 1px solid #d8d8d8;
    border-right: 1px solid #d8d8d8;
    vertical-align: top;
    box-sizing: border-box;
}

.compare-table-custom th:last-child,
.compare-table-custom td:last-child {
    border-right: none;
}

/* Product Card Column Header */
.compare-col-header {
    width: 25%;
    position: relative;
    background: #ffffff;
}

.compare-col-header.label-column {
    width: 20%;
    background: #fcfcfc;
}

.compare-product-card {
    position: relative;
    text-align: left;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.compare-product-card .remove-product-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 22px;
    height: 22px;
    border: 1px solid #ccc;
    border-radius: 50%;
    color: #888888;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.compare-product-card .remove-product-btn:hover {
    background: #d93939;
    border-color: #d93939;
    color: #ffffff;
}

.compare-product-card .product-img-link {
    display: block;
    text-align: center;
    margin-bottom: 15px;
}

.compare-product-card .product-img-link img {
    height: 160px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.compare-product-card .product-img-link img:hover {
    transform: scale(1.05);
}

.compare-product-card .product-title {
    font-size: 14px;
    font-weight: bold;
    color: #333333;
    line-height: 1.4;
    margin: 0 0 8px 0;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.compare-product-card .product-title a {
    color: #333333;
    text-decoration: none;
}

.compare-product-card .product-title a:hover {
    color: #2f80ed;
}

.compare-product-card .price-row {
    margin-bottom: 8px;
}

.compare-product-card .sale-price {
    font-size: 16px;
    font-weight: bold;
    color: #d93939;
}

.compare-product-card .regular-price {
    font-size: 12px;
    color: #999999;
    text-decoration: line-through;
    margin-left: 5px;
}

.compare-product-card .discount-percent {
    font-size: 12px;
    color: #d93939;
    font-weight: 500;
}

.compare-product-card .rating-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #777777;
    margin-top: auto;
}

.compare-product-card .rating-row .stars {
    color: #ffb400;
}

/* Empty Column Add Product Card */
.compare-add-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    position: relative;
}

.compare-add-slot:hover {
    border-color: #2f80ed;
    background: #f7faff;
}

.compare-add-slot .plus-icon {
    font-size: 32px;
    color: #2f80ed;
    margin-bottom: 10px;
    font-weight: 300;
}

.compare-add-slot span {
    font-size: 14px;
    color: #555555;
    font-weight: 500;
}

/* Search autocomplete wrapper in column */
.compare-search-wrapper {
    position: relative;
    width: 100%;
    margin-top: 15px;
    display: none; /* Shows when clicked */
}

.compare-search-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.compare-search-input:focus {
    border-color: #2f80ed;
    outline: none;
    box-shadow: 0 0 5px rgba(47, 128, 237, 0.2);
}

.compare-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
    text-align: left;
}

.compare-search-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.2s ease;
}

.compare-search-item:last-child {
    border-bottom: none;
}

.compare-search-item:hover {
    background: #f2f7ff;
}

.compare-search-item img {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.compare-search-item .item-details {
    flex-grow: 1;
    min-width: 0;
}

.compare-search-item .item-name {
    font-size: 12px;
    font-weight: 500;
    color: #333333;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-search-item .item-price {
    font-size: 11px;
    color: #d93939;
    font-weight: bold;
}

/* Accordion Section Header Row */
.spec-group-header {
    background: #f7f7f7;
    cursor: pointer;
    user-select: none;
}

.spec-group-header td {
    font-size: 15px;
    font-weight: bold;
    color: #333333;
    padding: 12px 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: none;
}

.spec-group-header td span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spec-group-header td svg {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
    fill: #333;
}

.spec-group-header.collapsed td svg {
    transform: rotate(-90deg);
}

/* Individual spec rows */
.spec-row.hidden-row {
    display: none;
}

/* Tô màu xám nhẹ cho hàng thuộc tính có giá trị khác nhau */
.spec-row.spec-diff .spec-value-col {
    background: #f5f6f8;
}

.spec-label-col {
    background: #fdfdfd;
    font-weight: 600;
    color: #666666;
    font-size: 13.5px;
}

.spec-value-col {
    font-size: 13.5px;
    color: #333333;
    line-height: 1.6;
}

/* Key specs layout (So sánh nhanh) */
.key-spec-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.key-spec-list li {
    position: relative;
    padding-left: 12px;
    margin-bottom: 6px;
    font-size: 13.5px;
    color: #333333;
}

.key-spec-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #999999;
}

/* Diff highlight and hide visual animations */
.spec-row {
    transition: opacity 0.3s ease, height 0.3s ease;
}

/* Responsive adjustment */
@media (max-width: 768px) {
    .compare-bar-products {
        overflow-x: auto;
        padding-bottom: 5px;
    }
    .compare-bar-item, .compare-bar-empty {
        width: 150px;
        flex-shrink: 0;
    }
    .compare-bar-actions {
        margin-left: 10px;
    }
    .compare-bar-actions .btn-so-sanh {
        padding: 8px 15px;
        font-size: 12px;
    }
    .compare-table-custom th, .compare-table-custom td {
        padding: 10px;
    }
    .compare-product-card .product-img-link img {
        height: 110px;
    }
}

/* Toast Notification Style */
.compare-bar-toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 33, 33, 0.95);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    text-align: center;
    pointer-events: none;
}

/* --- POPUP "THÊM SẢN PHẨM" (đã xem gần nhất + tìm kiếm) --- */
body.cam-noscroll {
    overflow: hidden;
}

.compare-add-modal {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: none;
}

.compare-add-modal.open {
    display: block;
}

.compare-add-modal .cam-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.compare-add-modal .cam-dialog {
    position: relative;
    z-index: 1;
    width: min(900px, 92%);
    margin: 60px auto 30px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.compare-add-modal .cam-close {
    align-self: flex-end;
    background: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #333333;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transition: background 0.2s ease, color 0.2s ease;
}

.compare-add-modal .cam-close:hover {
    background: #f0f0f0;
    color: #d93939;
}

.compare-add-modal .cam-close .cam-close-x {
    font-size: 18px;
    line-height: 1;
}

.compare-add-modal .cam-panel {
    width: 100%;
    min-height: 60vh;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 10px;
    padding: 26px 28px 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    background: #ffffff;
}

.compare-add-modal .cam-title {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #333333;
    margin: 0 0 16px;
}

.compare-add-modal .cam-section {
    margin-bottom: 22px;
}

.compare-add-modal .cam-section:last-child {
    margin-bottom: 0;
}

.compare-add-modal .cam-recent-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid #eeeeee;
    border-radius: 8px;
    overflow: hidden;
}

.compare-add-modal .cam-loading {
    grid-column: 1 / -1;
    padding: 30px;
    text-align: center;
    color: #888888;
    font-size: 13px;
}

.compare-add-modal .cam-recent-item {
    padding: 16px 14px;
    text-align: center;
    border-right: 1px solid #eeeeee;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: box-shadow 0.2s ease;
}

.compare-add-modal .cam-recent-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.compare-add-modal .cam-recent-item:nth-child(3n) {
    border-right: none;
}

.compare-add-modal .cam-item-img img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    transition: transform 0.25s ease;
}

.compare-add-modal .cam-recent-item:hover .cam-item-img img {
    transform: scale(1.05);
}

.compare-add-modal .cam-item-title {
    font-size: 13px;
    font-weight: 500;
    color: #242424;
    text-decoration: none;
    line-height: 1.45;
    margin: 12px 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 38px;
}

.compare-add-modal .cam-item-title:hover {
    color: #2f80ed;
}

.compare-add-modal .cam-item-price {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.compare-add-modal .cam-price {
    font-size: 15px;
    font-weight: 700;
    color: #e30019;
}

.compare-add-modal .cam-price-sub {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.compare-add-modal .cam-regular {
    color: #999999;
    text-decoration: line-through;
    font-size: 12px;
}

.compare-add-modal .cam-discount {
    background: #fff0f1;
    color: #e30019;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
}

.compare-add-modal .cam-add-btn {
    background: #ffffff;
    border: 1px solid #2f80ed;
    border-radius: 4px;
    color: #2f80ed;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 7px 14px;
    margin-top: auto;
    transition: background 0.2s ease, color 0.2s ease;
}

.compare-add-modal .cam-add-btn:hover {
    background: #2f80ed;
    color: #ffffff;
}

.compare-add-modal .cam-search-wrapper {
    margin-top: 0;
}

.compare-add-modal .cam-search-wrapper .compare-search-input {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

@media (max-width: 600px) {
    .compare-add-modal .cam-recent-list {
        grid-template-columns: repeat(2, 1fr);
    }
    .compare-add-modal .cam-recent-item:nth-child(3n) {
        border-right: 1px solid #eeeeee;
    }
    .compare-add-modal .cam-recent-item:nth-child(2n) {
        border-right: none;
    }
    .compare-add-modal .cam-dialog {
        margin: 50px auto 20px;
    }
    .compare-add-modal .cam-panel {
        padding: 20px 16px 24px;
    }
}
