/* Cart Toggle Button */
.cart-toggle {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
    transition: var(--transition);
}

.cart-toggle:hover {
    color: var(--accent-green);
}

.cart-toggle svg {
    display: block;
}

.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-green);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.cart-count:empty,
.cart-count[data-count="0"] {
    display: none;
}

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

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Cart Drawer */
.cart-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: var(--bg-primary);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

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

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.cart-header h2 {
    font-family: var(--font-heading);
    font-size: 24px;
    color: var(--text-primary);
    margin: 0;
}

.cart-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

.cart-close:hover {
    color: var(--accent-green);
}

/* Cart Location Indicator */
.cart-location {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.cart-location strong {
    color: var(--accent-green);
}

.cart-location:empty {
    display: none;
}

/* Cart Items */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.cart-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.cart-item-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-variant {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.cart-item-price {
    font-weight: 600;
    color: var(--accent-green);
}

/* Sale Price in Cart */
.cart-item-price.on-sale {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-item-price.on-sale .sale-price {
    color: #ef4444;
    font-weight: 700;
}

.cart-item-price.on-sale .original-price {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 400;
    text-decoration: line-through;
}

.cart-item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    transition: var(--transition);
}

.cart-item-remove:hover {
    color: #dc3545;
}

/* Quantity Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.quantity-btn {
    background: var(--bg-secondary);
    border: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition);
}

.quantity-btn:hover {
    background: var(--accent-green);
    color: white;
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-value {
    width: 30px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

/* Cart Footer */
.cart-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.cart-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.cart-subtotal span:last-child {
    color: var(--accent-green);
}

.cart-note {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
}

/* Add to Cart Button */
.add-to-cart {
    transition: all 0.2s ease;
}

.add-to-cart.adding {
    pointer-events: none;
    opacity: 0.7;
}

.add-to-cart.added {
    background: var(--accent-green) !important;
    color: white !important;
}

/* Product Card Cart Button */
.product-card .add-to-cart {
    width: 100%;
    margin-top: 10px;
}

/* Out of Stock State */
.out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
}

.out-of-stock .add-to-cart {
    background: var(--text-secondary) !important;
    cursor: not-allowed;
}

/* ==========================================================================
   MOBILE RESPONSIVE
   ========================================================================== */

/* Tablet and mobile */
@media (max-width: 768px) {
    .cart-drawer {
        max-width: 100%;
        width: 100%;
    }

    .cart-header {
        padding: 16px;
    }

    .cart-header h2 {
        font-size: 20px;
    }

    /* Larger touch target for close button */
    .cart-close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 28px;
    }

    .cart-location {
        padding: 10px 16px;
        font-size: 13px;
    }

    .cart-items {
        padding: 16px;
    }

    .cart-item {
        gap: 12px;
        padding: 12px 0;
    }

    .cart-item-image {
        width: 70px;
        height: 70px;
        border-radius: 6px;
    }

    .cart-item-name {
        font-size: 14px;
    }

    .cart-item-variant {
        font-size: 12px;
    }

    /* Touch-friendly remove button */
    .cart-item-remove {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
    }

    /* Touch-friendly quantity controls */
    .quantity-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .quantity-value {
        width: 36px;
        font-size: 15px;
    }

    .cart-footer {
        padding: 16px;
    }

    .cart-subtotal {
        font-size: 16px;
    }

    .cart-footer .btn {
        min-height: 48px;
        font-size: 14px;
    }

    .cart-note {
        font-size: 12px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .cart-item {
        flex-wrap: wrap;
    }

    .cart-item-image {
        width: 60px;
        height: 60px;
    }

    .cart-item-controls {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }

    .cart-item-details {
        flex: 1;
    }

    .cart-item-name {
        font-size: 13px;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .cart-close:hover,
    .cart-item-remove:hover,
    .quantity-btn:hover {
        background: inherit;
        color: inherit;
    }

    .cart-close:active,
    .cart-item-remove:active {
        opacity: 0.7;
        transform: scale(0.95);
    }

    .quantity-btn:active {
        background: var(--accent-green);
        color: white;
    }
}

/* Header Actions Alignment */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Smaller Order Online button in header */
.header-actions .btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .header-actions .btn-sm {
        display: none;
    }

    .header-actions .cart-toggle {
        display: flex;
    }
}
