/* ============================================
   Download Button - Animaciones Premium y Estados
   ============================================ */

/* Botón primario BLANCO con efecto de cristal brillante */
.btn-primary {
    position: relative;
    background: white;
    color: #667eea;
    box-shadow: 
        0 8px 30px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 0 rgba(102, 126, 234, 0.1);
    animation: gentlePulse 3s ease-in-out infinite;
    overflow: hidden;
    border: 2px solid rgba(102, 126, 234, 0.15);
    font-weight: 600;
}

/* Gradiente sutil de fondo para dar profundidad */
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(102, 126, 234, 0.03) 0%,
        rgba(255, 255, 255, 1) 50%,
        rgba(118, 75, 162, 0.03) 100%
    );
    z-index: 0;
}

/* Animación de pulso suave continua - con borde brillante */
@keyframes gentlePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 8px 30px rgba(0, 0, 0, 0.3),
            0 2px 8px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset 0 -1px 0 rgba(102, 126, 234, 0.1),
            0 0 0 0 rgba(102, 126, 234, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset 0 -1px 0 rgba(102, 126, 234, 0.2),
            0 0 0 12px rgba(102, 126, 234, 0);
    }
}

/* Efecto de brillo CRISTALINO visible sobre fondo blanco */
.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -150%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(102, 126, 234, 0.15) 10%,
        rgba(102, 126, 234, 0.35) 30%,
        rgba(118, 75, 162, 0.5) 50%,
        rgba(240, 147, 251, 0.35) 70%,
        rgba(240, 147, 251, 0.15) 90%,
        transparent 100%
    );
    transform: skewX(-20deg);
    animation: shineStrong 3s ease-in-out infinite;
    z-index: 1;
    filter: blur(2px);
    mix-blend-mode: multiply;
    opacity: 0.8;
}

/* Animación de brillo más fuerte y visible */
@keyframes shineStrong {
    0% {
        left: -150%;
    }
    50% {
        left: 150%;
    }
    100% {
        left: 150%;
    }
}

/* Animación del borde brillante */
@keyframes borderShine {
    0%, 100% {
        opacity: 0;
        transform: translateX(-100%);
    }
    50% {
        opacity: 0.8;
        transform: translateX(0);
    }
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 
        0 16px 50px rgba(0, 0, 0, 0.4),
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 0 rgba(102, 126, 234, 0.2);
    animation: none;
    border-color: rgba(102, 126, 234, 0.3);
}

.btn-primary:hover::after {
    animation: shineStrong 0.6s ease-in-out;
    opacity: 1;
    filter: blur(1px);
}

.btn-primary:active {
    transform: translateY(-1px) scale(1.02);
}

.btn > * {
    position: relative;
    z-index: 2;
}

/* Estado de descarga */
.btn-primary.downloading {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    pointer-events: none;
    animation: downloadingPulse 1s ease-in-out infinite;
}

@keyframes downloadingPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(0.98);
    }
}

.btn-primary.downloading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: downloadProgress 1.5s ease-in-out infinite;
    z-index: 1;
}

@keyframes downloadProgress {
    0% {
        left: -100%;
    }
    100% {
        left: 200%;
    }
}

/* Estado de éxito */
.btn-primary.success {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    animation: successBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successBounce {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Spinner de descarga */
.download-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { 
        transform: rotate(360deg); 
    }
}

/* Check mark de éxito */
.success-check {
    display: inline-block;
    animation: checkPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkPop {
    0% {
        transform: scale(0) rotate(-45deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* ============================================
   Sistema de Notificaciones Toast
   ============================================ */

.toast-container {
    position: fixed;
    top: 100px;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}

.toast {
    background: white;
    color: var(--text);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    transform: translateX(450px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-left: 4px solid var(--primary);
}

[data-theme="dark"] .toast {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(450px);
    opacity: 0;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    animation: toastIconPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes toastIconPop {
    0% {
        transform: scale(0) rotate(-180deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.toast-close:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Variantes de toast */
.toast.toast-success {
    border-left-color: #4ade80;
}

.toast.toast-info {
    border-left-color: #3b82f6;
}

.toast.toast-warning {
    border-left-color: #fbbf24;
}

.toast.toast-error {
    border-left-color: #ef4444;
}

/* Barra de progreso en toast */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 0 12px;
    animation: toastProgress 3s linear forwards;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

.toast.toast-success .toast-progress {
    background: #4ade80;
}

.toast.toast-info .toast-progress {
    background: #3b82f6;
}

.toast.toast-downloading .toast-progress {
    background: var(--primary);
    animation: toastProgressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes toastProgressIndeterminate {
    0% {
        left: -50%;
        width: 50%;
    }
    100% {
        left: 100%;
        width: 50%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 80px;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .toast {
        padding: 0.875rem 1.25rem;
    }
    
    .toast-icon {
        font-size: 1.25rem;
    }
    
    .toast-title {
        font-size: 0.9rem;
    }
    
    .toast-message {
        font-size: 0.8rem;
    }
}