/* Cart Styles */
:root {
    --primary-color: #d9534f;
    --dark-color: #222;
    --light-gray: #f4f4f4;
    --border-color: #e1e1e1;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 450px;
    height: 100%;
    background-color: #fff;
    z-index: 1001;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: right 0.4s ease-in-out;
    display: flex;
    flex-direction: column;
}

/* Active states */

/* --- Cart item layout fine-tune --- */
.cart-item{display:flex;gap:12px;padding:8px 0;border-bottom:1px solid var(--border-color,#eee);}
.cart-item-image{flex-shrink:0;}
.cart-item-details{flex:1;min-width:0;}
.cart-item-name{font-size:14px;margin:0 0 2px;}
.cart-item-desc{font-size:12px;color:#666;margin:0 0 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.cart-item-quantity-controls{display:inline-flex;gap:6px;align-items:center;margin-top:4px;}
.cart-item-price-remove{text-align:right;white-space:nowrap;}
.cart-item-price{font-weight:600;font-size:14px;display:block;margin-bottom:4px;}
.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-sidebar.active {
    right: 0;
}

/* Cart Header */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.close-cart-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #888;
    padding: 0;
    line-height: 1;
}

/* Cart Body */
.cart-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.cart-empty {
    text-align: center;
    color: #777;
    margin-top: 50px;
}

.cart-item {
    display: flex;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    margin-right: 1rem;
}

.cart-item-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.cart-item-title {
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.cart-item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.quantity-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0.8rem;
    font-size: 1rem;
}

.item-quantity {
    padding: 0 0.5rem;
    font-size: 0.9rem;
    min-width: 20px;
    text-align: center;
}

.cart-item-price {
    font-weight: 600;
}

.remove-item-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 1rem;
}

.remove-item-btn img {
    width: 16px;
    height: 16px;
    display: block;
}

.remove-item-btn:hover {
    background-color: var(--light-gray);
}

/* Cart Footer */
.cart-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #fff;
    margin-top: auto; /* Push footer to the bottom */
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.cart-total span:last-child {
    font-weight: 700;
}

.checkout-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--dark-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.checkout-btn:hover {
    background-color: #444;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        max-width: 100%;
        right: -100%; /* Ensure it's off-screen initially */
    }

    .cart-sidebar.active {
        right: 0;
    }
}
