/**
 * =================================================================
 * CARRITO DRAWER - ESTILO LATERAL PROFESIONAL
 * Modal deslizable desde la derecha (mobile y desktop)
 * =================================================================
 */

/* ============================================
   OVERLAY - Fondo oscuro
   ============================================ */
#carrito-modal {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 99999 !important;
    display: none !important;
    opacity: 0;
    transition: opacity 0.3s ease !important;
}

#carrito-modal:not(.hidden) {
    display: flex !important;
    opacity: 1;
}

/* ============================================
   DRAWER - Panel lateral (COMPACTO)
   ============================================ */
#carrito-modal > div:first-child {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 380px !important; /* Reducido de 480px a 380px */
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5) !important;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 100000 !important;
    overflow: hidden !important;
}

/* Animación de entrada */
#carrito-modal:not(.hidden) > div:first-child {
    transform: translateX(0);
}

/* ============================================
   HEADER DEL DRAWER (COMPACTO)
   ============================================ */
#carrito-modal .bg-gradient-to-r {
    flex-shrink: 0 !important;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
    padding: 1rem 1rem 1rem 1.25rem !important; /* Reducido padding */
    border-bottom: 2px solid rgba(255, 255, 255, 0.1) !important;
}

#carrito-modal .bg-gradient-to-r h2 {
    color: white !important;
    font-size: 1.25rem !important; /* Reducido de 1.5rem */
    font-weight: 800 !important;
    margin: 0 !important;
    padding-right: 3rem !important; /* Espacio para botón cerrar */
}

#carrito-modal .bg-gradient-to-r p {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.8rem !important; /* Reducido */
    margin-top: 0.25rem !important;
}

/* Botón cerrar (MÁS PEQUEÑO) */
#closeCarrito {
    position: absolute !important;
    top: 0.75rem !important;
    right: 0.75rem !important;
    width: 36px !important; /* Reducido de 40px */
    height: 36px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(10px) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 50% !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
    font-size: 1rem !important; /* Tamaño del icono */
}

#closeCarrito:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: rotate(90deg) scale(1.1) !important;
}

/* ============================================
   ÁREA DE CONTENIDO - Scrolleable (OPTIMIZADA)
   ============================================ */
#carrito-modal .flex-1.overflow-y-auto {
    flex: 1 1 0% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 1rem !important; /* Reducido de 1.5rem */
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
    
    /* Scroll personalizado oscuro */
    scrollbar-width: thin !important;
    scrollbar-color: rgba(220, 38, 38, 0.5) rgba(255, 255, 255, 0.1) !important;
}

/* Scroll para Webkit (MÁS DELGADO) */
#carrito-modal .flex-1.overflow-y-auto::-webkit-scrollbar {
    width: 6px !important; /* Reducido de 8px */
}

#carrito-modal .flex-1.overflow-y-auto::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 10px !important;
}

#carrito-modal .flex-1.overflow-y-auto::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #dc2626, #991b1b) !important;
    border-radius: 10px !important;
}

#carrito-modal .flex-1.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #991b1b, #7f1d1d) !important;
}

/* ============================================
   ITEMS DEL CARRITO (COMPACTOS)
   ============================================ */
#carritoItems {
    padding: 0 !important;
}

#carritoItems > div {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-left: 3px solid #dc2626 !important; /* Reducido de 4px */
    border-radius: 0.5rem !important; /* Reducido de 0.75rem */
    padding: 0.75rem !important; /* Reducido de 1rem */
    margin-bottom: 0.75rem !important; /* Reducido de 1rem */
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
}

#carritoItems > div:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-left-color: #ef4444 !important;
    transform: translateX(-2px) !important; /* Reducido de -4px */
}

/* Nombre del producto (MÁS PEQUEÑO) */
#carritoItems p.font-black {
    color: white !important;
    font-size: 0.9rem !important; /* Reducido de 1rem */
    margin-bottom: 0.25rem !important;
    line-height: 1.2 !important;
}

/* Precio (MÁS COMPACTO) */
#carritoItems p.text-blue-600 {
    color: #fbbf24 !important;
    font-weight: 800 !important;
    font-size: 1.1rem !important; /* Reducido de 1.25rem */
}

/* Controles de cantidad (MÁS PEQUEÑOS) */
#carritoItems .bg-gray-100 {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 0.4rem !important;
    padding: 0.25rem 0.5rem !important;
}

#carritoItems .increment,
#carritoItems .decrement {
    background: transparent !important;
    color: white !important;
    font-weight: bold !important;
    border-radius: 0.25rem !important;
    transition: all 0.2s ease !important;
    width: 28px !important; /* Más pequeño */
    height: 28px !important;
    font-size: 1rem !important;
}

#carritoItems .increment:hover,
#carritoItems .decrement:hover {
    background: rgba(220, 38, 38, 0.3) !important;
    transform: scale(1.2) !important;
}

#carritoItems .increment:active,
#carritoItems .decrement:active {
    transform: scale(0.95) !important;
}

/* Contador (MÁS PEQUEÑO) */
#carritoItems span.w-10 {
    color: white !important;
    font-weight: 800 !important;
    width: 32px !important; /* Más compacto */
    text-align: center !important;
    font-size: 0.95rem !important;
}

/* Botón eliminar (MÁS COMPACTO) */
#carritoItems .remove {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
    transition: all 0.2s ease !important;
    width: 36px !important; /* Reducido */
    height: 36px !important;
    flex-shrink: 0 !important;
}

#carritoItems .remove:hover {
    background: #ef4444 !important;
    color: white !important;
    transform: rotate(15deg) scale(1.1) !important;
}

/* ============================================
   CARRITO VACÍO
   ============================================ */
#carritoVacio {
    text-align: center !important;
    padding: 3rem 1rem !important;
    color: rgba(255, 255, 255, 0.5) !important;
}

#carritoVacio i {
    color: rgba(255, 255, 255, 0.2) !important;
    font-size: 4rem !important;
    margin-bottom: 1rem !important;
}

#carritoVacio p {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ============================================
   FORMULARIO DE DATOS (MÁS COMPACTO)
   ============================================ */
#formularioDatos {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.5rem !important; /* Reducido */
    padding: 1rem !important; /* Reducido de 1.5rem */
    margin-top: 0.75rem !important;
}

#formularioDatos h3 {
    color: white !important;
    font-size: 1rem !important; /* Reducido de 1.125rem */
    font-weight: 700 !important;
    margin-bottom: 0.75rem !important;
}

#formularioDatos label {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.8rem !important; /* Reducido */
    font-weight: 600 !important;
    display: block !important;
    margin-bottom: 0.25rem !important;
}

#formularioDatos .space-y-4 > div {
    margin-bottom: 0.75rem !important; /* Reducir espacio entre campos */
}

#formularioDatos input,
#formularioDatos select {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-radius: 0.4rem !important;
    padding: 0.625rem 0.875rem !important; /* Más compacto */
    font-size: 0.875rem !important;
    transition: all 0.3s ease !important;
    width: 100% !important;
}

#formularioDatos input:focus,
#formularioDatos select:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: #dc2626 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
}

#formularioDatos input::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

#formularioDatos p.text-xs {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ============================================
   FOOTER - Totales y botones (MÁS COMPACTO)
   ============================================ */
#carrito-modal .border-t-2 {
    flex-shrink: 0 !important;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
    border-top: 2px solid rgba(255, 255, 255, 0.1) !important;
    padding: 1rem !important; /* Reducido de 1.5rem */
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3) !important;
}

/* Resumen de totales (MÁS COMPACTO) */
#carrito-modal .bg-gradient-to-r.from-blue-50 {
    background: rgba(220, 38, 38, 0.15) !important;
    backdrop-filter: blur(10px) !important;
    border: 2px solid rgba(220, 38, 38, 0.3) !important;
    border-radius: 0.5rem !important; /* Reducido */
    padding: 0.75rem !important; /* Reducido de 1rem */
    margin-bottom: 0.75rem !important;
}

#carrito-modal .text-gray-700 {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.875rem !important;
}

#carrito-modal .text-gray-800 {
    color: white !important;
    font-size: 1rem !important;
}

#carrito-modal .text-blue-600,
#carritoCount,
#carritoTotal {
    color: #fbbf24 !important;
    font-weight: 800 !important;
}

#carritoTotal {
    font-size: 1.5rem !important; /* Reducido de 2xl */
}

#carritoCount {
    font-size: 1rem !important;
}

#carrito-modal .text-gray-500 {
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 0.75rem !important;
}

/* Botones de acción (MÁS COMPACTOS) */
#limpiarCarrito {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 2px solid rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
    font-weight: 700 !important;
    padding: 0.75rem !important; /* Reducido de 1rem */
    border-radius: 0.5rem !important;
    transition: all 0.3s ease !important;
    font-size: 0.875rem !important;
}

#limpiarCarrito:hover {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: #ef4444 !important;
    transform: scale(1.02) !important;
}

#enviarWsp {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border: none !important;
    color: white !important;
    font-weight: 800 !important;
    padding: 0.75rem 1rem !important; /* Reducido */
    border-radius: 0.5rem !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
    transition: all 0.3s ease !important;
    font-size: 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
}

#enviarWsp:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6) !important;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    #carrito-modal > div:first-child {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    #carrito-modal .flex-1.overflow-y-auto {
        padding: 1rem !important;
    }
    
    #carritoItems > div {
        padding: 0.875rem !important;
    }
    
    #formularioDatos {
        padding: 1rem !important;
    }
    
    #carrito-modal .border-t-2 {
        padding: 1rem !important;
    }
    
    /* Botones en columna en pantallas muy pequeñas */
    @media (max-width: 400px) {
        #carrito-modal .border-t-2 .flex.gap-3 {
            flex-direction: column !important;
        }
        
        #limpiarCarrito,
        #enviarWsp {
            width: 100% !important;
        }
    }
}

/* ============================================
   ANIMACIONES ADICIONALES
   ============================================ */
@keyframes slideInItem {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#carritoItems > div {
    animation: slideInItem 0.3s ease-out;
}

/* ============================================
   ESTADOS DE INTERACCIÓN
   ============================================ */
button:active {
    transform: scale(0.95) !important;
}

/* Efecto de pulsación en botones importantes */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }
}

#enviarWsp:not(:disabled) {
    animation: pulse 2s infinite;
}
