/**
 * Estilos para el Sistema de Límite Disponible Dinámico
 */

/* Badge mejorado del límite disponible */
#ShowLimiteDisponible {
    position: relative;
}

#ShowLimiteDisponible a {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.3s ease;
}

#ShowLimiteDisponible a:hover {
    transform: scale(1.05);
}

#ShowLimiteDisponible span.label {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white !important; /* Forzar texto blanco SIEMPRE */
}

/* Forzar que todos los elementos internos también sean blancos */
#ShowLimiteDisponible span.label * {
    color: white !important;
}

/* Animación de actualización */
#ShowLimiteDisponible span.actualizando {
    animation: pulseUpdate 0.3s ease;
}

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

/* Animación de pulso para estados críticos */
.pulse-animation {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    50% { 
        opacity: 0.8;
        box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
    }
}

/* Iconos de estado */
#ShowLimiteDisponible .icono-estado {
    font-size: 14px;
    margin-right: 4px;
}

/* Barra de progreso del límite */
#barraProgresoLimite {
    position: relative;
    width: 100%;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

#barraProgresoLimite .barra-fill {
    height: 100%;
    transition: width 0.5s ease, background-color 0.3s ease;
    border-radius: 3px;
}

/* Tooltip mejorado */
#ShowLimiteDisponible .tooltip-limite {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

#ShowLimiteDisponible:hover .tooltip-limite {
    opacity: 1;
}

#ShowLimiteDisponible .tooltip-limite:after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Container para alertas */
#alertasLimite {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.alert-limite-dinamico {
    animation: slideInRight 0.5s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Widget de resumen del límite (opcional) */
.widget-limite-disponible {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.widget-limite-disponible .titulo {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 8px;
}

.widget-limite-disponible .valor {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
}

.widget-limite-disponible .progreso {
    background: rgba(255,255,255,0.2);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.widget-limite-disponible .progreso-fill {
    height: 100%;
    background: white;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.widget-limite-disponible .info {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
}

/* Responsive */
@media (max-width: 768px) {
    #alertasLimite {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    #ShowLimiteDisponible span.label {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .widget-limite-disponible {
        padding: 16px;
    }
    
    .widget-limite-disponible .valor {
        font-size: 24px;
    }
}

/* Estilos para cuando se excede el límite */
.label-danger.excedido {
    background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%) !important;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Mejora del badge con gradientes */
.label-success.mejorado {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.label-warning.mejorado {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%) !important;
}

.label-danger.mejorado {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
}

/* Efecto de brillo en hover */
#ShowLimiteDisponible span.label:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

/* Contador animado */
.valor-disponible {
    display: inline-block;
    transition: all 0.3s ease;
    font-variant-numeric: tabular-nums;
}

/* Loading spinner cuando se actualiza */
.limite-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}