/* ======================
   CART SYSTEM STYLES
   ====================== */

/* Base Cart Styles */
[data-cart-count] {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

/* Button States */
.add-to-cart {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.add-to-cart.loading {
    pointer-events: none;
}

.add-to-cart.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    z-index: 1;
}

/* Cart Preview Styles */
[data-cart-preview] {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 1050;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 1.5rem;
}

body.cart-preview-open {
    overflow: hidden;
}

[data-cart-preview].show {
    right: 0;
}

.cart-preview-header {
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cart-preview-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.cart-preview-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

.cart-items {
    margin-bottom: 1.5rem;
}

.cart-item {
    display: flex;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    position: relative;
    gap: 1rem;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image {
    width: 80px;
    flex-shrink: 0;
}

.cart-item-image img {
    width: 100%;
    height: auto;
    border-radius: 0.25rem;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: #6c757d;
    font-size: 0.9rem;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: auto;
    align-self: flex-start;
}

.cart-summary {
    padding: 1.5rem 0;
    border-top: 1px solid #eee;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.cart-actions .btn {
    padding: 0.75rem;
}

.empty-cart {
    text-align: center;
    padding: 2rem 0;
}

.empty-cart i {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.empty-cart p {
    margin-bottom: 1.5rem;
}

/* Loading State */
.cart-loading {
    text-align: center;
    padding: 2rem 0;
}

.cart-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Error State */
.cart-error {
    text-align: center;
    padding: 2rem 0;
}

.cart-error i {
    font-size: 2rem;
    color: #dc3545;
    margin-bottom: 1rem;
}

.cart-error p {
    margin-bottom: 1.5rem;
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.animate-bounce {
    animation: bounce 0.5s;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
}

.toast {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    border: none;
}

/* Quantity Controls */
.quantity-control {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
}

.quantity-control button {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quantity-control button:hover {
    background: #e9ecef;
}

.quantity-control input {
    width: 50px;
    height: 30px;
    text-align: center;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    padding: 0;
}

/* Remove spinner controls from number inputs */
.quantity-control input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity-control input[type="number"]::-webkit-inner-spin-button,
.quantity-control input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Mobile Styles */
@media (max-width: 768px) {
    [data-cart-preview] {
        max-width: 100%;
        border-radius: 0;
    }

    .cart-actions {
        grid-template-columns: 1fr;
    }

    .cart-item {
        flex-direction: column;
        gap: 0.75rem;
    }

    .cart-item-image {
        width: 100%;
    }

    .cart-item-remove {
        margin-left: 0;
        align-self: flex-end;
    }
}

/* Cart Overlay */
.cart-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

body.cart-preview-open .cart-preview-overlay {
    opacity: 1;
    visibility: visible;
}

/* Empty State Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-cart {
    animation: fadeIn 0.5s ease;
}

/* Smooth transitions for cart items */
.cart-item {
    transition: all 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    [data-cart-preview] {
        padding: 1rem;
    }
    
    .cart-item {
        padding: 0.75rem 0;
    }
    
    .cart-summary {
        padding: 1rem 0;
    }
}