/*
 * Responsive WooCommerce Tables (Cart, Checkout Review, Order Details)
 * Converts desktop tables into mobile-friendly stacked cards.
 */

@media screen and (max-width: 768px) {

    /* Base Table Resets */
    .woocommerce table.shop_table,
    .woocommerce-page table.shop_table,
    table.shop_table {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }

    /* Hide Table Headers */
    .woocommerce table.shop_table thead,
    table.shop_table thead {
        display: none !important;
    }

    /* Convert Rows to Cards */
    .woocommerce table.shop_table tbody,
    table.shop_table tbody,
    .woocommerce table.shop_table tfoot,
    table.shop_table tfoot {
        display: block !important;
        width: 100% !important;
    }

    .woocommerce table.shop_table tr,
    table.shop_table tr {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin-bottom: 20px !important;
        background: #fff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
        overflow: hidden !important;
    }

    /* Cells as Block Rows */
    .woocommerce table.shop_table td,
    .woocommerce table.shop_table th,
    table.shop_table td,
    table.shop_table th {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        text-align: right !important;
        width: 100% !important;
        padding: 14px 20px !important;
        border-top: none !important;
        border-bottom: 1px solid #f1f5f9 !important;
        box-sizing: border-box !important;
        font-family: 'Inter', sans-serif !important;
    }

    /* Remove last border in cell */
    .woocommerce table.shop_table td:last-child,
    .woocommerce table.shop_table th:last-child {
        border-bottom: none !important;
    }

    /* Force pseudo-element for labels if data-title exists */
    .woocommerce table.shop_table td::before,
    table.shop_table td::before {
        content: attr(data-title);
        display: block !important;
        font-weight: 700 !important;
        color: #64748B !important;
        text-transform: uppercase !important;
        font-size: 11px !important;
        letter-spacing: 0.05em !important;
        text-align: left !important;
        padding-right: 15px !important;
    }
    
    /* Order totals row specific styling */
    .woocommerce table.shop_table tfoot th,
    table.shop_table tfoot th {
        display: block !important;
        text-align: left !important;
        background: #f8fafc !important;
        color: #0f172a !important;
        font-weight: 800 !important;
        border-bottom: none !important;
        padding: 10px 20px 4px !important;
    }
    .woocommerce table.shop_table tfoot td,
    table.shop_table tfoot td {
        background: #f8fafc !important;
        font-size: 16px !important;
        font-weight: 800 !important;
        color: #7c3aed !important;
        border-bottom: 1px solid #e2e8f0 !important;
        justify-content: flex-end !important;
    }
    .woocommerce table.shop_table tfoot tr {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Fix Product Name */
    .woocommerce table.shop_table td.product-name,
    table.shop_table td.product-name {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 6px !important;
        background: #f8fafc !important;
    }
    .woocommerce table.shop_table td.product-name::before {
        display: none !important; /* Product names usually don't need label */
    }
    .woocommerce table.shop_table td.product-name a {
        font-weight: 700 !important;
        font-size: 15px !important;
        color: #0f172a !important;
        text-decoration: none !important;
    }
    
    /* Remove quantity table row style and center items */
    .woocommerce table.shop_table td.product-quantity .quantity {
        margin: 0 0 0 auto !important;
    }
    
    /* Order Details Product Total */
    .woocommerce table.shop_table td.product-total {
        font-weight: 800 !important;
        color: #7c3aed !important;
    }

    /* Cart Images */
    .woocommerce table.shop_table td.product-thumbnail {
        justify-content: center !important;
        background: #fff !important;
    }
    .woocommerce table.shop_table td.product-thumbnail::before { display: none !important; }
    .woocommerce table.shop_table td.product-thumbnail img {
        width: 80px !important;
        height: auto !important;
        border-radius: 8px !important;
    }
    
    /* Remove item link formatting on cart table so it doesn't break flex */
    .woocommerce table.shop_table td.product-remove {
        position: absolute;
        top: 10px;
        right: 10px;
        border: none !important;
        width: auto !important;
        padding: 0 !important;
    }
    .woocommerce table.shop_table td.product-remove::before { display: none !important; }

}
