* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Empêche le scroll de la page entière */
}

.container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 85vh;
    max-height: 85vh;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0; /* Important pour que flex fonctionne correctement */
    max-height: calc(85vh - 140px); /* Hauteur max moins header et input */
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.message-content {
    flex: 1;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 15px;
    border-top-left-radius: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.user-message .message-content {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border-top-right-radius: 5px;
    border-top-left-radius: 15px;
    padding: 12px 15px; /* Padding réduit pour les messages utilisateur */
    min-height: auto; /* Pas de hauteur minimale */
}

/* Bouton de copie sur fond bleu (messages utilisateur) */
.user-message .copy-button {
    background: rgba(255,255,255,0.2);
    color: white;
}

.user-message .copy-button:hover {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

/* Animations pour le streaming */
.typing-indicator {
    color: #6c757d;
    font-size: 1.2em;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.typing-cursor {
    color: #007bff;
    font-weight: bold;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.streaming-content {
    min-height: 30px;
}

.message-content p {
    margin-bottom: 10px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Gestion des liens longs */
.message-content a {
    word-break: break-all;
    overflow-wrap: break-word;
}

/* Gestion des listes */
.message-content ul, .message-content ol {
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 10px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 5px;
    line-height: 1.5;
}

/* Titres dans les messages */
.message-content h4 {
    color: #495057;
    margin: 12px 0 8px 0;
    font-size: 1.1em;
    font-weight: 600;
}

/* Premier titre sans marge du haut */
.message-content h4:first-child {
    margin-top: 0;
}

/* Texte en gras */
.message-content strong {
    font-weight: 600;
    color: #2c3e50;
}

.faq-links {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.faq-links h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.faq-links details {
    cursor: pointer;
}

.faq-links summary {
    color: #1976d2;
    font-weight: 500;
    padding: 5px 0;
    outline: none;
}

.faq-links summary:hover {
    color: #1565c0;
}

.faq-list {
    margin-top: 10px;
    padding-left: 15px;
}

.faq-list div {
    margin-bottom: 5px;
}

.faq-link {
    display: block;
    background: #e3f2fd;
    color: #1976d2;
    padding: 5px 10px;
    border-radius: 15px;
    text-decoration: none;
    font-size: 0.85rem;
    margin: 2px 0;
    transition: all 0.2s ease;
    width: fit-content;
}

.faq-link:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-1px);
}

.chat-input-container {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    margin-top: auto;
    flex-shrink: 0;
}

.input-group {
    display: flex;
    gap: 10px;
}

#questionInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

#questionInput:focus {
    border-color: #667eea;
}

.send-button {
    width: 50px;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-info {
    text-align: right;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #6c757d;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.loading-spinner i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

.loading-spinner p {
    color: #495057;
    font-weight: 500;
}

.footer {
    text-align: center;
    padding: 20px;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
}

/* Wrapper pour contenu + bouton copie */
.content-wrapper {
    position: relative;
}

/* Contenu principal avec espace pour le bouton */
.main-content {
    padding-bottom: 45px; /* Espace pour le bouton en bas à droite */
}

.copy-button {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.15);
    border: none;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    font-size: 15px;
    transition: all 0.2s ease;
    opacity: 0.8;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.copy-button:hover {
    background: rgba(0,0,0,0.2);
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.copy-button:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .chat-container {
        height: 60vh;
    }

    .message {
        margin-bottom: 15px;
    }

    .message-avatar {
        width: 35px;
        height: 35px;
        margin-right: 10px;
    }

    .copy-button {
        width: 32px;
        height: 32px;
        font-size: 13px;
        bottom: 6px;
        right: 6px;
    }
}
