/* ==========================================================================
   VARIABLES GLOBALES ET COULEURS (Charte Graphique Moderne & Médicale)
   ========================================================================== */
:root {
    --bg-main: #f8fafc;         /* Fond de page ultra-clair, reposant */
    --bg-card: #ffffff;         /* Fond des formulaires et blocs */
    --text-dark: #0f172a;       /* Texte principal (Bleu nuit presque noir) */
    --text-muted: #64748b;      /* Texte secondaire (Gris doux) */
    
    /* Couleurs de marque */
    --primary: #0f2d4a;         /* Bleu Marine profond (Sécurité, Confiance) */
    --primary-light: #1e4b75;   /* Bleu plus clair pour les hovers */
    --accent: #e05a36;          /* Orange Corail */
    --accent-light: #fbeeea;    /* Fond corail très léger */
    
    /* États */
    --valid: #10b981;          /* Vert moderne */
    --invalid: #ef4444;         /* Rouge moderne */
    
    /* Structure */
    --radius: 12px;            /* Arrondis modernes */
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

/* ==========================================================================
   STYLE GÉNÉRAL
   ========================================================================== */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   CONTENEUR & STRUCTURE RESPONSIVE
   ========================================================================== */
.container {
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

h1, h2, h3, h4 {
    color: var(--primary);
    margin-top: 0;
    font-weight: 700;
}

h1 { font-size: 2rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }

/* ==========================================================================
   EN-TÊTE ET NAVIGATION (Menu Horizontal Préservé)
   ========================================================================== */
header {
    background-color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin: 1rem;
    box-shadow: var(--shadow);
}

.connexion {
    background-color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.connexion a {
    color: #ffffff !important;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Liste du menu - Assure l'alignement horizontal */
.nav-menu ul {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
    list-style: none;
    gap: 8px;
    align-items: center;
}

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    display: inline-block;
    color: #cbd5e1;
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-menu a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-menu a.active {
    background-color: var(--accent);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   FORMULAIRES GÉNÉRAUX
   ========================================================================== */
form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
}

form ul {
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

form li {
    list-style: none;
    display: flex;
    flex-direction: column;
    width: 100%;
}

form label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

form input[type="text"],
form input[type="number"],
form select,
form textarea {
    width: 100%;
    max-width: 300px;
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    padding: 10px;
    border-radius: 6px;
}

form input:focus, form select:focus, form textarea:focus {
    background-color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(224, 90, 54, 0.15);
    outline: none;
}

/* ==========================================================================
   PAGE DE CHAT PRINCIPALE (Structure Linéaire Standard)
   ========================================================================== */
.top-bar { 
    display: flex; 
    justify-content: space-between; 
    width: 100%; 
    max-width: 600px; 
    margin: 0 auto 15px auto; 
    align-items: center; 
}
.lang-switch a { margin: 0 5px; text-decoration: none; font-weight: bold; color: var(--text-dark); }
.logout-btn { text-decoration: none; color: var(--invalid); font-size: 14px; font-weight: bold; }

/* Conteneur principal */
.chat-container { 
    width: 100%; 
    max-width: 600px; 
    margin: 0 auto;
    background: var(--bg-card); 
    border-radius: var(--radius); 
    box-shadow: var(--shadow); 
    border: 1px solid #e2e8f0;
    padding: 15px; /* Ajoute de l'espace interne global */
}

/* Boîte des messages */
.chat-box { 
    width: 100%;
    height: 50vh; /* Hauteur fixe pour la discussion */
    overflow-y: auto; 
    background: #f8fafc; 
    display: flex; 
    flex-direction: column; 
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px; /* Crée l'espace physique avec le formulaire en dessous */
    border: 1px solid #e2e8f0;
}

/* Bulles de messages */
.msg { margin-bottom: 15px; padding: 12px 16px; border-radius: 12px; max-width: 80%; word-break: break-word; line-height: 1.4; }
.bot { background: #e1f5fe; align-self: flex-start; color: #0d47a1; border-bottom-left-radius: 2px; }
.user { background: #e8f5e9; align-self: flex-end; text-align: left; color: #1b5e20; border-bottom-right-radius: 2px; }

/* Zone d'envoi positionnée STRICTEMENT SOUS le chat */
.chat-input { 
    width: 100%;
    position: relative !important;
    display: block !important; /* Force le positionnement en dessous */
    clear: both;
}

/* Isolation totale du mini-formulaire de chat face aux formulaires généraux */
.chat-input form { 
    display: flex !important; 
    flex-direction: row !important; /* Aligne le textarea et le bouton côte à côte */
    gap: 10px !important; 
    align-items: flex-end !important; 
    padding: 0 !important; 
    background: transparent !important; 
    border: none !important; 
    box-shadow: none !important; 
    width: 100% !important;
}

/* Le champ de saisie forcé */
#chat-textarea {
    flex: 1 !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 44px !important;
    height: 44px;
    padding: 10px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 6px !important;
    
    /* CORRECTIF LOGIQUE : Force la couleur d'écriture en sombre */
    background-color: #ffffff !important;
    color: #0f172a !important; /* Force le texte en Bleu Nuit/Noir */
    caret-color: #e05a36 !important; /* Force le curseur de frappe en Orange Corail pour le voir */
    
    font-size: 15px !important;
    line-height: 1.4 !important;
    resize: none !important;
    display: block !important;
}

#chat-textarea:focus { 
    border-color: var(--accent) !important; 
    box-shadow: 0 0 0 3px rgba(224, 90, 54, 0.15) !important;
    outline: none !important; 
}

/* Bouton d'envoi */
.chat-input button { 
    padding: 0 20px !important; 
    border: none !important; 
    background: var(--accent) !important; 
    color: white !important; 
    border-radius: 6px !important; 
    cursor: pointer !important; 
    height: 44px !important; 
    font-weight: bold; 
    transition: background 0.2s;
}
.chat-input button:hover { background: #c84825 !important; }
img.uploaded-img { max-width: 200px; border-radius: 6px; display: block; margin-top: 5px; }

/* ==========================================================================
   BANNIÈRE COOKIES
   ========================================================================== */
#cookie-banner {
    position: fixed; bottom: 20px; left: 20px; max-width: 400px;
    background: var(--bg-card); color: var(--text-dark); padding: 20px;
    border-radius: var(--radius); box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    z-index: 999999; display: none; border: 1px solid #e2e8f0;
}
.cookie-buttons { display: flex; gap: 10px; margin-top: 15px; }
.cookie-btn { flex: 1; padding: 10px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn-accept { background: var(--valid); color: white; }
.btn-refuse { background: #cbd5e1; color: var(--text-dark); }

/* ==========================================================================
   MEDIA QUERIES : ADAPTATION ORDINATEUR (Écrans > 768px)
   ========================================================================== */
@media screen and (min-width: 768px) {
    form ul { grid-template-columns: repeat(2, 1fr); }
    form li.full-width, form li:last-child { grid-column: span 2; }
}
/* ==========================================================================
   CORRECTIF SÉCURITÉ : Empêche le menu mobile invisible de bloquer l'écran
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Si le menu n'a pas la classe active/ouverte, il ne doit PAS intercepter les clics */
    .nav-menu:not(.active) {
        display: none !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }
}
/* ==========================================================================
   FORCE L'INTERACTIVITÉ ET LE CLIC SUR LE TEXTAREA DU CHAT
   ========================================================================== */
.chat-input, 
.chat-input form, 
#chat-textarea {
    position: relative !important;
    z-index: 99999 !important; /* Passe au-dessus de tout écran invisible */
    pointer-events: auto !important; /* Force le navigateur à intercepter le clic */
}

#chat-textarea {
    max-width: none !important; /* Annule le bridage des formulaires classiques */
    width: 100% !important;     /* Occupe tout l'espace disponible */
    cursor: text !important;    /* Force l'apparition du curseur de texte */
}

.chat-date-separator {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin: 20px 0 10px 0;
    background: var(--accent-light);
    padding: 5px 10px;
    border-radius: 20px;
    align-self: center;
}

.chat-session-separator {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin: 15px 0 5px 0;
    font-style: italic;
    align-self: center;
    width: 100%;
}

.chat-time {
    display: block;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.4);
    text-align: right;
    margin-top: 4px;
}

/* Styles pour enrichir la page d'accueil */
.welcome-container section {
    margin-bottom: 3rem;
}
.hero-section {
    text-align: center;
    padding: 2rem 0;
}
.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.main-hero-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--primary-light);
    font-style: italic;
}
.features-list li {
    margin-bottom: 0.8rem;
    list-style-type: '✓ ';
    padding-left: 0.5rem;
}
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}
.action-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow);
}
.action-card .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.info-note {
    background-color: var(--accent-light);
    border: 1px solid var(--accent);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    color: var(--primary);
}
.section-divider {
    border: 0;
    height: 1px;
    background: #e2e8f0;
    margin: 3rem 0;
}
