/* Éditeur d'image et vignettes d'émission (préfixe .img-). Charte claire ; canevas sur fond neutre. */

/* ---------- Liste ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.img-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3);
  cursor: pointer; transition: border-color var(--duration) var(--ease);
}
.img-card:hover, .img-card:focus-visible { border-color: var(--accent); outline: none; }
.img-card-thumb {
  aspect-ratio: 16 / 9; border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 13px;
}
.img-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-card-meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; gap: var(--space-2); }
.img-card-actions { display: flex; justify-content: flex-end; }

/* ---------- Éditeur ---------- */
.img-editor { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; background: var(--bg); }
.img-topbar {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; min-height: 48px;
}
.img-topbar-group { display: flex; align-items: center; gap: var(--space-1); }
.img-topbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 var(--space-1); }
.img-topbar-spacer { flex: 1; }
.img-name { font-family: var(--font-heading); font-weight: 600; font-size: 16px; border: 1px solid transparent; border-radius: var(--radius-s); padding: 2px 6px; min-width: 120px; max-width: 320px; background: transparent; color: var(--text); }
.img-name:hover { border-color: var(--border-strong); }
.img-name:focus { border-color: var(--accent); outline: none; }
.img-save-state { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.img-save-state.is-warn { color: var(--warn); }
.img-save-state.is-danger { color: var(--danger); }
.img-zoom { font-size: 12px; color: var(--text-2); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.img-tool[aria-pressed="true"] { background: var(--blue-light); color: var(--accent); border-color: var(--accent); }
.img-kbd { font-size: 10px; color: var(--text-3); margin-left: 2px; }

/* Barre d'options de l'outil courant */
.img-options { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-1) var(--space-3); min-height: 34px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.img-options .field { flex-direction: row; align-items: center; gap: var(--space-2); }
.img-options .field > label { font-size: 12px; white-space: nowrap; }
.img-options .input { padding: 2px 6px; font-size: 12px; min-height: 26px; }
.img-opt { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.img-opt input[type="range"] { width: 110px; }
.img-opt input[type="number"] { width: 64px; min-height: 26px; padding: 2px 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.img-opt-unit { color: var(--text-3); font-size: 11px; }
.img-swatches { position: relative; width: 44px; height: 32px; display: flex; align-items: center; }
.img-swatch { position: absolute; width: 24px; height: 24px; padding: 0; border: 2px solid var(--surface); border-radius: var(--radius-s); box-shadow: 0 0 0 1px var(--border-strong); background: none; cursor: pointer; }
.img-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.img-swatch::-webkit-color-swatch { border: none; border-radius: 2px; }
.img-swatch-fg { left: 0; top: 0; z-index: 2; }
.img-swatch-bg { left: 12px; top: 8px; z-index: 1; }
.img-swatches .btn { position: absolute; right: -30px; top: 2px; }
.img-swatches { margin-right: 30px; }

.img-body { display: grid; grid-template-columns: 1fr 320px; flex: 1; min-height: 0; }
.img-stage { position: relative; overflow: hidden; background: var(--surface-2); outline: none; touch-action: none; }
.img-stage canvas { display: block; width: 100%; height: 100%; }
.img-stage.is-panning { cursor: grab; }
.img-stage.is-crop, .img-stage.is-rect, .img-stage.is-ellipse, .img-stage.is-line, .img-stage.is-polygon, .img-stage.is-gradient { cursor: crosshair; }
.img-stage.is-text { cursor: text; }
.img-stage.is-brush, .img-stage.is-erase { cursor: none; }
.img-stage.is-eyedropper { cursor: crosshair; }
.img-stage.is-mask { box-shadow: inset 0 0 0 3px var(--warn); }
.img-crop-actions { position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%); display: flex; gap: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2); box-shadow: var(--shadow-md); }
.img-stage-note { position: absolute; bottom: var(--space-3); left: var(--space-3); font-size: 12px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 2px 8px; }
.img-mask-note { position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--warn-text); background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius-s); padding: 3px 10px; }

.img-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.img-panel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.img-panel-layers { flex: 0 1 42%; min-height: 160px; }
.img-panel-props { flex: 1 1 auto; overflow: auto; }
.img-panel-history { flex: 0 0 auto; max-height: 30%; }
.img-panel-history[open] { flex: 0 1 30%; }
.img-panel-history > summary { cursor: pointer; list-style: none; }
.img-panel-history > summary::before { content: ''; display: inline-block; width: 0; height: 0; border: 4px solid transparent; border-left-color: var(--text-3); margin-right: 6px; transition: transform var(--duration) var(--ease); }
.img-panel-history[open] > summary::before { transform: rotate(90deg); }
.img-panel-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3); font-size: 13px; font-weight: 600; color: var(--text-2); }
.img-panel-head .page-actions { gap: 2px; }
.img-layers { list-style: none; margin: 0; padding: 0 var(--space-2) var(--space-2); overflow: auto; flex: 1; min-height: 0; }
.img-layer { transition: background-color .12s var(--ease), border-color .12s var(--ease), transform .12s var(--ease-out); animation: rise-in .18s var(--ease-out) both; }
.img-layer {
  display: grid; grid-template-columns: 16px 20px 24px auto 1fr 24px; align-items: center; gap: 2px;
  padding: 2px 4px 2px calc(4px + var(--depth, 0) * 16px); border-radius: var(--radius-s); font-size: 13px; cursor: default; border: 1px solid transparent; position: relative;
}
.img-layer:hover { background: var(--hover); }
.img-layer.is-selected { background: var(--blue-light); border-color: var(--blue-subtle); }
.img-layer.is-hidden .img-layer-name, .img-layer.is-hidden .img-layer-thumb { opacity: .45; }
.img-layer.is-mask-edit { outline: 2px solid var(--warn); outline-offset: -2px; }
.img-layer.is-dragover-top::before, .img-layer.is-dragover-bottom::before { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; background: var(--accent); }
.img-layer.is-dragover-top::before { top: -1px; }
.img-layer.is-dragover-bottom::before { bottom: -1px; }
.img-layer-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.img-layer-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 4px; border-radius: var(--radius-s); }
.img-layer-name[contenteditable="true"] { background: var(--input-bg); outline: 1px solid var(--accent); white-space: normal; }
.img-layer-kind { color: var(--text-3); font-size: 11px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-layer .btn-icon { width: 24px; height: 24px; min-width: 24px; padding: 0; }
.img-layer .btn-icon svg { width: 14px; height: 14px; }
.img-layer .btn-icon.is-on { color: var(--warn-text); }
.img-layer-grip { color: var(--text-3); cursor: grab; display: flex; align-items: center; justify-content: center; }
.img-layer-thumbs { display: flex; align-items: center; gap: 3px; margin-right: 4px; }
.img-layer-thumb { width: 48px; height: 36px; border-radius: 3px; border: 1px solid var(--border-strong); background: repeating-conic-gradient(#cbd5e1 0 25%, #f8fafc 0 50%) 0 0 / 10px 10px; display: block; }
.img-layer-thumb.is-mask { width: 20px; height: 20px; background: #000; border-color: var(--border-strong); }
.img-layer-maskbtn { padding: 0; border: none; background: none; cursor: pointer; display: flex; border-radius: 3px; }
.img-layer-maskbtn.is-on .img-layer-thumb { outline: 2px solid var(--warn); }

.img-props { padding: var(--space-2) var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.img-props .field > label { font-size: 12px; }
.img-props .input { padding: 4px 8px; font-size: 13px; }
.img-props-head { display: flex; align-items: flex-end; gap: var(--space-2); }
.img-props-head .field { flex: 1; }
.img-props-head .img-layer-kind { padding-bottom: 8px; }
.img-props-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); align-items: end; }
.img-props-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
.img-props-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-1); }
.img-props-title { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-top: var(--space-2); padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.img-align { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.img-align .btn { padding: 4px 8px; font-size: 12px; }
.img-color { display: flex; align-items: center; gap: var(--space-2); }
.img-color input[type="color"] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-s); background: none; cursor: pointer; }
.img-range { width: 100%; min-width: 0; }
.img-slider { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.img-slider > label { font-size: 12px; font-weight: 500; color: var(--text-2); display: flex; gap: 4px; align-items: baseline; }
.img-slider-row { display: grid; grid-template-columns: 1fr 64px 24px; gap: var(--space-1); align-items: center; }
.img-slider-num { padding: 2px 4px !important; font-size: 12px !important; min-height: 24px; font-variant-numeric: tabular-nums; }
.img-slider .btn-icon { width: 24px; height: 24px; min-width: 24px; padding: 0; }
.img-fx-list { display: flex; flex-direction: column; gap: var(--space-2); }
.img-fx { border: 1px solid var(--border); border-radius: var(--radius-s); padding: var(--space-1) var(--space-2); }
.img-fx.is-on { border-color: var(--blue-subtle); background: var(--blue-light); }
.img-fx-head { display: flex; align-items: center; justify-content: space-between; }
.img-fx-head .check { font-size: 13px; }
.img-fx-body { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-1); }
.img-fill, .img-gradient { display: flex; flex-direction: column; gap: var(--space-2); }
.img-asset-note { font-size: 12px; color: var(--text-muted); }
.img-asset-note.is-warn { color: var(--warn); }
.img-bg-preview { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-s); border: 1px solid var(--border); object-fit: cover; display: block; background: var(--surface-2); }
.img-history { list-style: none; margin: 0; padding: 0 var(--space-2) var(--space-2); overflow: auto; flex: 1; min-height: 0; max-height: 200px; }
.img-history-btn { display: block; width: 100%; text-align: left; background: none; border: none; padding: 3px 8px; font: inherit; font-size: 12px; color: var(--text-2); border-radius: var(--radius-s); cursor: pointer; }
.img-history-btn:hover { background: var(--hover); }
.img-history-item.is-current .img-history-btn { color: var(--text); font-weight: 600; background: var(--blue-light); }
.img-history-item.is-future .img-history-btn { color: var(--text-3); }

/* ---------- Dialogues ---------- */
.img-editor [hidden], .dialog [hidden], .img-guest [hidden] { display: none !important; }
.img-dialog-tabs { margin-bottom: var(--space-3); }
.img-steps { display: flex; gap: var(--space-2); font-size: 13px; color: var(--text-3); margin-bottom: var(--space-4); }
.img-steps .is-current { color: var(--accent); font-weight: 600; }
.img-steps .is-done { color: var(--text-2); }
.img-guests { display: grid; gap: var(--space-3); }
.img-guest { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); display: grid; grid-template-columns: 1fr 180px; gap: var(--space-3); align-items: start; }
.img-guest-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); font-weight: 600; grid-column: 1 / -1; }
.img-guest-preview { aspect-ratio: 16 / 9; background: var(--surface-2); border-radius: var(--radius-s); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-3); font-size: 12px; position: relative; }
.img-guest-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-guest-preview.is-cutout { background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface-2) 0 50%) 0 0 / 16px 16px; }
.img-guest-body { display: flex; flex-direction: column; gap: var(--space-2); }
.img-video { width: 100%; max-height: 240px; background: #000; border-radius: var(--radius-s); display: block; }
.img-video-wrap { position: relative; }
.img-zone { position: absolute; inset: 0; pointer-events: none; }
.img-zone-box { position: absolute; border: 2px solid var(--accent); background: rgba(9,87,208,.12); box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.img-capture-row { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.img-capture-row .field { flex: 1; min-width: 120px; }
.img-bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-2); }
.img-bg-item { border: 2px solid var(--border); border-radius: var(--radius-s); padding: 2px; cursor: pointer; background: var(--surface); text-align: left; }
.img-bg-item[aria-pressed="true"] { border-color: var(--accent); }
.img-bg-item img, .img-bg-item .img-bg-swatch { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-radius: 2px; }
.img-bg-item span { display: block; font-size: 12px; color: var(--text-2); padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-progress-list { display: flex; flex-direction: column; gap: var(--space-2); }
.img-progress-item { display: grid; grid-template-columns: 1fr 160px 60px; gap: var(--space-2); align-items: center; font-size: 13px; }
.img-export-preview { width: 100%; max-height: 50vh; object-fit: contain; display: block; background: repeating-conic-gradient(var(--surface-3) 0 25%, var(--surface-2) 0 50%) 0 0 / 16px 16px; border: 1px solid var(--border); border-radius: var(--radius-s); }
.img-export-result { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; font-size: 13px; }
.img-hint { font-size: 12px; color: var(--text-muted); }
.img-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.img-assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-2); max-height: 40vh; overflow: auto; }

@media (max-width: 900px) {
  .img-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .img-side { border-left: none; border-top: 1px solid var(--border); max-height: 45vh; }
  .img-guest { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .img-card { transition: none; }
}

/* Dépôt d'images sur le canevas, propositions d'amélioration Core Image */
.img-stage.is-dropping { outline: 2px dashed var(--accent); outline-offset: -6px; }
.img-enhance { display: flex; flex-direction: column; gap: 6px; }
.img-enhance-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); }
.img-enhance-text { min-width: 0; font-size: 12px; }

/* Propositions IA (Gemini) dans le tunnel de vignette, 29 octobre 2026 */
.img-ai { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.img-ai > summary { cursor: pointer; font-weight: 600; }
.img-ai-bgs { display: flex; flex-wrap: wrap; gap: 8px; }
.img-ai-bg { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 128px; height: 72px; border-radius: 8px; border: 2px solid var(--border); overflow: hidden; cursor: pointer; background: var(--surface); }
.img-ai-bg.is-on { border-color: var(--accent); }
.img-ai-bg input { position: absolute; top: 4px; left: 4px; z-index: 1; }
.img-ai-bg-thumb { position: absolute; inset: 0; background-size: cover; background-position: center; }
.img-ai-add { color: var(--text-2); font-size: 13px; }
.img-ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.img-ai-card { margin: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.img-ai-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.img-ai-card figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; }

/* Propositions Gemini dans les propriétés du document (29 octobre 2026) */
.img-ai-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 240px; overflow-y: auto; }
.img-ai-thumb { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; overflow: hidden; }
.img-ai-thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.img-ai-thumb:hover { border-color: var(--border-strong, var(--border)); }
.img-ai-thumb.is-current { border-color: var(--accent); }
.img-ai-thumb:disabled { cursor: default; }
