* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: #f0f2f5; height: 100vh; overflow: hidden; }
.app-container { display: flex; height: 100%; position: relative; }

/* --- SIDEBAR --- */
.sidebar { 
    width: 300px; 
    background: #1e1e2e; 
    color: #cdd6f4; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px solid #45475a; 
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar h2 { font-size: 1.1rem; margin: 0 0 15px 0; color: #89b4fa; }
.actions { display: flex; gap: 8px; margin-bottom: 10px; }
.actions button { flex: 1; padding: 8px; cursor: pointer; background: #313244; border: 1px solid #45475a; color: white; border-radius: 4px; font-size: 0.8rem; }

#file-tree-container { flex: 1; overflow-y: auto; }
.tree-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 4px; cursor: pointer; margin: 2px 0; }
.tree-item:hover { background: #45475a; }
.folder-item { color: #f9e2af; font-weight: bold; }
.file-item { color: #bac2de; font-size: 0.9rem; }
.btn-del { cursor: pointer; color: #f38ba8; border: none; background: none; font-size: 1.2rem; padding: 0 5px; }

/* --- EDITOR AREA --- */
.editor-area { flex: 1; display: flex; flex-direction: column; width: 100%; }
.toolbar { background: white; padding: 10px 15px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #ddd; flex-wrap: nowrap; overflow-x: auto; }

.group { display: flex; gap: 5px; align-items: center; }
.toolbar button, .toolbar select { padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; background: #f8f9fa; cursor: pointer; }

.path-display { font-size: 0.8rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }

.page-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; justify-content: center; background: #f0f2f5; }

#editor { 
    width: 100%; 
    max-width: 210mm; 
    min-height: 297mm; 
    background: white; 
    padding: 20mm; 
    box-shadow: 0 0 15px rgba(0,0,0,0.1); 
    outline: none; 
}

button.primary { background: #a6e3a1; color: #11111b; border: none; font-weight: bold; }

/* --- LOGIQUE RESPONSIVE --- */
.mobile-only { display: none; }
#sidebar-overlay { display: none; } /* Caché par défaut partout */

@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: block; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%); 
        z-index: 1000;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* AFFICHAGE DE L'OVERLAY : Quand la sidebar est active, on montre l'overlay qui la suit */
    .sidebar.active + #sidebar-overlay {
        display: block;
    }

    #sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .toolbar { padding: 8px; justify-content: flex-start; }
    
    #editor { 
        padding: 15px; 
        box-shadow: none; 
        max-width: 100%;
    }
    
    .page-container { padding: 10px; }
}
/* Conteneur principal identique à Writer pour la cohérence */
.app-container { display: flex; height: 100vh; background: #1e1e2e; }

/* Zone de messages */
#chat-window { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: #f0f2f5; 
    height: 100%;
}

#messages-container { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 5px;
}

/* Style des bulles de message */
.msg { 
    padding: 10px 15px; 
    border-radius: 12px; 
    max-width: 70%; 
    word-wrap: break-word;
    position: relative;
    line-height: 1.4;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.msg b { font-size: 0.85rem; }
.msg small { color: rgba(255,255,255,0.6); font-size: 0.75rem; }

/* MOI : Bleu et à droite */
.msg.me { 
    background: #89b4fa; 
    color: #1e1e2e; 
    align-self: flex-end; 
    border-bottom-right-radius: 2px;
}
.msg.me small { color: rgba(0,0,0,0.5); }

/* LES AUTRES : Sombre et à gauche */
.msg.others { 
    background: #313244; 
    color: #cdd6f4; 
    align-self: flex-start; 
    border-bottom-left-radius: 2px;
}

/* Zone de saisie en bas */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    outline: none;
}

.chat-input-area button {
    padding: 10px 20px;
    background: #a6e3a1;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}
/* Feedback visuel lors du survol d'un dossier avec un fichier */
.tree-item.drag-over {
    background-color: #45475a !important;
    outline: 2px dashed #f9e2af !important;
    border-radius: 4px;
}

/* Indicateur que l'élément est déplaçable */
.tree-item[draggable="true"] {
    cursor: grab;
}
.tree-item[draggable="true"]:active {
    cursor: grabbing;
}