/* =======================================================
   1. MAIN LAYOUT STRUCTURE & OVERRIDE FIXES (Desktop)
      - Enforces the 3fr / 1fr grid layout and maximum width.
   ======================================================= */

.wc-block-components-sidebar-layout.wc-block-cart {
    /* FORCE GRID LAYOUT */
    display: grid !important;
    grid-template-columns: 3fr 1fr !important; 
    gap: 50px !important; 
    
    /* ENFORCE CONTAINER WIDTH */
    max-width: 1300px !important; 
    width: 100% !important; 
    margin: 30px auto !important; 
    background-color: transparent;
}

/* Ensure the main content block takes full width of its grid cell */
.wc-block-components-main.wc-block-cart__main {
    width: 100% !important; 
    max-width: 100% !important;
    background-color: white;
}

/* Sidebar Totals Section Styling (White & Minimal) */
.wc-block-components-sidebar.wc-block-cart__sidebar {
    padding: 30px !important;
    background-color: white; 
    border: 1px solid #e9e9e9; 
    border-radius: 0;
    box-shadow: none;
    height: fit-content; 
    width: 100% !important; 
}

/* =======================================================
   2. TABLE & COLUMN WIDTH FIXES (Desktop Three-Column Layout - Reverted)
      - Forces the table structure to (Image | Details | Total Price)
   ======================================================= */

/* Force Table Width and Layout */
table.wc-block-cart-items {
    width: 100% !important; 
    table-layout: fixed !important; /* Forces columns to respect declared widths */
    border-collapse: collapse;
}

/* Header Columns Widths (Restored to 3 columns) */
.wc-block-cart-items__header-image { width: 12% !important; }
.wc-block-cart-items__header-product { width: auto !important; } /* Auto width to fill remaining space */
.wc-block-cart-items__header-total { width: 20% !important; display: table-cell !important; } /* Restore original Total header column */

/* TD Cell Widths (Restored to 3 columns) */
.wc-block-cart-items td.wc-block-cart-item__image {
    width: 12% !important; 
    min-width: 170px !important; /* Ensures space for 150px image + padding */
    padding-left: 0 !important;
    vertical-align: middle;
}
.wc-block-cart-items td.wc-block-cart-item__product {
    width: auto !important; /* Auto width to fill remaining space */
    padding-left: 20px !important;
    vertical-align: middle;
    /* Revert to standard table cell display */
    display: table-cell !important;
    align-items: initial !important; 
}
.wc-block-cart-items td.wc-block-cart-item__total {
    /* Restore original Total price column */
    width: 20% !important; 
    text-align: right !important;
    vertical-align: middle;
    display: table-cell !important; 
}

/* 3. ULTIMATE IMAGE WIDTH OVERRIDE */

/* Ensure the anchor link doesn't interfere */
.wc-block-cart-items td.wc-block-cart-item__image a {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    line-height: 0 !important;
}

/* Target the <img> element directly with max specificity */
.wc-block-cart-items td.wc-block-cart-item__image img {
    /* *** NEW AGGRESSIVE WIDTH/HEIGHT FIX *** */
    width: 150px !important; 
    max-width: 150px !important; 
    min-width: 150px !important; 
    height: 150px !important; 
    /* *************************************** */
    
    display: block !important;
    box-sizing: border-box !important;
    object-fit: cover !important; 
    border-radius: 4px !important; 
    margin: 0 auto !important;
}


/* =======================================================
   4. AESTHETIC & CONTENT STYLING (Desktop - Reverted)
   ======================================================= */

/* Header & Row Styling */
.wc-block-cart-items__header {
    border-bottom: 1px solid #b3b3b3; 
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    color: #555;
}
.wc-block-cart-items__header th {
    padding-bottom: 15px;
}
.wc-block-cart-items__row {
    border-bottom: 1px solid #f0f0f0; 
    background-color: white;
}
.wc-block-cart-items__row:last-child {
    border-bottom: 1px solid #b3b3b3; 
}
.wc-block-cart-items__row td {
    padding: 20px 0; /* Vertical spacing */
}

/* Styling for the product details inner wrapper (Back to original margin) */
.wc-block-cart-item__wrap {
    margin-left: 40px !important; 
    /* Remove previous desktop grid setup */
    display: block; 
    grid-template-columns: none; 
    align-items: initial;
    width: 100%;
}
/* Remove the total element that was added for desktop/large screens */
.wc-block-cart-item__row-total {
    display: none; 
}

/* Typography and Prices (Revert product name size) */
.wc-block-components-product-name {
    font-weight: 600;
    font-size: 2rem !important; /* Revert to 2rem */
    color: #333;
    line-height: 1.2; 
    margin-bottom: 5px;
}
.wc-block-components-product-metadata p {
    font-size: 0.9rem;
    color: #777;
    margin: 0;
}
/* Individual price styling (Red color) */
.wc-block-components-product-metadata .wc-block-formatted-money-amount {
    font-size: 1.1rem;
    font-weight: 600 !important;
    color: #c61d23 !important; 
    display: block; 
    margin-bottom: 15px;
}

/* Quantity Selector & Remove Link (Revert to block stacking) */
.wc-block-cart-item__quantity {
    /* Revert to block stacking (column layout) */
    display: block; 
    align-items: flex-start; 
    gap: 0; 
    margin-top: 10px;
    max-width: 150px; /* Limit width */
}
.wc-block-components-quantity-selector {
    border: 1px solid #ddd;
    border-radius: 0; 
}
.wc-block-cart-item__remove-link {
    color: #777 !important; 
    font-size: 0.85rem;
    text-transform: uppercase;
    text-decoration: none;
    /* Revert display back to block to sit below quantity */
    display: block !important; 
    margin-top: 8px !important; 
    clear: both !important; 
    font-weight: 400 !important; 
}

/* Restore the total price in the separate column (wc-block-cart-item__total) */
.wc-block-cart-item__total {
    font-weight: 700;
    font-size: 1.1rem; /* Revert size for standard total */
    color: #111;
    text-align: right;
}

/* Sidebar Totals & Checkout Button */
.wc-block-cart__totals-title {
    font-size: 1.6rem;
    font-weight: 300; 
    border-bottom: 1px solid #e9e9e9;
    padding-bottom: 15px;
    margin-bottom: 25px;
}
.wc-block-components-totals-footer-item {
    border-top: 1px solid #dcdcdc; 
    margin-top: 20px;
    padding-top: 20px !important;
}
.wc-block-components-totals-footer-item-tax-value {
    font-weight: 700;
    font-size: 1.25rem; 
    color: #111;
}

.wc-block-cart__submit-button {
    width: 100% !important;
    background-color: #c61d23 !important; /* CHANGED TO REQUESTED RED */
    color: white !important;
    font-weight: 600 !important;
    padding: 18px !important;
    border-radius: 0 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.wc-block-cart__submit-button:hover {
    background-color: #a9171f !important; /* Darker red for hover state */
}


/* =======================================================
   5. MOBILE RESPONSIVENESS (Layout Final - Terintegrasi Penuh)
   ======================================================= */

@media (max-width: 991px) {

    /* HIDE HEADER & MAIN LAYOUT */
    .wc-block-cart-items__header {
        display: none !important;
    }
    .wc-block-components-sidebar-layout.wc-block-cart {
        display: block !important;
        padding: 20px;
    }
    
    /* SEMBUNYIKAN HARGA TOTAL */
    .wc-block-cart-items td.wc-block-cart-item__total {
        display: none !important; 
    }

    /* ITEM CARD LAYOUT (FLEXBOX UTAMA pada TR) */
    .wc-block-cart-items__row {
        display: flex !important;
        align-items: flex-start;
        /* Hapus space-between jika Anda ingin ikon hapus berada di dalam detail produk dan tidak terpisah */
        /* Jika Anda ingin ikon hapus di pojok kanan card: biarkan justify-content: space-between */
        justify-content: flex-start; /* Ubah ke flex-start agar ikon hapus tidak didorong jauh jika order:99 dihapus */ 
        padding: 15px;
        margin-bottom: 15px;
        border: 1px solid #e0e0e0; 
        border-radius: 6px; 
        background-color: #ffffff;
        min-height: 100px; 
    }

    /* ------------------------------------------------ */
    /* MENGATUR GAMBAR PRODUK (Cell Pertama) */
    /* ------------------------------------------------ */
    .wc-block-cart-item__image {
        width: 70px !important;
        min-width: 70px !important;
        flex-shrink: 0; 
        margin-right: 15px;
        padding: 0 !important; 
    }
    .wc-block-cart-item__image img {
        width: 70px !important;
        height: 70px !important;
        border-radius: 4px;
        object-fit: cover;
    }

    /* ------------------------------------------------ */
    /* MENGATUR DETAIL PRODUK (Cell Kedua) & RESET GRID */
    /* ------------------------------------------------ */
    .wc-block-cart-items td.wc-block-cart-item__product {
        display: flex !important;
        flex-direction: column;
        flex-grow: 1;
        width: auto !important;
        padding: 0 !important;
        
        /* === RESET PROPERTI CSS GRID BAWAAN === */
        grid-column-end: unset !important;
        grid-column-start: unset !important;
        grid-row-start: unset !important;
        justify-self: unset !important;
        margin-left: 0 !important; 
        /* === END RESET === */
    }

    /* MENGATUR SEMUA TD AGAR TIDAK MENGGANGGU FLEX UTAMA */
    .wc-block-cart-items__row td {
        display: block !important; 
        width: auto !important;
        padding: 0 !important; 
    }
    
    /* Mengatur Wrapper utama di dalam cell produk agar bisa flex */
    .wc-block-cart-item__wrap {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        /* Hapus margin-left 5px ini, margin harusnya ada di antara image dan product details */
        /* Jika margin diperlukan, gunakan di sini: margin-left: 5px; */
        margin-left: 5px !important;
    }

    /* Penyesuaian Harga dan Nama Produk */
    .wc-block-cart-item__wrap .wc-block-components-product-name {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 2px;
    }
    
    /* FIX HARGA DISKON: Targetkan SPAN Pembungkus */
    .wc-block-cart-item__wrap .wc-block-cart-item__prices {
        font-size: 14px;
        opacity: 1 !important; /* Kembalikan opacity 1 agar harga jelas */
        /* Hapus display flex di sini */
        /* width: 100px !important; */
    }

    .wc-block-cart-item__wrap .wc-block-components-product-price {
        display: flex !important; /* AKTIVASI FLEX PADA SPAN PEMBUNGKUS HARGA */
        flex-direction: column !important;
        align-items: start;
        gap: 8px; /* Jarak antar harga */
    }
    
    /* Penyesuaian tampilan harga lama (del) */
    .wc-block-cart-item__wrap .wc-block-components-product-price del {
        opacity: 0.6;
        font-size: 13px;
        text-decoration: line-through;
        align-self: flex-start !important;
    }
    
    /* Penyesuaian tampilan harga diskon (ins) */
    .wc-block-cart-item__wrap .wc-block-components-product-price ins {
        font-weight: 700 !important;
        color: #d63638 !important;
        margin-left: unset;
        text-decoration: none !important;
    }

    /* ------------------------------------------------ */
    /* MENGATUR BARIS KUANTITAS & HAPUS (KIRI) - FIX ORDER */
    /* ------------------------------------------------ */
    
    /* Kuantitas Selector Container */
    .wc-block-cart-item__quantity {
        display: flex !important; 
        justify-content: flex-start !important; /* Ratakan konten di dalamnya ke kiri */
        align-items: center !important; 
        align-self: flex-start !important; /* FIX OVERWRITE align-self */
        margin-top: 8px;
        width: auto !important; /* Gunakan width auto, tidak perlu 100% jika di kiri */
    }
    
    /* Tombol/Link Remove item diubah menjadi Ikon (di samping Quantity) */
.wc-block-cart-item__remove-link {
    /* HAPUS order: 99; agar elemen ini berada di flow normal di samping quantity selector */
    order: unset !important;
    margin: 0 0 0 15px !important;
    color: #e0e0e0;
    padding: 0 !important; /* Paksa padding 0 */
    
    /* FIX SVG VISIBILITY */
    background: none !important; /* Hapus semua background bawaan */
    background-color: transparent !important; /* Pastikan tidak ada warna solid */

    /* Ganti teks menjadi ikon tempat sampah */
    text-indent: -9999px !important; /* Paksa sembunyikan teks */
    width: 20px !important; /* Paksa lebar */
    height: 20px !important; /* Paksa tinggi */
    
    /* Paksa background SVG */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23999999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>') !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    background-position: center !important;
    
    /* Tambahkan display: block jika elemen defaultnya inline dan ini bermasalah */
    display: block !important;
}

.wc-block-cart-item__remove-link:hover {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23d63638" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>') !important;
}
    
    /* Penyesuaian Quantity Selector */
    .wc-block-components-quantity-selector {
        max-width: 100px;
        border-radius: 4px;
    }
    .wc-block-components-quantity-selector__input {
        height: 30px !important;
        padding: 0 5px !important;
    }
    .wc-block-components-quantity-selector__button {
        width: 30px !important;
        height: 30px !important;
    }


}