/* =========================================================
   ANAI - ASISTENTE EDUCATIVO DE MEDICINA
   DISEÑO MODERNO PREMIUM (LIGHT MODE / TONOS BLANCOS)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.aws-agent-chat-wrapper {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1e293b;
    box-sizing: border-box;
    width: 100%;
    margin: 20px 0;
}

.aws-agent-chat-wrapper * {
    box-sizing: border-box;
}

/* =========================================================
   1. CONTENEDOR PRINCIPAL DEL CHAT (MODO EMBEBIDO/INLINE)
   ========================================================= */
.aws-agent-chat-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 620px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: row;
    overflow: hidden;
    z-index: 10;
}

/* =========================================================
   2. PANEL LATERAL (SIDEBAR DE HILOS Y NAVEGACIÓN)
   ========================================================= */
.anai-sidebar {
    width: 260px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, margin-left 0.3s ease;
    z-index: 20;
}

.anai-sidebar.collapsed {
    margin-left: -260px;
}

.anai-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.anai-new-chat-btn {
    width: 100%;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}

.anai-new-chat-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.anai-sidebar-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 14px 16px 6px;
    margin: 0;
}

.anai-threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.anai-thread-item {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.anai-thread-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.anai-thread-item.active {
    background: #e2e8f0;
    color: #1e293b;
    font-weight: 600;
}

/* =========================================================
   3. ÁREA PRINCIPAL DE CHAT
   ========================================================= */
.anai-main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    height: 100%;
    position: relative;
}

/* Cabecera */
.aws-agent-chat-header {
    background: #ffffff;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aws-agent-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.anai-avatar-header {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.aws-agent-title {
    font-weight: 700;
    font-size: 16px;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
}

.aws-agent-status {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.aws-agent-status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
}

.anai-toggle-sidebar-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.anai-toggle-sidebar-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Área de mensajes */
.aws-agent-chat-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #fafafa;
    scroll-behavior: smooth;
}

.aws-agent-chat-body::-webkit-scrollbar {
    width: 6px;
}

.aws-agent-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Filas de mensaje con Icono */
.anai-msg-row {
    display: flex;
    gap: 12px;
    max-width: 90%;
    animation: msgPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.anai-msg-row.bot {
    align-self: flex-start;
}

.anai-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* TAMAÑO FIJO INMUTABLE PARA EL LOGO DE LA IA */
.anai-bot-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0 !important;
    align-self: flex-start !important;
    margin-top: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Burbujas de chat */
.aws-chat-msg {
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

/* VIÑETAS Y LISTAS MARKDOWN */
.aws-chat-msg ul,
.aws-chat-msg ol {
    margin: 8px 0;
    padding-left: 22px;
}

.aws-chat-msg li {
    margin-bottom: 5px;
    line-height: 1.55;
}

/* TABLAS MARKDOWN DENTRO DE LOS MENSAJES */
.aws-chat-msg table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13.5px;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.aws-chat-msg th,
.aws-chat-msg td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
}

.aws-chat-msg th {
    background: #f1f5f9;
    font-weight: 600;
    color: #0f172a;
}

@keyframes msgPop {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.anai-msg-row.bot .aws-chat-msg {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 2px;
}

.anai-msg-row.user .aws-chat-msg {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border-top-right-radius: 2px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Indicador de Estado y Typing en Tiempo Real */
.aws-chat-typing-container {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 13px;
    color: #475569;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.aws-chat-typing-container.active {
    display: flex;
}

.aws-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.aws-chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: #2563eb;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.aws-chat-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.aws-chat-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.anai-progress-text {
    font-weight: 500;
    color: #2563eb;
}

/* Pie del chat (Input) */
.aws-agent-chat-footer {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.aws-agent-input {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px 16px;
    color: #0f172a;
    font-size: 14.5px;
    outline: none;
    transition: all 0.2s ease;
}

.aws-agent-input:focus {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.aws-agent-send-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.aws-agent-send-btn:hover {
    background: #1d4ed8;
}

.aws-agent-send-btn:active {
    transform: scale(0.95);
}
