/* ===== Chatbot Flottant ===== */
.chatbot-toggle {
    position: fixed;
    bottom: 90px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary, #7b2cbf);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    box-shadow: 0 8px 25px rgba(123, 44, 191, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 35px rgba(123, 44, 191, 0.5);
}
.chatbot-toggle .badge-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 3px solid var(--bg-color, #fdfdfd);
}

.chatbot-window {
    position: fixed;
    bottom: 160px;
    right: 25px;
    width: 380px;
    max-width: calc(100vw - 50px);
    height: 520px;
    max-height: calc(100vh - 200px);
    background: var(--bg-color, #fdfdfd);
    border: 1px solid var(--glass-border, rgba(123,44,191,0.1));
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.chatbot-window.open {
    display: flex;
    animation: chatbotSlideUp 0.3s ease;
}

@keyframes chatbotSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chatbot-header {
    background: var(--primary, #7b2cbf);
    color: white;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}
.chatbot-header i {
    font-size: 1.4rem;
}
.chatbot-header h6 {
    margin: 0;
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
}
.chatbot-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.chatbot-close:hover {
    background: rgba(255,255,255,0.3);
}

.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-color, #fdfdfd);
}

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    animation: msgIn 0.25s ease;
    word-wrap: break-word;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: var(--glass-bg, rgba(123,44,191,0.05));
    border: 1px solid var(--glass-border, rgba(123,44,191,0.1));
    color: var(--text-main, #2d3436);
    border-bottom-left-radius: 4px;
}
.chatbot-msg.user {
    align-self: flex-end;
    background: var(--primary, #7b2cbf);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-msg .msg-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary, #7b2cbf);
    font-weight: 600;
    text-decoration: none;
    margin-top: 6px;
    transition: color 0.2s;
}
.chatbot-msg .msg-link:hover {
    color: var(--primary-dark, #5a189a);
    text-decoration: underline;
}

.chatbot-msg .suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.chatbot-msg .suggestion-chip {
    background: var(--comprendre-soft, rgba(0,119,182,0.1));
    color: var(--primary, #7b2cbf);
    border: 1px solid var(--glass-border, rgba(123,44,191,0.15));
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}
.chatbot-msg .suggestion-chip:hover {
    background: var(--primary, #7b2cbf);
    color: white;
    border-color: var(--primary);
}

.chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    border-top: 1px solid var(--glass-border, rgba(123,44,191,0.1));
    background: var(--bg-color, #fdfdfd);
}
.chatbot-input-area input {
    flex: 1;
    border: 1px solid var(--glass-border, rgba(123,44,191,0.15));
    border-radius: 25px;
    padding: 10px 18px;
    font-size: 0.9rem;
    outline: none;
    background: var(--white, #fff);
    color: var(--text-main, #2d3436);
    transition: border-color 0.2s;
}
.chatbot-input-area input:focus {
    border-color: var(--primary, #7b2cbf);
    box-shadow: 0 0 0 3px rgba(123,44,191,0.1);
}
.chatbot-input-area .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary, #7b2cbf);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chatbot-input-area .send-btn:hover {
    background: var(--primary-dark, #5a189a);
    transform: scale(1.05);
}
.chatbot-input-area .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-typing {
    align-self: flex-start;
    background: var(--glass-bg, rgba(123,44,191,0.05));
    border: 1px solid var(--glass-border, rgba(123,44,191,0.1));
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 18px;
    display: flex;
    gap: 5px;
}
.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted, #57606f);
    border-radius: 50%;
    animation: typingDot 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 typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30%           { opacity: 1;   transform: scale(1.2); }
}

/* Dark theme adjustments */
body.dark-theme .chatbot-window {
    background: #12121a;
    border-color: rgba(255,255,255,0.1);
}
body.dark-theme .chatbot-messages {
    background: #12121a;
}
body.dark-theme .chatbot-msg.bot {
    background: #1a1a2e;
    border-color: rgba(255,255,255,0.08);
    color: #e1e1e6;
}
body.dark-theme .chatbot-input-area {
    background: #12121a;
    border-top-color: rgba(255,255,255,0.1);
}
body.dark-theme .chatbot-input-area input {
    background: #1a1a2e;
    color: #e1e1e6;
    border-color: rgba(255,255,255,0.15);
}
body.dark-theme .chatbot-toggle .badge-dot {
    border-color: #030305;
}

/* Tablet & Small Desktop */
@media (max-width: 1024px) {
    .chatbot-window {
        right: 20px;
        bottom: 150px;
        width: 360px;
        height: 480px;
    }
}

/* Mobile landscape & small tablets */
@media (max-width: 768px) {
    .chatbot-window {
        right: 10px;
        bottom: 140px;
        width: calc(100vw - 20px);
        height: 55vh;
        max-height: 500px;
        border-radius: 16px;
    }
    .chatbot-toggle {
        right: 15px;
        bottom: 75px;
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }
    .chatbot-header {
        padding: 12px 14px;
    }
    .chatbot-header h6 {
        font-size: 0.95rem;
    }
    .chatbot-messages {
        padding: 12px;
    }
    .chatbot-msg {
        max-width: 90%;
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    .chatbot-input-area {
        padding: 10px 12px;
    }
    .chatbot-input-area input {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .chatbot-window {
        right: 8px;
        bottom: 130px;
        width: calc(100vw - 16px);
        height: 60vh;
        max-height: 450px;
        border-radius: 14px;
    }
    .chatbot-toggle {
        right: 12px;
        bottom: 70px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    .chatbot-toggle .badge-dot {
        width: 12px;
        height: 12px;
    }
    .chatbot-header {
        padding: 10px 12px;
    }
    .chatbot-header h6 {
        font-size: 0.85rem;
    }
    .chatbot-header i {
        font-size: 1.1rem;
    }
    .chatbot-messages {
        padding: 10px;
        gap: 8px;
    }
    .chatbot-msg {
        max-width: 92%;
        font-size: 0.8rem;
        padding: 7px 10px;
        border-radius: 12px;
    }
    .chatbot-msg .suggestion-chip {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    .chatbot-input-area {
        padding: 8px 10px;
        gap: 6px;
    }
    .chatbot-input-area input {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
    .chatbot-input-area .send-btn {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
    .chatbot-close {
        width: 28px;
        height: 28px;
    }
    /* Make sure chatbot doesn't overlap the accessibility bar */
    .chatbot-window.open {
        max-height: calc(100vh - 160px);
    }
}

/* Very small screens (e.g. old phones) */
@media (max-width: 360px) {
    .chatbot-window {
        height: 55vh;
        max-height: 380px;
    }
    .chatbot-toggle {
        width: 44px;
        height: 44px;
        font-size: 1rem;
        bottom: 65px;
        right: 10px;
    }
}
