/* Container CSS Using Config Variable */
.chatbot-container {
    width: 100%;
    max-width: 650px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border: 1px solid #e4e8f0;
    margin: 16px auto;
    transition: box-shadow 0.2s ease;
}
.chatbot-container:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13), 0 2px 6px rgba(0, 0, 0, 0.07);
}

/* ---- Header ---- */
.chatbot-header {
    background: var(--theme-color, #007bff);
    color: #ffffff;
    padding: 14px 18px;
}
.chatbot-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-header-main {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.20);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.30);
}
.chatbot-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.chatbot-header-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.chatbot-header-sub {
    font-size: 0.72rem;
    opacity: 0.78;
    font-weight: 400;
    margin-top: 1px;
}
.chatbot-header-sub.ai-security-info-btn {
    position: static;
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border-radius: 0;
    outline: none;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.chatbot-header-sub.ai-security-info-btn:hover,
.chatbot-header-sub.ai-security-info-btn:focus {
    background: none;
    color: inherit;
    opacity: 1;
    text-decoration: underline;
}
.chatbot-header-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.chatbot-header-action {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
.chatbot-header-action:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}
.chatbot-header-action i {
    font-size: 12px;
}

/* ---- Chat display container ---- */
.chatbox {
    height: 320px;
    overflow-y: auto;
    list-style: none;
    padding: 18px 16px;
    margin: 0;
    background: #f7f9fc;
    scroll-behavior: smooth;
}

/* ---- Core message rules ---- */
.chat {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 14px;
}
.chat p, .chat > div {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    word-wrap: break-word;
}

/* ---- Inbound ---- */
.chat.incoming {
    justify-content: flex-start;
}
.chat.incoming .bot-icon {
    width: 32px;
    height: 32px;
    background: #e4e8f0;
    color: #495057;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    border: 1px solid #d0d5de;
}
.chat.incoming p, .chat.incoming > div {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e4e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat.incoming.error p {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ---- Outbound ---- */
.chat.outgoing {
    justify-content: flex-end;
}
.chat.outgoing p {
    background: var(--theme-color, #007bff);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    border: 1px solid transparent;
}

/* ---- Input footer ---- */
.chatbot-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid #e4e8f0;
    padding: 12px 14px;
    background: #ffffff;
}
.question-area {
    flex: 1;
    border: 1px solid #d0d5de;
    border-radius: 10px;
    outline: none;
    resize: none;
    overflow-y: hidden;
    font-size: 0.9rem;
    padding: 9px 12px;
    color: #1f2937;
    background: #f7f9fc;
    max-height: 110px;
    line-height: 1.45;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    font-family: inherit;
}
.question-area:focus {
    border-color: var(--theme-color, #007bff);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.12);
}
.question-area::placeholder {
    color: #9ca3af;
}

/* ---- Send button ---- */
.chatbot-input .send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: var(--theme-color, #007bff);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.chatbot-input .voice-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #d0d5de;
    background: #f3f6fb;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.chatbot-input .voice-btn:hover:not(:disabled) {
    transform: scale(1.08);
}
.chatbot-input .voice-btn.is-listening {
    background: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}
.chatbot-input .voice-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.send-btn:hover:not(:disabled) {
    transform: scale(1.08);
}
.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Loading dots (pulsing) ---- */
.loading-dots span {
    animation: pulseDots 1.4s infinite both;
    font-weight: bold;
    display: inline-block;
    font-size: 1.4rem;
    line-height: 0.8;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

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

/* Bot icon styling for incoming messages */
.chat.incoming .bot-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background-color: #007bff;
    color: #fff;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat.incoming .bot-icon i {
    font-size: 14px;
}

/* User icon styling for outgoing messages */
.chat.outgoing .user-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background-color: #7c8799;
    color: #fff;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat.outgoing .user-icon i {
    font-size: 14px;
}