/* --- Base & Header --- */
body.editor-body { 
    margin: 0; padding: 0; overflow: hidden; /* Empêche le scroll sur la page entière */
    display: flex; flex-direction: column; 
    height: 100vh; /* OBLIGATOIRE : Donne une hauteur stricte pour que flex fonctionne */
    background: #f8fafc; font-family: 'Inter', sans-serif; 
}

.editor-header { 
    height: 56px; background: white; border-bottom: 1px solid #e2e8f0; 
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 20px; flex-shrink: 0; z-index: 60; position: sticky; top: 0; 
}
.editor-header .logo img { height: 28px; object-fit: contain; }
.editor-header .doc-name { font-size: 14px; font-weight: 600; color: #475569; }
.editor-header .close-editor { 
    color: #94a3b8; font-size: 20px; background: transparent; border: none; cursor: pointer;
    transition: color 0.2s; display: flex; align-items: center; justify-content: center; 
    width: 36px; height: 36px; border-radius: 8px;
}
.editor-header .close-editor:hover { color: #ef4444; background: #fee2e2; }

/* --- Conteneur de l'application --- */
#app-container { 
    flex: 1; display: flex; flex-direction: column; position: relative; 
    background: #f8fafc; 
    min-height: 0; /* OBLIGATOIRE pour empêcher le flex-child d'exploser sa taille */
}

/* --- UI Éditeur --- */
#editor-ui { 
    flex: 1; display: flex; flex-direction: column; 
    min-height: 0; /* OBLIGATOIRE */
    overflow: hidden;
}

/* --- Écran d'Accueil --- */
#start-screen { 
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 40px 20px; z-index: 20; background: #f8fafc; 
}
.action-card { 
    width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; 
    padding: 50px 20px; border-radius: 24px; background: white; border: 2px dashed #cbd5e1; 
    cursor: pointer; transition: all 0.3s; text-align: center; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); 
}
.action-card:hover { border-color: #4f46e5; transform: translateY(-4px); box-shadow: 0 10px 25px -5px rgba(79,70,229,0.15); background: #fafafa; }
.action-card i { font-size: 54px; color: #6366f1; margin-bottom: 20px; }

/* --- Toolbar PC Blanche Moderne --- */
.desktop-toolbar { 
    min-height: 64px; background: white; border-bottom: 1px solid #e2e8f0; display: flex; 
    align-items: center; padding: 8px 16px; gap: 8px; flex-shrink: 0; flex-wrap: wrap; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); z-index: 55; position: sticky; top: 0; 
}
.tool-divider { width: 1px; height: 32px; background: #e2e8f0; margin: 0 8px; }

.t-btn { 
    height: 40px; padding: 0 14px; display: flex; align-items: center; gap: 8px; border-radius: 8px; 
    color: #475569; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; 
    white-space: nowrap; border: none; background: transparent; 
}
.t-btn:hover { background: #f1f5f9; color: #0f172a; }
.t-btn.active { background: #e0e7ff; color: #4f46e5; }
.t-btn.t-icon { width: 40px; padding: 0; justify-content: center; }

.ui-select { background: white; border: 1px solid #cbd5e1; color: #334155; height: 36px; border-radius: 8px; padding: 0 12px; font-size: 13px; font-weight: 500; outline: none; cursor: pointer; }
.ui-input { background: white; border: 1px solid #cbd5e1; color: #334155; height: 36px; border-radius: 8px; padding: 0 8px; font-size: 13px; width: 60px; text-align: center; outline: none; font-weight: 500; }

.font-info-box { display: flex; flex-direction: column; justify-content: center; min-width: 120px; max-width: 160px; padding: 4px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }

/* Bouton Global Enregistrer (FAB) */
.global-fab { 
    position: fixed; bottom: 30px; right: 30px; background: #4f46e5; color: white; height: 60px; 
    padding: 0 24px; border-radius: 30px; display: flex; align-items: center; justify-content: center; 
    gap: 12px; font-size: 16px; font-weight: bold; box-shadow: 0 10px 25px -5px rgba(79,70,229,0.5); 
    cursor: pointer; z-index: 100; transition: all 0.3s; 
}
.global-fab:hover { transform: translateY(-3px); box-shadow: 0 15px 35px -5px rgba(79,70,229,0.6); background: #4338ca; }
.hidden-input { display: none !important; width: 0; height: 0; visibility: hidden; position: absolute; }

/* Dropdown Formes */
.ui-dropdown { position: relative; }
.ui-dropdown-menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    background: white; border: 1px solid #e2e8f0; border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.14); display: none; z-index: 9999;
    min-width: 170px; padding: 6px;
}
.ui-dropdown-menu.open { display: block; }
.ui-dropdown-item { padding: 10px 14px; color: #334155; font-size: 13px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 10px; border-radius: 6px; transition: background 0.1s; }
.ui-dropdown-item:hover { background: #f1f5f9; color: #0f172a; }

/* --- Mobile Layout --- */
.mobile-editor-header { display: none; }
.mobile-toolbar { display: none; }
.mobile-prop-toolbar { display: none; }

@media (max-width: 1024px) {
    .editor-header { display: none !important; }
    .desktop-toolbar { display: none !important; }

    .mobile-editor-header { 
        display: flex; position: sticky; top: 0; height: 52px; background: white; border-bottom: 1px solid #e2e8f0; 
        align-items: center; padding: 0 16px; justify-content: space-between; flex-shrink: 0; z-index: 40; box-shadow: 0 1px 3px rgba(0,0,0,0.08); 
    }
    .mobile-toolbar { 
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: white; 
        border-top: 1px solid #e2e8f0; justify-content: space-around; align-items: center; z-index: 50; 
        padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 15px rgba(0,0,0,0.08); 
    }

    .m-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #64748b; font-size: 9px; font-weight: 700; width: 48px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
    .m-btn i { font-size: 17px; transition: background 0.15s; }
    .m-btn.active { color: #4f46e5; }
    .m-btn.active i { background: #e0e7ff; padding: 3px 10px; border-radius: 10px; }

    .global-fab { bottom: 84px; right: 16px; width: 58px; height: 58px; padding: 0; border-radius: 50%; font-size: 21px; z-index: 99; }
    .global-fab span { display: none; }

    .mobile-prop-toolbar.visible {
        display: flex !important; flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 6px;
        position: fixed; bottom: calc(64px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 9990;
        background: white; border-top: 2px solid #e0e7ff; box-shadow: 0 -6px 24px rgba(79,70,229,0.13); padding: 9px 14px;
        animation: propToolbarIn 0.18s ease-out;
    }
    @keyframes propToolbarIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
}