/**
 * Kian AI - Estilos Dinámicos
 * Animaciones, transiciones y efectos de resplandor.
 */

/* Animaciones globales */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    50% {
        opacity: 0.7;
    }
}

/* Animación de resplandor para interacciones */
@keyframes glow {
    from {
        box-shadow: 0 0 5px -5px var(--cyan);
    }

    to {
        box-shadow: 0 0 20px 5px var(--cyan);
    }
}

/* Indicador de escritura */
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: pulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Indicador de Pensamiento */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--cyan);
    font-size: var(--font-size-sm);
}

/* Animación del Brain Icon (Legacy) */
.thinking-indicator .icon svg {
    animation: pulse 1.5s infinite;
}

/* Nueva Mascota (Logo Thinking) */
.thinking-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    animation: pulse 1.5s infinite ease-in-out;
}

/* Transiciones Generales */
.btn-icon,
.message-bubble,
.attachment-preview,
.form-input {
    transition: transform var(--transition-fast), box-shadow var(--transition-normal), background-color var(--transition-fast);
}

/* Efectos de Hover y Foco */
.btn-icon:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 0 15px -2px var(--cyan);
    color: var(--cyan);
}

#send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 0 20px -2px var(--lime-green);
    background: var(--lime-green);
}

.message.user:hover .message-bubble {
    box-shadow: 0 0 25px -5px hsla(180, 100%, 50%, 0.5);
}

.message.assistant:hover .message-bubble {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.attachment-preview:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.form-input:focus {
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--cyan);
}

/* Animación de grabación */
@keyframes recordingPulse {
    0% {
        box-shadow: 0 0 0 0 hsla(180, 100%, 50%, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px hsla(180, 100%, 50%, 0);
    }

    100% {
        box-shadow: 0 0 0 0 hsla(180, 100%, 50%, 0);
    }
}

.btn-icon.recording {
    color: var(--cyan);
    animation: recordingPulse 2s infinite;
}

/* Estados Activos */
.btn-icon.active {
    color: var(--cyan);
    box-shadow: 0 0 15px -2px var(--cyan);
}

/* Animaciones de Modal */
.modal-backdrop {
    animation: fadeIn var(--transition-normal);
}

.modal {
    animation: scaleIn var(--transition-normal);
}

.modal-backdrop.closing {
    animation: fadeOut var(--transition-normal) forwards;
}

.modal-backdrop.closing .modal {
    animation: scaleIn var(--transition-normal) reverse forwards;
}

/* Efecto de máscara para scroll suave */
.messages-container {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%);
}

/* Ciclos de pensamiento - badges */
.cycle-badge {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: all var(--transition-normal);
}

.cycle-badge.active {
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
    transform: scale(1.3);
}

.cycle-badge.completed {
    background: var(--lime-green);
}

/* Accesibilidad del foco */
*:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* Deshabilitar el contorno de foco visible para el textarea */
.input-field:focus-visible {
    outline: none;
}

/* --- Visor de Imágenes (Lightbox) --- */
.image-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-viewer-modal.active {
    opacity: 1;
}

.viewer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    cursor: zoom-out;
}

.viewer-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    position: relative;
    z-index: 10;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.image-viewer-modal.active .viewer-image {
    transform: scale(1);
}

.viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.viewer-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.viewer-close svg {
    width: 24px;
    height: 24px;
}