/* WebSync Cart Widget - Optimized Base Styles */
:where(.websync-cart-wrapper) {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

:where(.websync-cart-wrapper, .websync-cart-wrapper *) {
    box-sizing: border-box;
}

/* Layout Components */
.websync-cart-wrapper .websync-cart-content,
.websync-cart-main-content {
    display: grid;
    gap: 20px;
    width: 100%;
    grid-template-columns: 2fr 1fr;
}

.websync-cart-main-content form.woocommerce-cart-form {
    flex: 1;
}

/* Cart Table */
.websync-cart-wrapper table.shop_table {
    background: #fff;
    border-collapse: collapse;
}

.websync-cart-wrapper table.shop_table.websync-cart-form__contents {
    width: 100%;
    margin-bottom: 30px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.websync-cart-wrapper table.shop_table thead {
    border-bottom: 1px solid #ccc;
}

.websync-cart-wrapper table.shop_table :is(th, td) {
    padding: 15px;
    text-align: left;
    border: none;
}

.websync-cart-wrapper table.shop_table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.websync-cart-wrapper table.shop_table td {
    vertical-align: middle;
}

.websync-cart-wrapper table.shop_table.websync-cart-form__contents td.product-remove {
    width: 50px;
}

/* Cart Totals */
.websync-cart-wrapper .cart_totals {
    background: #f8f9fa;
    padding: 25px;
    border: 1px solid #e9ecef;
    margin-bottom: 30px;
    position: sticky;
    top: 20px;
}

.websync-cart-wrapper .cart_totals h2 {
    margin-bottom: 20px;
    color: #343a40;
    font-size: 22px;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.websync-cart-wrapper .cart_totals table {
    width: 100%;
    border-collapse: collapse;
}

.websync-cart-wrapper .cart_totals :is(th, td) {
    padding: 12px 0;
    border-bottom: 1px solid #dee2e6;
    text-align: left;
    vertical-align: top;
    background-color: #F8F9FA;
}

.websync-cart-wrapper .cart_totals tr:last-child :is(th, td) {
    border-bottom: none;
}

/* Shipping Methods */
.websync-cart-wrapper .cart_totals :is(.shipping-methods, ul#shipping_method) {
    list-style: none;
    padding: 0;
    margin: 5px 0 0;
    display: block !important;
}

.websync-cart-wrapper .cart_totals :is(.shipping-methods li, ul#shipping_method li) {
    margin-bottom: 5px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.websync-cart-wrapper .cart_totals .shipping-methods li.selected {
    background: #ebf8ff;
    border-color: #4299e1;
}

.websync-cart-wrapper .cart_totals :is(.shipping-methods li input[type="radio"], ul#shipping_method li input) {
    margin-right: 8px;
}

.websync-cart-wrapper .cart_totals ul#shipping_method li {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.websync-cart-wrapper .cart_totals ul#shipping_method li label {
    display: inline;
    margin: 0;
}

.websync-cart-wrapper .cart_totals .woocommerce-shipping-destination {
    font-size: 13px;
    color: #718096;
    margin-top: 5px;
    font-style: italic;
}

/* Shipping Calculator Button */
:is(.websync-cart-wrapper .cart_totals .shipping-calculator-button, .shipping-calculator-button) {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 15px;
    background: #e2e8f0;
    color: #4a5568;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #cbd5e0;
    transition: background-color 0.2s ease;
}

:is(.websync-cart-wrapper .cart_totals .shipping-calculator-button, .shipping-calculator-button):hover {
    background: #cbd5e0;
}

/* Shipping Preview/Editor */
:is(.websync-shipping-editor-preview, .shipping-calculator-form) {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin-top: 20px;
}

.websync-shipping-editor-preview .description {
    margin-top: 8px;
    color: #6c757d;
    font-style: italic;
}

/* Order Total Section */
.websync-cart-wrapper .cart_totals .order-total {
    background: #f7fafc;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    border: 2px solid #e2e8f0;
}

.websync-cart-wrapper .cart_totals .order-total th {
    font-size: 18px;
    color: #2d3748;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.websync-cart-wrapper .cart_totals .order-total td {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.websync-cart-wrapper .cart_totals .order-total .amount {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
}

/* Empty Cart */
.websync-cart-wrapper.websync-empty-cart-message {
    padding: 40px 20px;
    text-align: center;
}

.websync-empty-cart-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.websync-empty-cart-icon {
    margin-bottom: 25px;
    color: #6c757d;
}

.websync-empty-cart-icon svg {
    stroke: #adb5bd;
    width: 64px;
    height: 64px;
}

.websync-empty-cart-container h3 {
    color: #343a40;
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: 600;
}

.websync-empty-cart-container p {
    color: #6c757d;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.websync-empty-cart-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.websync-empty-cart-actions .button {
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    min-width: 160px;
    transition: all 0.3s ease;
}

.websync-button-primary {
    background-color: #2271b1;
    color: white !important;
}

.websync-button-primary:hover {
    background-color: #135e96;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.2);
}

/* Product Elements */
.websync-cart-wrapper .product-thumbnail img {
    width: 80px;
    height: auto;
    border-radius: 4px;
}

.websync-cart-wrapper .product-name {
    font-weight: 500;
    color: #343a40;
}

.websync-cart-wrapper .product-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.websync-cart-wrapper .product-name a:hover {
    color: #2271b1;
}

/* Quantity Input */
.websync-cart-wrapper .quantity .qty {
    width: 70px;
    padding: 8px 10px;
    text-align: center;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Remove Button */
.websync-cart-wrapper .product-remove a {
    color: #dc3545;
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    display: inline-block;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.websync-cart-wrapper .product-remove a:hover {
    background: #f8d7da;
    color: #721c24;
}

/* Coupon & Actions */
.websync-cart-coupon-row {
    display: flex;
    gap: 50px;
}

.websync-cart-wrapper .coupon {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

.websync-cart-wrapper .coupon .input-text {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    max-width: 300px;
}

.websync-cart-wrapper .coupon .button {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.websync-cart-wrapper .coupon .button:hover {
    background: #5a6268;
}

/* Cart Actions Container */
.websync-cart-actions .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

.websync-cart-actions .coupon {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.websync-cart-actions .coupon label {
    margin: 0;
    white-space: nowrap;
}

.websync-cart-actions .coupon .input-text {
    min-width: 200px;
}

.websync-cart-actions .actions:not(:has(.coupon)) {
    justify-content: flex-end;
}

/* Buttons */
.websync-cart-wrapper .websync-cart-update-button-container .button[name="update_cart"] {
    padding: 10px 20px;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.websync-cart-wrapper .websync-cart-update-button-container .button[name="update_cart"]:hover {
    background: #138496;
}

.elementor-widget-websync_cart .websync-cart-wrapper .cart_totals a.checkout-button {
    display: block;
    width: 100%;
    padding: 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.elementor-widget-websync_cart .websync-cart-wrapper .cart_totals a.checkout-button:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
}

/* Continue Shopping & Return */
.websync-continue-shopping {
    display: block;
    margin: 10px auto;
    text-align: center;

}
:is(.websync-continue-shopping-button, .websync-cart-wrapper .return-to-shop .button) {
    display: inline-block;
    padding: 12px 30px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.websync-continue-shopping-button {
    background-color: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.websync-continue-shopping-button:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.websync-cart-wrapper .return-to-shop .button {
    background: #6c757d;
    color: white;
    border: none;
}

.websync-cart-wrapper .return-to-shop .button:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Cross-sells */
.websync-cart-wrapper .cross-sells {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid #dee2e6;
}

.websync-cart-wrapper .cross-sells h2 {
    margin-bottom: 20px;
    color: #343a40;
    font-size: 24px;
    font-weight: 600;
}

.websync-cart-wrapper .cross-sells ul.products,
.websync-cross-sells ul.products {
    display: grid;
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.websync-cart-wrapper .cross-sells ul.products:after,
.websync-cart-wrapper .cross-sells ul.products:before {
    display: none;
}

/* Cross-sells Products Grid */
.websync-cross-sells ul.products.columns-1 { grid-template-columns: 1fr; }
.websync-cross-sells ul.products.columns-2 { grid-template-columns: repeat(2, 1fr); }
.websync-cross-sells ul.products.columns-3 { grid-template-columns: repeat(3, 1fr); }
.websync-cross-sells ul.products.columns-4 { grid-template-columns: repeat(4, 1fr); }

.websync-cross-sells ul.products li.product {
    background: #fff;
    border: 1px solid #eee;
    padding: 16px;
    text-align: center;
    border-radius: 6px;
    width: 100%;
}

.websync-cross-sells ul.products li.product .woocommerce-loop-product__title {
    font-size: 16px;
    margin-bottom: 6px;
}

.websync-cross-sells ul.products li.product .price {
    font-size: 15px;
    margin-bottom: 10px;
    display: block;
}

.websync-cross-sells ul.products li.product .button {
    background: #6b3fa0;
    color: #fff;
    padding: 10px 16px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.websync-cross-sells ul.products li.product .button:hover {
    background: #583388;
}

/* Loading States */
.websync-cart-wrapper .blockUI.blockOverlay {
    background: rgba(255,255,255,0.8) !important;
}

/* Editor Preview */
.websync-cart-editor-preview {
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    text-align: center;
    margin: 20px 0;
}

.websync-cart-editor-preview h4 {
    color: white;
    font-size: 18px;
    margin-bottom: 10px;
}

.websync-cart-editor-preview p {
    opacity: 0.9;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .websync-cross-sells ul.products.columns-4,
    .websync-cross-sells ul.products.columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .websync-cart-wrapper .cart_totals {
        position: static;
    }

    .websync-cart-wrapper .coupon {
        min-width: 100%;
    }

    .websync-cart-wrapper .actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 768px) {
    .websync-cart-wrapper {
        padding: 15px;
    }

    .websync-cart-totals-wrapper .cart_totals tr {
        background-color: #F8F9FA;
    }

    .websync-cart-totals-wrapper .cart_totals .shop_table tbody {
        display: block;
    }

    .websync-cart-wrapper .cart_totals ul#shipping_method li,
    .websync-cart-totals-wrapper .cart_totals td {
        background-color: #F8F9FA;
    }

    .websync-cart-coupon-row,
    .websync-cart-main-content {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .websync-cart-wrapper table.shop_table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents thead {
        display: none;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents tbody {
        display: block;
        width: 100%;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents tbody tr {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 15px;
        background: #F8F9FA;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents tbody td {
        display: block;
        text-align: left;
        padding: 10px 0;
        border-bottom: 1px solid #e7e7e7;
        background: #F8F9FA;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents tbody td:before {
        content: attr(data-title);
        font-weight: 600;
        display: block;
        margin-bottom: 5px;
        color: #495057;
    }

    .websync-cart-wrapper table.shop_table.websync-cart-form__contents tbody td:last-child {
        border-bottom: none;
    }

    .websync-cross-sells ul.products,
    .websync-cart-wrapper .cross-sells ul.products {
        grid-template-columns: 1fr !important;
    }

    .websync-empty-cart-actions {
        flex-direction: column;
        align-items: center;
    }

    .websync-empty-cart-actions .button {
        width: 100%;
        max-width: 250px;
    }

    .websync-empty-cart-container {
        padding: 30px 20px;
    }

    .websync-cart-wrapper .cart_totals ul#shipping_method {
        width: 100%;
        display: flex !important;
        flex-direction: column;
        padding-top: 15px;
    }

    .websync-cart-wrapper .cart_totals .shipping-calculator-form {
        text-align: left;
    }

    .websync-cart-wrapper .cart_totals .shipping-calculator-form label {
        line-height: 1.5;
    }
}