/* LPS AI Chatbot Widget - ECLAIR v3 */

#lps-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Floating bubble */
#lps-chatbot-bubble {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#lps-chatbot-bubble:hover {
    transform: scale(1.1);
}

/* Bubble image - perfect circle */
#lps-chatbot-bubble img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    clip-path: circle(50%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Tooltip "A l'aide!?" */
.aide_tooltip {
    position: absolute;
    bottom: 85px;
    right: 0;
    background: #004AAD;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.aide_tooltip::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 25px;
    border-width: 6px;
    border-style: solid;
    border-color: #004AAD transparent transparent transparent;
}

/* Chat window */
#lps-chatbot-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#lps-chatbot-window.lps-chatbot-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Header */
#lps-chatbot-header {
    background: var(--lps-chatbot-color, #004AAD);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.lps-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lps-chatbot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lps-chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.lps-chatbot-title {
    font-weight: 600;
    font-size: 15px;
}

.lps-chatbot-status {
    font-size: 12px;
    opacity: 0.85;
}

#lps-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.8;
}

#lps-chatbot-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* Messages area */
#lps-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fb;
}

#lps-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#lps-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Message bubbles */
.lps-chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: lps-msg-appear 0.3s ease;
}

@keyframes lps-msg-appear {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.lps-chatbot-msg.bot {
    background: white;
    color: #004AAD;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lps-chatbot-msg.user {
    background: var(--lps-chatbot-color, #004AAD);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.lps-chatbot-msg a {
    color: var(--lps-chatbot-color, #004AAD);
    text-decoration: underline;
}

.lps-chatbot-msg.user a {
    color: white;
}

/* Sources - hidden, links are inline */
.lps-chatbot-sources {
    display: none !important;
}

/* Typing indicator */
.lps-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lps-chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #aaa;
    border-radius: 50%;
    animation: lps-typing-bounce 1.4s infinite ease-in-out;
}

.lps-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.lps-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lps-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Action buttons */
#lps-chatbot-actions {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: white;
    border-top: 1px solid #eee;
}

#lps-chatbot-actions.lps-chatbot-hidden {
    display: none;
}

.lps-chatbot-action-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--lps-chatbot-color, #004AAD);
    background: white;
    color: var(--lps-chatbot-color, #004AAD);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.lps-chatbot-action-btn:hover {
    background: var(--lps-chatbot-color, #004AAD);
    color: white;
}

/* Input area */
#lps-chatbot-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: white;
    border-top: 1px solid #eee;
}

#lps-chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

#lps-chatbot-input:focus {
    border-color: var(--lps-chatbot-color, #004AAD);
}

#lps-chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--lps-chatbot-color, #004AAD);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

#lps-chatbot-send:hover {
    transform: scale(1.05);
}

#lps-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #lps-chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    #lps-chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        bottom: 85px;
        right: -5px;
        border-radius: 12px;
    }
}

/* Markdown in bot messages */
.lps-chatbot-msg.bot strong { font-weight: 600; }
.lps-chatbot-msg.bot em { font-style: italic; }
.lps-chatbot-msg.bot ul, .lps-chatbot-msg.bot ol {
    margin: 6px 0;
    padding-left: 20px;
}
.lps-chatbot-msg.bot li { margin: 2px 0; }
.lps-chatbot-msg.bot p { margin: 4px 0; }
.lps-chatbot-msg.bot code {
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
}
