* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 0;
    -webkit-text-size-adjust: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Soporte para notch en iPhone */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Contenedor principal del chat */
.chat-container {
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    max-width: 100%;
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, #000000 80%);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    border-radius: 0;
}

/* Decoración de fondo sutil */
.chat-container::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 384px;
    height: 384px;
    background: rgba(88, 28, 135, 0.1);
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    z-index: 0;
}

/* En desktop: pantalla completa */
@media (min-width: 768px) {
    body {
        padding: 0;
        background: #0f172a;
    }
    
    .chat-container {
        position: fixed;
        max-width: 1080px;
        margin: 0 auto;
        left: 0;
        right: 0;
        height: 100vh;
        border-radius: 0;
    }
}

/* Header del chat */
.chat-header {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    color: white;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    border-radius: 0;
    flex-shrink: 0;
    min-height: 60px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    width: 100%;
    pointer-events: none;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.bot-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #8b5cf6;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.bot-details h1 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 2px;
    color: #f1f5f9;
}

.status {
    font-size: 12px;
    opacity: 0.8;
    font-weight: 300;
    color: #a78bfa;
}

/* Botón de finalizar chat */
.menu-button {
    pointer-events: auto;
    background: none;
    border: none;
    color: #e2e8f0;
    cursor: pointer;
    padding: 8px;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.menu-button:hover {
    background-color: rgba(139, 92, 246, 0.2);
}

.menu-button:active {
    background-color: rgba(139, 92, 246, 0.3);
}

/* Pantalla de chat finalizado */
.chat-ended {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, #000000 80%);
}

.ended-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #8b5cf6;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
    margin-bottom: 24px;
}

.chat-ended h2 {
    font-size: 24px;
    font-weight: 500;
    color: #f1f5f9;
    margin-bottom: 8px;
}

.chat-ended p {
    font-size: 15px;
    color: #94a3b8;
    margin-bottom: 32px;
}

.new-chat-button {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-button:hover {
    background: linear-gradient(135deg, #a78bfa 0%, #818cf8 100%);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
}

.new-chat-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 8px;
    padding-top: 72px;
    padding-bottom: 120px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 2px;
}

/* Mensajes */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: copilot-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@media (min-width: 768px) {
    .message {
        max-width: 75%;
    }
}

@keyframes copilot-slide-up {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    padding: 6px 12px 8px 12px;
    border-radius: 7.5px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 18.5px;
    position: relative;
}

.message-content p {
    margin: 0;
    white-space: normal;
}

.message-content p + p {
    margin-top: 8px;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 8px 0 4px 0;
    font-weight: 700;
    line-height: 1.3;
    color: #f1f5f9;
}

.message-content h1 {
    font-size: 23px;
}

.message-content h2 {
    font-size: 21px;
}

.message-content h3 {
    font-size: 19.5px;
}

.message-content strong {
    font-weight: 600;
    color: #f1f5f9;
}

.message-content em {
    font-style: italic;
}

.message-content a {
    color: #a78bfa;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.message-content a:hover {
    color: #c4b5fd;
}

.message-content br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* Mensajes del bot - Texto limpio sin burbuja */
.bot-message .message-content {
    background: transparent;
    color: #e2e8f0;
    font-weight: 400;
    padding: 8px 4px;
    border: none;
    box-shadow: none;
    font-size: 20px;
    line-height: 1.6;
    border-radius: 0;
}

.bot-message .message-content p {
    color: #e2e8f0;
}

/* Efecto de aparición de sentencias línea por línea */
.bot-message .message-content .sentence {
    opacity: 0;
    display: inline;
    transition: opacity 0.4s ease-in-out;
}

.bot-message .message-content .sentence.visible {
    opacity: 1;
}

/* Mensajes del usuario - Burbuja estilo Copilot */
.user-message .message-content {
    background: rgba(60, 60, 60, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-weight: 500;
    border-radius: 18px 18px 4px 18px;
    font-size: 20px;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Indicador de escritura */
.typing-message {
    animation: copilot-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.typing-bubble {
    background: transparent !important;
    box-shadow: none;
    border-radius: 5.5px 5.5px 5.5px 0;
    padding: 12px 16px !important;
    min-width: 60px;
}

.typing-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(45deg, #3b82f6, #8b5cf6);
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Resplandor de pensando */
#thinking-glow {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    height: 60px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(59, 130, 246, 0.7),
        rgba(168, 85, 247, 0.8),
        rgba(236, 72, 153, 0.7),
        transparent
    );
    border-radius: 50%;
    filter: blur(45px);
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
    z-index: 10;
}

/* Clase para activar el resplandor */
.chat-container.thinking #thinking-glow {
    opacity: 1;
    animation: glow-move 2s ease-in-out infinite alternate;
}

@keyframes glow-move {
    0% {
        transform: translateX(-70%) scale(1.0);
    }
    100% {
        transform: translateX(-30%) scale(1.1);
    }
}

/* Texto "Pensando" que aparece después de 4 segundos */
#thinking-text {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0;
    pointer-events: none;
    z-index: 11;
    transition: opacity 0.5s ease-in-out;
    background: linear-gradient(90deg, 
        #3b82f6,
        #8b5cf6,
        #ec4899,
        #3b82f6
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
}

/* Clase para mostrar el texto "Pensando" */
.chat-container.thinking-extended #thinking-text {
    opacity: 1;
    animation: thinking-text-glow 2s ease-in-out infinite;
}

@keyframes thinking-text-glow {
    0% {
        background-position: 0% 50%;
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
    }
    50% {
        background-position: 100% 50%;
        filter: drop-shadow(0 0 12px rgba(236, 72, 153, 0.6));
    }
    100% {
        background-position: 0% 50%;
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
    }
}

/* Ocultar input cuando está esperando respuesta */
.chat-input.waiting {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-input:not(.waiting) {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Input de chat */
.chat-input {
    background: linear-gradient(to top, rgba(0,0,0,1) 20%, rgba(0,0,0,0.8) 60%, transparent 100%);
    border-top: none;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    min-height: 62px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 25px;
    padding: 4px 6px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transition: border-color 0.3s ease, padding 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: rgba(139, 92, 246, 0.5);
}

#messageInput {
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    color: #ffffff;
    max-height: 100px;
    min-height: 24px;
    box-shadow: none;
}

#messageInput::placeholder {
    color: #6b7280;
}

.options-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 2px;
}

.options-button:hover {
    background: rgba(75, 85, 99, 0.6);
}

.options-button:active {
    background: rgba(75, 85, 99, 0.8);
}

.options-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: transparent;
}

.options-button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Botón circular de enviar estilo WhatsApp */
.send-button-circle {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: #00a884;
    color: #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-button-circle:hover {
    background: #06cf9c;
}

.send-button-circle:active {
    background: #008f6f;
    transform: scale(0.95);
}

.send-button-circle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #00a884;
}

.send-button-circle svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    margin-left: 2px;
}

/* Botón de adjuntar archivo (clip/ganchito) */
.attach-button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 2px;
}

.attach-button:hover {
    background: rgba(75, 85, 99, 0.6);
    color: #9ca3af;
}

.attach-button:active {
    background: rgba(75, 85, 99, 0.8);
}

.attach-button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Menú de opciones */
.options-menu {
    position: fixed;
    bottom: 80px;
    left: 16px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.options-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.options-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.options-menu-item:hover {
    background: rgba(139, 92, 246, 0.2);
}

.options-menu-item:active {
    background: rgba(139, 92, 246, 0.3);
}

.options-menu-item svg {
    color: #a78bfa;
    flex-shrink: 0;
}

.options-menu-item .menu-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* Divisor del menú */
.menu-divider {
    height: 1px;
    background: rgba(139, 92, 246, 0.2);
    margin: 6px 8px;
}

/* Item de terminar chat */
.options-menu-item.end-chat-item {
    color: #fca5a5;
}

.options-menu-item.end-chat-item:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Contenedor del contenido del input (textarea + pill) */
.input-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Pill de archivo adjunto */
.attachment-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 16px;
    padding: 4px 8px 4px 10px;
    margin: 0 8px 8px 8px;
    max-width: fit-content;
    animation: pill-fade-in 0.2s ease;
}

@keyframes pill-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.attachment-icon {
    font-size: 14px;
}

.attachment-name {
    font-size: 12px;
    color: #c4b5fd;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #e2e8f0;
    transition: all 0.2s;
    padding: 0;
}

.attachment-remove:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.attachment-remove:active {
    transform: scale(0.9);
}

/* Input expandido cuando hay adjunto */
.input-wrapper.has-attachment {
    padding-bottom: 6px;
}

.input-wrapper.has-attachment .input-content {
    padding-top: 4px;
}

/* Estado de error */
.message.error-message .message-content {
    background: rgba(254, 215, 215, 0.2);
    color: #fca5a5;
    border-left: 3px solid #ef4444;
}

/* Mensaje de advertencia (warning) */
.warning-message {
    align-self: center !important;
    max-width: 90% !important;
    animation: warning-slide-in 0.3s ease forwards;
}

@keyframes warning-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.warning-message .warning-content {
    background: rgba(55, 55, 55, 0.95) !important;
    border: 2px solid #f59e0b !important;
    border-radius: 12px !important;
    padding: 10px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2) !important;
}

.warning-message .warning-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.warning-message .warning-content p {
    color: #fbbf24 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    margin: 0 !important;
}

.warning-message.warning-fade-out {
    animation: warning-fade-out 0.3s ease forwards;
}

@keyframes warning-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Warning en modo WhatsApp */
.whatsapp-style .warning-message .warning-content {
    background: rgba(35, 49, 56, 0.95) !important;
    border-color: #f59e0b !important;
}

/* Botón de link */
.link-button-container {
    margin-top: 6px;
    width: 100%;
}

.link-button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 10px 12px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 7.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
}

.link-button:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: #8b5cf6;
}

.link-button:active {
    background: rgba(30, 41, 59, 1);
    transform: scale(0.98);
}

.link-button-text {
    font-size: 14px;
    font-weight: 500;
    color: #a78bfa;
    margin-bottom: 2px;
}

.link-button-url {
    font-size: 12px;
    color: #94a3b8;
    word-break: break-all;
    text-align: left;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-button-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #8b5cf6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-button-arrow svg {
    width: 16px;
    height: 16px;
}

/* Botón de video - Nuevo diseño con YouTube */
.video-button-container {
    margin-top: 12px;
    width: 100%;
}

.video-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.video-button:hover {
    opacity: 0.8;
}

.video-button:active {
    opacity: 0.6;
}

.youtube-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.youtube-icon svg {
    width: 32px;
    height: 32px;
}

.video-text-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.video-button-text {
    font-size: 15px;
    font-weight: 500;
    color: #e2e8f0;
}

.video-button-subtitle {
    font-size: 13px;
    color: #94a3b8;
}

/* Botón de web - Diseño similar al de video */
.web-button-container {
    margin-top: 12px;
    width: 100%;
}

.web-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.web-button:hover {
    opacity: 0.8;
}

.web-button:active {
    opacity: 0.6;
}

.web-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.web-icon svg {
    width: 28px;
    height: 28px;
}

.web-text-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.web-button-text {
    font-size: 15px;
    font-weight: 500;
    color: #e2e8f0;
}

.web-button-subtitle {
    font-size: 13px;
    color: #94a3b8;
}

/* Imagen en el chat */
.image-container {
    margin-top: 12px;
    width: 100%;
    max-width: 280px;
}

.chat-image {
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-image:hover {
    opacity: 0.9;
}

/* Modal de imagen */
.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.image-modal-overlay.show {
    opacity: 1;
}

.image-modal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
}

.image-modal-img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 8px;
    object-fit: contain;
}

.image-modal-instruction {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

/* Modal de video */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.video-modal-overlay.show {
    opacity: 1;
}

.video-modal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 90vh;
}

.video-modal-iframe {
    width: 350px;
    height: 622px;
    max-width: 90vw;
    max-height: 80vh;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 400px) {
    .video-modal-iframe {
        width: 100vw;
        height: calc(100vw * 16 / 9);
        max-height: 75vh;
        border-radius: 0;
    }
}

.video-modal-instruction {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

/* Estilos específicos para el mensaje de bienvenida - Pastilla de aviso */
.welcome-message {
    align-self: center !important;
    max-width: fit-content !important;
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Animación de entrada para el mensaje de bienvenida */
.welcome-animate {
    animation: welcome-fade-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

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

.welcome-message .message-content {
    background: rgba(55, 55, 55, 0.9) !important;
    border: 1px solid #22c55e !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.welcome-message .welcome-text {
    font-size: 13px;
    font-weight: 500;
    color: #a1a1aa;
    letter-spacing: 0.3px;
}

/* Avatar en reposo */
.ai-avatar-idle {
    width: 80px;
    height: 80px;
    background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
    background-size: 300% 300%;
    border-radius: 50%;
    animation: gradient-spin 4s ease infinite;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    margin-bottom: 20px;
}

@keyframes gradient-spin {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Avatar de bienvenida (imagen) */
.welcome-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    margin-bottom: 20px;
    border: 2px solid #8b5cf6;
}

/* ========================================
   ESTILOS WHATSAPP (Tema Oscuro)
   ======================================== */

/* Patrón de fondo WhatsApp (imagen real de WhatsApp dark mode) */
.whatsapp-style .chat-container {
    background: #0b141a !important;
    position: relative;
    isolation: isolate;
}

/* Fondo con patrón de doodles estilo WhatsApp dark */
.whatsapp-style .chat-container::before {
    display: block !important;
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-image: url("whatsapp-pattern.png") !important;
    background-repeat: repeat !important;
    background-size: 270px auto !important;
    opacity: 0.06 !important;
    border-radius: 0 !important;
    filter: none !important;
    mix-blend-mode: normal !important;
    transform: none !important;
    pointer-events: none !important;
    z-index: 0 !important;
}

/* Capa oscura (ya no necesaria con el nuevo patrón transparente) */
.whatsapp-style .chat-container::after {
    display: none !important;
}

/* Asegurar que el contenido esté sobre el fondo */
.whatsapp-style .chat-messages {
    position: relative;
    z-index: 1;
}

.whatsapp-style .chat-input {
    z-index: 2;
}

.whatsapp-style .whatsapp-header {
    z-index: 1001;
}

.whatsapp-style .options-menu {
    z-index: 1002;
}

/* Body WhatsApp */
.whatsapp-style {
    background-color: #0b141a !important;
}

/* Área de mensajes WhatsApp */
.whatsapp-style .chat-messages {
    background: transparent !important;
    padding-top: calc(70px + env(safe-area-inset-top)) !important;
}

/* Mensajes del bot - Estilo WhatsApp */
.whatsapp-style .bot-message .message-content {
    background: #202c33 !important;
    color: #e9edef !important;
    border-radius: 7.5px 7.5px 7.5px 0 !important;
    padding: 6px 12px 8px 12px !important;
    font-size: 20px !important;
    font-weight: 400 !important;
    line-height: 1.6 !important;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13) !important;
    position: relative;
}

.whatsapp-style .bot-message .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-bottom: 13px solid transparent;
    border-right: 8px solid #202c33;
}

.whatsapp-style .bot-message .message-content p {
    color: #e9edef !important;
}

/* Mensajes del usuario - Estilo WhatsApp */
.whatsapp-style .user-message .message-content {
    background: #005c4b !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    color: #e9edef !important;
    border-radius: 7.5px 7.5px 0 7.5px !important;
    font-size: 20px !important;
    line-height: 1.6 !important;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13) !important;
    font-weight: 500 !important;
    position: relative;
}

.whatsapp-style .user-message .message-content::before {
    content: '';
    position: absolute;
    right: -7px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-bottom: 13px solid transparent;
    border-left: 8px solid #005c4b;
}

/* Header estilo WhatsApp */
.whatsapp-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding-top: env(safe-area-inset-top);
    background: #202c33;
    z-index: 1001;
    align-items: center;
    padding-left: 8px;
    padding-right: 8px;
    gap: 10px;
}

.whatsapp-style .whatsapp-header {
    display: flex;
}

.whatsapp-style .chat-header {
    display: none !important;
}

.whatsapp-back-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.whatsapp-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.whatsapp-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.whatsapp-header-name {
    color: #e9edef;
    font-size: 16px;
    font-weight: 500;
}

.whatsapp-header-status {
    color: #8696a0;
    font-size: 13px;
}

.whatsapp-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.whatsapp-header-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.whatsapp-header-btn:hover {
    background: rgba(134, 150, 160, 0.1);
}

/* Mensaje de bienvenida WhatsApp - pastilla centrada con borde verde */
.whatsapp-style .welcome-message {
    align-self: center !important;
    max-width: fit-content !important;
    margin-top: 20px !important;
    margin-bottom: 10px !important;
}

.whatsapp-style .welcome-message .message-content {
    background: rgba(35, 49, 56, 0.95) !important;
    border: 1px solid #25D366 !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.whatsapp-style .welcome-message .message-content::before {
    display: none !important;
}

.whatsapp-style .welcome-message .welcome-text {
    color: #8696a0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}

/* Input WhatsApp */
.whatsapp-style .chat-input {
    background: transparent !important;
    padding: 8px 10px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
}

.whatsapp-style .input-wrapper {
    background: #202c33 !important;
    border: none !important;
    border-radius: 21px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

.whatsapp-style .input-wrapper:focus-within {
    border-color: transparent !important;
}

.whatsapp-style #messageInput {
    color: #e9edef !important;
}

.whatsapp-style #messageInput::placeholder {
    color: #8696a0 !important;
}

.whatsapp-style .options-button {
    color: #8696a0 !important;
}

.whatsapp-style .options-button:hover {
    background: rgba(134, 150, 160, 0.1) !important;
    color: #e9edef !important;
}

/* Botón circular de enviar en modo WhatsApp */
.whatsapp-style .send-button-circle {
    background: #00a884 !important;
    color: #000000 !important;
}

.whatsapp-style .send-button-circle:hover {
    background: #06cf9c !important;
}

.whatsapp-style .send-button-circle:active {
    background: #008f6f !important;
}

/* Botón de adjuntar archivo en modo WhatsApp */
.whatsapp-style .attach-button {
    color: #8696a0 !important;
}

.whatsapp-style .attach-button:hover {
    background: rgba(134, 150, 160, 0.1) !important;
    color: #e9edef !important;
}

/* Ocultar botón de opciones en el input en modo WhatsApp */
.whatsapp-style .options-button {
    display: none !important;
}

/* Ocultar botón de búsqueda en el header WhatsApp */
.whatsapp-style #whatsappSearchBtn {
    display: none !important;
}

/* Menú de opciones WhatsApp - posicionado debajo del header */
.whatsapp-style .options-menu {
    background: #233138 !important;
    border: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
    top: calc(60px + env(safe-area-inset-top)) !important;
    bottom: auto !important;
    right: 8px !important;
    left: auto !important;
}

.whatsapp-style .options-menu-item {
    color: #e9edef !important;
}

.whatsapp-style .options-menu-item:hover {
    background: rgba(134, 150, 160, 0.1) !important;
}

.whatsapp-style .menu-divider {
    background: rgba(134, 150, 160, 0.2) !important;
}

.whatsapp-style .options-menu-item.end-chat-item {
    color: #f15c6d !important;
}

.whatsapp-style .options-menu-item.end-chat-item:hover {
    background: rgba(241, 92, 109, 0.1) !important;
}

/* Burbuja de escritura estilo WhatsApp */
.whatsapp-typing-message {
    animation: copilot-slide-up 0.3s ease forwards;
}

.whatsapp-typing-bubble {
    background: #202c33 !important;
    border-radius: 7.5px 7.5px 7.5px 0 !important;
    padding: 16px 20px !important;
    min-width: 70px;
    min-height: 44px;
    position: relative;
    overflow: visible;
}

.whatsapp-typing-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-bottom: 13px solid transparent;
    border-right: 8px solid #202c33;
}

.whatsapp-typing-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    min-height: 12px;
    padding-top: 4px;
}

.whatsapp-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8696a0;
    animation: whatsappTypingBounce 1.4s infinite ease-in-out;
}

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

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

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

@keyframes whatsappTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Ocultar efectos de resplandor en modo WhatsApp */
.whatsapp-style #thinking-glow,
.whatsapp-style #thinking-text {
    display: none !important;
}

/* Pill de adjunto WhatsApp */
.whatsapp-style .attachment-pill {
    background: rgba(0, 92, 75, 0.3) !important;
    border-color: rgba(0, 92, 75, 0.5) !important;
}

.whatsapp-style .attachment-name {
    color: #8696a0 !important;
}

/* Pantalla de chat finalizado WhatsApp */
.whatsapp-style .chat-ended {
    background: #0b141a !important;
}

.whatsapp-style .chat-ended h2 {
    color: #e9edef !important;
}

.whatsapp-style .chat-ended p {
    color: #8696a0 !important;
}

.whatsapp-style .new-chat-button {
    background: #00a884 !important;
    box-shadow: none !important;
}

.whatsapp-style .new-chat-button:hover {
    background: #06cf9c !important;
    box-shadow: none !important;
}

.whatsapp-style .ended-avatar {
    border-color: #00a884 !important;
    box-shadow: 0 0 20px rgba(0, 168, 132, 0.3) !important;
}

/* Links y botones en mensajes WhatsApp */
.whatsapp-style .link-button,
.whatsapp-style .video-button,
.whatsapp-style .web-button {
    background: rgba(32, 44, 51, 0.8) !important;
    border-color: rgba(134, 150, 160, 0.2) !important;
}

.whatsapp-style .link-button:hover,
.whatsapp-style .video-button:hover,
.whatsapp-style .web-button:hover {
    background: rgba(32, 44, 51, 1) !important;
    border-color: rgba(134, 150, 160, 0.4) !important;
}

.whatsapp-style .link-button-text,
.whatsapp-style .video-button-text,
.whatsapp-style .web-button-text {
    color: #00a884 !important;
}

.whatsapp-style .link-button-url,
.whatsapp-style .video-button-subtitle,
.whatsapp-style .web-button-subtitle {
    color: #8696a0 !important;
}

.whatsapp-style .link-button-arrow {
    color: #00a884 !important;
}

/* Scrollbar WhatsApp */
.whatsapp-style .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(134, 150, 160, 0.3) !important;
}

/* Títulos y strong en mensajes WhatsApp */
.whatsapp-style .message-content h1,
.whatsapp-style .message-content h2,
.whatsapp-style .message-content h3,
.whatsapp-style .message-content strong {
    color: #e9edef !important;
}

.whatsapp-style .message-content a {
    color: #53bdeb !important;
}

.whatsapp-style .message-content a:hover {
    color: #7fcef3 !important;
}

/* ========================================
   IMÁGENES ADJUNTAS EN MENSAJES DEL USUARIO
   ======================================== */

/* Contenedor del mensaje con imagen */
.message-content.has-attached-image {
    padding: 0 !important;
    overflow: hidden;
}

/* Contenedor de la imagen adjunta */
.attached-image-container {
    width: 75vw;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 18px 18px 0 0;
    overflow: hidden;
}

/* Imagen adjunta */
.attached-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.attached-image:hover {
    opacity: 0.9;
}

/* Texto debajo de la imagen (caption) */
.attached-image-caption {
    padding: 8px 12px !important;
    margin: 0 !important;
}

/* Estilo específico para mensajes del usuario con imagen */
.user-message .message-content.has-attached-image {
    border-radius: 18px 18px 4px 18px;
    background: rgba(60, 60, 60, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-message .attached-image-container {
    border-radius: 17px 17px 0 0;
}

/* Sin texto, redondear toda la imagen */
.user-message .message-content.has-attached-image:not(:has(.attached-image-caption)) {
    border-radius: 18px 18px 4px 18px;
}

.user-message .message-content.has-attached-image:not(:has(.attached-image-caption)) .attached-image-container {
    border-radius: 17px 17px 3px 17px;
}

/* ========================================
   ESTILO WHATSAPP PARA IMÁGENES ADJUNTAS
   ======================================== */

.whatsapp-style .user-message .message-content.has-attached-image {
    background: #005c4b !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 7.5px 7.5px 0 7.5px !important;
}

.whatsapp-style .user-message .attached-image-container {
    border-radius: 6px 6px 0 0 !important;
    background: rgba(0, 0, 0, 0.2);
}

.whatsapp-style .user-message .message-content.has-attached-image::before {
    content: '';
    position: absolute;
    right: -7px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-bottom: 13px solid transparent;
    border-left: 8px solid #005c4b;
}

/* Sin texto en WhatsApp */
.whatsapp-style .user-message .message-content.has-attached-image:not(:has(.attached-image-caption)) {
    border-radius: 7.5px 7.5px 0 7.5px !important;
}

.whatsapp-style .user-message .message-content.has-attached-image:not(:has(.attached-image-caption)) .attached-image-container {
    border-radius: 6px 6px 0 6px !important;
}

.whatsapp-style .attached-image-caption {
    padding: 6px 8px !important;
    color: #e9edef !important;
}
