/**
 * Éditeur « Personnaliser / Télécharger » — suit la maquette pdfG.php dans le layout dashboard.
 *
 * Couleurs : uniquement les variables du thème du dashboard (--card, --line, --muted, --brand…),
 * donc le mode sombre fonctionne sans code supplémentaire. Préfixe .cz- : aucun conflit.
 * Mobile first : une colonne ; l'aperçu devient un « dock » flottant (comme l'outil image).
 */
[hidden] { display: none !important; }

.cz { margin-inline: auto; max-width: 72rem; padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }

/* ---------- introduction + actions ---------- */
.cz-intro { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .85rem; margin-bottom: 1.1rem; }
.cz-eyebrow { margin-bottom: .2rem; color: var(--brand); font-size: .6875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.cz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.cz-actions .f-btn-add, .cz-actions .f-btn-alt { box-sizing: border-box; margin: 0; min-height: 2.5rem; line-height: 1.25; justify-content: center; }
.cz-synced { color: var(--ok); font-size: .6875rem; }
.cz-spinner {
    display: none; width: .8rem; height: .8rem; border: 2px solid rgb(255 255 255 / 45%);
    border-top-color: #fff; border-radius: 50%; animation: cz-spin .7s linear infinite;
}
.is-busy .cz-spinner { display: inline-block; }
@keyframes cz-spin { to { transform: rotate(360deg); } }
.cz-status { margin-bottom: 1rem; border: 1px solid var(--danger); border-radius: .65rem; padding: .75rem 1rem;
    color: var(--danger); background: var(--danger-soft); font-size: .875rem; }

/* ---------- grille ---------- */
.cz-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 761px) { .cz-workspace { grid-template-columns: minmax(0, 23.5rem) minmax(0, 1fr); gap: 1.25rem; } }

/* ---------- éditeur ---------- */
.cz-editor { padding: 1.15rem; }
.cz-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.cz-heading h2 { margin: 0; font-size: .875rem; font-weight: 700; }
.cz-small { color: var(--muted); font-size: .625rem; text-transform: uppercase; letter-spacing: .03em; }
.cz-field { margin-top: .8rem; }
.cz-field > label, .cz-group-label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .625rem; font-weight: 700; }
.cz-field textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
.cz-field .f-inp { font-size: .75rem; padding: .55rem .65rem; }
.cz-error { margin-top: .25rem; color: var(--danger); font-size: .6875rem; }
.cz-two { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 .65rem; }
@media (min-width: 420px) { .cz-two { grid-template-columns: 1fr 1fr; } }
.cz-divider { height: 1px; margin: 1.1rem 0; background: var(--line); }

/* thèmes : miniatures de la maquette */
.cz-themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 420px) { .cz-themes { grid-template-columns: repeat(4, 1fr); } }
.cz-theme { position: relative; }
.cz-theme input { position: absolute; opacity: 0; pointer-events: none; }
.cz-theme label {
    display: grid; min-height: 6.6rem; align-content: start; justify-items: center; gap: .35rem; padding: .55rem .35rem;
    border: 1px solid var(--line); border-radius: .6rem; color: var(--muted); cursor: pointer; font-size: .625rem;
    text-align: center;
}
.cz-theme input:checked + label { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.cz-theme input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }
.cz-thumb { width: 2.2rem; height: 2.2rem; padding: .3rem; border: 1px solid var(--line); border-radius: .25rem; background: #fff; }
.cz-thumb i { display: block; width: 100%; height: 3px; margin-bottom: 3px; border-radius: 2px; background: #b7c1d3; }
.cz-thumb i:first-child { width: 72%; height: 5px; background: var(--swatch, #1d4ed8); }
.cz-thumb.modern i:first-child { width: 7px; height: 21px; float: left; margin-right: 4px; }
.cz-thumb.modern i:nth-child(2) { width: 14px; margin-top: 1px; }
.cz-thumb.elegant { border-top: 4px solid var(--swatch, #1d4ed8); }
.cz-thumb.elegant i:first-child { margin-top: 2px; }
.cz-thumb.compact { padding: .25rem; }
.cz-thumb.compact i { height: 2px; margin-bottom: 2px; }
.cz-theme-copy { display: grid; gap: .08rem; }
.cz-theme-copy strong { color: var(--text); font-size: .625rem; line-height: 1.15; }
.cz-theme-copy small { color: var(--muted); font-size: .5rem; line-height: 1.22; }
.cz-theme input:checked + label .cz-theme-copy strong { color: var(--brand); }

.cz-color { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.cz-color-picker { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .625rem; }
.cz-color input[type="color"] { width: 2.4rem; height: 2.4rem; padding: 2px; border: 1px solid var(--line); border-radius: .45rem; background: var(--card); cursor: pointer; }
.cz-link { border: 0; background: none; padding: 0; color: var(--brand); font-size: .625rem; text-decoration: underline; cursor: pointer; }

.cz-checks { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; }
.cz-checks label { display: flex; align-items: center; gap: .5rem; min-height: 2.25rem; color: var(--text); font-size: .6875rem; cursor: pointer; }
.cz-checks input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.cz-note { margin: .9rem 0 0; color: var(--muted); font-size: .625rem; line-height: 1.5; }

/* ---------- aperçu ---------- */
.cz-preview-shell { overflow: hidden; border: 1px solid var(--line); border-radius: .85rem; background: var(--bg); }
.cz-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 3.2rem; padding: 0 1rem; border-bottom: 1px solid var(--line); background: var(--card); }
.cz-preview-heading h2 { margin: 0; font-size: .75rem; font-weight: 700; }
.cz-preview-meta { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .625rem; }
.cz-live { display: inline-flex; align-items: center; gap: .3rem; color: var(--ok); }
.cz-live::before { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; content: ""; }
.cz-stage { padding: 1.1rem; min-height: 24rem; }
.cz-paper { margin-inline: auto; overflow: hidden; background: #fff; box-shadow: 0 16px 42px rgb(28 39 68 / 14%); }
.cz-paper iframe { display: block; border: 0; background: #fff; }
.cz-dock-toggle { display: none; }

/* ---------- toast ---------- */
.cz-toast {
    position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 60; max-width: calc(100vw - 2.4rem); padding: .7rem .95rem;
    border-radius: .6rem; color: #fff; background: #20283a; box-shadow: 0 8px 30px rgb(0 0 0 / 25%); font-size: .75rem;
    opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none;
}
.cz-toast.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- mobile : aperçu flottant (même principe que l'outil image) ---------- */
@media (max-width: 760px) {
    .cz-actions { width: 100%; }
    .cz-actions .f-btn-add, .cz-actions .f-btn-alt { flex: 1 1 auto; }
    .cz-synced { display: none; }
    .cz-preview-shell {
        position: fixed; right: .75rem; bottom: max(.65rem, env(safe-area-inset-bottom, 0px)); left: .75rem; z-index: 40;
        height: 3.7rem; border-radius: .9rem; box-shadow: 0 8px 30px rgb(0 0 0 / 18%); background: var(--card);
        transition: height .22s ease;
    }
    .cz-preview-shell[aria-expanded="true"] { display: flex; flex-direction: column; height: min(78dvh, 44rem); }
    .cz-preview-heading { display: none; }
    .cz-dock-toggle {
        display: flex; box-sizing: border-box; width: 100%; min-height: 3.6rem; align-items: center; justify-content: space-between;
        gap: .75rem; padding: .55rem .9rem; border: 0; background: var(--card); color: var(--text); text-align: left; cursor: pointer;
    }
    .cz-dock-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; }
    .cz-dock-label, .cz-dock-action { display: inline-flex; align-items: center; gap: .55rem; }
    .cz-dock-label { font-size: .875rem; font-weight: 700; }
    .cz-dock-live { border-radius: 999px; padding: .2rem .45rem; color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); font-size: .625rem; font-weight: 600; }
    .cz-dock-action { color: var(--muted); font-size: .75rem; }
    .cz-dock-chevron { display: inline-block; color: var(--brand); font-size: 1rem; transition: transform .2s ease; }
    .cz-preview-shell[aria-expanded="true"] .cz-dock-chevron { transform: rotate(180deg); }
    .cz-stage-wrap { display: none; }
    .cz-preview-shell[aria-expanded="true"] .cz-stage-wrap { display: block; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
    .cz-stage { padding: .65rem; min-height: 0; }
    .cz-toast { bottom: 5.2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cz-preview-shell, .cz-dock-chevron, .cz-toast, .cz-spinner { transition: none; animation: none; }
}
