/* Bulle */
#chatbot-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
}

#chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
}

/* Fenêtre de chat */
#chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 650px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
}

#chatbot-window.open {
    display: flex;
}

/* Content wrapper */
.chatbot-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.05rem;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

/* Sélection profil */
.profile-selection {
    padding: 20px;
    text-align: center;
    overflow-y: auto;
    max-height: 500px;
}

.profile-selection p {
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: bold;
}

.profile-selection .profile-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    margin: 10px 0;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #2d3748;
}

.profile-selection .profile-btn:hover {
    background: #f7fafc;
    border-color: #667eea;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.profile-selection .profile-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

/* Messages */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0; /* Important pour le flex + scroll */
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: min-content;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-bot {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
}

.message-error {
    align-self: flex-start;
    background: #fff3cd;
    border: 2px solid #ffc107;
    color: #856404;
    max-width: 85%;
}

.message-error .retry-button:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    color: #666;
}

/* Loading animation */
.message-bot .message-content:after {
    content: '';
    animation: none;
}

.message-bot:has(.message-content:contains("Recherche en cours")) .message-content {
    position: relative;
    padding-right: 20px;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
    opacity: 0.6;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Footer */
.chatbot-footer {
    padding: 12px 16px;
    border-top: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

.footer-input {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #f7fafc;
    border-color: #667eea;
    transform: translateY(-1px);
}

#chatbot-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

#chatbot-send {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Rappel anonymat (toujours visible en haut) */
.anonymity-notice {
    background: #f0fdf4;
    border-bottom: 1px solid #86efac;
    padding: 8px 12px;
    font-size: 11px;
    text-align: center;
    color: #166534;
    line-height: 1.4;
}

.anonymity-notice strong {
    color: #15803d;
    font-size: 11px;
}

/* Bandeau RGPD */
.rgpd-banner {
    background: #f0f4ff;
    border-bottom: 2px solid #667eea;
    padding: 16px;
    font-size: 14px;
}

.rgpd-content p {
    margin: 0;
    color: #2d3748;
}

.rgpd-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.rgpd-btn-accept {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.rgpd-btn-accept:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

/* Écran de reprise */
.resume-screen {
    padding: 20px;
    text-align: center;
}

.resume-screen h3 {
    margin-bottom: 16px;
    color: #2d3748;
}

.resume-screen p {
    margin-bottom: 12px;
    color: #4a5568;
}

#resume-code-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 16px;
}

#resume-code-input:focus {
    outline: none;
    border-color: #667eea;
}

.resume-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    flex: 1;
    background: white;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.error-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
}

.profile-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.link-button {
    background: none;
    border: none;
    color: #667eea;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
}

.link-button:hover {
    color: #5568d3;
}

/* Modal */
.chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin: 0 0 16px 0;
    color: #2d3748;
}

.modal-content p {
    margin: 8px 0;
    color: #4a5568;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* Rating stars */
.rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
    font-size: 32px;
}

.rating-stars span {
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.3;
}

.rating-stars span:hover {
    transform: scale(1.2);
    opacity: 1;
}

#feedback-text {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-top: 12px;
}

#feedback-text:focus {
    outline: none;
    border-color: #667eea;
}

/* Resume code display */
.resume-code-display {
    background: #f7fafc;
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 16px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #667eea;
    margin: 16px 0;
    font-family: monospace;
}

/* Responsive */
@media (max-width: 768px) {
    #chatbot-window {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .modal-content {
        max-width: 90%;
        padding: 20px;
    }

    .rating-stars {
        font-size: 28px;
    }
}
