#chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 999;
}
#chatbot-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.2); }
#chatbot-toggle svg { width: 24px; height: 24px; fill: #fff; }
[data-theme="dark"] #chatbot-toggle { background: #3b82f6 !important; box-shadow: 0 4px 16px rgba(59,130,246,0.4) !important; }
[data-theme="dark"] #chatbot-toggle svg { fill: #fff !important; }

#chatbot-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(0.96);
    transition: opacity 0.25s, transform 0.25s;
}
#chatbot-panel.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}
.chatbot-header span { font-size: 0.95rem; font-weight: 600; color: #fff; }
.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.chatbot-close:hover { opacity: 1; }

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chatbot-messages::-webkit-scrollbar { width: 5px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.chatbot-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border: none;
}
.chatbot-msg.assistant {
    align-self: flex-start;
    background: var(--bg-alt, #f8fafc);
    border: 1px solid var(--border);
    color: var(--text);
}
.chatbot-msg code { background: rgba(0,0,0,0.06); padding: 2px 5px; border-radius: 4px; font-size: 0.85em; }
.chatbot-msg strong { font-weight: 600; }

.chatbot-typing {
    align-self: flex-start;
    background: var(--bg-alt, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    display: none;
}
.chatbot-typing.visible { display: flex; align-items: center; gap: 4px; }
.chatbot-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: chatbot-bounce 1.2s infinite; }
.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatbot-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.chatbot-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
#chatbot-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-alt, #f8fafc);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
#chatbot-input::placeholder { color: var(--text-muted); }
#chatbot-input:focus { border-color: var(--accent); }

#chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}
#chatbot-send:hover { transform: scale(1.08); }
#chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#chatbot-send svg { width: 18px; height: 18px; fill: #fff; }

@media (max-width: 640px) {
    #chatbot-panel {
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100dvh;
        border: none;
        border-radius: 0;
        position: fixed;
    }
    .chatbot-messages {
        flex: 1;
        min-height: 0;
    }
    .chatbot-input-row {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    #chatbot-input { font-size: 16px; }
    #chatbot-toggle { bottom: 16px; right: 16px; }
    .chatbot-header {
        padding: 14px 16px;
        background: var(--accent);
    }
    .chatbot-header span { font-size: 1.05rem; }
    .chatbot-close {
        font-size: 2rem;
        padding: 4px 10px;
        color: #fff;
        background: rgba(255,255,255,0.2);
        border-radius: 8px;
    }
}
