/* Cart Enhancements CSS */

/* Animaciones del carrito */
@keyframes cartBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes cartPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes slideInFromBottom {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutToBottom {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* Estilos del botón de carrito */
.cart-button {
    position: relative;
    overflow: hidden;
}

.cart-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.cart-button:active::before {
    width: 300px;
    height: 300px;
}

.cart-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Estados del botón */
.cart-button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.cart-button.loading .button-text {
    display: none;
}

.cart-button.loading .button-loading {
    display: inline-flex;
}

.cart-button.success {
    background-color: #10b981 !important;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.cart-button.error {
    background-color: #ef4444 !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Estados del botón de agregar al carrito */
button[onclick*="addToCart"] {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

button[onclick*="addToCart"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

button[onclick*="addToCart"].loading {
    background-color: #6b7280 !important;
    cursor: wait;
}

button[onclick*="addToCart"].success {
    background-color: #10b981 !important;
    transform: scale(1.05);
}

button[onclick*="addToCart"].error {
    background-color: #ef4444 !important;
    animation: shake 0.5s ease-in-out;
}

/* Contador del carrito */
.cart-badge {
    animation: cartBounce 0.6s ease-in-out;
    transition: all 0.3s ease;
}

.cart-badge.updated {
    animation: cartPulse 0.5s ease-in-out;
    background: #10b981;
}

/* Mini carrito flotante */
.mini-cart {
    animation: slideInFromBottom 0.3s ease-out;
}

.mini-cart.removing {
    animation: slideOutToBottom 0.3s ease-in;
}

/* Notificaciones mejoradas */
.enhanced-notification {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.notification-success {
    border-left-color: #10b981;
}

.notification-error {
    border-left-color: #ef4444;
}

.notification-warning {
    border-left-color: #f59e0b;
}

.notification-info {
    border-left-color: #3b82f6;
}

/* Indicadores de stock */
.stock-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.stock-indicator.low {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.stock-indicator.critical {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.stock-indicator.out {
    background-color: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

/* Selector de cantidad */
.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.quantity-selector:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.quantity-selector button {
    padding: 0.5rem;
    background: #f9fafb;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quantity-selector button:hover {
    background: #f3f4f6;
    color: #374151;
}

.quantity-selector button:active {
    background: #e5e7eb;
}

.quantity-selector input {
    border: none;
    text-align: center;
    background: white;
    font-weight: 500;
    color: #111827;
}

.quantity-selector input:focus {
    outline: none;
    background: #f8fafc;
}

/* Indicadores de precio */
.price-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.original-price {
    text-decoration: line-through;
    color: #6b7280;
    font-size: 0.875rem;
}

.current-price {
    color: #059669;
    font-weight: 600;
    font-size: 1.125rem;
}

.savings-badge {
    background: #dcfce7;
    color: #166534;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Estados de hover y focus */
.cart-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.cart-button:focus {
    outline: none;
    ring: 2px;
    ring-offset: 2px;
    ring-color: #3b82f6;
}

/* Responsive design */
@media (max-width: 640px) {
    .quantity-selector {
        flex-direction: column;
        width: auto;
    }
    
    .quantity-selector input {
        width: 4rem;
        text-align: center;
    }
    
    .mini-cart {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        width: auto;
    }
    
    .enhanced-notification {
        left: 1rem;
        right: 1rem;
        width: auto;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .enhanced-notification {
        background: rgba(17, 24, 39, 0.95);
        color: #f9fafb;
        border-color: rgba(75, 85, 99, 0.5);
    }
    
    .mini-cart {
        background: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }
    
    .quantity-selector {
        border-color: #4b5563;
    }
    
    .quantity-selector button {
        background: #374151;
        color: #d1d5db;
    }
    
    .quantity-selector button:hover {
        background: #4b5563;
        color: #f3f4f6;
    }
    
    .quantity-selector input {
        background: #374151;
        color: #f9fafb;
    }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .cart-button,
    .cart-badge,
    .mini-cart,
    .enhanced-notification {
        animation: none;
        transition: none;
    }
}

/* Estados de carga */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Modal de redirección al carrito */
#cart-redirect-modal {
    backdrop-filter: blur(5px);
}

#cart-redirect-modal .bg-white {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

#cart-redirect-modal button {
    transition: all 0.2s ease;
}

#cart-redirect-modal button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#cart-redirect-modal button:active {
    transform: translateY(0);
}

/* Tooltips */
.cart-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 50;
}

.cart-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1f2937;
}

.cart-button:hover .cart-tooltip {
    opacity: 1;
}
