/* ========================================
   CRÉATEUR DE LIVRE D'EXERCICES - STYLES
   ======================================== */

/* Header du livre */
.livre-header {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius-lg);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.livre-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    border: none;
    padding: 0;
}

.livre-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Toolbar principal */
.livre-toolbar {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
}

.toolbar-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-section:not(:last-child) {
    padding-right: 1rem;
    border-right: 2px solid var(--border-color);
}

.livre-toolbar button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.livre-toolbar button:active {
    transform: translateY(0) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

/* Container principal */
.livre-container {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 1.5rem;
    min-height: calc(100vh - 400px);
    margin-bottom: 2rem;
}

/* Sidebar gauche - Structure */
.livre-sidebar {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 2px solid var(--border-color);
}

.sidebar-header h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    border: none;
    padding: 0;
}

.livre-titre-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Structure vide */
.structure-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.structure-empty p {
    margin: 0;
    font-size: 0.95rem;
}

/* Chapitre dans la structure */
.structure-chapitre {
    margin-bottom: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    overflow: hidden;
    transition: var(--transition);
}

.structure-chapitre:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.chapitre-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.chapitre-toggle {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.chapitre-header.collapsed .chapitre-toggle {
    transform: rotate(-90deg);
}

.chapitre-titre {
    flex: 1;
    font-size: 0.95rem;
}

.chapitre-actions {
    display: flex;
    gap: 0.25rem;
}

.chapitre-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.chapitre-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chapitre-pages {
    padding: 0.5rem;
    display: none;
}

.chapitre-header:not(.collapsed) + .chapitre-pages {
    display: block;
}

/* Page dans la structure */
.structure-page {
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-size: 0.9rem;
}

.structure-page:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

.structure-page.active {
    background: linear-gradient(135deg, var(--accent-color), var(--success));
    color: white;
    font-weight: 600;
    border-color: var(--accent-color);
}

.page-numero-small {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.structure-page.active .page-numero-small {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Workspace - Zone de travail */
.livre-workspace {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-header {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#page-titre {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.page-numero-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.workspace-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon-only {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-only:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.zoom-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
}

/* Container de la page */
.page-container {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Page A4 */
.page-a4 {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    position: relative;
    padding: 20mm 15mm;
    box-sizing: border-box;
    transition: transform 0.2s;
}

.page-a4.show-grid {
    background-image: 
        linear-gradient(rgba(200, 200, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(200, 200, 255, 0.2) 1px, transparent 1px);
    background-size: 10mm 10mm;
}

/* Éléments de la page - POSITIONNEMENT LIBRE */
.page-element {
    position: absolute;
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: move;
    user-select: none;
    background: white;
}

.page-element:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    z-index: 10;
}

.page-element.selected,
.page-element.dragging {
    border-color: var(--accent-color);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.3);
    z-index: 100;
}

.page-element.resizing {
    border-color: var(--warning);
    z-index: 100;
}

/* Handle de redimensionnement */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    cursor: nwse-resize;
    border-radius: 0 0 6px 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.resize-handle::before {
    content: '⋰';
    position: absolute;
    bottom: 0;
    right: 2px;
    color: white;
    font-size: 10px;
}

.page-element:hover .resize-handle {
    opacity: 0.7;
}

.page-element.resizing .resize-handle {
    opacity: 1;
}

/* Welcome screen */
.page-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    text-align: center;
    position: static;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.page-welcome h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.page-welcome p {
    margin: 0;
    color: #999;
}

/* Éléments de la page */
.page-element {
    position: relative;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 2px dashed transparent;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: move;
}

.page-element:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.page-element.selected {
    border-color: var(--accent-color);
    background: rgba(6, 182, 212, 0.1);
}

.element-toolbar {
    position: absolute;
    top: -35px;
    right: 0;
    display: none;
    gap: 0.25rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1000;
}

.page-element:hover .element-toolbar {
    display: flex;
}

.element-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    background: var(--bg-input);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.element-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* Exercice normal */
.exercice-normal {
    border: 3px solid var(--primary-color);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(147, 197, 253, 0.05));
    padding: 1rem;
    border-radius: 8px;
}

.exercice-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #333;
}

.exercice-numero {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.exercice-points {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.exercice-consigne {
    font-style: italic;
    color: #555;
    margin-bottom: 0.5rem;
}

.exercice-contenu {
    color: #333;
    line-height: 1.6;
}

/* Devoir maison */
.exercice-dm {
    border: 3px solid #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(251, 191, 36, 0.08));
    padding: 1rem;
    border-radius: 8px;
    position: relative;
}

.exercice-dm::before {
    content: '🏠';
    position: absolute;
    top: 3.5rem;
    right: 1rem;
    font-size: 3rem;
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
}

.exercice-dm .exercice-header {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 0.5rem 0.75rem;
    margin: -1rem -1rem 0.75rem -1rem;
    border-radius: 5px 5px 0 0;
    position: relative;
    z-index: 1;
}

.exercice-dm .exercice-numero {
    background: rgba(255, 255, 255, 0.25);
}

.dm-badge {
    background: rgba(255, 255, 255, 0.9);
    color: #f59e0b;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Titre de section - Style 1 (Dégradé bleu - par défaut) */
.titre-section,
.titre-section.style-1 {
    padding: 0.5rem 1rem;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border: none !important;
    cursor: move !important;
    position: relative;
    z-index: 1;
}

.titre-section .element-toolbar {
    z-index: 10;
}

.titre-section .element-content {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

/* Titre de section - Style 2 (Encadré avec bordure gauche) */
.titre-section.style-2 {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(147, 197, 253, 0.05));
    border-left: 6px solid var(--primary-color) !important;
    border-radius: 0 8px 8px 0;
    padding-left: 1.5rem;
}

.titre-section.style-2 .element-content {
    color: var(--primary-color);
}

/* Titre de section - Style 3 (Souligné simple) */
.titre-section.style-3 {
    background: transparent;
    border: none !important;
    border-bottom: 3px solid var(--primary-color) !important;
    padding: 0.75rem 0.5rem;
    border-radius: 0;
}

.titre-section.style-3 .element-content {
    color: var(--primary-color);
    font-size: 1.4rem;
}

/* Titre de section - Style 4 (Badge arrondi) */
.titre-section.style-4 {
    background: var(--primary-color);
    border-radius: 25px;
    padding: 0.75rem 2rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    text-align: center;
    border: none !important;
}

.titre-section.style-4 .element-content {
    color: white;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

/* Séparateur */
.separateur {
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    border: none !important;
    cursor: move !important;
    padding: 0;
}

/* Encadré */
.encadre {
    border: 3px solid var(--success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(52, 211, 153, 0.05));
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.encadre-content {
    color: #333;
    line-height: 1.6;
    font-weight: 500;
}

.encadre::before {
    content: '💡';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.2rem;
    opacity: 0.5;
}

/* Paragraphe */
.paragraphe {
    padding: 0.75rem;
    background: transparent;
    border: 2px dashed #ddd !important;
}

.paragraphe .element-content {
    color: #333;
    line-height: 1.6;
}

/* Images */
.image-element {
    border: 2px solid #ddd;
    padding: 0;
    overflow: visible;
    background: white;
    border-radius: 4px;
}

.image-element img {
    display: block;
    pointer-events: none;
    border-radius: 4px;
    overflow: hidden;
}

.image-element:hover {
    border-color: var(--primary-color);
}

/* Graphique de fonction */
.graphique-element {
    border: 2px solid #8b5cf6;
    background: white;
    padding: 0.75rem;
    border-radius: 8px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.graphique-element canvas {
    display: block;
    pointer-events: none;
    flex: 1;
    max-width: 100%;
    max-height: 100%;
}

.graphique-element:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.graphique-titre {
    font-weight: 600;
    color: #8b5cf6;
    margin-bottom: 0;
    text-align: center;
    font-size: 0.9rem;
}

/* Éléments attachés */
.attached-elements {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px dashed rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.attached-graphique,
.attached-image {
    position: relative;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 0.75rem;
}

.attached-toolbar {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    display: flex;
    gap: 0.25rem;
    z-index: 10;
}

.attached-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.attached-btn:hover {
    background: #fee;
    border-color: #f87171;
    transform: scale(1.05);
}

.attached-graphique-titre {
    font-weight: 600;
    color: #7c3aed;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.attached-graphique canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    display: block;
}

.attached-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}

.attached-image-legende {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-style: italic;
    color: #666;
    text-align: center;
}

/* Bouton d'attachement dans la toolbar */
.btn-attach-element {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    color: white;
}

.btn-attach-element:hover {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    transform: scale(1.05);
}

/* Element content wrapper */
.element-content {
    position: relative;
    z-index: 2;
}

.exercice-dm .exercice-consigne,
.exercice-dm .exercice-contenu {
    position: relative;
    z-index: 2;
}

/* Exercice avec niveau (1-5 étoiles) */
.exercice-niveau {
    border: 3px solid #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(167, 139, 250, 0.05));
    padding: 1rem;
    border-radius: 8px;
    position: relative;
}

.exercice-niveau .exercice-header {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: white;
    padding: 0.5rem 0.75rem;
    margin: -1rem -1rem 0.75rem -1rem;
    border-radius: 5px 5px 0 0;
    position: relative;
    z-index: 1;
}

.exercice-niveau .exercice-numero {
    background: rgba(255, 255, 255, 0.25);
}

.niveau-stars {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Styles spécifiques par niveau */
.exercice-niveau.niveau-1 {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(52, 211, 153, 0.04));
}

.exercice-niveau.niveau-1 .exercice-header {
    background: linear-gradient(135deg, #10b981, #34d399);
}

.exercice-niveau.niveau-2 {
    border-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(147, 197, 253, 0.04));
}

.exercice-niveau.niveau-2 .exercice-header {
    background: linear-gradient(135deg, #3b82f6, #93c5fd);
}

.exercice-niveau.niveau-3 {
    border-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.04));
}

.exercice-niveau.niveau-3 .exercice-header {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.exercice-niveau.niveau-4 {
    border-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(248, 113, 113, 0.04));
}

.exercice-niveau.niveau-4 .exercice-header {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

.exercice-niveau.niveau-5 {
    border-color: #7c3aed;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(167, 139, 250, 0.05));
}

.exercice-niveau.niveau-5 .exercice-header {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
}

.exercice-niveau .exercice-consigne,
.exercice-niveau .exercice-contenu {
    position: relative;
    z-index: 1;
}

/* Panel éléments à droite */
.livre-elements-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-bottom: 2px solid var(--border-color);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    border: none;
    padding: 0;
}

.panel-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.panel-tab {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 0.85rem;
}

.panel-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.element-category {
    margin-bottom: 1.5rem;
}

.element-category h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    border: none;
    padding: 0;
}

.btn-add-element {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
    color: var(--text-primary);
    font-weight: 500;
}

.btn-add-element:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.btn-add-element.devoir-maison {
    border-color: #f59e0b;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), transparent);
}

.btn-add-element.devoir-maison:hover {
    border-color: #f59e0b;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), transparent);
}

.element-icon {
    font-size: 1.3rem;
}

.element-label {
    flex: 1;
    text-align: left;
    font-size: 0.9rem;
}

/* Boutons de thème */
.btn-style-theme {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-weight: 500;
}

.btn-style-theme:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

/* Contrôles de marge */
.margin-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.margin-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.margin-controls input {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Modal d'édition */
.modal-livre,
.modal-livre-exercices {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content-livre {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid var(--border-color);
}

.modal-header-livre {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

.modal-header-livre h3 {
    margin: 0;
    font-size: 1.3rem;
    border: none;
    padding: 0;
    color: white;
}

.modal-close-livre {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close-livre:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body-livre {
    padding: 2rem;
}

.form-group-livre {
    margin-bottom: 1.5rem;
}

.form-group-livre label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group-livre input,
.form-group-livre select,
.form-group-livre textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group-livre input:focus,
.form-group-livre select:focus,
.form-group-livre textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group-livre small {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer-livre {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Boutons stylés */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(64, 156, 255, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: white;
    transition: all 0.3s ease;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 199, 111, 0.4);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-color), var(--info));
    color: white;
    transition: all 0.3s ease;
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, var(--info), var(--info-dark));
    color: white;
    transition: all 0.3s ease;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 211, 153, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), var(--warning-dark));
    color: white;
    transition: all 0.3s ease;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.4);
}

.btn-ai {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    border: none;
    transition: all 0.3s;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-icon {
    font-size: 1.1rem;
}

/* Modal IA */
.modal-ia {
    max-width: 600px;
}

#ia-status {
    font-size: 0.9rem;
}

#ia-status.loading {
    background: #e0f2fe;
    border: 1px solid #38bdf8;
    color: #0369a1;
}

#ia-status.success {
    background: #dcfce7;
    border: 1px solid #4ade80;
    color: #15803d;
}

#ia-status.error {
    background: #fee2e2;
    border: 1px solid #f87171;
    color: #991b1b;
}

/* Responsive */
@media (max-width: 1200px) {
    .livre-container {
        grid-template-columns: 250px 1fr;
    }
    
    .livre-elements-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .livre-container {
        grid-template-columns: 1fr;
    }
    
    .livre-sidebar {
        order: 2;
        max-height: 300px;
    }
    
    .page-a4 {
        width: 100%;
        min-height: auto;
        transform: scale(0.8);
        transform-origin: top center;
    }
}

/* Styles pour MathLive (formules LaTeX) */
math-field {
    font-family: 'Latin Modern Math', 'Computer Modern', serif;
    border: none !important;
    background: transparent !important;
    color: #333 !important;
}

math-field[read-only] {
    pointer-events: none;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Forcer MathLive à afficher seulement le rendu, pas le texte source */
math-field::part(content) {
    display: block !important;
}

math-field::part(virtual-keyboard-toggle),
math-field::part(menu-toggle) {
    display: none !important;
}

.exercice-consigne math-field,
.exercice-contenu math-field {
    color: inherit !important;
    vertical-align: middle;
}

.exercice-dm math-field {
    color: #333 !important;
}

/* Conteneurs pour les formules LaTeX rendues */
.math-inline,
.math-display {
    display: inline-block;
}

.math-display {
    display: block;
    text-align: center;
}

