/**
 * NBDesigner Cart Page Fixes
 * Fixes the broken layout and styling issues on the WooCommerce cart page
 */

/* 1. Fix Cart Table Structure */
.woocommerce table.cart td.product-name {
    width: 40% !important;
    min-width: 300px !important;
}

.woocommerce table.cart .product-thumbnail {
    width: 100px !important;
    display: inline-block !important;
    vertical-align: top !important;
    margin-right: 15px !important;
    float: left;
}

.woocommerce table.cart .product-thumbnail img {
    width: 100px !important;
    height: auto !important;
    display: block !important;
    max-width: 100px !important;
}

/* 2. Hide Duplicate/Debug Images */
.woocommerce table.cart .nbd-cart-item-design-view {
    display: inline-block !important;
    vertical-align: top !important;
    max-width: 100px;
    margin-right: 15px;
}

/* Hide all extra NBDesigner images except the first */
.woocommerce table.cart .nbd-cart-item-design-view img:not(:first-child) {
    display: none !important;
}

/* Hide duplicate thumbnail containers */
.woocommerce table.cart td.product-name .nbd-cart-item-design-view + .nbd-cart-item-design-view {
    display: none !important;
}

/* 3. Style the Edit Design Button */
.nbd-edit-design,
a.nbd-edit-design {
    background: #007cba !important;
    color: white !important;
    padding: 5px 15px !important;
    text-decoration: none !important;
    border-radius: 3px !important;
    display: inline-block !important;
    margin-top: 10px !important;
    font-size: 12px !important;
    text-transform: uppercase;
    font-weight: 600;
    border: none !important;
    transition: background 0.3s ease;
}

.nbd-edit-design:hover,
a.nbd-edit-design:hover {
    background: #005a87 !important;
    color: white !important;
    text-decoration: none !important;
}

/* 4. Fix the Price Display */
.nbd-extra-price {
    display: block !important;
    font-size: 14px !important;
    color: #666 !important;
    margin-top: 5px !important;
    font-style: italic;
}

/* Better formatting for design fee */
.woocommerce table.cart .product-name small.nbd-extra-price {
    display: block;
    margin-top: 8px;
    padding: 5px 10px;
    background: #f0f8ff;
    border-left: 3px solid #007cba;
    border-radius: 3px;
}

/* 5. Product Info Layout */
.woocommerce table.cart td.product-name .product-info-wrapper {
    display: inline-block;
    vertical-align: top;
    max-width: calc(100% - 120px);
}

.woocommerce table.cart .product-name dl {
    margin: 10px 0 !important;
    font-size: 14px !important;
    clear: both;
}

.woocommerce table.cart .product-name dt {
    display: inline !important;
    font-weight: bold !important;
    color: #333;
}

.woocommerce table.cart .product-name dd {
    display: inline !important;
    margin-left: 5px !important;
    margin-right: 15px;
    color: #666;
}

/* 6. Clean up the Custom Designs text */
.woocommerce table.cart .product-name > p {
    margin: 10px 0 5px !important;
    font-size: 14px !important;
    color: #007cba;
    font-weight: 600;
}

/* 7. Format product variations properly */
.woocommerce table.cart .variation {
    margin-top: 8px !important;
    padding: 8px;
    background: #f7f7f7;
    border-radius: 3px;
    font-size: 13px;
}

.woocommerce table.cart .variation dt,
.woocommerce table.cart .variation dd {
    display: inline-block !important;
    margin: 0 5px 0 0 !important;
}

/* 8. Clean up the overall product cell */
.woocommerce table.cart td.product-name {
    padding: 20px !important;
}

/* Ensure product name link is styled properly */
.woocommerce table.cart td.product-name > a {
    font-weight: 600 !important;
    color: #333 !important;
    font-size: 16px !important;
    text-decoration: none !important;
    display: block;
    margin-bottom: 8px;
}

.woocommerce table.cart td.product-name > a:hover {
    color: #007cba !important;
}

/* 9. Fix NBDesigner's container structure */
.nbd-cart-item-root {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    width: 100%;
}

/* 10. Responsive fixes */
@media (max-width: 768px) {
    .woocommerce table.cart td.product-name {
        width: 100% !important;
        min-width: auto !important;
    }
    
    .woocommerce table.cart .product-thumbnail {
        width: 80px !important;
        margin-right: 10px !important;
    }
    
    .woocommerce table.cart .product-thumbnail img {
        width: 80px !important;
    }
}

/* 11. Hide debug/test output */
.nbd-cart-item-design-view .nbd-design-id,
.nbd-cart-item-design-view .nbd-design-folder {
    display: none !important;
}

/* 12. Better integration with design thumbnail */
.nbd-cart-item-design-view {
    border: 1px solid #e1e1e1;
    padding: 3px;
    border-radius: 3px;
    background: white;
}

/* 13. Fix any overflow issues */
.woocommerce table.cart td {
    overflow: visible !important;
}

/* 14. Clean up spacing */
.woocommerce table.cart .product-name > * {
    margin-bottom: 8px;
}

.woocommerce table.cart .product-name > *:last-child {
    margin-bottom: 0;
}

/* 15. Fix stacked images issue */
.woocommerce table.cart .nbd-cart-item-design-view a {
    display: block;
    width: 100px;
    height: 100px;
    overflow: hidden;
}

.woocommerce table.cart .nbd-cart-item-design-view img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Only show first design thumbnail */
.nbd-cart-item-design-view a:not(:first-of-type) {
    display: none !important;
}

/* 16. Hide backorder notice in cart (made-to-order) */
.woocommerce-cart .backorder_notification {
    display: none !important;
}
