/* =========================================
   1. LAYOUT CHUNG, CHECKBOX & NÚT TRANG CHI TIẾT
   ========================================= */
.product-sku-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
}

.spc-compare-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

/* Nút So sánh trang Chi tiết sản phẩm (Ngang hàng Tiêu đề H1) */
.spc-compare-checkbox.spc-single-title-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 5px 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: all 0.2s ease !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.spc-compare-checkbox.spc-single-title-btn:hover {
    border-color: var(--spc-primary-color, #3b71ea) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12) !important;
}

.spc-compare-checkbox.spc-single-title-btn input[type="checkbox"].spc-btn-trigger {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    border: 1.5px solid #64748b !important;
    border-radius: 3px !important;
    outline: none !important;
    background-color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    margin: 0 !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.spc-compare-checkbox.spc-single-title-btn input[type="checkbox"].spc-btn-trigger:checked {
    background-color: var(--spc-primary-color, #3b71ea) !important;
    border-color: var(--spc-primary-color, #3b71ea) !important;
}

.spc-compare-checkbox.spc-single-title-btn input[type="checkbox"].spc-btn-trigger:checked::after {
    content: '' !important;
    position: absolute !important;
    width: 4px !important;
    height: 8px !important;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: rotate(45deg) !important;
    top: 1px !important;
    left: 4px !important;
}

.spc-compare-checkbox.spc-single-title-btn .spc-checkbox-label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    margin: 0 !important;
    line-height: 1 !important;
}

.spc-compare-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--spc-primary-color, #3b71ea) !important;
    border-radius: 3px;
    outline: none;
    background-color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    vertical-align: middle;
    margin: 0;
    cursor: pointer;
}

.spc-compare-checkbox input[type="checkbox"]:checked {
    background-color: var(--spc-primary-color, #3b71ea) !important;
}

.spc-compare-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    top: 1px;
    left: 4px;
}

.spc-checkbox-label {
    font-size: 14px;
    color: var(--spc-primary-color, #3b71ea) !important;
    font-weight: 700;
}

/* Product Meta Tags (Model & Mã kho) */
.product-meta-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-sku-tag,
.product-warehouse-tag {
    background-color: #f2f4f7;
    color: #6c757d;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

/* Đảm bảo container của sản phẩm trong danh sách có relative */
.product-small,
.product-small .box,
.product-small .box-image,
li.product,
.product-category,
.woocommerce-loop-product__link {
    position: relative;
}

/* =========================================
   1B. LỚP PHỦ HÌNH ẢNH HOVER & ẨN NÚT XEM CHI TIẾT
   ========================================= */
.pc-thumb-v5 {
    position: relative !important;
}

.pc-thumb-v5::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(30, 58, 138, 0.18) !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
    z-index: 2 !important;
}

.product-card-v5:hover .pc-thumb-v5::after {
    opacity: 1 !important;
}

/* Ẩn hoàn toàn nút Xem chi tiết */
.btn-qv-v5,
.pc-action-v5 .btn-qv-v5 {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}




/* =========================================
   2. BẢNG SO SÁNH (COMPARE TABLE)
   ========================================= */
.spc-compare-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border: 1px solid #ddd;
    table-layout: fixed;
    font-family: sans-serif;
    border-radius: 8px;
    overflow: hidden;
}

.spc-compare-table td {
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 15px !important;
    vertical-align: top;
    color: #333;
    position: relative;
}

.spc-compare-table tbody td:last-child {
    border-right: none;
}

.spc-compare-table tr:last-child td {
    border-bottom: none;
}

.spc-label-col {
    width: 150px;
    font-weight: 700;
    background-color: #f9fafb;
    color: #374151;
    font-size: 14px;
    vertical-align: middle !important;
}

.spc-product-col img {
    max-width: 100%;
    height: auto;
    max-height: 150px;
    display: block;
    margin: 10px auto;
    object-fit: contain;
}

.spc-remove-table {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #9ca3af;
    line-height: 1;
    transition: color 0.2s;
}

.spc-remove-table:hover {
    color: #ef4444;
}

.spc-product-title {
    color: #111827;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    display: block;
    line-height: 1.4;
    text-align: center;
    margin-bottom: 5px;
    transition: color 0.2s;
}

.spc-product-title:hover {
    color: var(--spc-primary-color, #3b71ea);
}

.spc-price-col {
    text-align: center;
    background-color: #fff;
}

.spc-price-col .amount {
    color: #ef4444;
    font-size: 16px;
    font-weight: 700;
    display: block;
}

.spc-price-col del .amount {
    color: #9ca3af;
    font-size: 13px;
    font-weight: normal;
    text-decoration: line-through;
}

.spc-action-row td {
    vertical-align: middle;
}

.spc-buy-btn {
    background-color: var(--spc-primary-color, #3b71ea) !important;
    color: #fff !important;
    border: 1px solid var(--spc-primary-color, #3b71ea) !important;
    width: 100%;
    border-radius: 6px !important;
    font-weight: 700;
    text-transform: uppercase !important;
    font-size: 13px !important;
    padding: 0 15px !important;
    height: 40px !important;
    line-height: 38px !important;
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
    transition: all 0.2s;
}

.spc-buy-btn:hover {
    background-color: var(--spc-primary-color-hover, #295dd2) !important;
    border-color: var(--spc-primary-color-hover, #295dd2) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.spc-info-table {
    width: 100%;
    border-collapse: collapse;
}

.spc-info-table tr:nth-child(odd) {
    background-color: #f9fafb;
}

.spc-info-table tr:nth-child(even) {
    background-color: #fff;
}

.spc-info-table td {
    padding: 8px 10px;
    border: none;
    font-size: 13px;
    vertical-align: middle;
}

.spc-info-label {
    font-weight: 600;
    width: 40%;
    color: #4b5563;
}

.spc-info-value {
    color: #111827;
}

/* =========================================
   3. KHAY NỔI SO SÁNH (FLOATING TRAY)
   ========================================= */
#spc-floating-btn {
    position: fixed;
    bottom: 80px;
    left: 20px;
    background: #fff;
    color: var(--spc-primary-color, #3b71ea);
    padding: 8px 18px;
    border-radius: 30px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 99990;
    display: none;
    font-size: 15px;
    cursor: pointer;
    border: 1.5px solid var(--spc-primary-color, #3b71ea);
    transition: all 0.2s;
}

#spc-floating-btn:hover {
    transform: translateY(-2px);
    background: var(--spc-primary-color, #3b71ea);
    color: #fff;
}

#spc-tray {
    position: fixed;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: auto;
    min-width: 800px;
    max-width: 95%;
    background: #fff;
    z-index: 99999;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

#spc-tray.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.spc-tray-header {
    background: var(--spc-primary-color, #3b71ea);
    color: #fff;
    padding: 14px 20px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 7px 7px 0 0;
}

#spc-tray-close {
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.spc-tray-body {
    padding: 15px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
}

#spc-tray-list {
    display: flex;
    gap: 8px;
}

.spc-item-box {
    position: relative;
    width: 210px;
    height: 160px;
    border: 1px dashed #d1d5db;
    padding: 15px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    transition: all 0.2s;
}

.spc-item-box.has-product {
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.spc-item-box img {
    height: 85px;
    width: auto;
    object-fit: contain;
    margin-bottom: 10px;
}

.spc-item-box .spc-name {
    font-size: 13px;
    color: #374151;
    text-align: center;
    line-height: 1.4;
    overflow: hidden;
    height: 36px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-weight: 500;
}

.spc-item-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.spc-item-remove:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

.spc-plus {
    font-size: 42px;
    color: #d1d5db;
    font-weight: 300;
    line-height: 1;
    margin-bottom: 5px;
}

.spc-text {
    font-size: 13px;
    color: #9ca3af;
    margin-top: 0;
}

.spc-tray-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
}

.spc-tray-actions .button {
    width: 100% !important;
    margin: 0 !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    height: 40px;
    line-height: 40px;
    padding: 0 15px;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-sizing: border-box;
}

#spc-go {
    background-color: var(--spc-primary-color, #3b71ea) !important;
    border: 1px solid var(--spc-primary-color, #3b71ea) !important;
    color: #fff !important;
}

#spc-go:hover {
    background-color: var(--spc-primary-color-hover, #295dd2) !important;
    box-shadow: 0 2px 8px rgba(59, 113, 234, 0.3);
}

#spc-clear {
    background-color: #f3f4f6 !important;
    border: 1px solid #e5e7eb !important;
    color: #4b5563 !important;
}

#spc-clear:hover {
    background-color: #e5e7eb !important;
    color: #1f2937 !important;
}

/* =========================================
   4. MODAL TÌM KIẾM SẢN PHẨM (SEARCH MODAL)
   ========================================= */
#spc-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 50px;
}

.spc-search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.spc-search-box {
    position: relative;
    background: #fff;
    width: 95%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.spc-search-header {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    padding: 15px;
    background: #f9fafb;
    align-items: center;
}

#spc-search-input {
    flex: 1;
    border: 1px solid #d1d5db;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    margin-bottom: 0;
    height: 42px;
}

#spc-search-input:focus {
    border-color: var(--spc-primary-color, #3b71ea);
    box-shadow: 0 0 0 3px var(--spc-primary-color-light, rgba(59, 113, 234, 0.15));
}

#spc-search-close {
    margin-left: 10px;
    cursor: pointer;
    font-weight: bold;
    color: #4b5563;
    font-size: 14px;
    background: #fff;
    padding: 8px 15px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    transition: all 0.2s;
}

#spc-search-close:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

#spc-search-results {
    padding: 0;
    overflow-y: auto;
}

.spc-search-empty {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.spc-search-loading {
    padding: 40px 20px;
    text-align: center;
    color: #4b5563;
    font-size: 14px;
    position: relative;
}

.spc-search-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--spc-primary-color, #3b71ea);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spc-result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.spc-result-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    transition: background-color 0.2s;
}

.spc-result-item:last-child {
    border-bottom: none;
}

.spc-result-item:hover {
    background-color: #f9fafb;
}

.spc-res-img {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    flex-shrink: 0;
}

.spc-res-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 1px solid #f3f4f6;
    border-radius: 4px;
}

.spc-res-info {
    flex: 1;
}

.spc-res-name {
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 5px;
    font-weight: 500;
}

.spc-res-price {
    font-size: 14px;
    color: #ef4444;
    font-weight: 700;
    margin-top: 5px;
}

.spc-res-price .amount {
    color: #ef4444 !important;
}

.spc-res-price del {
    color: #9ca3af;
    font-size: 12px;
    font-weight: normal;
    margin-right: 5px;
}

.spc-res-price del .amount {
    color: #9ca3af !important;
}

.spc-res-action {
    margin-left: 10px;
    text-align: right;
}

.spc-add-btn {
    color: var(--spc-primary-color, #3b71ea);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    font-weight: 600;
}

.spc-add-btn:hover {
    text-decoration: underline;
    color: var(--spc-primary-color-hover, #295dd2);
}

/* =========================================
   5. RESPONSIVE MOBILE (THIẾT KẾ CO GIÃN TỐT)
   ========================================= */
@media (max-width: 768px) {

    /* Khung Tray trên di động */
    #spc-tray {
        width: 96%;
        left: 2%;
        bottom: 80px;
        min-width: unset;
        max-width: 100%;
        border-radius: 8px;
        transform: translateY(120%);
        padding-bottom: 0;
        box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    }

    #spc-tray.open {
        transform: translateY(0);
    }

    .spc-tray-header {
        border-radius: 8px 8px 0 0;
        padding: 10px 15px;
        font-size: 13px;
    }

    /* Chia đều 3 slot */
    .spc-tray-body {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        min-height: auto;
    }

    #spc-tray-list {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        width: 100%;
        overflow: visible;
        padding-bottom: 0;
    }

    .spc-item-box {
        width: auto;
        min-width: 0;
        height: 110px;
        padding: 8px 5px;
    }

    .spc-item-box img {
        height: 45px;
        margin-bottom: 5px;
    }

    .spc-item-box .spc-name {
        font-size: 10px;
        line-height: 1.3;
        height: 26px;
        margin-bottom: 0;
    }

    .spc-plus {
        font-size: 24px;
        margin-bottom: 0;
    }

    .spc-text {
        display: none;
    }

    .spc-item-remove {
        width: 18px;
        height: 18px;
        line-height: 16px;
        font-size: 12px;
        top: -6px;
        right: -6px;
    }

    /* Nút bấm ở dưới */
    .spc-tray-actions {
        flex-direction: row !important;
        width: 100%;
        gap: 8px;
    }

    .spc-tray-actions .button {
        width: 50% !important;
        font-size: 12px !important;
        height: 36px !important;
        line-height: 36px !important;
        padding: 0 5px !important;
    }

    /* Nút nổi */
    #spc-floating-btn {
        bottom: 140px;
        left: 10px;
        font-size: 13px;
        padding: 6px 12px;
    }

    /* Bảng so sánh */
    .spc-compare-table {
        font-size: 12px;
    }

    .spc-label-col {
        width: 100px;
        padding: 10px !important;
    }
    
    .spc-compare-table td {
        padding: 10px !important;
    }
    
    .spc-buy-btn {
        font-size: 11px !important;
        padding: 0 5px !important;
        height: 34px !important;
        line-height: 32px !important;
    }
}

/* =========================================
   TÍCH HỢP THEME MEGALINE - NÚT OVERLAY ẢNH ĐẠI DIỆN
   Ghi đè thuộc tính width:100%/height:100% từ class .aspect-ratio-16-9 > *
   ========================================= */
.pc-thumb-v5 {
    position: relative !important;
}

.aspect-ratio-16-9 > .spc-compare-checkbox.spc-thumb-overlay,
.pc-thumb-v5 .spc-compare-checkbox.spc-thumb-overlay {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    right: auto !important;
    bottom: auto !important;
    max-width: fit-content !important;
    max-height: fit-content !important;
    z-index: 10 !important;
    gap: 6px !important;
    background: #f8f8f8 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
}

.spc-compare-checkbox.spc-thumb-overlay:hover {
    border-color: var(--spc-primary-color, #3b71ea) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

.spc-compare-checkbox.spc-thumb-overlay input[type="checkbox"].spc-btn-trigger {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
    max-width: 12px !important;
    max-height: 12px !important;
    border: 1.5px solid #64748b !important;
    border-radius: 3px !important;
    outline: none !important;
    background-color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    margin: 0 !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.spc-compare-checkbox.spc-thumb-overlay input[type="checkbox"].spc-btn-trigger:checked {
    background-color: var(--spc-primary-color, #3b71ea) !important;
    border-color: var(--spc-primary-color, #3b71ea) !important;
}

.spc-compare-checkbox.spc-thumb-overlay input[type="checkbox"].spc-btn-trigger:checked::after {
    content: '' !important;
    position: absolute !important;
    width: 2px !important;
    height: 6px !important;
    border: solid white !important;
    border-width: 0 2px 2px 0 !important;
    transform: rotate(45deg) !important;
    top: 1px !important;
    left: 3px !important;
}

.spc-compare-checkbox.spc-thumb-overlay .spc-checkbox-label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #6a7282 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    line-height: 1 !important;
}

/* Xử lý khoảng cách khi có thẻ SALE */
.pc-thumb-v5:has(.onsale-flash) .spc-compare-checkbox.spc-thumb-overlay {
    top: 36px !important;
}

/* =========================================
   TỰ ĐỘNG ẨN SIDEBAR VÀ MỞ RỘNG 100% TRANG SO SÁNH
   ========================================= */
.page:has(.spc-compare-table) .sidebar,
.page:has(.spc-compare-table) aside.sidebar,
.page:has(.spc-table-wrapper) .sidebar,
.page:has(.spc-table-wrapper) aside.sidebar,
.page-template-default:has(.spc-compare-table) .sidebar,
.page-template-default:has(.spc-table-wrapper) .sidebar {
    display: none !important;
}

.page:has(.spc-compare-table) .layout-sidebar,
.page:has(.spc-table-wrapper) .layout-sidebar,
.page-template-default:has(.spc-compare-table) .layout-sidebar,
.page-template-default:has(.spc-table-wrapper) .layout-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}



