:root {
    --bg-utm: #139749;
    --bg-utm-secondary: #ffcf00;
}

.btn-utm {
    background-color: var(--bg-utm);
}
.btn-utm-secondary {
    background-color: var(--bg-utm-secondary);
}


/* ===== SCROLL Y EVENTOS DEL BODY ===== */
/* Permitir scroll en toda la página */
html, body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
}

/* Contenedor principal con scroll */
.app-root {
    overflow-y: auto !important;
    height: auto !important;
}

/* Card avatar - no debe bloquear el scroll */
.card-avatar {
    position: relative;
    overflow: visible;
}

/* ===== IFRAME DEL AVATAR ===== */
/* CRÍTICO: El iframe NO debe capturar NINGÚN evento */
.interfaz-avatar iframe {
    pointer-events: none !important;
    width: 100%;
    height: 95vh;
    border: none;
}

/* Contenedor de la interfaz de avatar */
/* ESTA LÍNEA ESTÁ CAUSANDO PROBLEMAS AL MODAL DE INICIAR SESIÓN */
/* .interfaz-avatar {
    position: relative;
    z-index: 1;
} */

/* ===== CONTROLES - SOLUCIÓN DEFINITIVA ===== */
/* El contenedor de controles NO captura eventos, pero está debajo de los modales */
#controles {
    pointer-events: none !important;
    z-index: 1000 !important; /* Debajo de los modales (1040-1055) */
}

/* TODOS los elementos dentro de #controles SÍ capturan eventos */
#controles * {
    pointer-events: auto !important;
}

/* DOCK - Asegurar que esté completamente funcional */
#dock {
    pointer-events: auto !important;
    z-index: 1003 !important; /* Debajo de los modales */
}

#dock * {
    pointer-events: auto !important;
}

/* Botones del dock - FORZAR funcionalidad */
#btnDockChat,
#btnDockMic,
#btnDockHistory {
    pointer-events: auto !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
}

/* Los iconos dentro de los botones NO deben capturar eventos */
#btnDockChat i,
#btnDockMic i,
#btnDockHistory i,
.btn i,
button i {
    pointer-events: none !important;
}

/* CHATBAR */
#chatBar {
    pointer-events: auto !important;
    z-index: 1002 !important; /* Debajo de los modales */
}

#chatBar * {
    pointer-events: auto !important;
}

/* Badge de estado */
.tag-texto-real-time {
    pointer-events: auto !important;
    z-index: 1003 !important; /* Debajo de los modales */
}

/* Todos los botones de la aplicación */
.btn,
button {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Input de texto */
input,
textarea {
    pointer-events: auto !important;
}

/* Chat interface completa */
.interfaz-chat {
    pointer-events: auto !important;
    z-index: 999 !important; /* Debajo de los modales y controles */
}

.interfaz-chat * {
    pointer-events: auto !important;
}

/* ===== MODALES DE BOOTSTRAP ===== */
/* CRÍTICO: Los modales deben estar por encima de TODO y ser completamente funcionales */

/* Cuando hay un modal abierto, ocultar los controles del dock */
body.modal-open #controles,
body.modal-open #dock,
body.modal-open #chatBar,
body.modal-open .tag-texto-real-time {
    display: none !important;
}

/* Backdrop del modal (fondo gris semitransparente) */
.modal-backdrop {
    pointer-events: none !important; /* El backdrop NO debe capturar eventos */
    z-index: 1040 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
}

/* Modal container - DEBE capturar eventos */
.modal {
    pointer-events: auto !important; /* CRÍTICO: El modal SÍ captura eventos */
    z-index: 1050 !important;
}

/* Dialog del modal */
.modal-dialog {
    pointer-events: auto !important;
}

/* ===== FORZAR TEMA CLARO EN MODALES ===== */
/* Sobrescribir el tema oscuro de Bootstrap */
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-body,
[data-bs-theme="dark"] .modal-footer,
.modal-content,
.modal-header,
.modal-body,
.modal-footer {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* Contenido del modal */
.modal-content {
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
    background-color: #ffffff !important;
    color: #212529 !important;
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    border-radius: 0.5rem !important;
}

/* Header del modal */
.modal-header {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-bottom: 1px solid #dee2e6 !important;
}

/* Título del modal */
.modal-title {
    color: #212529 !important;
}

/* Body del modal */
.modal-body {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* Footer del modal */
.modal-footer {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-top: 1px solid #dee2e6 !important;
}

/* Labels y textos */
[data-bs-theme="dark"] .modal label,
[data-bs-theme="dark"] .modal .form-label,
[data-bs-theme="dark"] .modal p,
.modal label,
.modal .form-label,
.modal p {
    color: #212529 !important;
}

/* Inputs con fondo blanco */
[data-bs-theme="dark"] .modal input.form-control,
[data-bs-theme="dark"] .modal textarea.form-control,
[data-bs-theme="dark"] .modal select.form-select,
.modal input.form-control,
.modal textarea.form-control,
.modal select.form-select {
    background-color: #ffffff !important;
    color: #212529 !important;
    border: 1px solid #ced4da !important;
}

/* Foco en inputs */
.modal input.form-control:focus,
.modal textarea.form-control:focus,
.modal select.form-select:focus {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-color: #86b7fe !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Todos los elementos dentro del modal deben capturar eventos */
.modal *,
.modal-header,
.modal-body,
.modal-footer,
.modal-header *,
.modal-body *,
.modal-footer * {
    pointer-events: auto !important;
}

/* Inputs específicos del modal */
.modal input,
.modal textarea,
.modal select,
.modal .form-control {
    pointer-events: auto !important;
    cursor: text !important;
    user-select: text !important;
}

/* Botones del modal */
.modal button,
.modal .btn,
.modal .btn-close {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Labels del modal */
.modal label,
.modal .form-label {
    pointer-events: auto !important;
}

@media (min-width: 768px) {
    .fixed-card {
        position: fixed;   /* Posición fija */
        z-index: 1000;     /* Asegura que esté por encima de otros elementos */
        width: 32%;
    }
}
/* En pantallas menores a 768px (móviles) se comporta de forma normal */
@media (max-width: 767.98px) {
    .fixed-card {
        position: static;
    }
}

#audioMotion > canvas{
    max-width: 100%;
    width: 200px;
    height: 50px;
}

.chat-container {
    height: 80vh;
    overflow-y: auto;
    padding: 1rem;
}
.message {
    max-width: 75%;
    padding: .5rem 1rem;
    border-radius: 1rem;
    margin-bottom: .75rem;
    position: relative;
    word-wrap: break-word;
}
.incoming {
    background-color: #fff;
    border: 1px solid #dee2e6;
    margin-right: auto;
}
.outgoing {
    background-color: #0d6efd;
    color: #fff;
    margin-left: auto;
}
.reaction-btn {
    font-size: .9rem;
    line-height: 1;
    padding: .2rem .5rem;
    margin-right: .3rem;
}
.reactions {
    margin-top: .5rem;
    text-align: right;
}

.input-container {
    /* background-color: #1f1f1f; */
    border-radius: 50px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    width: 52.2%;
    max-width: 100%;
    left: 38px;
    position: fixed;
    bottom: 43px;
    z-index: 1;
}

.input-container .input-icon {
    color: #b0b0b0;
    font-size: 1.2rem;
    margin-right: 10px;
}

.input-custom {
    background: transparent;
    border: none;
    color: #fff;
    flex: 1;
    outline: none;
    box-shadow: none !important;
}

.input-custom::placeholder {
    color: #aaa;
}
.input-custom::focus {
    background-color: transparent;
}

:root{
    --bg: #fff;
    --shadow: 0 12px 36px rgba(0,0,0,.14);
    --radius-pill: 999px;
    --btn-size: 44px;
    --accent: #0d6efd; /* solo para halo suave en listening */
}

/* Asegurar sobre el canvas de Unity */
.dock, .chatbar, .history-modal { z-index: 999999; }

/* ===== Dock ===== */
.dock{
    left: 50%;
    bottom: 56px;
    transform: translateX(-50%);
    border-radius: var(--radius-pill);
}
.dock-btn{
    width: var(--btn-size); height: var(--btn-size);
    border: 0; border-radius: 50%;
    background: #f3f5f7; color: #111;
    display: grid; place-items: center;
    font-size: 20px; cursor: pointer;
    transition: transform .15s ease, background .2s ease;
}
.dock-btn:hover{ transform: translateY(-1px); background:#e9eef3; }

/* ===== Chat bar (píldora grande) ===== */
.chatbar{
    left: 50%;
    bottom: 56px;
    opacity: 0;
    pointer-events: none;
    width: min(900px, 88vw);
    border-radius: var(--radius-pill);
    transition: transform .28s ease, opacity .28s ease, box-shadow .28s ease;
}
.chatbar.is-visible{
    opacity: 1; pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.view{
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
}

/* Imagen 2: input + dos botones */
.chat-input{
    border: 0; outline: 0; background: transparent;
    width: 100%; color:#111; font-size: 16px;
}
.chat-input::placeholder{ color:#9aa3ad; }
.actions{ display: flex; gap: 10px; }
.circle-btn{
    width: var(--btn-size); height: var(--btn-size);
    border-radius: 50%; border: 0; cursor: pointer;
    background:#f3f5f7; color:#111; display:grid; place-items:center;
    font-size: 22px; transition: transform .15s ease, background .2s ease;
}
.circle-btn:hover{ transform: translateY(-1px); background:#e9eef3; }

/* Imagen 3: línea/onda + dos botones (✓ y ■) */
.wave-line{
    position: relative;
    height: 6px;
    border-radius: 4px;
    /* background: #cfd6dc; */
    overflow: hidden;
}
.wave-line span{
    position: absolute;
    bottom: 0;
    width: 6px;
    border-radius: 3px;
    background: #111;
    opacity: .35;
    animation: pulse 1.2s ease-in-out infinite;
}
/* Generar 20 barras con offsets */
.wave-line span:nth-child(1){ left:5%;  animation-delay:0s;}
.wave-line span:nth-child(2){ left:10%; animation-delay:.05s;}
.wave-line span:nth-child(3){ left:15%; animation-delay:.1s;}
.wave-line span:nth-child(4){ left:20%; animation-delay:.15s;}
.wave-line span:nth-child(5){ left:25%; animation-delay:.2s;}
.wave-line span:nth-child(6){ left:30%; animation-delay:.25s;}
.wave-line span:nth-child(7){ left:35%; animation-delay:.3s;}
.wave-line span:nth-child(8){ left:40%; animation-delay:.35s;}
.wave-line span:nth-child(9){ left:45%; animation-delay:.4s;}
.wave-line span:nth-child(10){left:50%; animation-delay:.45s;}
.wave-line span:nth-child(11){left:55%; animation-delay:.5s;}
.wave-line span:nth-child(12){left:60%; animation-delay:.55s;}
.wave-line span:nth-child(13){left:65%; animation-delay:.6s;}
.wave-line span:nth-child(14){left:70%; animation-delay:.65s;}
.wave-line span:nth-child(15){left:75%; animation-delay:.7s;}
.wave-line span:nth-child(16){left:80%; animation-delay:.75s;}
.wave-line span:nth-child(17){left:85%; animation-delay:.8s;}
.wave-line span:nth-child(18){left:90%; animation-delay:.85s;}
.wave-line span:nth-child(19){left:95%; animation-delay:.9s;}
.wave-line span:nth-child(20){left:2%;  animation-delay:.95s;}

@keyframes pulse{
    0%,100%{ height: 2px; }
    50%   { height: 18px; opacity:.6; }
}

/* Halo sutil cuando está escuchando */
.chatbar.listening{ box-shadow: 0 0 0 3px rgba(13,110,253,.14), 0 12px 40px rgba(13,110,253,.25); }

/* ===== Modal de historial (sin Bootstrap) ===== */
.history-modal[hidden]{ display:none; }
.history-modal{
    position: fixed; inset: 0; background: rgba(0,0,0,.35);
    display: grid; place-items: center;
}
.history-dialog{
    width: min(800px, 92vw);
    background: var(--bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.history-header{
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid #edf0f3;
}
.btn-close-simple{
background: transparent; border: 0; font-size: 18px; cursor: pointer;
}
.history-body{ padding: 16px 18px; }
.history-body ul{ margin: 0; padding-left: 18px; }

/* Responsivo */
@media (max-width: 520px){
    .dock{ bottom: 40px; }
    .chatbar{ bottom: 40px; width: 92vw !important; }
}

/* ===== CHAT INTERFACE STYLES ===== */
.interfaz-chat {
    display: none;
    /* height: 100vh; */
    background: #212121;
    position: relative;
    overflow: hidden;
}

.interfaz-chat.show {
    display: block;
}

.chat-header {
    background: #343541;
    border-bottom: 1px solid #444654;
    /* padding: 1rem 1.5rem; */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-title {
    color: #ececf1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.chat-messages {
    height: calc(100vh - 78px);
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Scrollbar minimalista */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* Avatar minimalista */
.avatar-user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    min-width: 32px !important;
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
}

.avatar-assistant {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
    min-width: 32px !important;
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
}

/* Mensajes con layout mejorado */
.message-user {
    max-width: 80%;
    margin-left: auto;
    margin-right: 0;
}

.message-assistant {
    max-width: 85%;
    margin-left: 0;
    margin-right: auto;
}

/* Estilos para código y contenido HTML */
.message-content code {
    background: rgba(0, 0, 0, 0.3);
    color: #f8f8f2;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', Monaco, monospace;
    font-size: 0.875rem;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.4);
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.message-content blockquote {
    border-left: 3px solid #667eea;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

.message-content ul, .message-content ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.message-content li {
    margin: 0.25rem 0;
}

.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
    color: #fff;
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.message-content a {
    color: #667eea;
    text-decoration: underline;
}

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

/* Estilos para enlaces de descarga de archivos */
.message-content .file-download-link {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea !important;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(102, 126, 234, 0.3);
    margin: 0.25rem 0;
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none !important;
    transition: all 0.2s ease;
    max-width: 100%;
}

.message-content .file-download-link:hover {
    background: rgba(102, 126, 234, 0.25);
    color: #5a67d8 !important;
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.message-content .file-download-link:before {
    content: "📄";
    font-size: 1.1em;
}

/* Estilos para metadata académica */
.message-content .metadata-section {
    background: rgba(102, 126, 234, 0.08);
    border-left: 3px solid rgba(102, 126, 234, 0.5);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.75rem 0;
}

.message-content .metadata-title {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.message-content .metadata-item {
    color: rgba(255, 255, 255, 0.85);
    margin: 0.25rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-content .metadata-item strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
}

/* Botones de reacción */
.message-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
    /* margin-top: 0.5rem; */
}

.message-assistant:hover .message-actions {
    opacity: 1;
}

.btn-reaction {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #ececf1;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-reaction:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-reaction.active-like {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.btn-reaction.active-dislike {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-reaction i {
    margin-right: 0.25rem;
}

/* Status indicator minimalista */
.chat-status {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

/* Typing animation */
@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: #6c757d;
    border-radius: 50%;
    display: inline-block;
    margin: 0 1px;
    animation: typing 1.4s infinite;
}

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

/* Responsive chat interface */
@media (max-width: 768px) {
    .interfaz-avatar.with-chat {
        display: none;
    }
    
    .interfaz-chat.show {
        width: 100%;
    }
    
    .message-content {
        padding: 0 0.75rem;
        gap: 0.75rem;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
    }
}

@media (min-width: 769px) {
    .interfaz-avatar.with-chat {
        width: 50%;
    }
    
    .interfaz-chat.show {
        width: 50%;
    }
}

/* ===== CONTROLES ANIMATION ===== */
#controles {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

/* Cuando el chat está abierto, mover controles hacia la izquierda */
@media (min-width: 769px) {
    body.chat-open #controles {
        transform: translateX(-25%);
    }
}

/* En dispositivos móviles, mantener controles centrados */
@media (max-width: 768px) {
    #controles {
        transform: translateX(0) !important;
    }
}


/* Estilos para las filas expandibles */
.table tbody tr.shown {
    background-color: #f8f9fa;
}

.table tbody td.details-control {
    cursor: pointer;
    text-align: center;
    user-select: none;
}

.table tbody td.details-control i {
    transition: transform 0.3s ease;
    display: inline-block;
}

.table tbody td.details-control:hover i {
    transform: scale(1.2);
}

/* Animación suave para el contenido expandido */
.table tbody tr.shown td {
    border-bottom: none !important;
}

.table tbody tr.child {
    background-color: #f1f3f5;
}

.table tbody tr.child td {
    padding: 0 !important;
}

.table tbody tr.child .bg-light-primary {
    background-color: #f1f7ff !important;
    border-left: 4px solid #3699FF;
}

/* Mejorar apariencia de la tabla de detalles */
.table .table-sm td {
    padding: 0.5rem 0.75rem;
}

.table .table-sm tr:hover {
    background-color: rgba(54, 153, 255, 0.05);
}

/* Clase cursor-pointer */
.cursor-pointer {
    cursor: pointer;
}