/**
 * WooCommerce Cart Page Styles
 * RS Aquatics Theme
 */

/* ==========================================================================
   Base Cart Structure
   ========================================================================== */

.woocommerce {
    width: 100%;
}

.woocommerce-cart-form {
    width: 100%;
}

/* Clear floats */
.woocommerce::after {
    content: "";
    display: table;
    clear: both;
}

/* ==========================================================================
   Desktop Layout (768px and above)
   ========================================================================== */

@media (min-width: 768px) {
    .woocommerce-cart-form {
        float: left;
        width: 65%;
        padding-right: 30px;
    }

    .cart-collaterals {
        float: right;
        width: 35%;
        position: sticky;
        top: 0px;
    }
}

/* ==========================================================================
   Cart Table Styling
   ========================================================================== */

.woocommerce-cart-form__contents {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

/* Table Header */
.woocommerce-cart-form__contents thead {
    background: rgba(16, 81, 171, 0.05);
}

.woocommerce-cart-form__contents thead th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(16, 81, 171, 0.2);
}

.woocommerce-cart-form__contents thead th.product-thumbnail,
.woocommerce-cart-form__contents thead th.product-remove {
    width: 0;
    padding: 0;
}
.woocommerce-cart-form__contents thead th.product-remove{
    display: none;
}
/* ==========================================================================
   Product Row Styling (Desktop)
   ========================================================================== */

.cart_item {
    transition: all 0.3s ease;
}

.cart_item:hover {
    background: rgba(16, 81, 171, 0.03);
}

.cart_item > td {
    padding: 20px 12px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(16, 81, 171, 0.1);
}

/* Product Thumbnail */
.cart_item .product-thumbnail {
    width: 80px;
}

.cart_item .product-thumbnail img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(16, 81, 171, 0.2);
}

/* Product Name */
.cart_item .product-name {
    width: 35%;
}

.cart_item .product-name a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #fff;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.cart_item .product-name a:hover {
    color: var(--accent);
}

/* Product Price */
.cart_item .product-price {
    color: #9ca3af;
    font-size: 14px;
}

/* Product Subtotal */
.cart_item .product-subtotal {
    color: var(--accent);
    font-weight: 600;
    font-size: 16px;
}

/* Remove the default × remove link */
.cart_item .product-remove {
    display: none;
}

/* ==========================================================================
   Quantity Selector
   ========================================================================== */

.product-quantity {
    width: 140px;
}

.quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(17, 17, 24, 0.8);
    border: 1px solid rgba(16, 81, 171, 0.2);
    border-radius: 8px;
    padding: 4px;
}

.quantity-wrapper input.qty {
    width: 40px;
    height: 32px;
    text-align: center;
    background: transparent;
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    -moz-appearance: textfield;
}

.quantity-wrapper input.qty::-webkit-outer-spin-button,
.quantity-wrapper input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quantity-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}

/* Default state - Minus and Plus buttons */
.qty-minus,
.qty-plus {
    background: rgba(16, 81, 171, 0.1);
    color: var(--accent);
}

.qty-minus:hover,
.qty-plus:hover {
    background: rgba(16, 81, 171, 0.25);
    transform: scale(1.1);
}

/* Delete state - Red trash icon */
.qty-minus.is-delete {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.qty-minus.is-delete:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.1);
}

/* ==========================================================================
   Cart Actions (Coupon + Update Cart)
   ========================================================================== */

.actions {
    padding: 24px 0 !important;
    border-top: 2px solid rgba(16, 81, 171, 0.2);
}

/* Coupon Section */
.coupon {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1a1a24 !important;
    border: 1px solid #2d2d3d !important;
    border-radius: 0.75rem !important;
    color: #ffffff !important;
    font-size: 1rem !important;
    transition: all 0.3s ease !important;
}

.coupon label {
    display: none;
}

.coupon input.input-text {
    flex: 1;
    min-width: 0;
    width: auto;
    max-width: none;
    padding: 12px 16px;
    background: rgba(17, 17, 24, 0.5);
    border: 1px solid rgba(16, 81, 171, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    transition: all 0.3s ease;
}

.coupon input.input-text:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 81, 171, 0.1);
}

.coupon input.input-text::placeholder {
    color: #6b7280;
}

.coupon button.button {
    width: auto !important;
    padding: 12px 24px;
    background: rgba(16, 81, 171, 0.1);
    border: 1px solid rgba(16, 81, 171, 0.3);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    margin-top: unset !important;
}

.coupon button.button:hover {
    background: rgba(16, 81, 171, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 81, 171, 0.2);
}

/* Update Cart Button */
button[name="update_cart"] {
    padding: 12px 24px;
    background: transparent;
    border: 1px solid rgba(16, 81, 171, 0.3);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button[name="update_cart"]:hover:not(:disabled) {
    background: rgba(16, 81, 171, 0.1);
    transform: translateY(-2px);
}

button[name="update_cart"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Cart Totals Sidebar
   ========================================================================== */

.cart_totals {
    background: rgba(17, 17, 24, 0.7);
    border: 1px solid rgba(16, 81, 171, 0.1);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(10px);
}

.cart_totals h2 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(16, 81, 171, 0.2);
}

.cart_totals .shop_table {
    width: 100%;
    margin-bottom: 24px;
}

.cart_totals .shop_table tr {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cart_totals .shop_table th {
    font-weight: 500;
    color: #9ca3af;
}

.cart_totals .shop_table td {
    font-weight: 600;
    color: #fff;
}

.cart_totals .order-total {
    border-bottom: none;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 2px solid rgba(16, 81, 171, 0.2);
}

.cart_totals .order-total th,
.cart_totals .order-total td {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

/* Proceed to Checkout Button */
.wc-proceed-to-checkout {
    margin-top: 20px;
}

.wc-proceed-to-checkout .checkout-button {
    display: block;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 12px;
    color: #0a0a0f;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wc-proceed-to-checkout .checkout-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 81, 171, 0.4);
}

.wc-proceed-to-checkout .checkout-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.wc-proceed-to-checkout .checkout-button:hover::before {
    left: 100%;
}

/* ==========================================================================
   Mobile Layout (below 768px)
   ========================================================================== */

@media (max-width: 767px) {
    /* Stack layout */
    .woocommerce-cart-form,
    .cart-collaterals {
        float: none;
        width: 100%;
        padding-right: 0;
    }

    .cart-collaterals {
        position: static;
        margin-top: 30px;
    }

    /* Transform table to cards */
    .woocommerce-cart-form__contents,
    .woocommerce-cart-form__contents tbody,
    .woocommerce-cart-form__contents tr,
    .woocommerce-cart-form__contents td,
    .woocommerce-cart-form__contents th {
        display: block;
        width: 100%;
    }

    /* Hide table headers */
    .woocommerce-cart-form__contents thead {
        display: none;
    }

    /* Product card styling */
    .woocommerce-cart-form__contents .cart_item {
        display: grid !important;
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto auto;
        gap: 8px 12px;
        padding: 16px;
        margin-bottom: 16px;
        background: rgba(17, 17, 24, 0.5);
        border: 1px solid rgba(16, 81, 171, 0.1);
        border-radius: 12px;
        position: relative;
    }

    .woocommerce-cart-form__contents .cart_item > td {
        padding: 0;
        border: none;
    }

    /* Image on left */
    .woocommerce-cart-form__contents .cart_item .product-thumbnail {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: auto;
    }

    .woocommerce-cart-form__contents .cart_item .product-thumbnail img {
        width: 80px;
        height: 80px;
        border-radius: 8px;
    }

    /* Name on right */
    .woocommerce-cart-form__contents .cart_item .product-name {
        grid-column: 2;
        grid-row: 1;
        width: auto;
    }

    /* Price below name */
    .woocommerce-cart-form__contents .cart_item .product-price {
        grid-column: 2;
        grid-row: 2;
        width: auto;
        color: var(--accent);
        font-weight: 600;
        font-size: 16px;
    }

    /* Quantity and subtotal row */
    .woocommerce-cart-form__contents .cart_item .product-quantity {
        grid-column: 1 / span 2;
        grid-row: 3;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 12px;
        margin-top: 8px;
        border-top: 1px solid rgba(16, 81, 171, 0.1);
    }

    .woocommerce-cart-form__contents .cart_item .product-subtotal {
        display: none; /* Hide subtotal, show only in quantity row */
    }

    /* Show subtotal label in mobile */
    .woocommerce-cart-form__contents .cart_item .product-quantity::before {
        content: 'Subtotal: ';
        color: #6b7280;
        font-size: 14px;
    }

    .woocommerce-cart-form__contents .cart_item .product-quantity::after {
        content: attr(data-subtotal);
        color: var(--accent);
        font-weight: 600;
        font-size: 16px;
    }

    /* Mobile quantity selector */
    .quantity-wrapper {
        order: -1;
    }

    /* Actions section */
    .actions {
        padding: 16px 0 !important;
    }

    /* Coupon inline on mobile */
    .coupon {
        flex-direction: row;
    }

    .coupon button.button {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* ==========================================================================
   Extra Small Mobile (below 412px)
   ========================================================================== */

@media (max-width: 411px) {
    .woocommerce-cart-form__contents .cart_item {
        grid-template-columns: 60px 1fr;
        gap: 6px 10px;
        padding: 12px;
    }

    .woocommerce-cart-form__contents .cart_item .product-thumbnail img {
        width: 60px;
        height: 60px;
    }

    .woocommerce-cart-form__contents .cart_item .product-name a {
        font-size: 14px;
        -webkit-line-clamp: 2;
    }

    .woocommerce-cart-form__contents .cart_item .product-price {
        font-size: 14px;
    }

    .quantity-wrapper {
        transform: scale(0.9);
        transform-origin: left center;
    }

    .cart_totals {
        padding: 16px;
    }

    .cart_totals h2 {
        font-size: 18px;
    }

    .wc-proceed-to-checkout .checkout-button {
        padding: 14px 20px;
        font-size: 14px;
    }
}

/* ==========================================================================
   Empty Cart Styling
   ========================================================================== */

.woocommerce-cart .cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 18px;
}

.woocommerce-cart .cart-empty::before {
    content: '\f07a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    display: block;
    font-size: 64px;
    color: rgba(16, 81, 171, 0.2);
    margin-bottom: 24px;
}

.woocommerce-cart .return-to-shop {
    text-align: center;
    margin-top: 24px;
}

.woocommerce-cart .return-to-shop .button {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 12px;
    color: #0a0a0f;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
}

.woocommerce-cart .return-to-shop .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 81, 171, 0.4);
}

/* ==========================================================================
   Messages & Notifications
   ========================================================================== */

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
    padding: 16px 20px;
    margin-bottom: 24px;
    border-radius: 12px;
    border-left: 4px solid;
}

.woocommerce-message {
    background: rgba(16, 81, 171, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.woocommerce-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
}

.woocommerce-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.woocommerce-cart-form.processing {
    opacity: 0.6;
    pointer-events: none;
}

.woocommerce-cart-form.processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(16, 81, 171, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Cross-sells / Product Carousel
   ========================================================================== */

.cross-sells,
.cart-collaterals + section,
.cart-related-products {
    clear: both;
    /* margin-top: 60px; */
    padding-top: 40px;
    border-top: 1px solid rgba(16, 81, 171, 0.1);
}

.cross-sells h2,
.cart-related-products h2 {
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
}

/* ==========================================================================
   TASK-015: Mobile cart readability and table scoping
   ========================================================================== */

.rs-cart-shell {
    min-width: 0;
}

.rs-cart-shell .woocommerce-cart-form,
.rs-cart-shell .cart-collaterals,
.rs-cart-shell .cart_totals {
    max-width: 100%;
    min-width: 0;
}

.rs-cart-shell .woocommerce-cart-form__contents {
    width: 100%;
}

.rs-cart-shell .woocommerce-cart-form__contents .product-name a {
    overflow-wrap: anywhere;
}

.rs-cart-shell .cart_totals .shop_table {
    min-width: 0;
    table-layout: fixed;
}

.rs-cart-shell .cart_totals .shop_table th,
.rs-cart-shell .cart_totals .shop_table td {
    overflow-wrap: anywhere;
}

@media (max-width: 767px) {
    .rs-cart-shell .woocommerce-cart-form__contents {
        min-width: 0;
        border: 0;
    }

    .rs-cart-shell .woocommerce-cart-form__contents thead {
        display: none;
    }

    .rs-cart-shell .woocommerce-cart-form__contents,
    .rs-cart-shell .woocommerce-cart-form__contents tbody,
    .rs-cart-shell .woocommerce-cart-form__contents tr,
    .rs-cart-shell .woocommerce-cart-form__contents td {
        display: block;
        width: 100%;
    }

    .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
        display: grid;
        grid-template-columns: 4.75rem minmax(0, 1fr);
        gap: 0.75rem 1rem;
        margin-bottom: 1rem;
        padding: 1rem;
        border: 1px solid rgba(16, 81, 171, 0.12);
        border-radius: 0.875rem;
        background: rgba(17, 17, 24, 0.84);
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-remove {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        width: auto;
        padding: 0;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-thumbnail {
        grid-column: 1;
        grid-row: 1 / span 2;
        padding: 0;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-thumbnail img {
        width: 4.75rem;
        height: 4.75rem;
        object-fit: cover;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-name {
        grid-column: 2;
        grid-row: 1;
        padding: 0 2rem 0 0;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-price {
        grid-column: 2;
        grid-row: 2;
        width: auto;
        padding: 0;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-quantity {
        grid-column: 1 / -1;
        grid-row: 3;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.75rem 0 0;
        margin-top: 0.25rem;
        border-top: 1px solid rgba(16, 81, 171, 0.12);
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-quantity::before,
    .rs-cart-shell .woocommerce-cart-form__contents .product-quantity::after {
        content: none;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-subtotal {
        grid-column: 1 / -1;
        grid-row: 4;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        width: 100%;
        padding: 0.75rem 0 0;
        color: var(--accent);
        font-size: 1rem;
        font-weight: 700;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-subtotal::before {
        content: 'Subtotal';
        color: #9ca3af;
        font-size: 0.875rem;
        font-weight: 600;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .actions {
        display: block;
        width: 100%;
        padding: 1rem 0 0 !important;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .coupon {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .coupon input,
    .rs-cart-shell .woocommerce-cart-form__contents .coupon .button,
    .rs-cart-shell .woocommerce-cart-form__contents button[name="update_cart"] {
        width: 100%;
    }

    .rs-cart-shell .cart-collaterals,
    .rs-cart-shell .cart_totals {
        width: 100%;
        float: none;
    }

    .rs-cart-shell .cart_totals .shop_table,
    .rs-cart-shell .cart_totals .shop_table tbody {
        display: table;
        width: 100%;
    }

    .rs-cart-shell .cart_totals .shop_table tr {
        display: table-row;
    }

    .rs-cart-shell .cart_totals .shop_table th,
    .rs-cart-shell .cart_totals .shop_table td {
        display: table-cell;
        width: auto;
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 411px) {
    .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
        grid-template-columns: 4rem minmax(0, 1fr);
        padding: 0.875rem;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-thumbnail img {
        width: 4rem;
        height: 4rem;
    }
}

/* ==========================================================================
   TASK-015.A: Cart mobile overflow and recommended product containment
   ========================================================================== */

.rs-cart-shell,
.rs-cart-shell .woocommerce,
.rs-cart-shell .woocommerce-cart-form,
.rs-cart-shell .woocommerce-cart-form__contents,
.rs-cart-shell .cart-collaterals,
.rs-cart-shell .cart_totals {
    max-width: 100%;
    min-width: 0;
}

.rs-cart-shell .woocommerce-cart-form__contents,
.rs-cart-shell .shop_table {
    table-layout: auto;
}

.rs-cart-shell .product-name,
.rs-cart-shell .product-price,
.rs-cart-shell .product-quantity,
.rs-cart-shell .product-subtotal,
.rs-cart-shell .cart_totals th,
.rs-cart-shell .cart_totals td {
    min-width: 0;
    overflow-wrap: anywhere;
}

.rs-cart-shell .quantity-wrapper {
    max-width: 100%;
}

.rs-cart-shell .coupon,
.rs-cart-shell .actions {
    max-width: 100%;
    min-width: 0;
}

.woocommerce-cart-page .product-carousel,
.woocommerce-cart-page .product-carousel .slick-list,
.woocommerce-cart-page .product-carousel .slick-track,
.woocommerce-cart-page .product-carousel .slick-slide,
.woocommerce-cart-page .cart-related-products,
.woocommerce-cart-page .cross-sells {
    max-width: 100%;
}

.woocommerce-cart-page .product-carousel .slick-list {
    overflow: hidden;
}

.woocommerce-cart-page .product-carousel .slick-slide {
    min-width: 0;
}

@media (max-width: 767px) {
    .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
        grid-template-columns: minmax(3.75rem, 4.25rem) minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-name {
        min-width: 0;
        padding-right: 1.75rem;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-name a {
        display: block;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-quantity {
        flex-wrap: wrap;
        align-items: center;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-subtotal {
        flex-wrap: wrap;
    }

    .rs-cart-shell .quantity-wrapper {
        flex: 0 1 auto;
        transform: none;
    }

    .rs-cart-shell .coupon {
        padding: 0.75rem;
    }

    .rs-cart-shell .coupon input.input-text,
    .rs-cart-shell .coupon button.button,
    .rs-cart-shell button[name="update_cart"] {
        max-width: 100%;
        white-space: normal;
    }

    .rs-cart-shell .cart_totals {
        padding: 1rem;
        overflow: hidden;
    }

    .rs-cart-shell .cart_totals .shop_table,
    .rs-cart-shell .cart_totals .shop_table tbody,
    .rs-cart-shell .cart_totals .shop_table tr,
    .rs-cart-shell .cart_totals .shop_table th,
    .rs-cart-shell .cart_totals .shop_table td {
        max-width: 100%;
    }

    .rs-cart-shell .wc-proceed-to-checkout .checkout-button {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .woocommerce-cart-page .product-carousel {
        overflow: hidden;
    }
}

@media (max-width: 380px) {
    .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
        grid-template-columns: 3.5rem minmax(0, 1fr);
        gap: 0.625rem;
        padding: 0.75rem;
    }

    .rs-cart-shell .woocommerce-cart-form__contents .product-thumbnail img {
        width: 3.5rem;
        height: 3.5rem;
    }
}

/* ==========================================================================
   TASK-017: Light theme cart surfaces
   ========================================================================== */

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents thead {
    background: #eaf8fb;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents thead th,
body.rs-light-theme .rs-cart-shell .product-subtotal,
body.rs-light-theme .rs-cart-shell .cart_totals .order-total th,
body.rs-light-theme .rs-cart-shell .cart_totals .order-total td {
    color: var(--primary-dark);
}

body.rs-light-theme .rs-cart-shell .cart_item:hover {
    background: #f3fbfd;
}

body.rs-light-theme .rs-cart-shell .cart_item > td,
body.rs-light-theme .rs-cart-shell .actions,
body.rs-light-theme .rs-cart-shell .cart_totals .shop_table tr,
body.rs-light-theme .rs-cart-shell .cart_totals h2,
body.rs-light-theme .cross-sells,
body.rs-light-theme .cart-related-products {
    border-color: var(--dark-600) !important;
}

body.rs-light-theme .rs-cart-shell .cart_item .product-name a,
body.rs-light-theme .rs-cart-shell .cart_totals h2,
body.rs-light-theme .rs-cart-shell .cart_totals .shop_table td,
body.rs-light-theme .cross-sells h2,
body.rs-light-theme .cart-related-products h2 {
    color: var(--text-primary);
}

body.rs-light-theme .rs-cart-shell .cart_item .product-price,
body.rs-light-theme .rs-cart-shell .cart_totals .shop_table th,
body.rs-light-theme .woocommerce-cart .cart-empty {
    color: var(--gray-300);
}

body.rs-light-theme .rs-cart-shell .quantity-wrapper,
body.rs-light-theme .rs-cart-shell .coupon,
body.rs-light-theme .rs-cart-shell .cart_totals,
body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
    background: #ffffff !important;
    border-color: var(--dark-600) !important;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

body.rs-light-theme .rs-cart-shell .coupon input.input-text,
body.rs-light-theme .rs-cart-shell .quantity-wrapper input.qty {
    background: #f8fbfc !important;
    border-color: var(--dark-600) !important;
    color: var(--text-primary) !important;
}

body.rs-light-theme .rs-cart-shell .wc-proceed-to-checkout .checkout-button,
body.rs-light-theme .woocommerce-cart .return-to-shop .button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: #ffffff !important;
}

/* ==========================================================================
   TASK-017.A: Light theme cart readability and carousel fallback
   ========================================================================== */

body.rs-light-theme .rs-cart-shell,
body.rs-light-theme .rs-cart-shell .woocommerce,
body.rs-light-theme .rs-cart-shell .woocommerce-cart-form,
body.rs-light-theme .rs-cart-shell .cart-collaterals,
body.rs-light-theme .rs-cart-shell .cart_totals,
body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item,
body.rs-light-theme .rs-cart-shell .quantity-wrapper,
body.rs-light-theme .rs-cart-shell .coupon,
body.rs-light-theme .cross-sells,
body.rs-light-theme .cart-related-products {
    background: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents thead {
    background: var(--surface-hover) !important;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents thead th,
body.rs-light-theme .rs-cart-shell .cart_totals h2,
body.rs-light-theme .rs-cart-shell .cart_totals .order-total th,
body.rs-light-theme .rs-cart-shell .cart_totals .order-total td,
body.rs-light-theme .cross-sells h2,
body.rs-light-theme .cart-related-products h2 {
    color: var(--text-primary) !important;
}

body.rs-light-theme .rs-cart-shell .cart_item .product-name a,
body.rs-light-theme .rs-cart-shell .cart_totals .shop_table td,
body.rs-light-theme .rs-cart-shell .product-subtotal,
body.rs-light-theme .rs-cart-shell .woocommerce-Price-amount,
body.rs-light-theme .rs-cart-shell .amount {
    color: var(--text-primary) !important;
}

body.rs-light-theme .rs-cart-shell .cart_item .product-price,
body.rs-light-theme .rs-cart-shell .cart_totals .shop_table th,
body.rs-light-theme .rs-cart-shell .product-name .variation,
body.rs-light-theme .woocommerce-cart .cart-empty {
    color: var(--text-secondary) !important;
}

body.rs-light-theme .rs-cart-shell .cart_item:hover {
    background: var(--surface-hover) !important;
}

body.rs-light-theme .rs-cart-shell .coupon input.input-text,
body.rs-light-theme .rs-cart-shell .quantity-wrapper input.qty {
    background: var(--surface-elevated) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

body.rs-light-theme .rs-cart-shell .remove {
    background: var(--danger-soft) !important;
    color: var(--danger) !important;
}

body.rs-light-theme .rs-cart-shell .remove:hover {
    background: var(--danger) !important;
    color: #ffffff !important;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel:not(.slick-initialized) {
    display: grid !important;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel.slick-initialized {
    display: block !important;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel,
body.rs-light-theme .woocommerce-cart-page .product-carousel .slick-list {
    min-height: 19rem;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel .slick-slide {
    height: auto;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel .slick-slide > div {
    height: 100%;
}

/* ==========================================================================
   TASK-019: Cart hierarchy and carousel visibility polish
   ========================================================================== */

.woocommerce-cart-page .product-carousel--has-items:not(.slick-initialized) {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
    min-height: 0;
}

.woocommerce-cart-page .product-carousel-empty {
    max-width: 42rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    min-height: 0;
}

body.rs-light-theme .rs-cart-shell {
    box-shadow: var(--shadow-sm);
}

body.rs-light-theme .rs-cart-shell .woocommerce {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form,
body.rs-light-theme .rs-cart-shell .cart-collaterals {
    box-shadow: none !important;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents,
body.rs-light-theme .rs-cart-shell .cart_totals {
    background: var(--surface) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item {
    box-shadow: none;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents thead {
    background: var(--surface-soft) !important;
}

body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents .actions {
    padding: 1rem !important;
    background: var(--surface-elevated);
    border-top: 1px solid var(--border-subtle) !important;
}

body.rs-light-theme .rs-cart-shell .coupon {
    background: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    box-shadow: none;
}

body.rs-light-theme .rs-cart-shell .cart_totals {
    padding: 1.25rem;
}

body.rs-light-theme .rs-cart-shell .cart_totals .shop_table tr {
    border-color: var(--border-subtle) !important;
}

body.rs-light-theme .rs-cart-shell .quantity-wrapper {
    background: var(--surface-elevated) !important;
    border-color: var(--border-subtle) !important;
    box-shadow: none;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel,
body.rs-light-theme .woocommerce-cart-page .product-carousel .slick-list {
    min-height: 0;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel--has-items:not(.slick-initialized) {
    display: grid !important;
}

body.rs-light-theme .woocommerce-cart-page .product-carousel-empty {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 1024px) {
    .woocommerce-cart-page .product-carousel--has-items:not(.slick-initialized) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none;
        overflow: visible;
    }

    body.rs-light-theme .rs-cart-shell .woocommerce-cart-form__contents tr.cart_item,
    body.rs-light-theme .rs-cart-shell .cart_totals {
        box-shadow: var(--shadow-sm);
    }

    .woocommerce-cart-page .product-carousel--has-items:not(.slick-initialized) {
        grid-template-columns: 1fr;
    }
}
