/* =========================================================
   CPSP Compare Product — Modern Redesign (FIXED MOBILE SCROLL)
   Palette:
     - Primary   : #1a1a1a (hitam elegan)
     - Accent    : #d61f31 (merah JETE)
     - BG        : #fafafa
     - Border    : #ececec
     - Text      : #1a1a1a
     - Muted     : #777
   ========================================================= */

/* ---------- Wrapper ---------- */
.cpsp-compare-app {
    max-width: 1180px;
    margin: 40px auto 60px;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
    line-height: 1.6;
}

/* ---------- Header ---------- */
.cpsp-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ececec;
}
.cpsp-compare-header h2 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: #1a1a1a;
}

.cpsp-clear-all {
    background: #fff;
    border: 1px solid #bdbdbd;
    color: #666;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cpsp-clear-all:hover {
    border-color: #d61f31;
    color: #d61f31;
    background: #fff5f6;
}

/* ---------- Slots (grid produk terpilih) ---------- */
.cpsp-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 40px;
    align-items: center;
}

.cpsp-slot {
    position: relative;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 14px;
    padding: 22px 18px;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    align-items: center;
    transition: all 0.25s ease;
    overflow: hidden;
}
.cpsp-slot.filled:hover {
    border-color: #d61f31;
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
}

.cpsp-slot.empty {
    border: 1.5px dashed #d5d5d5;
    background: #fff;
}
.cpsp-slot.empty:hover {
    border-color: #d61f31;
    background: #ffe4f0;
}

/* Tombol tambah produk */
.cpsp-slot-add {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #888;
    width: 100%;
    height: 100%;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.2s ease;
}
.cpsp-slot-add:hover {
    color: #d61f31;
}
.cpsp-plus {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px dashed #c8c8c8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 300;
    color: #999;
    transition: all 0.2s ease;
}
.cpsp-slot-add:hover .cpsp-plus {
    border-color: #d61f31;
    color: #d61f31;
    background: #fff5f6;
    transform: rotate(90deg);
}

/* Tombol remove (x) di slot terisi */
.cpsp-slot-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    color: rgb(136, 136, 136);
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: rgb(245, 245, 245);
    border:1px solid #b3a5a5;
    transition: 0.2s;
    border-radius: 10px !important;
}
.cpsp-slot:hover .cpsp-slot-remove {
    opacity: 1;
}
.cpsp-slot-remove:hover {
    background: #d61f31;
    color: #fff;
}

/* Isi slot */
.cpsp-slot-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.cpsp-slot img {
    max-width: 110px;
    height: auto;
    margin: 0 auto 14px;
    display: block;
    transition: transform 0.3s ease;
}
.cpsp-slot.filled:hover img {
    transform: scale(1.05);
}
.cpsp-slot-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cpsp-slot-price {
    font-size: 14px;
    color: #d61f31;
    font-weight: 700;
}

/* ---------- Hint / pesan kosong ---------- */
.cpsp-hint {
    text-align: center;
    color: #999;
    padding: 50px 20px;
    font-size: 14px;
    background: #fafafa;
    border-radius: 14px;
    border: 1px dashed #e5e5e5;
}

/* ---------- Modal pencarian ---------- */
.cpsp-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: cpsp-fade-in 0.2s ease;
}
@keyframes cpsp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.cpsp-search-modal {
    background: #fff;
    max-width: 520px;
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    border-radius: 18px;
    padding: 30px 26px 22px;
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    animation: cpsp-slide-up 0.25s ease;
    -webkit-overflow-scrolling: touch; /* FIX SCROLL MODAL */
}
@keyframes cpsp-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cpsp-search-modal h3 {
    margin: 0 0 18px;
    font-size: 17px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.2px;
}

.cpsp-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: #d61f31;
    border: none;
    border-radius: 10px!important;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.cpsp-modal-close:hover {
    background: #1a1a1a;
    color: #fff;
}

#cpsp-search-input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid #ececec;
    border-radius: 10px;
    margin-bottom: 16px;
    box-sizing: border-box;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a1a;
    background: #fafafa;
    transition: all 0.2s ease;
    outline: none;
}
#cpsp-search-input:focus {
    border-color: #d61f31;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(214, 31, 49, 0.08);
}

/* Hasil pencarian */
.cpsp-search-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}
.cpsp-search-item:last-child {
    border-bottom: none;
}
.cpsp-search-item:hover {
    background: #fafafa;
}
.cpsp-search-item img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ececec;
    flex-shrink: 0;
    background: #fff;
}
.cpsp-search-info {
    flex: 1;
    min-width: 0;
}
.cpsp-search-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.35;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cpsp-search-price {
    font-size: 13px;
    color: #d61f31;
    font-weight: 600;
}
.cpsp-search-add-btn {
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-family: inherit;
}
.cpsp-search-add-btn:hover {
    background: #d61f31;
    transform: translateY(-1px);
}

.cpsp-no-result {
    text-align: center;
    color: #aaa;
    padding: 30px 0;
    font-size: 13.5px;
}

/* =========================================================
   Tabel Perbandingan (FIXED SCROLL)
   ========================================================= */

.cpsp-table-wrap {
    overflow-x: auto; /* Ganti hidden jadi auto agar bisa digeser */
    overflow-y: hidden;
    border-radius: 14px;
    border: 1px solid #d1d1d1 !important;
    background: #fff;
    -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
    touch-action: pan-x pan-y; /* Izinkan geser horizontal & vertikal */
    max-width: 100%;
}

/* Reset total border dari tema */
.cpsp-compare-app table.cpsp-table,
.cpsp-compare-app .cpsp-table,
.entry-content .cpsp-table,
.woocommerce .cpsp-table {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    font-size: 14px;
    min-width: 640px;
    border: none !important;
    background: #fff;
    box-shadow: none !important;
}

/* Reset border di semua sel, lalu pasang border tipis kita sendiri */
.cpsp-compare-app .cpsp-table th,
.cpsp-compare-app .cpsp-table td,
.entry-content .cpsp-table th,
.entry-content .cpsp-table td {
    padding: 16px 14px;
    text-align: center;
    vertical-align: middle;
    border: none !important;
    border-top: none !important;
    border-left: none !important;
    border-bottom: 1px solid #d1d1d1 !important;
    border-right: 1px solid #d1d1d1 !important;
    background-clip: padding-box;
}

/* Kolom terakhir: hilangkan border kanan */
.cpsp-compare-app .cpsp-table th:last-child,
.cpsp-compare-app .cpsp-table td:last-child {
    border-right: none !important;
}

/* Baris terakhir: hilangkan border bawah */
.cpsp-compare-app .cpsp-table tr:last-child td,
.cpsp-compare-app .cpsp-table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Header kolom (nama produk) */
.cpsp-compare-app .cpsp-table thead th {
    background: #fafafa !important;
    border-bottom: 1px solid #ececec !important;
    padding: 22px 14px 18px;
    min-width: 180px;
    position: relative;
    font-weight: 600;
}
.cpsp-compare-app .cpsp-table thead th a {
    text-decoration: none;
    color: inherit;
    display: block;
}
.cpsp-compare-app .cpsp-table th img {
    max-width: 90px;
    height: auto;
    display: block;
    margin: 0 auto 10px;
    transition: transform 0.3s ease;
    border: none !important;
    border-radius: 6px;
}
.cpsp-compare-app .cpsp-table thead th a:hover img {
    transform: scale(1.06);
}
.cpsp-th-title {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 13px;
    line-height: 1.4;
    margin-top: 4px;
}

.cpsp-remove-col {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgb(136, 136, 136);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border:1px solid;
}
.cpsp-remove-col:hover {
    background: #d61f31;
    color: #fff;
}

/* Label baris (kolom kiri) */
.cpsp-compare-app .cpsp-table .cpsp-row-label {
    text-align: left;
    font-weight: 600;
    color: #666;
    background: #fafafa !important;
    font-size: 13px;
    min-width: 150px;
    white-space: nowrap;
    vertical-align: middle;
    position: sticky;
    left: 0;
    z-index: 2;
}

/* Stok */
.cpsp-instock {
    display: inline-block;
    color: #16a34a;
    background: #f0fdf4;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12.5px;
    font-weight: 600;
}
.cpsp-outstock {
    display: inline-block;
    color: #dc2626;
    background: #fef2f2;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12.5px;
    font-weight: 600;
}

/* Tombol di dalam tabel */
.cpsp-table .button,
.cpsp-add-cart-btn,
.cpsp-select-options-btn {
    display: inline-block;
    background: #1a1a1a !important;
    color: #fff !important;
    padding: 15px 30px !important;
    border-radius: 8px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    border: none !important;
    transition: all 0.2s ease !important;
    line-height: 1.2 !important;
    white-space: nowrap;
}
.cpsp-table .button:hover,
.cpsp-add-cart-btn:hover,
.cpsp-select-options-btn:hover {
    background: #d61f31 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(214, 31, 49, 0.25);
}

/* ---------- Link "Bandingkan Produk" di single product ---------- */
.cpsp-compare-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 11px 20px;
    background: #fff;
    border: 1.5px solid #e5e5e5;
    border-radius: 100px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    color: #1a1a1a;
    transition: all 0.2s ease;
}
.cpsp-compare-link:hover {
    border-color: #d61f31;
    color: #d61f31;
    background: #fff5f6;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(214, 31, 49, 0.12);
}
.cpsp-compare-link .cpsp-icon {
    font-size: 17px;
    line-height: 1;
    color: #d61f31;
}

/* ---------- Responsive & Mobile Scroll Fix ---------- */
@media (max-width: 768px) {
    .cpsp-compare-app {
        margin: 24px auto 40px;
        padding: 0 16px;
    }
    .cpsp-compare-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .cpsp-compare-header h2 {
        font-size: 22px;
    }
    .cpsp-slots {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }
    .cpsp-slot {
        min-height: 200px;
        padding: 16px 12px;
    }
    .cpsp-slot img {
        max-width: 80px;
    }
    .cpsp-slot-remove {
        opacity: 1;
    }
    .cpsp-search-modal {
        padding: 24px 20px 18px;
        border-radius: 14px;
        max-height: 90vh; /* Beri ruang lebih */
    }
    .cpsp-table th,
    .cpsp-table td {
        padding: 12px 10px;
    }
    
    /* FIX: Matikan sticky di mobile karena sering bikin scroll macet */
    .cpsp-compare-app .cpsp-table .cpsp-row-label {
        position: static !important; 
        background: #fafafa !important;
        z-index: auto;
        font-size: 12px;
        min-width: 110px;
    }

    /* FIX: Pastikan body tidak terkunci */
    body, html {
        overflow-x: hidden !important;
        height: auto !important;
        position: relative !important;
    }

    /* FIX: Modal overlay scroll */
    .cpsp-search-overlay {
        align-items: flex-start !important;
        padding-top: 40px !important;
        overflow-y: auto !important;
    }
}