/**
 * Chatbot Widget — POC TeachMeUp × Mistral AI
 * BEM naming convention
 */

/* ── Root container ── */
.chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Toggle button ── */
.chatbot__toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #6f42c1;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chatbot__toggle:hover {
    background: #5a32a3;
    transform: scale(1.08);
}

.chatbot__toggle--hidden {
    display: none;
}

/* ── Chat panel ── */
.chatbot__panel {
    display: none;
    flex-direction: column;
    width: 360px;
    height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    position: absolute;
    bottom: 64px;
    right: 0;
}

.chatbot__panel--open {
    display: flex;
}

/* ── Header ── */
.chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #6f42c1;
    color: #fff;
    flex-shrink: 0;
}

.chatbot__title {
    font-size: 0.95rem;
    font-weight: 600;
}

.chatbot__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot__close:hover {
    opacity: 1;
}

/* ── Messages area ── */
.chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot__message {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.chatbot__message--bot {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chatbot__message--user {
    align-self: flex-end;
    background: #6f42c1;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot__message--error {
    align-self: flex-start;
    background: #fff3cd;
    color: #856404;
    border-bottom-left-radius: 4px;
    font-style: italic;
}

/* Markdown rendering in bot messages */
.chatbot__message--bot p {
    margin: 0 0 6px;
}

.chatbot__message--bot p:last-child {
    margin-bottom: 0;
}

.chatbot__message--bot ul {
    margin: 4px 0;
    padding-left: 18px;
}

.chatbot__message--bot li {
    margin-bottom: 2px;
}

.chatbot__message--bot a {
    color: #6f42c1;
    text-decoration: underline;
}

.chatbot__message--bot a:hover {
    color: #5a32a3;
}

.chatbot__message--bot strong {
    font-weight: 600;
}

/* ── Typing indicator ── */
.chatbot__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    align-self: flex-start;
}

.chatbot__typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    animation: chatbot-bounce 1.2s infinite;
}

.chatbot__typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot__typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ── Input area ── */
.chatbot__input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e9ecef;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot__input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot__input:focus {
    border-color: #6f42c1;
}

.chatbot__send {
    background: #6f42c1;
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chatbot__send:hover {
    background: #5a32a3;
}

.chatbot__send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 576px) {
    .chatbot__panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        right: -8px;
        bottom: 60px;
    }
}
