/* Estilos generales del contenedor */
.chatbot-simulation {
    width: 360px;
    margin: 30px auto;
    border-radius: 30px;
    overflow: hidden;
    background: #1a1a1a;
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
    padding: 10px 0;
}

/* Frame del móvil */
.chatbot-simulation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 20px;
    background: #1a1a1a;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* Área de mensajes */
.messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: #121212;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth; /* Añadido para scroll suave */
}

/* Scrollbar personalizada */
.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

/* Contenedor de mensajes con perspectiva */
.messages-wrapper {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    perspective: 1000px; /* Añadido para efecto 3D */
}

/* Estilos de los mensajes */
.message {
    margin-bottom: 20px;
    max-width: 85%;
    position: relative;
    transform-origin: left center;
    opacity: 0;
    will-change: transform, opacity; /* Optimización de rendimiento */
}

.user-message {
    margin-left: auto;
    background: #0084ff;
    color: white;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    transform-origin: right center;
    animation: fadeInSlideUser 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.bot-message {
    background: #262626;
    color: white;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    animation: fadeInSlideBot 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Animaciones mejoradas */
@keyframes fadeInSlideUser {
    0% {
        opacity: 0;
        transform: translateX(30px) scale(0.9) rotateY(-10deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotateY(0);
    }
}

@keyframes fadeInSlideBot {
    0% {
        opacity: 0;
        transform: translateX(-30px) scale(0.9) rotateY(10deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotateY(0);
    }
}

/* Estilos para adjuntos con animación */
.message-attachment {
    margin-top: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    transform: translateY(10px);
    opacity: 0;
    animation: fadeInUp 0.3s ease forwards;
    animation-delay: 0.2s;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-attachment a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    transition: transform 0.2s ease;
}

.message-attachment a:hover {
    text-decoration: underline;
    transform: translateX(4px);
}

/* Indicador de escritura mejorado */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #262626;
    border-radius: 18px 18px 18px 4px;
    width: fit-content;
    margin-bottom: 20px;
    opacity: 0;
    animation: fadeInSlideBot 0.3s ease forwards;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
        background: #999;
    }
}