/* Styles pour le chatbot Bioforce */

.chat-container {
    /* Conteneur invisible - pas de fond, bordure, ou ombre */
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    border-radius: 0;
    overflow: visible;

    /* Dimensions et positionnement */
    width: auto !important;
    height: auto !important;
    max-width: 100%;
    min-height: auto;
    max-height: 90vh;
    padding: 0 !important;
    margin: 0 !important;

    /* Positionnement */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;

    /* Layout */
    display: flex;
    flex-direction: column;

    /* Pointer events - évite que la zone invisible bloque les clics */
    pointer-events: none;

    font-family: 'Roboto', sans-serif;
}

/* Réactiver les pointer-events sur les éléments internes */
.chat-container * {
    pointer-events: auto;
}

.chat-container.dragging {
    /* Pas de shadow sur le conteneur invisible */
    box-shadow: none !important;
    opacity: 0.95;
}

.chat-container.dragging .chat-header {
    /* Ombre sur le header pendant le drag pour feedback visuel */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chat-header {
    background-color: #E84424; /* Couleur officielle Bioforce */
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    cursor: move; /* Indique que l'élément est déplaçable */
    user-select: none; /* Empêche la sélection de texte lors du déplacement */
    font-family: 'Roboto', sans-serif;

    /* Styles pour fenêtre volante */
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

    /* Largeur fixe pour correspondre aux autres éléments */
    width: 500px;
    min-width: 400px;
    max-width: 90vw;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header .toggle-btn, .chat-header .admin-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.chat-header .admin-btn {
    opacity: 0.7;
    transition: opacity 0.3s;
}

.chat-header .admin-btn:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;

    /* Fond légèrement transparent pour fenêtre volante */
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);

    /* Largeur fixe pour avoir une vraie fenêtre */
    width: 500px;
    min-width: 400px;
    max-width: 90vw;
    min-height: 400px;
    max-height: 70vh;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.4;
    font-family: 'Roboto', sans-serif;
}

.message p {
    margin: 0;
}

.message.user {
    align-self: flex-end;
    background-color: #0066cc; /* Bleu pour distinction claire */
    color: white;
    border-bottom-right-radius: 5px;
    margin-left: auto;
    margin-right: 10px;
    max-width: 70%;
}

.message.bot {
    align-self: flex-start;
    background-color: #f0f0f0; /* Gris clair pour meilleur contraste */
    color: #333;
    border-bottom-left-radius: 5px;
    border-left: 4px solid #0066cc; /* Barre bleue pour distinction */
    margin-right: auto;
    margin-left: 10px;
    max-width: 75%;
    line-height: 1.6; /* Améliore l'espacement des lignes */
}

/* Espacement amélioré pour les paragraphes */
.message.bot p {
    margin: 12px 0;
    line-height: 1.6;
}

.message.bot p:first-child {
    margin-top: 0;
}

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

/* Espacement pour les listes */
.message.bot ul, .message.bot ol {
    margin: 16px 0;
    padding-left: 24px;
    line-height: 1.7;
}

.message.bot li {
    margin-bottom: 10px;
}

.message.bot li:last-child {
    margin-bottom: 0;
}

/* Titres avec espacement renforcé */
.message.bot h1, .message.bot h2, .message.bot h3, .message.bot h4 {
    color: #E84424; /* Couleur Bioforce pour les titres */
    margin-top: 20px;
    margin-bottom: 12px;
    line-height: 1.3;
    font-weight: 600;
}

.message.bot h1:first-child,
.message.bot h2:first-child,
.message.bot h3:first-child,
.message.bot h4:first-child {
    margin-top: 0;
}

/* Texte en gras (strong) */
.message.bot strong {
    color: #E84424; /* Couleur officielle Bioforce */
    font-weight: 600;
}

/* Liens */
.message.bot a {
    color: #0066cc; /* Bleu cohérent avec le thème */
    text-decoration: none;
    font-weight: 500;
}

.message.bot a:hover {
    text-decoration: underline;
}

/* Séparateurs visuels */
.message.bot hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid #ddd;
}

/* Code blocks si présents */
.message.bot code {
    background-color: #e8e8e8;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.message.bot pre {
    background-color: #e8e8e8;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.message.bot pre code {
    background-color: transparent;
    padding: 0;
}

/* Styles pour la boîte de dialogue admin */
.admin-dialog {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1100;
    width: 300px;
}

.admin-dialog h3 {
    margin-top: 0;
    color: #E84424;
}

.admin-dialog input {
    width: 100%;
    padding: 8px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.admin-dialog .buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.admin-dialog button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.admin-dialog .cancel-btn {
    background-color: #f2f2f2;
    color: #333;
}

.admin-dialog .login-btn {
    background-color: #E84424;
    color: white;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
}

/* Style pour l'état minimisé du chatbot */
.chat-container.minimized .chat-messages,
.chat-container.minimized .chat-input {
    display: none;
}

.chat-container.minimized {
    height: auto;
    /* Pas de shadow sur le conteneur invisible */
    box-shadow: none !important;
}

.chat-container.minimized .chat-header {
    /* Shadow uniquement sur le header */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
}

/* Style pour l'erreur de mot de passe */
#admin-password.error {
    border-color: #ff3333;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.chat-input {
    display: flex;
    padding: 10px;

    /* Fond légèrement transparent pour fenêtre volante */
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);

    border-top: 1px solid #eaeaea;

    /* Coins arrondis en bas */
    border-radius: 0 0 12px 12px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);

    /* Largeur fixe pour correspondre à .chat-messages */
    width: 500px;
    min-width: 400px;
    max-width: 90vw;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-family: 'Roboto', sans-serif;
}

.chat-input button {
    background-color: #E84424; /* Couleur officielle Bioforce */
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    margin-left: 10px;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
}

.chat-input button:hover {
    background-color: #E84424; /* Version légèrement plus foncée pour le hover */
}

.message.references {
    font-size: 12px;
    background: none;
    color: #666;
    padding: 0 15px;
}

/* Styles pour les listes dans les messages */
.message.bot ul {
    list-style-type: disc;
    padding-left: 20px;
}

.message.bot ol {
    padding-left: 20px;
}

/* Styles pour la mise en forme markdown */
.message.bot p + p {
    margin-top: 8px;
}

.message.loading p {
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.loading p::after {
    content: "...";
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

/* Mode élargi pour les réponses longues */
.chat-container.expanded .chat-header,
.chat-container.expanded .chat-messages,
.chat-container.expanded .chat-input {
    width: 700px;
    max-width: 95vw;
    transition: width 0.3s ease;
}

.chat-container.expanded .message.bot {
    max-width: 85%;
}

/* Bouton d'agrandissement dans le header */
.chat-header .expand-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-header .expand-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Style pour rendre le chatbot adaptatif sur mobile */
@media (max-width: 480px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    /* En mode mobile, le mode élargi prend toute la largeur */
    .chat-container.expanded .chat-header,
    .chat-container.expanded .chat-messages,
    .chat-container.expanded .chat-input {
        width: 100%;
    }
}

/* Styles pour les sources et suggestions */
.message.bot.sources, 
.message.bot.suggestion, 
.message.bot.source {
    background-color: #f0f7ff;
    border-left: 3px solid #2196F3;
    margin-top: -10px;
    padding: 10px 15px;
    font-size: 0.95em;
}

.source-link, 
.suggestion-link {
    display: inline-block;
    background-color: #e1f0fe;
    color: #0277bd;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 4px;
    margin-top: 5px;
    transition: all 0.2s ease;
}

.source-link:hover,
.suggestion-link:hover {
    background-color: #0277bd;
    color: white;
    text-decoration: none;
}

/* Liens inline dans les messages du bot */
.inline-link {
    color: #0277bd;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}

.inline-link:hover {
    color: #E84424;
    text-decoration: underline;
}

.message.bot.chatbot-redirect {
    background-color: #fff8e5;
    border-left: 3px solid #ff9800;
    margin-top: 8px;
    padding: 10px 15px;
}

.message.bot.chatbot-actions {
    background-color: transparent;
    border: none;
    margin-top: 8px;
}

.chatbot-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chatbot-action-btn {
    background-color: #E84424;
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.chatbot-action-btn:hover,
.chatbot-action-btn:focus {
    background-color: #bd351c;
    transform: translateY(-1px);
}

.message.bot.chatbot-quick-suggestions {
    background-color: transparent;
    border: none;
    margin-top: 4px;
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chatbot-suggestion-btn {
    background-color: #e1f0fe;
    color: #0277bd;
    border: 1px solid #b5d9ff;
    border-radius: 16px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.chatbot-suggestion-btn:hover,
.chatbot-suggestion-btn:focus {
    background-color: #0277bd;
    color: #fff;
}

/* Feedback buttons styles */
.message.bot.chatbot-feedback {
    background-color: transparent;
    border: none;
    margin-top: 8px;
    padding: 8px 0;
}

.feedback-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 4px;
}

.feedback-btn {
    background-color: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.feedback-btn:hover:not(:disabled) {
    background-color: #e8e8e8;
    border-color: #bdbdbd;
    transform: scale(1.1);
}

.feedback-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.feedback-btn:disabled {
    cursor: not-allowed;
}

.feedback-thumbs-up svg {
    color: #666;
}

.feedback-thumbs-down svg {
    color: #666;
}

.feedback-thumbs-up:hover:not(:disabled) svg {
    color: #4CAF50;
}

.feedback-thumbs-down:hover:not(:disabled) svg {
    color: #f44336;
}

.message.bot.chatbot-form-block {
    background-color: #f5f7fb;
    border-left: 3px solid #4a67d6;
    margin-top: 12px;
    padding: 12px 15px;
}

.chatbot-form-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.chatbot-form-description {
    font-size: 0.9em;
    color: #4d5b75;
    margin-bottom: 10px;
}

.chatbot-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-form-field {
    display: flex;
    flex-direction: column;
    font-size: 0.9em;
    color: #273044;
    gap: 4px;
}

.chatbot-form-checkbox {
    flex-direction: row;
    align-items: center;
}

.chatbot-form-checkbox label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.chatbot-form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    border-radius: 4px;
}

.chatbot-form input,
.chatbot-form textarea {
    border: 1px solid #c7d2e4;
    border-radius: 6px;
    padding: 8px;
    font-size: 0.95em;
}

.chatbot-form textarea {
    resize: vertical;
    min-height: 70px;
}

.chatbot-form input:focus-visible,
.chatbot-form textarea:focus-visible {
    outline: none;
    border-color: #4a67d6;
    box-shadow: 0 0 0 3px rgba(74, 103, 214, 0.15);
}

.chatbot-form-submit {
    background-color: #4a67d6;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chatbot-form-submit:hover,
.chatbot-form-submit:focus-visible {
    background-color: #3a52aa;
}

.chatbot-form-submit:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.chatbot-form-status {
    font-size: 0.85em;
    margin-top: 8px;
    color: #4d5b75;
}

.chatbot-form-status.success {
    color: #2e7d32;
}

.chatbot-form-status.error {
    color: #c62828;
}

.chatbot-form .input-error {
    border-color: #c62828;
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.2);
}
.chatbot-accessibility {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    align-items: center;
    border-bottom: 1px solid #e8ecf4;
    background: #f4f7ff;
}

.chatbot-accessibility .accessibility-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #4d5b75;
    cursor: pointer;
}

.chatbot-accessibility .accessibility-toggle input {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid #aeb8d4;
}

.chat-container button:focus-visible,
.chat-container input:focus-visible,
.chat-container textarea:focus-visible,
.chat-container label:focus-visible {
    outline: 3px solid #ff6c42;
    outline-offset: 2px;
}

html.font-lg body {
    font-size: 1.5rem;
}

html.font-lg .chat-container {
    font-size: 1.5rem;
}

html.font-lg .chat-messages {
    font-size: 1.6rem;
    line-height: 1.8;
}

html.font-lg .chat-container input,
html.font-lg .chat-container button,
html.font-lg .chat-input,
html.font-lg .chat-header {
    font-size: 1.5rem;
}

html.font-lg .chatbot-suggestion-btn,
html.font-lg .chatbot-action-btn {
    font-size: 1.4rem;
    padding: 0.8em 1.4em;
}

html.high-contrast body {
    background: #121826;
    color: #f4f6fb;
}

html.high-contrast .chat-container {
    background: #0b1020;
    border: 2px solid #f4f6fb;
    color: #f4f6fb;
}

html.high-contrast .chat-header {
    background: #192245;
    color: #f4f6fb;
}

html.high-contrast .chatbot-form input,
html.high-contrast .chatbot-form textarea {
    background: #0b1020;
    border-color: #f4f6fb;
    color: #f4f6fb;
}

html.high-contrast .chatbot-form-submit {
    background-color: #f97316;
}

html.high-contrast .chatbot-accessibility {
    background: #192245;
    border-color: #f4f6fb;
}

html.high-contrast .chatbot-accessibility .accessibility-toggle {
    color: #f4f6fb;
}

html.high-contrast .message.bot {
    background: #1f2a4d;
    color: #f4f6fb;
}

html.high-contrast .message.user {
    background: #4b5563;
    color: #f4f6fb;
}
