.text-editor-container,
.text-editor-horizontal-layout {
    display: flex;
    flex-direction: column;
    gap: var(--styletext-gap);
}

/* Mise en page horizontale pour les grands écrans */
@media (min-width: 1200px) {
    .text-editor-horizontal-layout {
        display: block;
        max-width: 900px;
        margin: 0 auto;
    }
    .text-editor-main-panel {
        width: 100%;
    }
    
    .text-editor-sidebar {
        grid-area: sidebar;
    }
    
    .text-editor-sidebar .tool-panel {
        height: auto;
        margin-bottom: 1.5rem;
        background-color: var(--bg-light);
        border-radius: var(--border-radius);
    }
    
    .text-editor-sidebar .tool-panel-content {
        max-height: 300px;
        overflow-y: auto;
        padding: var(--spacing-md);
    }
    
    .sidebar-section {
        margin-bottom: 1.25rem;
    }
    
    .sidebar-section:last-child {
        margin-bottom: 0;
    }
    
    .sidebar-section h4 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
        color: var(--text-color);
    }
    
    .sidebar-select {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-sm);
        background-color: var(--input-bg);
        color: var(--text-color);
        font-size: 0.9rem;
    }
    
    .sidebar-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .sidebar-buttons .btn-sm {
        padding: 6px 10px;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    .sidebar-buttons .btn-sm .material-icons {
        font-size: 1rem;
    }
    
    .recent-docs-list {
        padding: 0;
        margin: 0;
        list-style: none;
    }
    
    .empty-list {
        color: var(--text-muted);
        font-style: italic;
        text-align: center;
        padding: 1rem 0;
    }
}

/* Pour les tablettes */
@media (min-width: 768px) and (max-width: 1199px) {
    .text-editor-horizontal-layout {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .text-editor-sidebar {
        display: flex;
        gap: 1.5rem;
        flex-direction: row;
    }
    
    .text-editor-sidebar .tool-panel {
        flex: 1;
    }
}

.text-editor-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--styletext-padding) 0;
    gap: var(--styletext-gap);
    flex-wrap: wrap;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md) var(--spacing-lg);
}

.filename-container {
    flex: 1;
    margin-right: var(--spacing-md);
}

.filename-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-weight: 500;
    font-size: var(--font-size);
    box-shadow: var(--inset-shadow);
    transition: all var(--transition-duration) var(--ease-in-out);
}

.filename-input:focus {
    border-color: var(--primary-color);
    box-shadow: var(--styletext-shadow-sm);
    outline: none;
}

.format-options, .import-options {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.format-select {
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: var(--font-size);
    box-shadow: var(--inset-shadow);
    transition: all var(--transition-duration) var(--ease-in-out);
}

.format-select:focus {
    border-color: var(--primary-color);
    box-shadow: var(--styletext-shadow-sm);
    outline: none;
}

#importBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 9px 16px;
    font-size: 0.95rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-duration) var(--ease-in-out);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--inset-shadow);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius-sm);
}

.color {
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--border-color);
    margin-right: 2px;
    margin-left: 2px;
    box-shadow: var(--inset-shadow);
    transition: all var(--transition-duration) var(--ease-in-out);
}
.color-red { background-color: #e74c3c; }
.color-blue { background-color: #3498db; }
.color-green { background-color: #27ae60; }
.color-black { background-color: #222; }
.color.active, .color:focus {
    border: 2px solid var(--primary-color);
    box-shadow: var(--styletext-shadow-sm);
    transform: translateY(-2px);
}

.fonts select {
    padding: 9px 14px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: var(--font-size);
    font-family: inherit;
    transition: all var(--transition-duration) var(--ease-in-out);
    box-shadow: var(--inset-shadow);
}
.fonts select:focus {
    border: 1.5px solid var(--primary-color);
    box-shadow: var(--styletext-shadow-sm);
    outline: none;
}

.text-editor-tabs {
    display: flex;
    background-color: var(--bg-color);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-bottom: none;
    margin-top: var(--spacing-md);
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-duration) var(--ease-in-out);
    flex: 1;
    text-align: center;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    font-size: var(--font-size);
}

.tab-btn:hover {
    background-color: var(--hover-color);
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    background-color: var(--card-bg);
}

#text-editor-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    overflow: hidden;
    background-color: var(--card-bg);
    box-shadow: var(--box-shadow);
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    height: 100%;
}

.tab-content.active {
    display: flex;
}

.text-editor {
    flex: 1;
    min-height: var(--styletext-min-height);
    padding: 30px;
    outline: none;
    border: none;
    line-height: var(--styletext-line-height);
    font-size: var(--styletext-font-size);
    color: var(--text-color);
    background-color: var(--card-bg);
    overflow-y: auto;
    font-family: 'Merriweather', serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: normal;
    
    /* Propriétés importantes pour la gestion des espaces */
    -webkit-nbsp-mode: space;
    unicode-bidi: plaintext;
    white-space: pre-wrap !important;
    word-spacing: normal;
    letter-spacing: normal;
    tab-size: 4;
    hyphens: auto;
    position: relative; /* Nécessaire pour le pseudo-élément du placeholder */
    
    /* Propriétés pour la gestion correcte des contenus éditables */
    -webkit-user-modify: read-write;
    -moz-user-modify: read-write;
    
    /* Assurer le bon affichage des espaces */
    visibility: visible !important;
    
    /* Désactiver les fonctionnalités d'auto-correction qui peuvent interférer */
    -webkit-text-fill-color: currentColor;
    text-rendering: optimizeLegibility;
}

/* Assurer que les espaces sont correctement rendus */
.text-editor br {
    content: " ";
    display: block;
    margin-bottom: 0.5em;
}

/* S'assurer que les espaces non-sécables sont rendus correctement */
.text-editor .nbsp {
    display: inline;
    white-space: pre;
    width: auto;
    height: auto;
}

/* Styles pour les caractères spéciaux comme les espaces insécables */
.text-editor:after {
    content: "";
}

.text-editor:focus {
    box-shadow: var(--inset-shadow);
}

/* Utilisation d'un pseudo-élément pour afficher le placeholder */
.text-editor.empty:before {
    content: "Commencez à écrire ici...";
    color: var(--text-muted);
    font-style: italic;
    position: absolute;
    left: 28px;
    top: 28px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Style du placeholder quand l'éditeur est vide et non focalisé */
.text-editor.empty:not(:focus):before {
    opacity: 1;
}

/* Style spécifique pour le curseur dans Firefox */
@-moz-document url-prefix() {
    .text-editor {
        caret-color: var(--primary-color);
    }
}

/* Style spécifique pour le curseur dans Chrome/Safari */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    .text-editor {
        caret-color: var(--primary-color);
    }
}

/* Assurer que le texte est toujours visible avec un bon contraste */
.text-editor[style*="color: white"], 
.text-editor[style*="color: #fff"], 
.text-editor[style*="color: rgb(255, 255, 255)"] {
    background-color: var(--bg-color);
}

.text-editor-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: var(--spacing-md);
    font-size: 0.95rem;
    gap: var(--spacing-md);
}

.text-stats {
    font-size: 0.98rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.separator {
    margin: 0 0.5rem;
    color: var(--border-color);
}

.text-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.text-actions {
    min-width: 120px;
    min-height: 44px;
    font-size: 1rem;
    border-radius: 8px;
    box-shadow: var(--inset-shadow);
    transition: box-shadow 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

.text-actions {
    color: #fff !important;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
}

.text-actions .btn:hover,
.text-actions .btn:focus {
    box-shadow: 0 4px 16px rgba(25, 118, 210, 0.12);
    background: var(--hover-color, #e3f2fd);
}

.text-editor-notification {
    position: fixed;
    bottom: var(--styletext-toast-bottom);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background-color: var(--success-color);
    color: var(--text-on-primary);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--hover-shadow);
    opacity: 0;
    transition: all var(--transition-duration) var(--ease-in-out);
    z-index: 1000;
    font-weight: 600;
}
.text-editor-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.text-editor-notification.notification-error {
    background-color: var(--error-color);
}
.text-editor-notification.notification-info {
    background-color: var(--info-color);
}

@media (max-width: 900px) {
    .text-actions {
        justify-content: flex-end;
    }
}
@media (max-width: 600px) {
    .editor-title {
        font-size: var(--font-size-lg);
    }
    .text-editor {
        font-size: var(--font-size);
        padding: var(--spacing-md) var(--spacing-sm);
        min-height: 200px;
    }
    .toolbar, .text-editor-options {
        padding: var(--spacing-sm);
        gap: var(--spacing-sm);
    }
    .text-editor-status-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .text-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.7rem;
    }
    .text-actions .btn {
        width: 100%;
        min-width: unset;
    }
}

/* Forcer la couleur des icônes en mode light */
.btn-icon-text {
    color: var(--text-color, #222) !important;
} 