/* ============================================
   WIDGET CHATBOT - Bulle flottante
   ============================================ */

/* Bulle de chat */
.chatbot-bubble {
    position: fixed;
    bottom: 2rem;
    right: 6rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color, #6366f1);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    z-index: 1050;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}

.chatbot-bubble.open .chatbot-bubble-icon-chat {
    display: none;
}

.chatbot-bubble.open .chatbot-bubble-icon-close {
    display: flex;
}

.chatbot-bubble-icon-close {
    display: none;
}

/* Panneau de chat */
.chatbot-panel {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    max-height: calc(100vh - 10rem);
    background: var(--dark-bg, #1a1a2e);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    z-index: 1051;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-panel.open {
    display: flex;
    animation: chatbotSlideIn 0.3s ease;
}

@keyframes chatbotSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--white, #fff);
}

.chatbot-header-status {
    font-size: 0.75rem;
    color: var(--gray-400, #9ca3af);
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 200px;
    max-height: none;
}

.chatbot-msg {
    max-width: 85%;
    padding: 0.6rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: var(--gray-200, #e5e7eb);
    border-bottom-left-radius: 4px;
}

/* Markdown dans les messages bot */
.chatbot-msg-bot p {
    margin: 0 0 0.4rem;
}

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

.chatbot-msg-bot a {
    color: var(--primary-light, #818cf8);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-msg-bot a:hover {
    color: #a5b4fc;
}

.chatbot-msg-bot strong {
    color: var(--white, #fff);
    font-weight: 600;
}

.chatbot-msg-bot em {
    font-style: italic;
}

.chatbot-msg-bot ol,
.chatbot-msg-bot ul {
    margin: 0.3rem 0;
    padding-left: 1.3rem;
}

.chatbot-msg-bot li {
    margin-bottom: 0.2rem;
}

.chatbot-msg-bot li:last-child {
    margin-bottom: 0;
}

.chatbot-msg-user {
    align-self: flex-end;
    background: var(--primary-color, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg-typing {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    color: var(--gray-400, #9ca3af);
    font-style: italic;
    border-bottom-left-radius: 4px;
}

/* Input */
.chatbot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: var(--white, #fff);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--primary-color, #6366f1);
}

.chatbot-input::placeholder {
    color: var(--gray-500, #6b7280);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color, #6366f1);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

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

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

/* Avertissement inactivite */
.chatbot-afk-warning {
    align-self: center;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    text-align: center;
    animation: chatbotSlideIn 0.3s ease;
}

.chatbot-afk-warning p {
    font-size: 0.85rem;
    color: #fbbf24;
    margin: 0 0 0.6rem;
    line-height: 1.4;
}

.chatbot-afk-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.chatbot-afk-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chatbot-afk-btn:hover {
    opacity: 0.85;
}

.chatbot-afk-stay {
    background: var(--primary-color, #6366f1);
    color: #fff;
}

.chatbot-afk-close {
    background: rgba(255, 255, 255, 0.1);
    color: var(--gray-300, #d1d5db);
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Mobile */
@media (max-width: 480px) {
    .chatbot-panel {
        width: calc(100vw - 2rem);
        right: 1rem;
        bottom: 5.5rem;
        max-height: 70vh;
    }

    .chatbot-bubble {
        right: 4.5rem;
        bottom: 1.5rem;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
}
