/* ========================================
   CART WIDGET STYLES - CSS HÍBRIDO
   Estilos que funcionan siempre, con fallbacks
   ======================================== */

/* ESTILOS BASE DEL CARRITO - SIEMPRE VISIBLES */
.cart-widget {
    position: relative !important;
    display: inline-block !important;
    margin: 0 10px !important;
}

.cart-menu-item {
    display: flex !important;
    align-items: center !important;
}

/* ÍCONO DEL CARRITO - ESTILOS CRÍTICOS */
.cart-icon {
    position: relative !important;
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 50% !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    transition: all 0.3s ease !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cart-icon:hover {
    background: #e9ecef !important;
    border-color: #007bff !important;
    transform: scale(1.05) !important;
}

.cart-icon i {
    font-size: 1.2rem !important;
    color: #007bff !important;
}

/* BADGE DEL CARRITO - SIEMPRE VISIBLE */
.cart-badge {
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    background-color: #dc3545 !important;
    color: white !important;
    border-radius: 50% !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 0.7rem !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: bold !important;
    border: 2px solid white !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    z-index: 1000 !important;
}

/* BADGE VISIBLE CUANDO HAY ITEMS */
.cart-badge[style*="display: flex"] {
    display: flex !important;
}

/* FORZAR VISIBILIDAD DEL BADGE CUANDO TIENE CONTENIDO */
.cart-badge:not(:empty) {
    display: flex !important;
}

/* BADGE CON CONTENIDO NUMÉRICO */
.cart-badge[style*="display: flex"],
.cart-badge[style*="display: block"],
.cart-badge[style*="display: inline-flex"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* DROPDOWN DEL CARRITO - ESTILOS CRÍTICOS */
.cart-dropdown {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    width: 350px !important;
    max-height: 500px !important;
    background: white !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 9999 !important;
    display: none !important;
    overflow: hidden !important;
    margin-top: 5px !important;
}

/* ESTADOS DEL DROPDOWN */
.cart-dropdown.show {
    display: block !important;
    animation: slideDown 0.3s ease !important;
}

.cart-dropdown[style*="display: block"] {
    display: block !important;
}

/* HEADER DEL DROPDOWN */
.cart-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px !important;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
    border-bottom: 1px solid #dee2e6 !important;
    border-radius: 8px 8px 0 0 !important;
}

.cart-header h6 {
    margin: 0 !important;
    font-weight: 700 !important;
    color: white !important;
    font-size: 1.1rem !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

.cart-header h6 i {
    margin-right: 8px !important;
    color: #ffd700 !important;
}

/* CONTADOR DE ITEMS EN EL HEADER */
.cart-item-count {
    display: block !important;
    margin-top: 4px !important;
    color: #e3f2fd !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
    padding: 2px 8px !important;
    border-radius: 12px !important;
    backdrop-filter: blur(10px) !important;
}

.cart-header button {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    color: white !important;
    padding: 0 !important;
    width: 28px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    backdrop-filter: blur(10px) !important;
}

.cart-header button:hover {
    background-color: rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* CONTENIDO DEL CARRITO */
.cart-items {
    max-height: 300px !important;
    overflow-y: auto !important;
    padding: 15px !important;
}

/* ITEMS INDIVIDUALES */
.cart-item {
    display: flex !important;
    align-items: center !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #f1f3f4 !important;
}

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

.item-info {
    flex: 1 !important;
    margin-right: 10px !important;
}

.item-name {
    margin: 0 !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    color: #2d2d2d !important;
    line-height: 1.3 !important;
}

.item-price {
    margin: 0 !important;
    font-size: 0.8rem !important;
    color: #6c757d !important;
}

.item-quantity {
    margin-right: 10px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    font-size: 0.85rem !important;
}

.item-subtotal {
    margin-right: 10px !important;
    font-weight: 600 !important;
    color: #28a745 !important;
    font-size: 0.9rem !important;
}

/* BOTÓN DE REMOVER */
.remove-item-btn {
    background: none !important;
    border: 1px solid #dc3545 !important;
    color: #dc3545 !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    font-size: 0.8rem !important;
}

.remove-item-btn:hover {
    background-color: #dc3545 !important;
    color: white !important;
}

/* TOTAL DEL CARRITO */
.cart-total {
    padding: 15px !important;
    border-top: 1px solid #dee2e6 !important;
    text-align: center !important;
    background-color: #f8f9fa !important;
    font-size: 1.1rem !important;
}

.cart-total strong {
    color: #2d2d2d !important;
}

/* ACCIONES DEL CARRITO */
.cart-actions {
    padding: 15px !important;
    border-top: 1px solid #dee2e6 !important;
}

.cart-actions button {
    width: 100% !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 10px 16px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
    margin-bottom: 8px !important;
}

.cart-actions button:last-child {
    margin-bottom: 0 !important;
}

.checkout-btn {
    background: #007bff !important;
    color: white !important;
}

.checkout-btn:hover {
    background: #0056b3 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3) !important;
}

.clear-cart-btn {
    background: #6c757d !important;
    color: white !important;
}

.clear-cart-btn:hover {
    background: #545b62 !important;
    transform: translateY(-1px) !important;
}

/* CARRITO VACÍO */
.cart-empty {
    text-align: center !important;
    padding: 30px 15px !important;
    color: #6c757d !important;
}

.cart-empty i {
    font-size: 3rem !important;
    margin-bottom: 15px !important;
    color: #dee2e6 !important;
}

.cart-empty p {
    margin: 0 !important;
    font-size: 1rem !important;
}

/* ANIMACIONES */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .cart-dropdown {
        width: 300px !important;
        right: -50px !important;
    }
    
    .cart-widget {
        margin: 0 5px !important;
    }
    
    .cart-icon {
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 6px !important;
    }
    
    .cart-icon i {
        font-size: 1rem !important;
    }
}

@media (max-width: 576px) {
    .cart-dropdown {
        width: 280px !important;
        right: -80px !important;
    }
    
    .cart-header h6 {
        font-size: 0.9rem !important;
    }
    
    .item-name {
        font-size: 0.8rem !important;
    }
    
    .item-subtotal {
        font-size: 0.8rem !important;
    }
}

/* ESTADOS DE LOADING */
.cart-loading {
    opacity: 0.6 !important;
    pointer-events: none !important;
}

.cart-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* SELECTORES ULTRA ESPECÍFICOS PARA FORZAR ESTILOS */
body .container .navbar .navbar-nav .cart-menu-item .cart-widget .cart-dropdown.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

body .container .navbar .navbar-nav .cart-menu-item .cart-widget .cart-dropdown:not(.show) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
} 