/* Bouton pour ouvrir/fermer le chatbot */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: #0073aa;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1);
}

#chatbot-toggle:hover {
    background: #005177;
    transform: scale(1.1);
}

#chatbot-toggle.hidden {
    transform: scale(0);
}

/* Conteneur du chatbot */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 500px;
    height: 500px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 100000;
    padding: 0;
    transform-origin: bottom left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    font-size: 14px;
}

#chatbot-container.minimized {
    transform: translateY(calc(100% + 20px));
    opacity: 0;
}

#chat-response {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    border: none;
    border-radius: 0;
    margin: 0;
}

/* Add input container styles */
.chat-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    min-width: 0; /* Prevents flex item from overflowing */
}

#send-chat {
    width: auto;
    min-width: 80px;
    padding: 10px 15px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

#send-chat:hover {
    background: #005177;
}

/* Markdown styles */
#chat-response code {
    background-color: #f6f8fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

#chat-response pre {
    background-color: #f6f8fa;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
}

#chat-response pre code {
    background-color: transparent;
    padding: 0;
}

#chat-response blockquote {
    border-left: 4px solid #dfe2e5;
    margin: 0;
    padding-left: 16px;
    color: #6a737d;
    font-size: 14px;
}

#chat-response table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 14px;
}

#chat-response th,
#chat-response td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
    font-size: 14px;
}

#chat-response th {
    background-color: #f6f8fa;
}

#chat-response ul,
#chat-response ol {
    padding-left: 20px;
    font-size: 14px;
}

#chat-response img {
    max-width: 100%;
    height: auto;
}

/* Message styles */
.user-message, .bot-message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
    max-width: 80%;
    animation: messageSlide 0.3s ease-out;
    font-size: 14px;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: #e3f2fd;
    margin-left: auto;
}

.bot-message {
    background: white;
    border: 1px solid #eee;
}

/* Code block styling */
pre {
    background: #2d2d2d;
    color: #ccc;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
}

code {
    font-family: 'Courier New', Courier, monospace;
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Close button */
#chatbot-minimize {
    position: static;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#chatbot-minimize:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

/* Update header styles */
.chatbot-header {
    padding: 15px;
    background: white;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.chatbot-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.icon-button {
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.icon-button:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

.icon-button.active {
    background: #e3f2fd;
    color: #0073aa;
}

/* Add these new styles */
#clear-chat {
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

#clear-chat:hover {
    background: #f0f0f0;
    color: #333;
    transform: scale(1.1);
}

/* Responsive styles */
@media screen and (max-width: 768px) {
    #chatbot-container {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
        transform-origin: bottom center;
        display: flex;
        flex-direction: column;
        padding: 0;
        position: fixed;
        top: 0;
        z-index: 100000;
    }

    .chatbot-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 15px;
        border-bottom: 1px solid #ddd;
        z-index: 100001;
        margin: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        height: 50px;
    }

    #chat-response {
        position: absolute;
        top: 50px;
        bottom: 60px;
        left: 0;
        right: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 15px;
        background: #f9f9f9;
        border: none;
        border-radius: 0;
        margin: 0;
        height: calc(100% - 110px);
    }

    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 15px;
        z-index: 100001;
        display: flex;
        align-items: center;
        gap: 10px;
        border-top: 1px solid #eee;
        height: 60px;
    }

    #chat-input {
        flex: 1;
        margin: 0;
        min-width: 0;
    }

    #send-chat {
        margin: 0;
        flex-shrink: 0;
    }

    /* Hide toggle when chat is open on mobile */
    .chat-open #chatbot-toggle {
        display: none;
    }

    #chatbot-container.minimized {
        transform: translateY(100%);
    }

    /* Handle virtual keyboard */
    @supports (-webkit-touch-callout: none) {
        #chatbot-container {
            height: -webkit-fill-available;
        }
    }
}

/* Context toggle styles */
.context-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    background: #f8f8f8;
    border: 1px solid #ddd;
}

.context-toggle:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.context-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.context-toggle span {
    user-select: none;
    white-space: nowrap;
}

/* Remove old context button styles */
.icon-button[title^="Toggle Page Context"] {
    display: none;
}

.context-toggle.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.context-toggle.disabled input[type="checkbox"] {
    cursor: not-allowed;
}

.context-toggle .context-notice {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

.context-toggle.disabled:hover {
    background: none;
    border-color: #ddd;
}
