/* ─── Kridexa ERP Chatbot Widget ─── */
/* Matches brand theme: cream/sage/gold/ink */

#kridexa-chatbot {
    --gold: #D4A855;
    --gold-light: #E8C86A;
    --cream: #FEFAE0;
    --sage-light: #E9EDC9;
    --sage: #CCD5AE;
    --ink: #1E2A3A;
    --ink-soft: #3D4F60;

    --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --chat-radius: 16px;
    --chat-bubble-radius: 18px;
    --chat-font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    font-family: var(--chat-font);
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}

/* ─── Toggle Button ─── */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--ink);
    font-size: 26px;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

#chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 40px rgba(212, 168, 85, 0.4);
}

#chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* ─── Chat Panel ─── */
#chatbot-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#chatbot-panel.hidden {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}

/* ─── Header ─── */
#chatbot-header {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--ink);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

#chatbot-close {
    background: none;
    border: none;
    color: var(--ink);
    font-size: 22px;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
    padding: 0 4px;
}

#chatbot-close:hover {
    opacity: 1;
}

/* ─── Messages Area ─── */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: var(--cream);
}

/* ─── Individual Messages ─── */
.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--chat-bubble-radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msg-fadein 0.2s ease;
}

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

.chatbot-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--ink);
    border-bottom-right-radius: 4px;
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: var(--ink);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sage-light);
}

.chatbot-msg.bot a {
    color: var(--gold);
    text-decoration: underline;
}

/* ─── Typing Indicator ─── */
.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--chat-bubble-radius);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sage-light);
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b5b5b5;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

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

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ─── Input Area ─── */
#chatbot-input-area {
    display: flex;
    border-top: 1px solid var(--sage-light);
    padding: 10px 12px;
    gap: 8px;
    flex-shrink: 0;
    background: #fff;
}

#chatbot-input {
    flex: 1;
    border: 1px solid var(--sage);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--cream);
}

#chatbot-input:focus {
    border-color: var(--gold);
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--ink);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

#chatbot-send:hover {
    opacity: 0.85;
}

#chatbot-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 480px) {
    #kridexa-chatbot {
        bottom: 12px;
        right: 12px;
    }

    #chatbot-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }

    #chatbot-panel.hidden {
        transform: translateY(20px);
    }
}
