/* =======================================================================
   JSON EDITOR - Editeur JSON intelligent pour Caramel
   Style Apple-like coherent avec le design existant
   ======================================================================= */

/* Container principal */
.json-editor {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1d1d1f;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
    /* Permettre le scroll interne */
    flex: 1;
    min-height: 0;
    background: #f5f5f7;
    border-radius: 8px;
}

/* Empecher la compression des elements de l'editeur */
.json-editor>* {
    flex-shrink: 0;
}

/* Header de l'editeur */
.json-editor__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid #e5e5ea;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: white;
}

.json-editor__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.json-editor__title-icon {
    color: #007AFF;
}

.json-editor__header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.json-editor__help-btn {
    background: white;
    border: 1.5px solid #007AFF;
    color: #007AFF;
    cursor: pointer;
    padding: 5px 13px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    white-space: nowrap;
}

.json-editor__help-btn i {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.json-editor__help-btn span {
    font-size: 0.85rem;
    font-weight: 500;
}

.json-editor__help-btn:hover {
    background: #F0F7FF;
    border-color: #0051D5;
    color: #0051D5;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.15);
    transform: translateY(-0.5px);
}

.json-editor__help-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    background: #E5F2FF;
}

.json-editor__help-btn:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Styles pour le contenu des tutoriels dans le popover d'aide editeur */
.help-popover__content .help-fields-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 18px;
    font-size: 14px;
}

.help-popover__content .help-fields-table th {
    background: #f5f5f7;
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    color: #1d1d1f;
    border-bottom: 2px solid #e5e5ea;
}

.help-popover__content .help-fields-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f5;
    color: #3a3a3c;
    vertical-align: top;
}

.help-popover__content .help-fields-table tr:last-child td {
    border-bottom: none;
}

.help-popover__content .help-fields-table code {
    background: #f0f0f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #007AFF;
}

.help-popover__content .help-example--good,
.help-popover__content .help-example--bad {
    border-radius: 10px;
    padding: 12px 16px;
    margin: 8px 0 14px;
    font-size: 14px;
    line-height: 1.6;
}

.help-popover__content .help-example--good {
    background: #f0faf0;
    border-left: 4px solid #34C759;
}

.help-popover__content .help-example--bad {
    background: #fef5f5;
    border-left: 4px solid #FF3B30;
}

.help-popover__content .help-example--good code,
.help-popover__content .help-example--bad code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.help-popover__content .help-example-label {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-popover__content .help-example--good .help-example-label {
    color: #248A3D;
}

.help-popover__content .help-example--bad .help-example-label {
    color: #D70015;
}

.help-popover__content h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0 0 6px;
}

.help-popover__content h4 {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 18px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-popover__content h4 i {
    font-size: 14px;
    color: #007AFF;
}

.help-popover__content .help-activity-desc {
    color: #6e6e73;
    font-style: italic;
    margin: 0 0 14px;
}

.help-popover__content .help-math-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    margin: 8px 0 14px;
    font-size: 14px;
}

.help-popover__content .help-math-grid code {
    background: #f0f0f5;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #007AFF;
    white-space: nowrap;
}

.help-popover__content .help-math-grid span {
    color: #6e6e73;
    padding: 3px 0;
}

/* Indicateur de modifications non sauvegardees */
.json-editor__unsaved-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #FFF3CD;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #856404;
}

.json-editor__unsaved-indicator i {
    color: #f0ad4e;
}

/* =======================================================================
   SECTIONS PLIABLES
   ======================================================================= */

.json-editor__section {
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    overflow: hidden;
    transition: all 200ms ease;
}

.json-editor__section:hover {
    border-color: #d2d2d7;
}

.json-editor__section-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #fafafa;
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    text-align: left;
    transition: all 150ms ease;
}

.json-editor__section-header:hover {
    background: #f0f0f2;
}

.json-editor__section--expanded .json-editor__section-header {
    border-bottom-color: #e5e5ea;
}

.json-editor__section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.json-editor__section-title i {
    color: #007AFF;
    font-size: 0.9em;
}

.json-editor__section-count {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    background: #007AFF;
    color: #ffffff;
    border-radius: 10px;
    margin-left: 0.5rem;
}

.json-editor__section-icon {
    transition: transform 200ms ease;
    color: #86868b;
    font-size: 0.9em;
}

.json-editor__section--expanded .json-editor__section-icon {
    transform: rotate(180deg);
}

.json-editor__section-content {
    padding: 6px 8px 8px 8px;
    display: none;
    background: #ffffff;
}

.json-editor__section--expanded .json-editor__section-content {
    display: block;
}

.json-editor__section-fields {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Mode compact : checkboxes côte à côte */
.json-editor__section-fields--compact {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    align-items: center;
}

.json-editor__section-fields--compact > .json-editor__field--checkbox {
    flex: 0 0 auto;
    margin-bottom: 0;
}

.json-editor__section-fields--compact > .json-editor__field:not(.json-editor__field--checkbox) {
    flex: 1 1 100%;
}

/* =======================================================================
   CHAMPS DE FORMULAIRE
   ======================================================================= */

.json-editor__field {
    margin-bottom: 2px;
}

.json-editor__field:last-child {
    margin-bottom: 0;
}

.json-editor__label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6e6e73;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.json-editor__label--required::after {
    content: " *";
    color: #FF3B30;
}

.json-editor__input,
.json-editor__textarea,
.json-editor__select {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    background: #ffffff;
    color: #1d1d1f;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.json-editor__input:focus,
.json-editor__textarea:focus,
.json-editor__select:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.json-editor__input::placeholder,
.json-editor__textarea::placeholder {
    color: #86868b;
}

.json-editor__textarea {
    min-height: 42px;
    resize: none;
    line-height: 1.4;
    margin-bottom: 0;
}

.json-editor__textarea--large {
    min-height: 56px;
}

.json-editor__input--error,
.json-editor__textarea--error {
    border-color: #FF3B30;
}

.json-editor__input--error:focus,
.json-editor__textarea--error:focus {
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.json-editor__error {
    display: block;
    font-size: 0.75rem;
    color: #FF3B30;
    margin-top: 0.3rem;
}

.json-editor__hint {
    display: block;
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 0.3rem;
}

/* Select */
.json-editor__select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Checkbox */
.json-editor__checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.25rem 0;
}

.json-editor__checkbox {
    width: 20px;
    height: 20px;
    accent-color: #007AFF;
    cursor: pointer;
}

.json-editor__checkbox-label {
    font-size: 14px;
    color: #1d1d1f;
    cursor: pointer;
}

/* Multi-checkbox (sélection multiple de zones) */
.json-editor__multi-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}

.json-editor__multi-checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px 3px 6px;
    border: 1px solid #d2d2d7;
    border-radius: 16px;
    background: #f5f5f7;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
    font-size: 13px;
    line-height: 1.4;
    user-select: none;
}

.json-editor__multi-checkbox-item:hover {
    background: #e8e8ed;
}

.json-editor__multi-checkbox-item:has(input:checked) {
    background: #e8f0fe;
    border-color: #007AFF;
}

.json-editor__multi-checkbox-input {
    width: 15px;
    height: 15px;
    accent-color: #007AFF;
    cursor: pointer;
    margin: 0;
}

.json-editor__multi-checkbox-label {
    color: #1d1d1f;
    white-space: nowrap;
}

/* Champs en ligne */
.json-editor__field-row {
    display: flex;
    gap: 1rem;
}

.json-editor__field-row>.json-editor__field {
    flex: 1;
}

/* Groupe de champs dépliable */
.json-editor__field-group {
    margin: 4px 0;
}

.json-editor__field-group-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #636366;
    border-radius: 6px;
    transition: background-color 150ms ease;
    user-select: none;
}

.json-editor__field-group-header:hover {
    background: #e8e8ed;
    color: #1d1d1f;
}

.json-editor__field-group-header i {
    font-size: 10px;
    transition: transform 150ms ease;
}

.json-editor__field-group-content {
    padding: 6px 0 0 0;
}

/* =======================================================================
   ELEMENTS DE TABLEAU (cards, answers, pairs...)
   ======================================================================= */

.json-editor__array {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.json-editor__array-item {
    background: #fafafa;
    border: 1px solid #ebebf0;
    border-radius: 8px;
    padding: 6px;
    position: relative;
    transition: all 150ms ease;
}

.json-editor__array-item:hover {
    border-color: #d2d2d7;
}

/* === Sous-chapitres (Livre) === */
/* Compteur CSS qui se réinitialise à chaque chapitre normal et incrémente sur les sous-chapitres.
   Affiche A., B., C., ... devant le titre du sous-chapitre. */
.json-editor__field--array > .json-editor__array-list,
.json-editor__field--array-nested > .json-editor__nested-array-content {
    counter-reset: subchapter-counter;
}

.json-editor__array-item--subchapter {
    counter-increment: subchapter-counter;
    margin-left: 1.75rem;
    border-left: 3px solid #c7d2fe;
    background: #f5f3ff;
}

.json-editor__array-item--subchapter:hover {
    border-color: #818cf8;
}

.json-editor__array-item--subchapter .json-editor__array-item-title::before {
    content: counter(subchapter-counter, upper-alpha) ". ";
    color: #6366f1;
    font-weight: 700;
    margin-right: 4px;
}

.json-editor__array-item--subchapter .json-editor__array-item-number {
    background: #c7d2fe;
    color: #4338ca;
}

.json-editor__array-item--dragging {
    opacity: 0.5;
    border-style: dashed;
    border-color: #007AFF;
}

.json-editor__array-item--drag-over {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
}

.json-editor__array-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #ebebf0;
}

/* Items d'arrays imbriqués : plus légers (réponses, sous-questions) */
.json-editor__field--array-nested .json-editor__array-item {
    background: #ffffff;
    border-color: #ebebf0;
    padding: 4px 6px;
}

.json-editor__field--array-nested .json-editor__array-item-header {
    margin-bottom: 2px;
    padding-bottom: 2px;
    border-bottom: none;
}

.json-editor__field--array-nested .json-editor__array-item-content {
    padding-top: 0;
}

/* Masquer le texte résumé quand l'item est déplié (le contenu est visible juste en dessous) */
.json-editor__field--array-nested .json-editor__array-item:not(.json-editor__array-item--collapsed) .json-editor__array-item-title > span:last-child {
    display: none;
}

.json-editor__array-item-title {
    font-weight: 600;
    font-size: 13px;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.json-editor__array-item-number {
    width: 24px;
    height: 24px;
    background: #007AFF;
    color: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.json-editor__array-item-actions {
    display: flex;
    gap: 6px;
}

.json-editor__array-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: #ffffff;
    color: #6e6e73;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
    font-size: 12px;
}

.json-editor__array-btn:hover {
    background: #e5e5ea;
    color: #1d1d1f;
}

.json-editor__array-btn--danger:hover {
    background: #FF3B30;
    color: #ffffff;
}

.json-editor__array-btn--drag {
    cursor: grab;
}

.json-editor__array-btn--drag:active {
    cursor: grabbing;
}

/* Styles pour item plié */
.json-editor__array-item--collapsed .json-editor__array-item-content {
    display: none;
}

.json-editor__array-item--collapsed {
    padding-bottom: 6px;
}

.json-editor__array-item--collapsed .json-editor__array-item-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Mode compact : item sans header, champs inline */
.json-editor__array-item--compact {
    padding: 4px 6px;
    border-radius: 6px;
}

.json-editor__compact-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.json-editor__compact-row > .json-editor__array-item-number {
    flex-shrink: 0;
}

.json-editor__compact-fields {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Dans compact, les row groupes sont inline */
.json-editor__compact-fields > .json-editor__field-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.json-editor__compact-fields > .json-editor__field-row > .json-editor__field {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.json-editor__compact-fields > .json-editor__field-row > .json-editor__field--number {
    flex: 0 0 70px;
}

.json-editor__compact-fields > .json-editor__field-row > .json-editor__field--checkbox {
    flex: 0 0 auto;
}

/* Masquer les labels dans le mode compact (sauf le premier item pour contexte) */
.json-editor__array-item--compact:not(:first-child) .json-editor__label {
    display: none;
}

.json-editor__compact-fields .json-editor__label {
    font-size: 0.7rem;
    margin-bottom: 1px;
}

.json-editor__compact-fields .json-editor__input,
.json-editor__compact-fields .json-editor__select {
    padding: 5px 8px;
    font-size: 13px;
}

.json-editor__compact-delete {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #c7c7cc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background-color 120ms ease, color 120ms ease;
}

.json-editor__compact-delete:hover {
    background: #FF3B30;
    color: #ffffff;
}

/* Validation somme des scores (ex: fraction multichoice Moodle) */
.json-editor__select--error {
    border-color: #FF3B30 !important;
    background-color: #FFF5F5 !important;
    color: #c0392b;
}

.json-editor__sum-error {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-top: 4px;
    background: #FFF5F5;
    border: 1px solid #FFD4D4;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #c0392b;
}

.json-editor__sum-error::before {
    content: '\f071'; /* fa-exclamation-triangle */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
}

/* Checkbox inline avec champ texte (QCM) */
.json-editor__inline-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.json-editor__inline-checkbox-row > .json-editor__field--checkbox {
    flex-shrink: 0;
    margin-bottom: 0;
    padding-top: 20px;
}

.json-editor__inline-checkbox-row > .json-editor__field--text,
.json-editor__inline-checkbox-row > .json-editor__field--textarea,
.json-editor__inline-checkbox-row > .json-editor__field--richtext,
.json-editor__inline-checkbox-row > .json-editor__field--richtext-compact {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

/* Numéros pour niveaux imbriqués (réponses) */
.json-editor__field--array-nested .json-editor__array-item-number {
    background: #8e8e93;
    /* Gris pour différencier du bleu principal */
    font-size: 11px;
    width: 20px;
    height: 20px;
}

/* Erreurs de validation visuelles */
.json-editor__field--error {
    border: 1px solid #FF3B30;
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 59, 48, 0.05);
}

.json-editor__input--error,
.json-editor__textarea--error,
.json-editor__select--error {
    border-color: #FF3B30 !important;
    background-color: #FFF5F5 !important;
}

/* Sous-section pliable dans un item */
.json-editor__array-item-subsection {
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid #e5e5ea;
}

.json-editor__array-item-subsection-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #86868b;
    cursor: pointer;
    padding: 4px 0;
}

.json-editor__array-item-subsection-header:hover {
    color: #1d1d1f;
}

.json-editor__array-item-subsection-header i {
    font-size: 0.7em;
    transition: transform 150ms ease;
}

.json-editor__array-item-subsection--expanded .json-editor__array-item-subsection-header i {
    transform: rotate(90deg);
}

.json-editor__array-item-subsection-content {
    display: none;
    padding-left: 4px;
    padding-top: 4px;
}

.json-editor__array-item-subsection--expanded .json-editor__array-item-subsection-content {
    display: block;
}

/* Champs compacts dans la sous-section et dans les items nested */
.json-editor__array-item-subsection-content .json-editor__field {
    margin-bottom: 0.25rem;
}

.json-editor__array-item-subsection-content .json-editor__textarea,
.json-editor__field--array-nested .json-editor__textarea {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.35;
}

.json-editor__array-item-subsection-content .json-editor__label {
    font-size: 0.78rem;
    margin-bottom: 0.15rem;
}

/* Bouton d'ajout */
.json-editor__add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border: 2px dashed #d2d2d7;
    border-radius: 8px;
    background: transparent;
    color: #007AFF;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 150ms ease;
}

.json-editor__add-btn:hover {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
}

.json-editor__add-btn i {
    font-size: 0.9em;
}

/* =======================================================================
   LAYOUT GRILLE POUR CHART ITEMS
   ======================================================================= */

/* Items Chart : disposition en grille compacte (4 colonnes) */
.json-editor__array-item-content[data-type="chart-item"] {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 8px;
    align-items: start;
}

.json-editor__array-item-content[data-type="chart-item"] > .json-editor__field {
    margin-bottom: 0;
}

/* =======================================================================
   LAYOUT GRILLE POUR ESSAY KEYWORDS
   ======================================================================= */

/* Mots-clés Essay : mot-clé + points sur la même ligne, le reste en pleine largeur */
.json-editor__array-item-content[data-type="essay-keyword"] {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 8px;
    align-items: start;
}

/* Le champ texte (mot-clé) prend la première colonne */
.json-editor__array-item-content[data-type="essay-keyword"] > .json-editor__field--text {
    grid-column: 1;
    margin-bottom: 0;
}

/* Le champ number (points) à côté, largeur fixe */
.json-editor__array-item-content[data-type="essay-keyword"] > .json-editor__field--number {
    grid-column: 2;
    margin-bottom: 0;
    min-width: 80px;
    max-width: 100px;
}

/* Explication et checkbox en pleine largeur en dessous */
.json-editor__array-item-content[data-type="essay-keyword"] > .json-editor__field--textarea,
.json-editor__array-item-content[data-type="essay-keyword"] > .json-editor__field--checkbox {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

/* =======================================================================
   EDITEUR DE FEEDBACK RANGES
   ======================================================================= */

.json-editor__feedback-ranges {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.json-editor__feedback-range {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 6px;
    background: #fafafa;
    border: 1px solid #ebebf0;
    border-radius: 6px;
    min-height: 36px;
}

.json-editor__feedback-range-inputs {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.json-editor__feedback-range-input {
    width: 50px;
    text-align: center;
    padding: 4px !important;
    font-size: 12px !important;
}

.json-editor__feedback-range-separator {
    color: #6e6e73;
    font-weight: 500;
    font-size: 12px;
}

.json-editor__feedback-range-percent {
    font-size: 11px;
    color: #86868b;
}

.json-editor__feedback-range-text {
    flex: 1;
}

.json-editor__feedback-range-text .json-editor__textarea {
    min-height: 24px;
    padding: 3px 8px;
    font-size: 12px;
    margin: 0;
    line-height: 1.3;
}

.json-editor__feedback-range-actions {
    flex-shrink: 0;
}

.json-editor__feedback-range-actions .json-editor__array-btn {
    width: 26px;
    height: 26px;
    font-size: 11px;
}

/* Barre visuelle des tranches */
.json-editor__feedback-bar {
    height: 6px;
    background: #e5e5ea;
    border-radius: 3px;
    display: flex;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.json-editor__feedback-bar-segment {
    height: 100%;
    transition: width 200ms ease;
}

.json-editor__feedback-bar-segment:nth-child(6n+1) {
    background: #FF3B30;
}

.json-editor__feedback-bar-segment:nth-child(6n+2) {
    background: #FF9500;
}

.json-editor__feedback-bar-segment:nth-child(6n+3) {
    background: #FFCC00;
}

.json-editor__feedback-bar-segment:nth-child(6n+4) {
    background: #34C759;
}

.json-editor__feedback-bar-segment:nth-child(6n+5) {
    background: #007AFF;
}

.json-editor__feedback-bar-segment:nth-child(6n+6) {
    background: #5856D6;
}

/* =======================================================================
   BARRE D'ACTIONS (footer) - Cachée car les boutons sont dans le footer de la modale
   ======================================================================= */

.json-editor__actions {
    display: none;
}

.json-editor__actions-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.json-editor__actions-right {
    display: flex;
    gap: 12px;
}

.json-editor__btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.json-editor__btn--primary {
    background: #007AFF;
    color: #ffffff;
    border: none;
}

.json-editor__btn--primary:hover {
    background: #006ee6;
    transform: translateY(-1px);
}

.json-editor__btn--primary:active {
    transform: translateY(0);
}

.json-editor__btn--primary:disabled {
    background: #86868b;
    cursor: not-allowed;
    transform: none;
}

.json-editor__btn--secondary {
    background: #ffffff;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
}

.json-editor__btn--secondary:hover {
    background: #f5f5f7;
    border-color: #c7c7cc;
}

.json-editor__btn--danger {
    background: #ffffff;
    color: #FF3B30;
    border: 1px solid #FF3B30;
}

.json-editor__btn--danger:hover {
    background: #FF3B30;
    color: #ffffff;
}

/* =======================================================================
   OBJETS IMBRIQUES
   ======================================================================= */

.json-editor__nested {
    background: #fafafa;
    border: 1px solid #e5e5ea;
    border-radius: 8px;
    padding: 12px;
    margin-top: 0.5rem;
}

.json-editor__nested-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6e6e73;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* =======================================================================
   LOADING & ETATS
   ======================================================================= */

.json-editor__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #6e6e73;
    gap: 1rem;
}

.json-editor__loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e5ea;
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: json-editor-spin 0.8s linear infinite;
}

@keyframes json-editor-spin {
    to {
        transform: rotate(360deg);
    }
}

.json-editor__empty {
    text-align: center;
    padding: 2rem;
    color: #86868b;
}

.json-editor__empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #d2d2d7;
}

/* =======================================================================
   VALIDATION VISUELLE
   ======================================================================= */

.json-editor__validation-summary {
    background: #FFEBEE;
    border: 1px solid #FFCDD2;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 1rem;
}

.json-editor__validation-summary-title {
    font-weight: 600;
    color: #C62828;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.json-editor__validation-summary-list {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.85rem;
    color: #B71C1C;
}

/* =======================================================================
   BOUTONS FOOTER MODALE (mode édition)
   ======================================================================= */

.preview-modal__cancel-btn,
.preview-modal__save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 150ms ease;
    font-family: inherit;
}

.preview-modal__cancel-btn {
    background: #ffffff;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
}

.preview-modal__cancel-btn:hover {
    background: #f5f5f7;
    border-color: #c7c7cc;
}

.preview-modal__save-btn {
    background: #007AFF;
    color: #ffffff;
    border: none;
}

.preview-modal__save-btn:hover {
    background: #0056CC;
    transform: translateY(-1px);
}

/* Colonnes du footer en mode édition */
.preview-modal__footer-col {
    flex: 1;
    display: flex;
    align-items: center;
}

.preview-modal__footer-col--center {
    justify-content: center;
}

.preview-modal__footer-col--right {
    justify-content: flex-end;
}

/* Bouton Aide dans le footer éditeur */
.preview-modal__editor-help-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 150ms ease;
    font-family: inherit;
    background: #ffffff;
    color: #007AFF;
    border: 1.5px solid #007AFF;
}

.preview-modal__editor-help-btn:hover {
    background: #F0F7FF;
    border-color: #0051D5;
    color: #0051D5;
}

/* =======================================================================
   RESPONSIVE
   ======================================================================= */

@media (max-width: 767px) {
    .json-editor {
        padding: 1rem;
    }

    .json-editor__field-row {
        flex-direction: column;
        gap: 0;
    }

    .json-editor__array-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .json-editor__array-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .json-editor__feedback-range {
        flex-direction: column;
    }

    .json-editor__feedback-range-inputs {
        width: 100%;
        justify-content: center;
    }

    .json-editor__actions {
        flex-direction: column;
        gap: 1rem;
    }

    .json-editor__actions-left,
    .json-editor__actions-right {
        width: 100%;
        justify-content: center;
    }

    .json-editor__btn {
        flex: 1;
        justify-content: center;
    }
}

/* Desktop: colonnes pour les formulaires larges */
@media (min-width: 1024px) {
    .json-editor__section-content--two-col {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

/* =======================================================================
   INTEGRATION AVEC LA MODALE DE PREVISUALISATION
   ======================================================================= */

/* Quand l'éditeur JSON est actif dans la modale, le conteneur preview s'adapte */
.preview-modal__preview--editor {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
    /* Empecher le scroll externe pour laisser l'editeur gerer le sien */
    min-height: 0 !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

/* Le content de la modale conserve son scroll naturel */
.preview-modal__content--editor {
    /* Garder overflow-y: auto du parent */
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
    /* Eviter les doubles scrollbars */
}

/* =======================================================================
   GRILLE D'EVALUATION (rubricGrid) - Editeur Devoir
   ======================================================================= */

.json-editor__rubric-grid {
    margin-bottom: 0.25rem;
}

/* En-tête : titre + boutons d'ajout */
.json-editor__rubric-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.json-editor__rubric-grid-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1d1d1f;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.json-editor__rubric-grid-btn-group {
    display: flex;
    gap: 6px;
}

.json-editor__rubric-grid-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1.5px dashed #d2d2d7;
    border-radius: 6px;
    background: transparent;
    color: #007AFF;
    cursor: pointer;
    transition: all 150ms ease;
    font-family: inherit;
}

.json-editor__rubric-grid-btn:hover {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
}

.json-editor__rubric-grid-btn i {
    font-size: 10px;
}

/* Message vide */
.json-editor__rubric-grid-empty {
    text-align: center;
    padding: 1.5rem;
    color: #86868b;
    font-size: 0.9rem;
    border: 2px dashed #e5e5ea;
    border-radius: 8px;
    background: #fafafa;
}

/* Conteneur du tableau (scroll horizontal) */
.json-editor__rubric-grid-table-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e5ea;
    border-radius: 8px;
}

/* Tableau principal */
.json-editor__rubric-grid-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 400px;
}

/* Cellules d'en-tête */
.json-editor__rubric-grid-th-criterion,
.json-editor__rubric-grid-th-level,
.json-editor__rubric-grid-th-actions {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    background: #f5f5f7;
    border-bottom: 2px solid #e5e5ea;
    color: #1d1d1f;
    white-space: nowrap;
}

.json-editor__rubric-grid-th-criterion {
    text-align: left;
    width: 140px;
    min-width: 120px;
}

.json-editor__rubric-grid-th-level {
    min-width: 160px;
}

.json-editor__rubric-grid-th-actions {
    width: 42px;
    min-width: 42px;
}

/* Bouton supprimer colonne (dans l'en-tête de niveau) */
.json-editor__rubric-grid-btn--del-col {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #86868b;
    cursor: pointer;
    font-size: 10px;
    margin-left: 4px;
    padding: 0;
    transition: all 150ms ease;
    vertical-align: middle;
}

.json-editor__rubric-grid-btn--del-col:hover {
    background: #FF3B30;
    color: #ffffff;
}

/* Cellule nom du critère */
.json-editor__rubric-grid-td-criterion {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e5ea;
    border-right: 1px solid #e5e5ea;
    vertical-align: top;
    background: #fafafc;
}

/* Handle drag & drop (dans la colonne actions) */
.json-editor__rubric-grid-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    cursor: grab;
    color: #c7c7cc;
    font-size: 12px;
    border-radius: 6px;
    transition: color 150ms ease, background 150ms ease;
    user-select: none;
}

.json-editor__rubric-grid-drag-handle:hover {
    color: #007AFF;
    background: rgba(0, 122, 255, 0.08);
}

.json-editor__rubric-grid-drag-handle:active {
    cursor: grabbing;
}

/* Ligne en cours de glissement */
.json-editor__rubric-grid-row--dragging {
    opacity: 0.4;
}

/* Ligne cible du drop */
.json-editor__rubric-grid-row--drag-over {
    outline: 2px dashed #007AFF;
    outline-offset: -2px;
    background: rgba(0, 122, 255, 0.04);
}

/* Champ nom du critère (textarea auto-resize) */
.json-editor__rubric-grid-input-name {
    width: 100%;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    background: #ffffff;
    color: #1d1d1f;
    resize: vertical;
    overflow: hidden;
    min-height: 32px;
    line-height: 1.4;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.json-editor__rubric-grid-input-name:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* Cellule niveau (score + descripteur) */
.json-editor__rubric-grid-td-level {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e5ea;
    border-right: 1px solid #e5e5ea;
    vertical-align: top;
}

/* Ligne score dans la cellule */
.json-editor__rubric-grid-score-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.json-editor__rubric-grid-score-label {
    font-size: 11px;
    font-weight: 500;
    color: #6e6e73;
    flex-shrink: 0;
}

.json-editor__rubric-grid-input-score {
    width: 50px;
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid #d2d2d7;
    border-radius: 5px;
    background: #ffffff;
    color: #1d1d1f;
    text-align: center;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.json-editor__rubric-grid-input-score:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* Textarea descripteur (auto-resize) */
.json-editor__rubric-grid-textarea-def {
    width: 100%;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    background: #ffffff;
    color: #1d1d1f;
    resize: vertical;
    overflow: hidden;
    line-height: 1.4;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.json-editor__rubric-grid-textarea-def:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* Cellule actions (drag handle + suppression empilés) */
.json-editor__rubric-grid-td-actions {
    padding: 4px;
    border-bottom: 1px solid #e5e5ea;
    vertical-align: middle;
}

/* Conteneur empilé : drag handle au-dessus, corbeille en-dessous */
.json-editor__rubric-grid-actions-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.json-editor__rubric-grid-btn--del-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: #f5f5f7;
    color: #86868b;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    transition: all 150ms ease;
}

.json-editor__rubric-grid-btn--del-row:hover {
    background: #FF3B30;
    color: #ffffff;
}

/* Responsive : sur petit écran, le tableau scrolle horizontalement */
@media (max-width: 767px) {
    .json-editor__rubric-grid-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .json-editor__rubric-grid-table {
        min-width: 500px;
    }
}

/* =======================================================================
   DARK MODE SUPPORT (si jamais implementé)
   ======================================================================= */

@media (prefers-color-scheme: dark) {
    /* Preparer pour le dark mode futur */
}

/* =======================================================================
   ANIMATIONS
   ======================================================================= */

.json-editor__section-content {
    animation: json-editor-fadeIn 200ms ease;
}

@keyframes json-editor-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.json-editor__array-item {
    animation: json-editor-slideIn 200ms ease;
}

@keyframes json-editor-slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =======================================================================
   CHAMP IMAGE — Widget d'upload et prévisualisation
   ======================================================================= */

/* Zone de dépôt */
.json-editor__image-dropzone {
    position: relative;
    border: 2px dashed var(--border-color, #ccc);
    border-radius: 6px;
    padding: 12px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: var(--bg-secondary, #fafafa);
}

.json-editor__image-dropzone:hover {
    border-color: var(--primary-color, #007AFF);
    background: var(--bg-hover, #f0f7ff);
}

.json-editor__image-dropzone--dragover {
    border-color: var(--primary-color, #007AFF);
    background: var(--bg-hover, #f0f7ff);
    z-index: 2;
}

.json-editor__image-dropzone-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.json-editor__image-dropzone-content i {
    font-size: 1.3rem;
    color: var(--text-secondary, #999);
}

.json-editor__image-dropzone-content p {
    margin: 0;
    color: var(--text-primary, #333);
    font-size: 0.85rem;
}

.json-editor__image-hint {
    font-size: 0.75rem;
    color: var(--text-secondary, #999);
    display: none; /* Affiché seulement au hover via la dropzone */
}

.json-editor__image-dropzone:hover .json-editor__image-hint {
    display: inline;
}

/* Input file caché — piloté par JS via click programmatique */
.json-editor__image-input {
    display: none;
}

/* Prévisualisation */
.json-editor__image-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.json-editor__image-preview-container {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color, #ddd);
    max-width: 100%;
}

.json-editor__image-preview-img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    background: var(--bg-secondary, #f5f5f5);
}

/* Bouton supprimer (coin supérieur droit de l'image) */
.json-editor__image-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s, transform 0.15s;
    opacity: 0;
    transform: scale(0.8);
}

.json-editor__image-preview-container:hover .json-editor__image-remove-btn {
    opacity: 1;
    transform: scale(1);
}

.json-editor__image-remove-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

/* Informations sous l'image */
.json-editor__image-info {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
}

/* --- Champs média (audio/vidéo) — éditeur « Image interactive » --- */
.json-editor__media-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.json-editor__media-player {
    width: 100%;
    border-radius: 8px;
}
audio.json-editor__media-player { height: 40px; }
video.json-editor__media-player {
    max-height: 240px;
    background: #000;
}
.json-editor__media-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
}
.json-editor__media-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Le bouton supprimer du média est inline (pas en survol d'image) → toujours visible */
.json-editor__media-remove-btn {
    position: static;
    opacity: 1;
    transform: none;
    flex: 0 0 auto;
}

/* Message d'erreur image */
.json-editor__image-error {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3f3;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    color: #c62828;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: json-editor-slideIn 200ms ease;
}

.json-editor__image-error i {
    color: #e53935;
}

/* Responsive */
@media (max-width: 600px) {
    .json-editor__image-dropzone {
        padding: 16px;
    }

    .json-editor__image-dropzone-content i {
        font-size: 1.5rem;
    }

    .json-editor__image-preview-img {
        max-height: 150px;
    }
}

/* =======================================================================
   MODALE DE CONFIRMATION (3 BOUTONS)
   ======================================================================= */

/* Overlay partagé pour toutes les modales de confirmation de l'éditeur */
.confirm-modal-overlay,
.json-editor__modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--backdrop-dark);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-confirm);
    animation: confirm-fade-in 0.2s ease-out;
}

.confirm-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    animation: confirm-slide-up 0.2s ease-out;
}

.confirm-modal__header h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
}

.confirm-modal__body p {
    margin: 0 0 1.5rem 0;
    font-size: 0.95rem;
    color: #6e6e73;
    line-height: 1.4;
}

.confirm-modal__footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.confirm-modal__btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    border: none;
    font-family: inherit;
}

.confirm-modal__btn--primary {
    background: #007AFF;
    color: #ffffff;
}

.confirm-modal__btn--primary:hover {
    background: #0056CC;
}

.confirm-modal__btn--secondary {
    background: #f5f5f7;
    color: #1d1d1f;
}

.confirm-modal__btn--secondary:hover {
    background: #e5e5ea;
}

.confirm-modal__btn--danger {
    background: #ffffff;
    color: #FF3B30;
    border: 1px solid #FF3B30;
}

.confirm-modal__btn--danger:hover {
    background: #FF3B30;
    color: #ffffff;
}

@keyframes confirm-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes confirm-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* =======================================================================
   Champ couleur (Color picker)
   ======================================================================= */

.json-editor__field--color {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.json-editor__color-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.json-editor__color-wrapper:focus-within {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.json-editor__color-input {
    width: 36px;
    height: 34px;
    padding: 3px;
    border: none;
    border-right: 1px solid #e5e5ea;
    cursor: pointer;
    background: #fafafa;
    flex-shrink: 0;
}

.json-editor__color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.json-editor__color-input::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.json-editor__color-text {
    flex: 1;
    min-width: 70px;
    max-width: 100px;
    padding: 6px 8px;
    border: none;
    font-family: monospace;
    font-size: 13px;
    background: transparent;
    text-transform: uppercase;
    color: #1d1d1f;
}

.json-editor__color-text:focus {
    outline: none;
}

/* =======================================================================
   TAG LIST (liste de mots en pastilles)
   ======================================================================= */

.json-editor__tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #ffffff;
    min-height: 42px;
    align-items: center;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    cursor: text;
}

.json-editor__tag-container:focus-within {
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.json-editor__tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 10px;
    background: #e8f0fe;
    border: 1px solid #c4d7f2;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    color: #1a4b8e;
    line-height: 1.3;
    transition: background-color 120ms ease, border-color 120ms ease;
    max-width: 100%;
}

.json-editor__tag:hover {
    background: #d4e4fc;
    border-color: #a3c0e8;
}

.json-editor__tag-text {
    cursor: text;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.json-editor__tag-edit {
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 0;
    min-width: 30px;
    width: auto;
}

.json-editor__tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #6e8ab5;
    cursor: pointer;
    font-size: 10px;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 120ms ease, color 120ms ease;
}

.json-editor__tag-remove:hover {
    background: #FF3B30;
    color: #ffffff;
}

.json-editor__tag-add {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: #86868b;
    padding: 4px 6px;
    min-width: 60px;
    flex: 1;
}

.json-editor__tag-add::placeholder {
    color: #c7c7cc;
    font-size: 13px;
}

/* Toggle segmenté (URL / Image) */
.json-editor__toggle {
    display: inline-flex;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f7;
    margin-top: 2px;
}

.json-editor__toggle-option {
    padding: 6px 16px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #86868b;
    transition: background 150ms ease, color 150ms ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.json-editor__toggle-option:not(:last-child) {
    border-right: 1px solid #d2d2d7;
}

.json-editor__toggle-option--active {
    background: #007AFF;
    color: #ffffff;
}

.json-editor__toggle-option:hover:not(.json-editor__toggle-option--active) {
    background: #e8e8ed;
    color: #1d1d1f;
}

.json-editor__toggle-option i {
    font-size: 12px;
}

/* =======================================================================
   LAYOUT MAITRE-DETAIL
   ======================================================================= */

.json-editor--master-detail {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Occupe toute la hauteur disponible du parent flex pour empêcher le scroll
       externe : sinon le moindre micro-débordement fait scroller la modale et
       on voit la TOC de gauche bouger légèrement avec le contenu. */
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.json-editor__body {
    display: grid;
    grid-template-columns: minmax(180px, 28%) 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    background: #ffffff;
}

/* =======================================================================
   PANNEAU NAVIGATION (gauche)
   ======================================================================= */

.json-editor__nav {
    overflow-y: auto;
    background: #fafafa;
    border-right: 1px solid #e5e5ea;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.json-editor__nav-section {
    display: flex;
    flex-direction: column;
}

/* Bouton section */
.json-editor__nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background-color 150ms ease, color 150ms ease;
}

.json-editor__nav-item:hover {
    background: #e8e8ed;
    color: #1d1d1f;
}

.json-editor__nav-item--active {
    background: #007AFF;
    color: #ffffff;
}

.json-editor__nav-item--active:hover {
    background: #0066d6;
    color: #ffffff;
}

.json-editor__nav-item-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.json-editor__nav-item--active .json-editor__nav-item-icon {
    color: #ffffff;
}

.json-editor__nav-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badge compteur dans le nav */
.json-editor__nav-count {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    background: rgba(0, 0, 0, 0.08);
    color: #6e6e73;
    border-radius: 10px;
    flex-shrink: 0;
}

.json-editor__nav-item--active .json-editor__nav-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Liste d'items dans le nav */
.json-editor__nav-items {
    display: none;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0 4px 8px;
    margin-top: 2px;
    max-height: 50vh;
    overflow-y: auto;
}

.json-editor__nav-items--visible {
    display: flex;
}

/* Item dans le nav */
.json-editor__nav-subitem {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #3a3a3c;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.json-editor__nav-subitem:hover {
    background: #f0f0f2;
    border-color: #e5e5ea;
}

.json-editor__nav-subitem--active {
    background: #e8f0fe;
    border-color: #007AFF;
    color: #1d1d1f;
    font-weight: 500;
}

.json-editor__nav-subitem--dragging {
    opacity: 0.4;
}

.json-editor__nav-subitem--drag-over {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.08);
}

.json-editor__nav-subitem-drag {
    color: #c7c7cc;
    cursor: grab;
    padding: 0 2px;
    flex-shrink: 0;
    font-size: 10px;
}

.json-editor__nav-subitem-drag:active {
    cursor: grabbing;
}

.json-editor__nav-subitem:hover .json-editor__nav-subitem-drag {
    color: #86868b;
}

.json-editor__nav-subitem-number {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #e5e5ea;
    color: #636366;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.json-editor__nav-subitem--active .json-editor__nav-subitem-number {
    background: #007AFF;
    color: #ffffff;
}

/* === Indicateur de rattachement parent (sous-chapitre Livre) === */
.json-editor__subchapter-parent-info {
    margin-top: 6px;
    padding: 6px 10px;
    background: #eef2ff;
    border-left: 3px solid #6366f1;
    border-radius: 6px;
    color: #4338ca;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.json-editor__subchapter-parent-info i {
    font-size: 11px;
    color: #6366f1;
}

/* === Sous-chapitres dans le menu de gauche (Livre) === */
/* Léger décalage à droite + pastille violette pour bien différencier les sous-chapitres */
.json-editor__nav-subitem--subchapter {
    margin-left: 1.25rem;
    border-left: 2px solid #c7d2fe;
}

.json-editor__nav-subitem--subchapter .json-editor__nav-subitem-number {
    background: #c7d2fe;
    color: #4338ca;
}

.json-editor__nav-subitem--subchapter.json-editor__nav-subitem--active .json-editor__nav-subitem-number {
    background: #6366f1;
    color: #ffffff;
}

.json-editor__nav-subitem-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.json-editor__nav-subitem-status {
    font-size: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.json-editor__nav-subitem-status--complete {
    color: #34C759;
}

.json-editor__nav-subitem-status--error {
    color: #FF9500;
}

.json-editor__nav-subitem-status--empty {
    color: #d2d2d7;
}

/* Bouton ajouter dans le nav */
.json-editor__nav-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    margin-top: 4px;
    border: 1.5px dashed #d2d2d7;
    border-radius: 6px;
    background: transparent;
    color: #007AFF;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.json-editor__nav-add-btn:hover {
    background: #f0f7ff;
    border-color: #007AFF;
}

.json-editor__nav-add-btn--large {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
}

/* =======================================================================
   PANNEAU DETAIL (droite)
   ======================================================================= */

.json-editor__detail {
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* Header du detail */
.json-editor__detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e5ea;
    flex-shrink: 0;
}

.json-editor__detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
}

.json-editor__detail-title i {
    color: #007AFF;
    font-size: 13px;
}

.json-editor__detail-item-number {
    width: 26px;
    height: 26px;
    background: #007AFF;
    color: #ffffff;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

/* Actions du detail */
.json-editor__detail-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.json-editor__detail-nav-btn,
.json-editor__detail-action-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #e5e5ea;
    border-radius: 6px;
    background: #ffffff;
    color: #636366;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 150ms ease;
}

.json-editor__detail-nav-btn:hover:not(:disabled),
.json-editor__detail-action-btn:hover {
    background: #f0f0f2;
    border-color: #d2d2d7;
    color: #1d1d1f;
}

.json-editor__detail-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.json-editor__detail-action-btn--danger:hover {
    background: #FF3B30;
    border-color: #FF3B30;
    color: #ffffff;
}

.json-editor__detail-actions-sep {
    width: 1px;
    height: 20px;
    background: #e5e5ea;
    margin: 0 4px;
}

/* Contenu du detail */
.json-editor__detail-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    justify-content: flex-start;
    align-content: flex-start;
}

/* Etat vide */
.json-editor__detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: #86868b;
    text-align: center;
    flex: 1;
}

.json-editor__detail-empty i {
    font-size: 32px;
    color: #d2d2d7;
}

.json-editor__detail-empty p {
    font-size: 14px;
    margin: 0;
}

/* =======================================================================
   AMELIORATIONS PANNEAU DETAIL
   ======================================================================= */

/* Champs dans le detail : labels plus lisibles */
.json-editor__detail-content > .json-editor__field > .json-editor__label,
.json-editor__detail-content > .json-editor__field-row .json-editor__label {
    font-size: 0.8rem;
    margin-bottom: 3px;
    color: #48484a;
}

/* Lignes de champs cote a cote (row groups) */
.json-editor__detail-content > .json-editor__field-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.json-editor__detail-content > .json-editor__field-row > .json-editor__field {
    flex: 1;
    min-width: 0;
}

/* Champs number : largeur reduite dans une row */
.json-editor__detail-content > .json-editor__field-row > .json-editor__field--number {
    flex: 0 0 80px;
}

/* Checkbox dans une row : compacte, alignee au bas du label */
.json-editor__detail-content > .json-editor__field-row > .json-editor__field--checkbox {
    flex: 0 0 auto;
    padding-top: 18px;
}

/* Champs color dans une row : compacts, alignes */
.json-editor__detail-content > .json-editor__field-row > .json-editor__field--color {
    flex: 0 1 auto;
    min-width: 0;
}

.json-editor__detail-content > .json-editor__field-row > .json-editor__field--color .json-editor__color-text {
    max-width: 80px;
}

/* Mise en valeur du premier champ (souvent le titre ou la question) */
.json-editor__detail-content > .json-editor__field:first-child .json-editor__input,
.json-editor__detail-content > .json-editor__field:first-child .json-editor__textarea {
    font-size: 14px;
    font-weight: 500;
    border-color: #c7c7cc;
}

/* Sections pliables dans le detail : espacement */
.json-editor__detail-content .json-editor__array-item-subsection {
    margin-top: 4px;
    border-top-color: #e5e5ea;
}

/* Animation douce lors du changement d'item */
.json-editor__detail-content {
    animation: detailFadeIn 150ms ease;
}

@keyframes detailFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Boutons nav prev/next : plus gros touch target */
.json-editor__detail-nav-btn {
    min-width: 32px;
    min-height: 32px;
}

/* =======================================================================
   RESPONSIVE : ecrans < 768px
   ======================================================================= */

@media (max-width: 768px) {
    .json-editor__body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .json-editor__nav {
        border-right: none;
        border-bottom: 1px solid #e5e5ea;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        padding: 4px 6px;
        gap: 4px;
    }

    .json-editor__nav-section {
        flex-shrink: 0;
        position: relative;
    }

    /* Sur mobile, la liste d'items est un dropdown positionne sous le bouton section */
    .json-editor__nav-items {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 10;
        background: #ffffff;
        border: 1px solid #e5e5ea;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        padding: 4px;
        max-height: 200px;
        min-width: 180px;
        overflow-y: auto;
    }

    /* Ouvrir le dropdown seulement au clic via la classe JS */
    .json-editor__nav-items--mobile-open {
        display: flex !important;
    }

    .json-editor__nav-subitem-drag {
        display: none;
    }

    /* Indicateur chevron sur les sections avec items (dropdown) */
    .json-editor__nav-section:has(.json-editor__nav-items) .json-editor__nav-item::after {
        content: '\f078'; /* fa-chevron-down */
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 9px;
        margin-left: 4px;
        opacity: 0.6;
    }

    /* Header detail plus compact sur mobile */
    .json-editor__detail-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .json-editor__detail {
        padding: 8px 10px;
    }

    /* Stacker les row groups sur mobile */
    .json-editor__detail-content > .json-editor__field-row {
        flex-direction: column;
        gap: 4px;
    }
}

