/* =============================================
   SHOPPING CART STYLES - COMPLETE
   ============================================= */

/* Cart Icon & Badge */
.cart-icon {
    position: relative;
    cursor: pointer;
    font-size: 1.8rem;
    transition: transform 0.3s ease;
    padding: 0.5rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.cart-icon:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.2);
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #F56565, #E53E3E);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(245,101,101,0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* =============================================
   CART MODAL
   ============================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #E2E8F0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: #1A202C;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal {
    background: #F7FAFC;
    border: 2px solid #E2E8F0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4A5568;
}

.close-modal:hover {
    background: #E53E3E;
    border-color: #E53E3E;
    color: white;
    transform: rotate(90deg);
}

/* =============================================
   CART ITEMS CONTAINER
   ============================================= */

#cartItems {
    margin-bottom: 1.5rem;
    min-height: 200px;
}

/* =============================================
   CART ITEM - CRITICAL IMAGE SIZING
   ============================================= */

.cart-item {
    margin-bottom: 1rem;
}

.cart-item-content {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    background: #F7FAFC;
    transition: all 0.3s;
}

.cart-item-content:hover {
    border-color: #F6AD55;
    background: white;
    box-shadow: 0 4px 12px rgba(246, 173, 85, 0.1);
}

/* CART ITEM IMAGE - CONTROLLED SIZE */
.cart-item-img {
    width: 80px !important;           /* Fixed width */
    height: 80px !important;          /* Fixed height */
    min-width: 80px !important;       /* Prevent shrinking */
    max-width: 80px !important;       /* Prevent growing */
    object-fit: cover !important;     /* Crop to fit */
    border-radius: 8px;
    flex-shrink: 0;                   /* Don't allow flexbox to shrink */
    border: 2px solid #E2E8F0;
    background: white;
}

/* Fallback for icon-based images */
.cart-item-img[style*="background"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* =============================================
   CART ITEM DETAILS
   ============================================= */

.cart-item-details {
    flex: 1;
    min-width: 0; /* Allow text to wrap */
}

.cart-item-details h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1A202C;
    font-weight: 600;
    line-height: 1.3;
}

.cart-item-price {
    color: #718096;
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

/* =============================================
   QUANTITY CONTROLS
   ============================================= */

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #CBD5E0;
    background: white;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #4A5568;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: #F6AD55;
    border-color: #F6AD55;
    color: white;
    transform: scale(1.05);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-display {
    min-width: 35px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: #1A202C;
    padding: 0.25rem 0.5rem;
    background: white;
    border-radius: 6px;
    border: 2px solid #E2E8F0;
}

/* =============================================
   CART ITEM ACTIONS
   ============================================= */

.cart-item-actions {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.cart-item-total {
    font-size: 1.2rem;
    font-weight: bold;
    color: #F6AD55;
    margin-bottom: 0.5rem;
}

.remove-btn {
    background: linear-gradient(135deg, #F56565, #E53E3E);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}

.remove-btn:hover {
    background: linear-gradient(135deg, #E53E3E, #C53030);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.4);
}

.remove-btn:active {
    transform: translateY(0);
}

/* =============================================
   CART TOTAL
   ============================================= */

.cart-total {
    font-size: 1.8rem;
    font-weight: bold;
    text-align: right;
    padding: 1.5rem;
    background: linear-gradient(135deg, #F6AD55, #ED8936);
    color: white;
    border-radius: 12px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(246, 173, 85, 0.3);
}

/* =============================================
   CART BUTTONS
   ============================================= */

.clear-cart-btn,
.checkout-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.clear-cart-btn {
    background: #EDF2F7;
    color: #4A5568;
    border: 2px solid #CBD5E0;
}

.clear-cart-btn:hover {
    background: #E53E3E;
    color: white;
    border-color: #E53E3E;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(229, 62, 62, 0.3);
}

.checkout-btn {
    background: linear-gradient(135deg, #48BB78, #38A169);
    color: white;
}

.checkout-btn:hover {
    background: linear-gradient(135deg, #38A169, #2F855A);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(72, 187, 120, 0.4);
}

/* =============================================
   EMPTY CART STATE
   ============================================= */

#cartItems > div[style*="text-align: center"] {
    padding: 3rem 1rem;
}

#cartItems > div[style*="text-align: center"] h3 {
    color: #4A5568;
    margin: 1rem 0 0.5rem;
}

#cartItems > div[style*="text-align: center"] p {
    color: #718096;
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
    }
    
    .cart-item-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cart-item-img {
        width: 100% !important;
        height: 200px !important;
        max-width: 100% !important;
    }
    
    .cart-item-actions {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 1rem;
    }
    
    .cart-total {
        font-size: 1.5rem;
        padding: 1rem;
    }
    
    .modal-header h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .cart-item-img {
        height: 150px !important;
    }
    
    .clear-cart-btn,
    .checkout-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* =============================================
   SCROLLBAR STYLING (for cart items overflow)
   ============================================= */

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #EDF2F7;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* =============================================
   STOCK WARNINGS IN CART
   ============================================= */

.cart-item-details small {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #FED7D7;
    color: #C53030;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}