/* Cart Dropdown */
.cart-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    width: 320px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    padding: 15px;
    z-index: 1000;
    display: none;
    max-height: 80vh;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.cart-dropdown.show {
    display: block !important;
}

/* Make sure buttons don't close the dropdown */
.cart-dropdown button {
    pointer-events: auto;
    z-index: 1002;
}

/* Quantity Controls - Prevent event propagation */
.quantity-controls button {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
    touch-action: manipulation;
    position: relative;
    z-index: 1002;
}

/* Cart Modal Styles */
.cart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
}

.cart-backdrop.show {
    display: block;
}

.cart-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    padding: 20px;
    z-index: 1050;
    display: none;
}

.cart-modal.show {
    display: block;
}

/* Close button for the modal */
.cart-modal .close-cart {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

.cart-modal .close-cart:hover {
    color: #dc3545;
}

/* Cart item styles */
.cart-item {
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image img {
    object-fit: cover;
}

.quantity-controls button {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Cart summary styles */
.cart-summary {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.cart-total {
    font-weight: bold;
    color: #dc3545;
}

/* Cart icon styles */
.cart-icon {
    position: relative;
    cursor: pointer;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* Prevent body scrolling when cart is open */
body.cart-open {
    overflow: hidden;
}

/* Floating Cart Icon */
.cart-icon-floating {
    position: fixed;
    bottom: 100px; /* Justo encima del botón de WhatsApp */
    right: 20px;  /* Igual que el botón de WhatsApp */
    z-index: 1000;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color, #ae211f);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
}

@media (max-width: 576px) {
  .cart-icon-floating {
    bottom: 90px; /* Ajusta según el tamaño del botón de WhatsApp en móvil */
    right: 20px;
  }
}

.cart-icon-floating:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.cart-icon-floating .cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Adjust cart dropdown position for floating cart */
.cart-dropdown {
    position: fixed;
    bottom: 100px; /* Ajustado para que no se superponga con el carrito */
    right: 30px;
    top: auto;
    transform: translateX(0);
}


@media (max-width: 768px) {
    .cart-modal {
        width: 95%;
        max-width: none;
    }
    .cart-icon-floating {
        width: 50px;
        height: 50px;
        bottom: 80px; /* Posicionado justo encima del botón de WhatsApp en móvil */
        right: 20px; /* Alineado con el botón de WhatsApp en móvil */
        font-size: 1.3rem;
    }
    
    .cart-dropdown {
        width: 280px;
        right: 20px;
        bottom: 140px; /* Ajustado para que no se superponga con el carrito */
    }
}