/* ============================================================
   XABIA AGENT STYLES (v40.6 - ORIGINAL RESTORED)
   ============================================================ */

/* --- CONTENEDOR PRINCIPAL --- */
#xabia-chatbox {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 450px;
    max-height: 80vh;
    background: var(--xabia-bg, #ffffff);
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

/* --- HISTORIAL DE MENSAJES --- */
.xabia-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fcfcfc;
    font-size: var(--xabia-font-size, 14px);
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar fina */
.xabia-chat-history::-webkit-scrollbar { width: 6px; }
.xabia-chat-history::-webkit-scrollbar-track { background: transparent; }
.xabia-chat-history::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.15); border-radius: 10px; }

/* --- BURBUJAS DE MENSAJE --- */
.xabia-msg {
    line-height: 1.5;
    animation: xFade 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    word-wrap: break-word;
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 15px;
    margin: 0;
}

.xabia-msg strong {
    color: var(--xabia-accent, #2271b1);
    font-weight: 700;
}

/* Mensaje del Usuario */
.xabia-msg.user {
    align-self: flex-end;
    background: var(--xabia-accent, #2271b1);
    color: #fff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.xabia-msg.user a { color: #fff; text-decoration: underline; }

/* Mensaje del Bot */
.xabia-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #1d1d1f;
    border: 1px solid #eee;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

/* --- INDICADOR DE ESCRITURA --- */
.xabia-typing-dots {
    display: flex;
    gap: 5px;
    padding: 10px 20px;
    align-items: center;
    height: 24px;
    background: transparent;
}
.xabia-typing-dots span {
    width: 6px; height: 6px; background-color: #ccc; border-radius: 50%;
    animation: xTyping 1.4s infinite ease-in-out both;
}
.xabia-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.xabia-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes xTyping { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1.1); opacity: 1; background-color: var(--xabia-accent, #2271b1); } }

/* --- ÁREA DE ENTRADA (INPUT) --- */
.xabia-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #fff;
}

/* FIX CRÍTICO: width: auto y flex-grow para combatir al tema de WP */
.xabia-input-field {
    flex-grow: 1;
    width: auto; 
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 15px;
    transition: border-color 0.2s;
    background: #fff;
    color: #333;
    margin: 0;
}

.xabia-input-field:focus {
    border-color: var(--xabia-accent, #2271b1);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

/* --- ICONOS --- */
.material-symbols-outlined {
    font-size: 22px;
    user-select: none;
    cursor: pointer;
    color: #86868b;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.material-symbols-outlined:hover { color: var(--xabia-accent, #2271b1); }

#x-mic.x-active {
    color: #ff3b30 !important;
    animation: xPulseRed 1.5s infinite;
}
@keyframes xPulseRed { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.1); opacity: 0.8; } 100% { transform: scale(1); opacity: 1; } }

/* --- BOTONES DE ACCIÓN --- */
.xabia-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    margin-right: 5px;
    padding: 6px 14px;
    background: var(--xabia-accent, #2271b1);
    color: #fff !important;
    border-radius: 20px;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.xabia-action-btn:hover { opacity: 0.9; transform: translateY(-1px); }