/* ===========================
   BASE
   =========================== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#chat-widget {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ===========================
   CAJA DEL CHAT
   =========================== */
.chat-box {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
}

/* HEADER */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #351d57; /* Se sobrescribe con inline style desde el template */
    /* color: #ffffff; */ /* Removido - se ajusta automáticamente según el color de fondo */
    font-weight: 600;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chat-header .close-btn {
    background: transparent;
    border: none;
    /* color: #ffffff; */ /* Removido - hereda el color del header que se ajusta automáticamente */
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* BOTÓN "NUEVA CONVERSACIÓN" */
.chat-reset-btn {
    margin: 8px 12px;
    padding: 8px 14px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 13px;
    cursor: pointer;
}

/* CONTENEDOR DE MENSAJES */
.chat-container {
    flex: 1;
    padding: 10px 14px 6px 14px;
    overflow-y: auto;
    background: #faf7ff;
}

/* MENSAJE USUARIO */
.human-message {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.human-message .bubble {
    /* background: #351d57; */ /* Removido - se aplica dinámicamente desde el template */
    /* color: #ffffff; */ /* Removido - se ajusta automáticamente según el color de fondo */
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 80%;
    font-size: 14px;
}

/* MENSAJE BOT */
.bot-line {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.bot-message {
    background: #ffffff;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 14px;
    max-width: 90%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

/* ===========================
   TYPING INDICATOR
   =========================== */
#typing-indicator {
    width: 100%;
    padding: 6px 0;
}

.typing-hidden {
    display: none;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #555;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
    0%   { opacity: .2; }
    20%  { opacity: 1; }
    100% { opacity: .2; }
}


/* ===========================
   INPUT / WRITE-BOX
   =========================== */
.write-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ddd;
    background: #ffffff;
}

#message-user {
    flex: 1;
    min-height: 42px;
    max-height: 80px;
    resize: none;
    border-radius: 10px;
    border: 1px solid #ccc;
    padding: 8px 10px;
    font-size: 14px;
}

/* BOTÓN ENVIAR */
.send-btn {
    /* background: #351d57; */ /* Removido - se aplica dinámicamente desde el template */
    /* color: #ffffff; */ /* Removido - se ajusta automáticamente según el color de fondo */
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ===========================
   BOTÓN FLOTANTE (ABRIR CHAT)
   =========================== */
.chat-toggler {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #351d57;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.chat-toggler img {
    width: 28px;
}

/* Ajuste global del avatar del bot */
.bot-avatar,
.bot-line img {
    width: 42px !important;
    height: 42px !important;
}

/* Imagen grande que aparece antes del chat */
#chat-box > img,
.bot-welcome-img {
    width: 140px !important;
    height: auto !important;
    margin: 0 auto 15px auto;
    display: block;
}


/* Mostrar / ocultar según estado del widget */
#chat-widget.chat-open  .chat-toggler { display: none; }
#chat-widget.chat-open  .chat-box     { display: flex; }

#chat-widget.chat-closed .chat-toggler { display: flex; }
#chat-widget.chat-closed .chat-box     { display: none; }
