/**
 * CSS para Sistema de Niveles del Carrito
 * Estilos específicos para el widget de niveles y progreso
 */

/* ================================
   WIDGET DE NIVELES - ESTILOS BASE
   ================================ */

.carrito-niveles-widget {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 1.5rem 1.5rem 1.5rem;
    border-left: 4px solid #FF8000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.carrito-niveles-widget::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(255, 128, 0, 0.1) 0%, transparent 50%);
    border-radius: 50%;
    transform: translate(25%, -25%);
}

/* ================================
   NIVEL ACTUAL
   ================================ */

.nivel-actual {
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 1;
}

.nivel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.nivel-icono {
    font-size: 1.4rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.nivel-nombre {
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    letter-spacing: 0.3px;
}

.nivel-total {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    display: inline-block;
    margin-top: 0.25rem;
}

/* ================================
   SIGUIENTE NIVEL
   ================================ */

.siguiente-nivel {
    border-top: 1px solid rgba(222, 226, 230, 0.8);
    padding-top: 1.25rem;
    position: relative;
    z-index: 1;
}

.nivel-objetivo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.objetivo-icono {
    font-size: 1.2rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.objetivo-nombre {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.nivel-faltante {
    font-size: 0.9rem;
    color: #495057;
    margin-bottom: 1rem;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 3px solid #FF8000;
}

.nivel-faltante strong {
    color: #212529;
    font-weight: 700;
}

/* ================================
   BARRA DE PROGRESO
   ================================ */

.nivel-progreso {
    margin-top: 1rem;
}

.progreso-barra {
    width: 100%;
    height: 10px;
    background: rgba(233, 236, 239, 0.8);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progreso-barra::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.5);
}

.progreso-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-nivel, #FF8000) 0%, var(--color-nivel-claro, #ffb366) 100%);
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progreso-fill::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
    border-radius: 6px 6px 0 0;
}

.progreso-texto {
    text-align: center;
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* ================================
   NIVEL MÁXIMO ALCANZADO
   ================================ */

.nivel-maximo {
    text-align: center;
    border-top: 1px solid rgba(222, 226, 230, 0.8);
    padding-top: 1.25rem;
    position: relative;
    z-index: 1;
}

.felicitaciones {
    color: #28a745;
    font-weight: 600;
    font-size: 0.95rem;
    background: rgba(40, 167, 69, 0.1);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(40, 167, 69, 0.2);
    position: relative;
    overflow: hidden;
}

.felicitaciones::before {
    content: "🎉";
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 2rem;
    opacity: 0.3;
    animation: celebrar 2s ease-in-out infinite;
}

@keyframes celebrar {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.1); }
}

/* ================================
   COLORES POR NIVEL
   ================================ */

/* Estándar */
.carrito-niveles-widget[data-nivel="estandar"] {
    border-left-color: #6c757d;
}

.carrito-niveles-widget[data-nivel="estandar"] .progreso-fill {
    --color-nivel: #6c757d;
    --color-nivel-claro: #9ca3af;
}

/* Platinum */
.carrito-niveles-widget[data-nivel="platinum"] {
    border-left-color: #17a2b8;
}

.carrito-niveles-widget[data-nivel="platinum"] .progreso-fill {
    --color-nivel: #17a2b8;
    --color-nivel-claro: #5bc0de;
}

/* Gold */
.carrito-niveles-widget[data-nivel="gold"] {
    border-left-color: #ffc107;
}

.carrito-niveles-widget[data-nivel="gold"] .progreso-fill {
    --color-nivel: #ffc107;
    --color-nivel-claro: #ffdb4d;
}

/* Diamond */
.carrito-niveles-widget[data-nivel="diamond"] {
    border-left-color: #6f42c1;
}

.carrito-niveles-widget[data-nivel="diamond"] .progreso-fill {
    --color-nivel: #6f42c1;
    --color-nivel-claro: #9966cc;
}

/* ================================
   ANIMACIONES
   ================================ */

.carrito-niveles-widget {
    animation: slideInFromTop 0.4s ease-out;
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nivel-actual, .siguiente-nivel {
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.siguiente-nivel {
    animation-delay: 0.1s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animación de pulso para el faltante */
.nivel-faltante {
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { 
        box-shadow: 0 0 0 rgba(255, 128, 0, 0);
    }
    50% { 
        box-shadow: 0 0 10px rgba(255, 128, 0, 0.3);
    }
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

@media (max-width: 768px) {
    .carrito-niveles-widget {
        margin: 1rem;
        padding: 1rem;
    }
    
    .nivel-header, .nivel-objetivo {
        gap: 0.5rem;
    }
    
    .nivel-icono, .objetivo-icono {
        font-size: 1.2rem;
    }
    
    .nivel-nombre {
        font-size: 1rem;
    }
    
    .nivel-faltante {
        font-size: 0.85rem;
        padding: 0.625rem;
    }
    
    .progreso-barra {
        height: 8px;
    }
}

/* ================================
   MODO OSCURO (OPCIONAL)
   ================================ */

@media (prefers-color-scheme: dark) {
    .carrito-niveles-widget {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
    }
    
    .nivel-total, .nivel-faltante, .progreso-texto {
        background: rgba(255, 255, 255, 0.1);
        color: #cbd5e0;
    }
    
    .progreso-barra {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .felicitaciones {
        background: rgba(40, 167, 69, 0.2);
        color: #68d391;
        border-color: rgba(40, 167, 69, 0.3);
    }
}

/* ================================
   ESTADOS ESPECIALES
   ================================ */

/* Cuando está cerca del siguiente nivel (más del 80%) */
.carrito-niveles-widget.cerca-nivel .progreso-fill {
    animation: brillar 1.5s ease-in-out infinite;
}

@keyframes brillar {
    0%, 100% { 
        filter: brightness(1);
    }
    50% { 
        filter: brightness(1.2);
    }
}

/* Cuando acaba de subir de nivel */
.carrito-niveles-widget.nuevo-nivel {
    animation: celebrarNivel 0.8s ease-out;
}

@keyframes celebrarNivel {
    0% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 4px 16px rgba(255, 128, 0, 0.3);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}
