/* ==============================================
   STYLES COMPLETS POUR LES MODÈLES DE DOCUMENTS
   ============================================== */

/* --- Conteneur principal --- */
.models-container {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ========== VUE GRILLE AMÉLIORÉE ========== */
.models-grid-view,
.models-list-view {
    display: none;
    flex: 1;
}

.models-grid-view.active,
.models-list-view.active {
    display: block;
}

/* Grille responsive avec cards adaptatives */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

@media (max-width: 1200px) {
    .models-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.2rem;
    }
}

@media (max-width: 768px) {
    .models-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .models-grid {
        grid-template-columns: 1fr;
    }
}

/* Card de modèle - design amélioré */
.model-card {
    background: var(--clr-bg-secondary);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid var(--clr-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.model-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 30px rgba(2, 132, 199, 0.15);
    border-color: var(--clr-blue);
}

.model-card.default {
    border-left: 4px solid #f59e0b;
}

.model-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f59e0b;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 30px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    letter-spacing: 0.3px;
}

.model-preview {
    height: 200px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    position: relative;
    overflow: hidden;
}

.model-preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

.mini-page {
    width: 140px;
    height: 180px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

.model-card:hover .mini-page {
    transform: scale(1.05) rotate(1deg);
}

.mini-header {
    height: 20px;
    background: linear-gradient(90deg, var(--clr-blue), #38bdf8);
    border-radius: 4px;
    margin-bottom: 8px;
}

.mini-line {
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 2px 0;
}

.mini-line:nth-child(2) { width: 90%; }
.mini-line:nth-child(3) { width: 75%; }
.mini-line:nth-child(4) { width: 60%; }
.mini-line:nth-child(5) { width: 45%; }

.mini-table {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 10px;
}

.mini-row {
    display: flex;
    gap: 3px;
}

.mini-row span {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 2px;
}

.mini-footer {
    height: 10px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-top: auto;
}

.model-info {
    padding: 1.2rem;
    flex: 1;
}

.model-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--clr-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-type {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.8rem;
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--clr-bg-primary);
    border-radius: 30px;
}

.model-meta {
    display: flex;
    gap: 1.2rem;
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
    border-top: 1px solid var(--clr-border);
    padding-top: 0.8rem;
    margin-top: 0.5rem;
}

.model-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.model-actions {
    display: flex;
    gap: 0.3rem;
    padding: 0.8rem 1.2rem 1.2rem;
    border-top: 1px solid var(--clr-border);
    background: var(--clr-bg-primary);
}

/* ========== ÉDITEUR DE MODÈLES AMÉLIORÉ ========== */
.editor-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--clr-bg-primary);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Barre d'outils principale */
.editor-toolbar {
    background: var(--clr-bg-secondary);
    border-bottom: 2px solid var(--clr-border);
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toolbar-separator {
    width: 1px;
    height: 30px;
    background: var(--clr-border);
    margin: 0 0.5rem;
}

.model-name-input {
    padding: 0.6rem 1rem;
    border: 2px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.95rem;
    width: 250px;
    transition: all 0.3s ease;
}

.model-name-input:focus {
    border-color: var(--clr-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.model-type-select {
    padding: 0.6rem 1rem;
    border: 2px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.95rem;
    min-width: 200px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 0.2rem;
    border: 1px solid var(--clr-border);
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Layout principal de l'éditeur */
.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: var(--clr-bg-primary);
    position: relative;
}

/* Panneaux latéraux redimensionnables */
.editor-sidebar {
    width: 300px;
    background: var(--clr-bg-secondary);
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease;
    position: relative;
    z-index: 10;
}

.editor-sidebar.right {
    border-right: none;
    border-left: 1px solid var(--clr-border);
    width: 350px;
}

.sidebar-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s ease;
    z-index: 20;
}

.editor-sidebar:hover .sidebar-resize-handle {
    background: var(--clr-blue);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 2px solid var(--clr-border);
    background: var(--clr-bg-primary);
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--clr-blue);
}

.sidebar-tabs {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.8rem;
}

.sidebar-tab-btn {
    padding: 0.5rem 1rem;
    border-radius: 30px;
    background: transparent;
    color: var(--clr-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
}

.sidebar-tab-btn:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
}

.sidebar-tab-btn.active {
    background: var(--clr-blue);
    color: white;
}

.sidebar-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-tab-content.active {
    display: block;
}

/* Catégories d'éléments */
.element-category {
    margin-bottom: 1.5rem;
}

.element-category h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.elements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
}

.element-item {
    background: var(--clr-bg-primary);
    border: 2px solid var(--clr-border);
    border-radius: 10px;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.element-item:hover {
    border-color: var(--clr-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(2, 132, 199, 0.15);
}

.element-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.element-item i {
    font-size: 1.5rem;
    color: var(--clr-blue);
}

.element-item span {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

/* Liste des champs */
.fields-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-item {
    background: var(--clr-bg-primary);
    border: 2px solid var(--clr-border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: all 0.2s ease;
}

.field-item:hover {
    border-color: var(--clr-blue);
    background: rgba(2, 132, 199, 0.05);
}

.field-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.field-code {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
    background: var(--clr-bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 30px;
    font-family: monospace;
}

/* Zone de travail (Canvas) */
.editor-canvas-area {
    flex: 1;
    background: #2d3748;
    overflow: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    position: relative;
}

.canvas-ruler {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--clr-bg-secondary);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    z-index: 5;
}

.ruler-mark {
    flex: 1;
    border-left: 1px solid var(--clr-border);
    height: 100%;
    position: relative;
}

.ruler-mark::after {
    content: attr(data-value);
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 8px;
    color: var(--clr-text-secondary);
}

.page-canvas {
    background: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    transform-origin: top center;
    margin: 0 auto;
    cursor: default;
    border-radius: 2px;
}

.page-canvas.show-grid {
    background-image: 
        linear-gradient(to right, #e2e8f0 1px, transparent 1px),
        linear-gradient(to bottom, #e2e8f0 1px, transparent 1px);
    background-size: 10mm 10mm;
}

.canvas-element {
    position: absolute;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    padding: 4px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: box-shadow 0.2s ease;
    border-radius: 2px;
}

.canvas-element:hover {
    border: 1px dashed var(--clr-blue);
    background: rgba(2, 132, 199, 0.02);
}

.canvas-element.selected {
    border: 2px solid var(--clr-blue);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
    z-index: 1000;
}

.canvas-element.selected::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid rgba(2, 132, 199, 0.3);
    border-radius: 4px;
    pointer-events: none;
}

.element-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--clr-blue);
    border: 2px solid white;
    border-radius: 2px;
    z-index: 1001;
}

.resize-handle-nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle-ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle-se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle-e { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.resize-handle-w { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }

/* Panneau des propriétés */
.properties-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.property-group {
    background: var(--clr-bg-primary);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--clr-border);
}

.property-group h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--clr-blue);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 0.5rem;
}

.property-row {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.property-row.half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.property-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.property-input {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid var(--clr-border);
    border-radius: 6px;
    background: var(--clr-bg-secondary);
    color: var(--clr-text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.property-input:focus {
    border-color: var(--clr-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.property-input[type="color"] {
    height: 40px;
    padding: 0.2rem;
}

.property-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.property-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========== ASSISTANT DE CRÉATION DE MODÈLE ========== */
.creation-wizard {
    padding: 1rem;
}

.wizard-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-step.active {
    display: block;
}

.wizard-step h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--clr-blue);
}

.wizard-step p {
    color: var(--clr-text-secondary);
    margin-bottom: 1.5rem;
}

.template-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.template-option-card {
    background: var(--clr-bg-primary);
    border: 2px solid var(--clr-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-option-card:hover {
    border-color: var(--clr-blue);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(2, 132, 199, 0.15);
}

.template-option-card.selected {
    border-color: var(--clr-blue);
    background: rgba(2, 132, 199, 0.05);
}

.template-option-card i {
    font-size: 2.5rem;
    color: var(--clr-blue);
    margin-bottom: 1rem;
}

.template-option-card h4 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.template-option-card p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    margin: 0;
}

.template-option-card small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.base-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.base-template-card {
    background: var(--clr-bg-primary);
    border: 2px solid var(--clr-border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.base-template-card:hover {
    border-color: var(--clr-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.base-template-card.selected {
    border-color: var(--clr-blue);
    background: rgba(2, 132, 199, 0.05);
}

.template-mini-preview {
    height: 120px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-mini-preview .mini-page {
    width: 80px;
    height: 100px;
}

.base-template-card .model-info {
    padding: 0.8rem;
}

.base-template-card .model-title {
    font-size: 0.9rem;
    margin: 0;
}

.wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--clr-border);
}

/* ========== MOVEABLE STYLES ========== */
.moveable-control-box {
    z-index: 10000 !important;
}

.moveable-line {
    background: var(--clr-blue) !important;
}

.moveable-control {
    background: white !important;
    border: 2px solid var(--clr-blue) !important;
    width: 10px !important;
    height: 10px !important;
    margin-top: -5px !important;
    margin-left: -5px !important;
}

.moveable-guideline {
    background: #f59e0b !important;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .editor-sidebar {
        width: 260px;
    }
    
    .editor-sidebar.right {
        width: 300px;
    }
}

@media (max-width: 992px) {
    .editor-toolbar {
        padding: 0.8rem;
    }
    
    .toolbar-group {
        width: 100%;
        justify-content: center;
    }
    
    .toolbar-separator {
        display: none;
    }
    
    .model-name-input,
    .model-type-select {
        width: 100%;
    }
    
    .editor-layout {
        flex-direction: column;
    }
    
    .editor-sidebar {
        width: 100%;
        height: 250px;
        border-right: none;
        border-bottom: 1px solid var(--clr-border);
    }
    
    .editor-sidebar.right {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--clr-border);
        height: 300px;
    }
    
    .sidebar-tab-content {
        display: flex !important;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0.5rem;
    }
    
    .element-category {
        display: inline-block;
        width: 280px;
        margin-right: 1rem;
        vertical-align: top;
        white-space: normal;
    }
    
    .elements-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .editor-canvas-area {
        padding: 1rem;
    }
    
    .page-canvas {
        transform: scale(0.8);
    }
    
    .template-options {
        grid-template-columns: 1fr;
    }
    
    .base-templates-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .wizard-footer {
        flex-direction: column;
        gap: 1rem;
    }
    
    .wizard-footer button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .editor-canvas-area {
        padding: 0.5rem;
    }
    
    .page-canvas {
        transform: scale(0.6);
    }
    
    .base-templates-grid {
        grid-template-columns: 1fr;
    }
    
    .models-grid {
        grid-template-columns: 1fr;
    }
    
    .model-preview {
        height: 160px;
    }
    
    .model-actions {
        flex-wrap: wrap;
    }
    
    .model-actions button {
        flex: 1;
    }
}

/* ==============================================
   ÉDITEUR DE MODÈLES DE DOCUMENTS - VERSION PROFESSIONNELLE
   ============================================== */

/* --- Conteneur principal de l'éditeur --- */
.editor-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1e2b;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Barre d'outils principale --- */
.editor-toolbar {
    height: 64px;
    background: #2d3344;
    border-bottom: 2px solid #3a4055;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: #e2e8f0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-divider {
    width: 1px;
    height: 32px;
    background: #3a4055;
    margin: 0 8px;
}

.editor-title-input {
    background: #1e2433;
    border: 1px solid #3a4055;
    border-radius: 6px;
    color: white;
    padding: 8px 16px;
    font-size: 14px;
    width: 300px;
    transition: all 0.2s ease;
}

.editor-title-input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.editor-type-select {
    background: #1e2433;
    border: 1px solid #3a4055;
    border-radius: 6px;
    color: white;
    padding: 8px 32px 8px 16px;
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    min-width: 200px;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid #3a4055;
    border-radius: 6px;
    color: #e2e8f0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background: #3a4055;
    color: white;
    border-color: #4b5563;
}

.toolbar-btn.primary {
    background: #3b82f6;
    border-color: #2563eb;
    color: white;
}

.toolbar-btn.primary:hover {
    background: #2563eb;
}

.zoom-indicator {
    background: #1e2433;
    border: 1px solid #3a4055;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    min-width: 70px;
    text-align: center;
}

/* --- Layout principal --- */
.editor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* --- Panneau latéral gauche (bibliothèque) --- */
.editor-left-panel {
    width: 300px;
    background: #2d3344;
    border-right: 2px solid #3a4055;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

.panel-header {
    padding: 16px;
    background: #252b3b;
    border-bottom: 2px solid #3a4055;
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-tabs {
    display: flex;
    gap: 4px;
    margin-top: 12px;
}

.panel-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.panel-tab:hover {
    background: #3a4055;
    color: white;
}

.panel-tab.active {
    background: #3b82f6;
    color: white;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Catégories d'éléments */
.element-category {
    margin-bottom: 24px;
}

.category-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-bottom: 12px;
}

.elements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.element-card {
    background: #1e2433;
    border: 2px solid #3a4055;
    border-radius: 8px;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.element-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    background: #252b3b;
}

.element-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.element-card i {
    font-size: 24px;
    color: #3b82f6;
}

.element-card span {
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
    text-align: center;
}

/* Liste des champs */
.fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-card {
    background: #1e2433;
    border: 2px solid #3a4055;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: all 0.2s ease;
}

.field-card:hover {
    border-color: #3b82f6;
    background: #252b3b;
}

.field-name {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
}

.field-code {
    font-size: 11px;
    color: #9ca3af;
    background: #2d3344;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
}

/* --- Zone de travail centrale --- */
.editor-canvas-area {
    flex: 1;
    background: #1a1e2b;
    overflow: auto;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
}

.canvas-container {
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: visible;
}

#pageCanvas {
    background: white;
    position: relative;
    transform-origin: top center;
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
}

#pageCanvas.show-grid {
    background-image: 
        linear-gradient(to right, #e2e8f0 1px, transparent 1px),
        linear-gradient(to bottom, #e2e8f0 1px, transparent 1px);
    background-size: 10mm 10mm;
}

/* Éléments du canvas */
.canvas-element {
    position: absolute;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    padding: 4px;
    border: 2px solid transparent;
    transition: box-shadow 0.2s ease;
    border-radius: 2px;
    min-width: 10px;
    min-height: 10px;
}

.canvas-element:hover {
    border: 2px dashed #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.canvas-element.selected {
    border: 2px solid #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    z-index: 1000;
}

.canvas-element.selected::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 4px;
    pointer-events: none;
}

/* --- Panneau latéral droit (propriétés) --- */
.editor-right-panel {
    width: 350px;
    background: #2d3344;
    border-left: 2px solid #3a4055;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.properties-panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.property-section {
    background: #1e2433;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #3a4055;
}

.property-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #3a4055;
    padding-bottom: 8px;
}

.property-row {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.property-row.half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.property-label {
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
}

.property-input {
    background: #2d3344;
    border: 1px solid #3a4055;
    border-radius: 4px;
    padding: 8px;
    color: white;
    font-size: 13px;
    transition: all 0.2s ease;
}

.property-input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.property-input[type="color"] {
    height: 40px;
    padding: 4px;
}

.property-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 13px;
}

.align-buttons {
    display: flex;
    gap: 4px;
}

.align-btn {
    flex: 1;
    background: #2d3344;
    border: 1px solid #3a4055;
    border-radius: 4px;
    padding: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.align-btn:hover {
    background: #3a4055;
    color: white;
}

.align-btn.active {
    background: #3b82f6;
    border-color: #2563eb;
    color: white;
}

/* --- Moveable styles --- */
.moveable-control-box {
    z-index: 10000 !important;
}

.moveable-line {
    background: #3b82f6 !important;
}

.moveable-control {
    background: white !important;
    border: 2px solid #3b82f6 !important;
    width: 10px !important;
    height: 10px !important;
    margin-top: -5px !important;
    margin-left: -5px !important;
}

.moveable-guideline {
    background: #f59e0b !important;
}

/* --- Assistant de création --- */
.creation-wizard {
    max-width: 900px;
    width: 90%;
}

.wizard-steps {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid #3a4055;
    padding-bottom: 20px;
}

.wizard-step-indicator {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.wizard-step-indicator:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: #3a4055;
    z-index: 1;
}

.wizard-step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2d3344;
    border: 2px solid #3a4055;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #e2e8f0;
    z-index: 2;
    background: #1e2433;
}

.wizard-step-indicator.active .wizard-step-number {
    background: #3b82f6;
    border-color: #2563eb;
    color: white;
}

.wizard-step-indicator.completed .wizard-step-number {
    background: #10b981;
    border-color: #059669;
    color: white;
}

.wizard-step-label {
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
}

.wizard-step-indicator.active .wizard-step-label {
    color: white;
}

.wizard-content {
    min-height: 400px;
}

.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
}

.wizard-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.wizard-option-card {
    background: #1e2433;
    border: 2px solid #3a4055;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wizard-option-card:hover {
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.wizard-option-card.selected {
    border-color: #3b82f6;
    background: #252b3b;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.wizard-option-card i {
    font-size: 48px;
    color: #3b82f6;
    margin-bottom: 16px;
}

.wizard-option-card h4 {
    font-size: 18px;
    margin-bottom: 8px;
    color: white;
}

.wizard-option-card p {
    color: #9ca3af;
    font-size: 14px;
    margin: 0;
}

.base-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.base-template-card {
    background: #1e2433;
    border: 2px solid #3a4055;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.base-template-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.base-template-card.selected {
    border-color: #3b82f6;
    background: #252b3b;
}

.template-mini-preview {
    height: 120px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.mini-page {
    width: 80px;
    height: 100px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-header {
    height: 12px;
    background: #3b82f6;
    border-radius: 2px;
    margin-bottom: 4px;
}

.mini-line {
    height: 3px;
    background: #cbd5e1;
    border-radius: 1px;
}

.base-template-card .model-info {
    padding: 12px;
}

.base-template-card .model-title {
    font-size: 14px;
    margin: 0 0 4px 0;
    color: white;
}

.base-template-card .model-type {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
}

.wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #3a4055;
}

/* --- Configuration des tableaux --- */
.table-column-config {
    background: #1e2433;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.table-column-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.table-column-row input,
.table-column-row select {
    flex: 1;
    background: #2d3344;
    border: 1px solid #3a4055;
    border-radius: 4px;
    padding: 6px;
    color: white;
    font-size: 12px;
}

/* --- Scrollbar personnalisée --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1e2433;
}

::-webkit-scrollbar-thumb {
    background: #3a4055;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}





/* ==============================================
   STYLES SPÉCIFIQUES AUX DOCUMENTS
   ============================================== */

/* --- Stepper --- */
.generation-stepper {
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
}

.stepper-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 800px;
    margin: 0 auto;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.8;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--clr-bg-primary);
    border: 2px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: var(--clr-blue);
    border-color: var(--clr-blue);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.step.completed .step-number {
    background: var(--clr-green);
    border-color: var(--clr-green);
    color: white;
}

.step.completed .step-number::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1rem;
}

.step-label {
    text-align: center;
}

.step-label span {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.step-label small {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

.step-connector {
    flex: 0.5;
    height: 2px;
    background: var(--clr-border);
    margin: 0 0.5rem;
    position: relative;
    top: -15px;
}

/* --- Contenu des étapes --- */
.generation-content {
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.content-header {
    margin-bottom: 2rem;
}

.content-header h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-header p {
    color: var(--clr-text-secondary);
}

/* --- Catégories de documents --- */
.document-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--clr-bg-primary);
    border-radius: 10px;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--clr-blue);
}

.category-card.selected {
    border-color: var(--clr-blue);
    background: rgba(2, 132, 199, 0.05);
}

.category-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.category-icon.pedagogique {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
}

.category-icon.administratif {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.category-icon.financier {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.category-icon.rh {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.category-icon.examens {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

.category-icon.communication {
    background: linear-gradient(135deg, #f97316, #fb923c);
}

.category-info {
    flex: 1;
}

.category-info h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.category-info p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.arrow {
    color: var(--clr-text-secondary);
    font-size: 0.9rem;
}

/* --- Modèles récents --- */
.recent-models {
    margin-top: 2rem;
}

.recent-models h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.model-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: var(--clr-bg-primary);
    border-radius: 8px;
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.model-card:hover {
    border-color: var(--clr-blue);
}

.model-card.selected {
    border-color: var(--clr-blue);
    background: rgba(2, 132, 199, 0.05);
}

.model-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.model-icon.bulletin {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
}

.model-icon.attestation {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.model-icon.facture {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.model-info {
    flex: 1;
}

.model-info h4 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.model-info p {
    font-size: 0.7rem;
    color: var(--clr-text-secondary);
}

/* --- Formulaire de paramètres --- */
.parameters-form {
    max-width: 800px;
}

.form-section {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--clr-bg-primary);
    border-radius: 8px;
}

.form-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--clr-blue);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* --- Sélection des données --- */
.data-source-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.source-btn {
    padding: 0.7rem 1.2rem;
    border-radius: 30px;
    background: var(--clr-bg-primary);
    border: 1px solid var(--clr-border);
    color: var(--clr-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.source-btn:hover {
    background: var(--clr-bg-secondary);
    border-color: var(--clr-blue);
}

.source-btn.active {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

.source-btn i {
    font-size: 1rem;
}

.data-filters {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box.large {
    flex: 1;
    min-width: 300px;
}

/* --- Résultats de recherche --- */
.data-results {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--clr-border);
}

.results-count {
    font-weight: 600;
    color: var(--clr-blue);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: var(--clr-bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.result-item:hover {
    border-color: var(--clr-blue);
}

.result-item.selected {
    background: rgba(2, 132, 199, 0.05);
    border-color: var(--clr-blue);
}

.result-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.result-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-info {
    flex: 1;
}

.result-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.result-info p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.result-badge {
    margin-left: auto;
}

/* --- Résumé de sélection --- */
.selection-summary {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.selection-summary h4 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    background: var(--clr-bg-secondary);
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--clr-border);
}

.selected-tag i {
    cursor: pointer;
    color: var(--clr-text-secondary);
}

.selected-tag i:hover {
    color: var(--clr-red);
}

.selection-total {
    font-size: 0.9rem;
    color: var(--clr-text-secondary);
}

/* --- Aperçu du document --- */
.preview-container {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--clr-bg-secondary);
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-size: 0.9rem;
}

.page-info {
    min-width: 100px;
    text-align: center;
    font-size: 0.9rem;
}

.document-preview {
    background: white;
    color: #1e293b;
    padding: 2rem;
    border-radius: 8px;
    min-height: 500px;
    max-height: 600px;
    overflow-y: auto;
    font-family: 'Times New Roman', serif;
    transition: transform 0.3s ease;
}

.theme-dark .document-preview {
    background: #1e293b;
    color: #f8fafc;
}

.preview-page {
    max-width: 800px;
    margin: 0 auto;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.preview-logo img {
    max-width: 80px;
    max-height: 60px;
    object-fit: contain;
}

.preview-title {
    flex: 1;
}

.preview-title h2 {
    font-size: 1.2rem;
    color: #0284c7;
    margin-bottom: 0.2rem;
}

.preview-title p {
    font-size: 0.8rem;
    color: #64748b;
}

.preview-student {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 6px;
}

.theme-dark .preview-student {
    background: #0f172a;
}

.student-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.student-info p {
    font-size: 0.8rem;
    color: #64748b;
}

.student-stats {
    display: flex;
    gap: 1rem;
}

.student-stats .stat {
    text-align: right;
}

.student-stats .label {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
}

.student-stats .value {
    font-size: 1.1rem;
    font-weight: 600;
}

.preview-table {
    margin-bottom: 2rem;
    overflow-x: auto;
}

.preview-table table {
    width: 100%;
    border-collapse: collapse;
}

.preview-table th {
    background: #f1f5f9;
    padding: 0.8rem;
    text-align: left;
    font-size: 0.9rem;
}

.theme-dark .preview-table th {
    background: #334155;
}

.preview-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e2e8f0;
}

.theme-dark .preview-table td {
    border-bottom-color: #334155;
}

.preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.signature p {
    margin: 0.2rem 0;
    font-size: 0.9rem;
}

.signature-image img {
    max-width: 100px;
    max-height: 40px;
    object-fit: contain;
}

.qr-code {
    text-align: center;
}

.qr-code img {
    width: 60px;
    height: 60px;
}

.qr-code p {
    font-size: 0.7rem;
    color: #64748b;
}

/* --- Options de génération --- */
.generation-options {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.generation-options h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
}

/* --- Navigation des étapes --- */
.step-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--clr-border);
}

.navigation-right {
    display: flex;
    gap: 1rem;
}

.btn-large {
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

/* --- Modale génération groupée --- */
.batch-info {
    background: rgba(2, 132, 199, 0.05);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--clr-blue);
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.batch-summary {
    background: var(--clr-bg-primary);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.batch-summary h4 {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.summary-stats .stat {
    text-align: center;
}

.summary-stats .label {
    display: block;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    margin-bottom: 0.2rem;
}

.summary-stats .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--clr-blue);
}

.progress-container {
    margin-top: 1rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.progress-bar {
    height: 8px;
    background: var(--clr-bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--clr-blue), #38bdf8);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-detail {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

/* --- Modale historique --- */
.history-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.history-filters .search-box {
    flex: 1;
    min-width: 250px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: var(--clr-bg-primary);
    border-radius: 6px;
}

.history-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.history-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.history-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.history-content {
    flex: 1;
}

.history-content h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.history-content p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.history-actions {
    display: flex;
    gap: 0.3rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .stepper-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .step {
        flex-direction: row;
        width: 100%;
        gap: 1rem;
    }
    
    .step-connector {
        display: none;
    }
    
    .step-number {
        margin-bottom: 0;
    }
    
    .document-categories {
        grid-template-columns: 1fr;
    }
    
    .models-grid {
        grid-template-columns: 1fr;
    }
    
    .data-source-selector {
        flex-direction: column;
    }
    
    .source-btn {
        width: 100%;
        justify-content: center;
    }
    
    .data-filters {
        flex-direction: column;
    }
    
    .search-box.large {
        min-width: auto;
    }
    
    .preview-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-group {
        justify-content: center;
    }
    
    .preview-header {
        flex-direction: column;
        text-align: center;
    }
    
    .preview-student {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .student-stats {
        justify-content: center;
    }
    
    .preview-footer {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        text-align: center;
    }
    
    .step-navigation {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .step-navigation button {
        width: 100%;
    }
    
    .navigation-right {
        flex-direction: column;
        width: 100%;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .history-filters {
        flex-direction: column;
    }
    
    .history-item {
        flex-wrap: wrap;
    }
    
    .history-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .result-item {
        flex-wrap: wrap;
    }
    
    .result-badge {
        width: 100%;
        margin-left: 3rem;
    }
    
    .selected-items {
        flex-direction: column;
    }
    
    .selected-tag {
        width: 100%;
        justify-content: space-between;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }
}



/* ============================================================================================================= */




/* ==============================================
   ÉDITEUR DE MODÈLES - STYLE COMPLET & RESPONSIVE
   ============================================== */

/* --- Structure principale --- */
.template-editor {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--clr-bg-primary);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Barre d'outils principale --- */
.editor-toolbar {
    height: 64px;
    background: var(--clr-bg-secondary);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    background: transparent;
    color: var(--clr-text-primary);
    border: 1px solid var(--clr-border);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: var(--clr-bg-primary);
    border-color: var(--clr-blue);
    color: var(--clr-blue);
    transform: translateY(-1px);
}

.toolbar-btn.primary {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.toolbar-btn.primary:hover {
    background: #0369a1;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.toolbar-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--clr-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.toolbar-icon-btn:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
    border-color: var(--clr-blue);
    transform: translateY(-1px);
}

.toolbar-icon-btn.active {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

.toolbar-separator {
    width: 1px;
    height: 30px;
    background: var(--clr-border);
}

.template-name-input {
    padding: 8px 16px;
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.95rem;
    width: 280px;
    transition: all 0.2s ease;
}

.template-name-input:focus {
    outline: none;
    border-color: var(--clr-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.template-badge-editor {
    padding: 4px 12px;
    background: var(--clr-bg-primary);
    border-radius: 30px;
    font-size: 0.75rem;
    color: var(--clr-blue);
    border: 1px solid var(--clr-border);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--clr-bg-primary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--clr-border);
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--clr-text-primary);
    font-weight: 600;
}

.view-controls {
    display: flex;
    gap: 5px;
    background: var(--clr-bg-primary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--clr-border);
}

/* --- Barre d'outils secondaire --- */
.editor-secondary-toolbar {
    height: 56px;
    background: var(--clr-bg-primary);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-settings {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-size: 0.85rem;
    color: var(--clr-text-secondary);
    font-weight: 500;
}

.setting-select, .setting-input {
    padding: 6px 12px;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    background: var(--clr-bg-secondary);
    color: var(--clr-text-primary);
    font-size: 0.85rem;
    width: 130px;
    transition: all 0.2s ease;
}

.setting-select:hover, .setting-input:hover {
    border-color: var(--clr-blue);
}

.setting-select:focus, .setting-input:focus {
    outline: none;
    border-color: var(--clr-blue);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.1);
}

.quick-actions {
    display: flex;
    gap: 5px;
    background: var(--clr-bg-secondary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--clr-border);
}

/* --- Zone de travail principale --- */
.editor-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #2d2d2d;
    position: relative;
}

/* --- Sidebars --- */
.editor-sidebar {
    width: 320px;
    background: var(--clr-bg-secondary);
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, min-width 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    z-index: 10;
    overflow: hidden;
}

.editor-sidebar.right {
    border-right: none;
    border-left: 1px solid var(--clr-border);
    box-shadow: -2px 0 8px rgba(0,0,0,0.05);
}

.editor-sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.editor-sidebar.collapsed .sidebar-content {
    display: none;
}

.sidebar-header {
    height: 56px;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background: var(--clr-bg-secondary);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--clr-text-primary);
    font-weight: 600;
}

.sidebar-header h3 i {
    color: var(--clr-blue);
    font-size: 1rem;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--clr-text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--clr-blue) var(--clr-bg-primary);
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: var(--clr-bg-primary);
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--clr-blue);
    border-radius: 3px;
}

/* --- Catégories d'éléments --- */
.element-category {
    margin-bottom: 25px;
}

.element-category h4 {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--clr-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.element-category h4 i {
    color: var(--clr-blue);
    font-size: 0.9rem;
}

.element-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.element-item {
    background: var(--clr-bg-primary);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: grab;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    color: var(--clr-text-primary);
    text-align: center;
}

.element-item:hover {
    border-color: var(--clr-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: var(--clr-bg-secondary);
}

.element-item:active {
    cursor: grabbing;
    opacity: 0.8;
}

.element-item i {
    font-size: 1.4rem;
    color: var(--clr-blue);
}

.element-item.small {
    flex-direction: row;
    padding: 8px 12px;
    font-size: 0.8rem;
    gap: 10px;
}

.element-item.small i {
    font-size: 1rem;
}

.element-accordion details {
    margin-bottom: 8px;
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--clr-bg-primary);
}

.element-accordion summary {
    padding: 12px 15px;
    background: var(--clr-bg-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--clr-text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.element-accordion summary:hover {
    background: var(--clr-bg-primary);
    color: var(--clr-blue);
}

.element-accordion summary i {
    color: var(--clr-blue);
    font-size: 0.9rem;
}

.element-accordion summary::-webkit-details-marker {
    display: none;
}

.element-accordion summary::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    transition: transform 0.2s ease;
}

.element-accordion details[open] summary::after {
    transform: rotate(180deg);
}

.element-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: var(--clr-bg-primary);
    max-height: 300px;
    overflow-y: auto;
}

/* --- Canvas --- */
.editor-canvas-area {
    flex: 1;
    overflow: auto;
    background: #404040;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    background-image: radial-gradient(circle at 25px 25px, #555 1px, transparent 1px);
    background-size: 50px 50px;
}

.paper-canvas {
    background: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    position: relative;
    transition: transform 0.2s ease, width 0.3s, height 0.3s;
    transform-origin: top center;
    margin-bottom: 100px;
    border-radius: 2px;
    will-change: transform;
}

.paper-canvas.show-grid {
    background-image: 
        linear-gradient(to right, #e2e8f0 1px, transparent 1px),
        linear-gradient(to bottom, #e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- Éléments du canvas --- */
.doc-element {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    user-select: none;
    overflow: hidden;
    transition: outline 0.1s ease;
    font-family: inherit;
    line-height: 1.2;
    word-break: break-word;
    background: transparent;
    border-radius: 2px;
}

.doc-element:hover {
    outline: 2px dashed var(--clr-blue);
    z-index: 999;
}

.doc-element.selected {
    outline: 3px solid var(--clr-blue);
    box-shadow: 0 0 0 1px white, 0 4px 12px rgba(2, 132, 199, 0.3);
    z-index: 1000;
}

.doc-element.text-dynamic {
    display: flex;
    align-items: center;
}

.doc-element.text-dynamic::before {
    content: '{ }';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--clr-blue);
    color: white;
    font-size: 0.6rem;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.doc-element.text-dynamic:hover::before {
    opacity: 1;
}

.doc-element.image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #94a3b8;
    font-size: 0.8rem;
}

.doc-element.table {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 0.8rem;
    overflow: auto;
}

.doc-element.table .table-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.doc-element.table .preview-row {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}

.doc-element.table .preview-cell {
    flex: 1;
    padding: 4px;
    border-right: 1px solid #e2e8f0;
    text-align: center;
}

/* --- Panneau de propriétés --- */
.properties-section {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.properties-section h4 {
    font-size: 0.9rem;
    margin-bottom: 15px;
    color: var(--clr-blue);
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.properties-section h4 i {
    font-size: 0.9rem;
}

.property-group {
    margin-bottom: 15px;
}

.property-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.property-group.half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.property-input, .property-select, .property-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    background: var(--clr-bg-primary);
    color: var(--clr-text-primary);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.property-input:hover, .property-select:hover, .property-textarea:hover {
    border-color: var(--clr-blue);
}

.property-input:focus, .property-select:focus, .property-textarea:focus {
    outline: none;
    border-color: var(--clr-blue);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.property-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: monospace;
}

.property-value {
    padding: 8px 12px;
    background: var(--clr-bg-primary);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--clr-text-primary);
    border: 1px solid var(--clr-border);
    font-weight: 500;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    padding: 5px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.85rem;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--clr-blue);
}

.property-divider {
    height: 1px;
    background: var(--clr-border);
    margin: 20px 0;
}

.delete-element-btn {
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--clr-red);
    border: 1px solid var(--clr-red);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.delete-element-btn:hover {
    background: var(--clr-red);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* --- Barre d'état --- */
.editor-statusbar {
    height: 32px;
    background: var(--clr-bg-secondary);
    border-top: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
    font-weight: 500;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-separator {
    color: var(--clr-border);
    font-weight: 300;
}

/* --- Templates grid (vue liste) --- */
.templates-view-switcher {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.view-switcher {
    display: flex;
    gap: 5px;
    background: var(--clr-bg-primary);
    border-radius: 10px;
    padding: 4px;
    border: 1px solid var(--clr-border);
}

.view-btn {
    padding: 8px 20px;
    border-radius: 8px;
    background: transparent;
    color: var(--clr-text-secondary);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-btn:hover {
    background: var(--clr-bg-secondary);
    color: var(--clr-text-primary);
}

.view-btn.active {
    background: var(--clr-blue);
    color: white;
}

.view-btn i {
    font-size: 0.9rem;
}

.templates-actions {
    display: flex;
    gap: 10px;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.template-card {
    background: var(--clr-bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--clr-shadow);
    border: 1px solid var(--clr-border);
    transition: all 0.3s ease;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    border-color: var(--clr-blue);
}

.template-card-header {
    padding: 18px 15px;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.template-badge {
    position: absolute;
    top: 12px;
    right: 15px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    letter-spacing: 0.3px;
}

.template-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.template-icon.bulletin { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.template-icon.facture { background: linear-gradient(135deg, #10b981, #34d399); }
.template-icon.attestation { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.template-icon.convocation { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.template-icon.sanction { background: linear-gradient(135deg, #ef4444, #f87171); }
.template-icon.stage { background: linear-gradient(135deg, #f97316, #fb923c); }
.template-icon.diplome { background: linear-gradient(135deg, #ec4899, #f472b6); }
.template-icon.recu { background: linear-gradient(135deg, #14b8a6, #2dd4bf); }
.template-icon.contrat { background: linear-gradient(135deg, #6b7280, #9ca3af); }
.template-icon.default { background: linear-gradient(135deg, #64748b, #94a3b8); }

.template-title h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    font-weight: 600;
}

.template-title p {
    font-size: 0.8rem;
    color: var(--clr-text-secondary);
}

.template-card-preview {
    height: 130px;
    background: var(--clr-bg-primary);
    padding: 15px;
    border-bottom: 1px solid var(--clr-border);
}

.mini-preview {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-card-footer {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--clr-bg-secondary);
}

.template-meta {
    font-size: 0.75rem;
    color: var(--clr-text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.template-actions {
    display: flex;
    gap: 5px;
}

/* --- Mode liste --- */
.templates-list .template-card {
    display: flex;
    align-items: center;
    padding: 10px;
}

.templates-list .template-card-header {
    border-bottom: none;
    padding: 0;
    min-width: 250px;
}

.templates-list .template-card-preview {
    flex: 1;
    height: 60px;
    padding: 5px;
    border-bottom: none;
    border-left: 1px solid var(--clr-border);
    border-right: 1px solid var(--clr-border);
}

.templates-list .template-card-footer {
    border-top: none;
    min-width: 150px;
}

/* --- Moveable styles --- */
.moveable-control-box {
    z-index: 9999 !important;
}

.moveable-line {
    background: var(--clr-blue) !important;
}

.moveable-control {
    background: white !important;
    border: 2px solid var(--clr-blue) !important;
    width: 10px !important;
    height: 10px !important;
    margin-left: -5px !important;
    margin-top: -5px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.moveable-guideline {
    background: #f59e0b !important;
    stroke: #f59e0b !important;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* --- Responsive Design --- */
@media (max-width: 1400px) {
    .editor-sidebar {
        width: 280px;
    }
    
    .template-name-input {
        width: 200px;
    }
}

@media (max-width: 1200px) {
    .editor-toolbar {
        height: auto;
        padding: 10px;
    }
    
    .toolbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .editor-secondary-toolbar {
        height: auto;
        padding: 10px;
    }
    
    .page-settings {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 992px) {
    .editor-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: 0 0 30px rgba(0,0,0,0.2);
    }
    
    .editor-sidebar.left {
        left: 0;
        transform: translateX(0);
    }
    
    .editor-sidebar.left.collapsed {
        transform: translateX(-100%);
    }
    
    .editor-sidebar.right {
        right: 0;
        transform: translateX(0);
    }
    
    .editor-sidebar.right.collapsed {
        transform: translateX(100%);
    }
    
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .templates-view-switcher {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-settings {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .setting-group {
        width: 100%;
    }
    
    .setting-select, .setting-input {
        width: 100%;
    }
    
    .quick-actions {
        width: 100%;
        justify-content: space-around;
    }
    
    .templates-list .template-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .templates-list .template-card-header,
    .templates-list .template-card-preview,
    .templates-list .template-card-footer {
        width: 100%;
        border-left: none;
        border-right: none;
    }
    
    .templates-list .template-card-preview {
        border-top: 1px solid var(--clr-border);
        border-bottom: 1px solid var(--clr-border);
    }
}

@media (max-width: 480px) {
    .editor-canvas-area {
        padding: 20px 10px;
    }
    
    .toolbar-left, .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .template-name-input {
        width: 100%;
    }
    
    .toolbar-separator {
        display: none;
    }
    
    .property-group.half {
        grid-template-columns: 1fr;
    }
}


/* ==============================================
   ÉDITEUR MOBILE - STYLE CANVA
   ============================================== */

@media (max-width: 768px) {
    .template-editor {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #1e1e1e;
    }

    /* Barre d'outils simplifiée */
    .editor-toolbar {
        height: 56px;
        padding: 0 12px;
        background: #2d2d2d;
        border-bottom: 1px solid #404040;
    }

    .toolbar-left, .toolbar-center, .toolbar-right {
        gap: 8px;
    }

    .toolbar-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .toolbar-btn span {
        display: none; /* Cache le texte, garde l'icône */
    }

    .toolbar-btn i {
        font-size: 1.1rem;
        margin: 0;
    }

    .toolbar-btn.primary span {
        display: inline; /* Garde le texte pour le bouton Enregistrer */
    }

    .template-name-input {
        width: 140px;
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .template-badge-editor {
        display: none; /* Cache le badge sur mobile */
    }

    .toolbar-center {
        order: 0;
        width: auto;
    }

    .zoom-controls {
        background: transparent;
        border: none;
        padding: 0;
    }

    .zoom-level {
        min-width: 45px;
        font-size: 0.8rem;
    }

    .view-controls {
        display: none; /* Cache les contrôles de grille sur mobile */
    }

    /* Barre d'outils secondaire */
    .editor-secondary-toolbar {
        height: 48px;
        padding: 0 12px;
        background: #262626;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .editor-secondary-toolbar::-webkit-scrollbar {
        display: none;
    }

    .page-settings {
        flex-wrap: nowrap;
        gap: 12px;
    }

    .setting-group {
        flex-shrink: 0;
    }

    .setting-group label {
        display: none; /* Cache les labels sur mobile */
    }

    .setting-select, .setting-input {
        width: 100px;
        padding: 6px 8px;
        font-size: 0.8rem;
        background: #333;
        border-color: #444;
        color: #fff;
    }

    .quick-actions {
        flex-shrink: 0;
        background: transparent;
        border: none;
        padding: 0;
        gap: 8px;
    }

    .quick-actions .toolbar-icon-btn {
        width: 36px;
        height: 36px;
        background: #333;
        border-radius: 8px;
        color: #fff;
    }

    /* Zone de travail - optimisée pour tactile */
    .editor-workspace {
        position: relative;
        background: #1a1a1a;
    }

    .editor-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        background: #2d2d2d;
        z-index: 100;
        transition: transform 0.3s ease;
        box-shadow: 2px 0 20px rgba(0,0,0,0.5);
    }

    .editor-sidebar.left {
        left: 0;
        transform: translateX(0);
    }

    .editor-sidebar.left.collapsed {
        transform: translateX(-100%);
    }

    .editor-sidebar.right {
        right: 0;
        transform: translateX(0);
    }

    .editor-sidebar.right.collapsed {
        transform: translateX(100%);
    }

    .sidebar-header {
        height: 60px;
        background: #333;
        border-bottom: 1px solid #404040;
        padding: 0 15px;
    }

    .sidebar-header h3 {
        color: #fff;
        font-size: 1rem;
    }

    .sidebar-header h3 i {
        color: #0284c7;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
        background: #404040;
        border-radius: 8px;
        color: #fff;
    }

    .sidebar-content {
        background: #2d2d2d;
        padding: 15px;
        height: calc(100% - 60px);
        overflow-y: auto;
    }

    /* Éléments plus gros pour le tactile */
    .element-item {
        min-height: 50px;
        background: #333;
        border-color: #444;
        color: #fff;
    }

    .element-item i {
        font-size: 1.3rem;
        color: #0284c7;
    }

    .element-item.small {
        padding: 10px 12px;
    }

    .element-accordion details {
        background: #333;
        border-color: #444;
    }

    .element-accordion summary {
        background: #3a3a3a;
        color: #fff;
        padding: 14px 15px;
    }

    .element-list {
        background: #2a2a2a;
        max-height: 250px;
    }

    /* Canvas - zone de dessin */
    .editor-canvas-area {
        padding: 20px 10px;
        background: #1a1a1a;
        background-image: radial-gradient(circle at 25px 25px, #333 1px, transparent 1px);
        background-size: 50px 50px;
    }

    .paper-canvas {
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        touch-action: none; /* Important pour le tactile */
    }

    .doc-element {
        cursor: move;
        touch-action: none; /* Important pour le drag tactile */
        -webkit-user-select: none;
        user-select: none;
    }

    .doc-element.selected {
        outline: 3px solid #0284c7;
        box-shadow: 0 0 0 2px rgba(2,132,199,0.3);
    }

    /* Panneau de propriétés - optimisé tactile */
    .property-group {
        margin-bottom: 20px;
    }

    .property-group label {
        color: #aaa;
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .property-input, .property-select, .property-textarea {
        padding: 12px;
        font-size: 1rem;
        background: #333;
        border-color: #444;
        color: #fff;
        border-radius: 8px;
    }

    .checkbox-group {
        gap: 25px;
    }

    .checkbox-group label {
        gap: 8px;
        font-size: 0.95rem;
    }

    .checkbox-group input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .delete-element-btn {
        padding: 14px;
        font-size: 1rem;
    }

    /* Barre d'état */
    .editor-statusbar {
        height: 40px;
        padding: 0 15px;
        background: #262626;
        border-top: 1px solid #333;
        color: #aaa;
    }

    /* Menu flottant pour les actions rapides (type Canva) */
    .mobile-float-menu {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: #2d2d2d;
        border-radius: 30px;
        padding: 8px 16px;
        display: flex;
        gap: 20px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.5);
        z-index: 200;
        border: 1px solid #404040;
    }

    .mobile-float-menu button {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.2rem;
        padding: 10px;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-float-menu button:active {
        background: #404040;
    }
}

@media (max-width: 480px) {
    .editor-toolbar {
        padding: 0 8px;
    }

    .template-name-input {
        width: 120px;
    }

    .toolbar-btn {
        padding: 6px 10px;
    }

    .setting-select, .setting-input {
        width: 80px;
        padding: 6px;
    }

    .quick-actions .toolbar-icon-btn {
        width: 32px;
        height: 32px;
    }

    .editor-canvas-area {
        padding: 10px 5px;
    }

    .paper-canvas {
        transform-origin: top left;
    }

    .mobile-float-menu {
        bottom: 15px;
        padding: 6px 12px;
        gap: 10px;
    }

    .mobile-float-menu button {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}



/* ================================================= */

/* ==============================================
   CORRECTIONS BOUTONS ET SIDEBARS
   ============================================== */

/* Correction des boutons qui débordent */
.toolbar-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.toolbar-btn span {
    display: inline-block;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar-btn i + span {
    margin-left: 4px;
}

/* Pour les très petits écrans */
@media (max-width: 480px) {
    .toolbar-btn {
        padding: 8px 10px;
        max-width: 100px;
    }
    
    .toolbar-btn span {
        max-width: 60px;
    }
    
    .toolbar-btn.primary span {
        max-width: 70px;
    }
}

/* Amélioration de l'affichage des sidebars */
.editor-sidebar {
    transition: transform 0.3s ease, width 0.3s ease;
    will-change: transform, width;
}

.editor-sidebar.left.collapsed {
    transform: translateX(-100%);
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
}

.editor-sidebar.right.collapsed {
    transform: translateX(100%);
    width: 0 !important;
    min-width: 0 !important;
    border-left: none;
}

/* Boutons de toggle améliorés */
.sidebar-toggle {
    background: var(--clr-bg-primary);
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--clr-blue);
    color: white;
    border-color: var(--clr-blue);
}

/* Indicateur visuel pour les sidebars repliées */
.editor-sidebar.left.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.editor-sidebar.right.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Overlay pour mobile quand les sidebars sont ouvertes */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 992px) {
    .editor-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        z-index: 1000;
        width: 85% !important;
        max-width: 320px;
        background: var(--clr-bg-secondary);
        box-shadow: 0 0 30px rgba(0,0,0,0.3);
    }
    
    .editor-sidebar.left {
        left: 0;
        transform: translateX(0);
    }
    
    .editor-sidebar.left.collapsed {
        transform: translateX(-100%);
    }
    
    .editor-sidebar.right {
        right: 0;
        transform: translateX(0);
    }
    
    .editor-sidebar.right.collapsed {
        transform: translateX(100%);
    }
    
    .sidebar-toggle {
        width: 40px;
        height: 40px;
    }
}