/* ===== Chatbot Widget ===== */
#chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-body);
}

#chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: var(--white);
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

#chatbot-toggle:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

/* Chat window */
#chatbot-window {
    display: none;
    flex-direction: column;
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: 1px solid var(--border);
}

#chatbot-window.open {
    display: flex;
}

/* Header */
#chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--accent);
    color: var(--white);
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

#chatbot-clear {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    font-size: 0.95rem;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

#chatbot-clear:hover {
    opacity: 1;
}

/* Messages area */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    min-height: 260px;
    max-height: 340px;
    background: var(--cream);
}

.chat-msg {
    max-width: 85%;
    animation: chatFadeIn 0.2s ease;
}

.chat-msg p {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    word-wrap: break-word;
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.bot p {
    background: var(--white);
    color: var(--charcoal);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.user p {
    background: var(--accent);
    color: var(--white);
    border-bottom-right-radius: var(--radius-sm);
}

/* Typing indicator */
.chat-msg.typing p {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
}


/* Markdown formatting inside bot messages */
.chat-msg.bot p ol,
.chat-msg.bot p ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
}

.chat-msg.bot p li {
    margin-bottom: 4px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.chat-msg.bot p strong {
    font-weight: 600;
    color: var(--charcoal);
}

.chat-msg.bot p a {
    color: var(--accent);
    text-decoration: underline;
}

.dot {
    width: 7px;
    height: 7px;
    background: var(--stone-dark);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Input area */
#chatbot-form {
    display: flex;
    border-top: 1px solid var(--border);
    background: var(--white);
}

#chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: transparent;
    color: var(--charcoal);
}

#chatbot-input::placeholder {
    color: var(--stone-dark);
}

#chatbot-send {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: var(--space-sm) var(--space-md);
    font-size: 1rem;
    transition: color var(--transition-fast);
}

#chatbot-send:hover {
    color: var(--accent-light);
}

/* Responsive */
@media (max-width: 480px) {
    #chatbot-window {
        width: calc(100vw - 32px);
        right: -8px;
        max-height: 60vh;
    }
}
