/* ---------- Bild-Dialog (Issue #20) ---------- */

.modal-content.image-dialog {
  width: 1100px;
  max-width: 96vw;
  height: 78vh;
  max-height: 900px;

  /* Dasselbe Blau wie Griff, Ausschnittrahmen und "Einfügen" — die Auswahl in
     Größe und Auflösung trägt die Akzentfarbe des Dialogs, nicht ein Grau. */
  --image-accent: #0969da;
  --image-accent-tint: rgba(9, 105, 218, 0.12);
}

/* Auf dunklem Grund trägt das kräftige Blau zu wenig; ein helleres hält den
   Rahmen sichtbar und den Text darauf lesbar. */
body.dark .modal-content.image-dialog {
  --image-accent: #58a6ff;
  --image-accent-tint: rgba(88, 166, 255, 0.18);
}

.image-dialog-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.image-dialog-preview-pane {
  flex: 1;
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--preview-bg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: auto;
}

.image-dialog-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.image-dialog-stage img {
  max-width: none;
  height: auto;
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.image-resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #0969da;
  border: 2px solid var(--bg);
  cursor: ew-resize;
  touch-action: none;
}

/* Zuschneiden: das Rechteck stanzt sich per riesigem Schatten aus einer
   Abdunklung frei — die Stage clippt ihn, solange zugeschnitten wird. */
.image-dialog-stage.cropping {
  overflow: hidden;
  cursor: crosshair;
}

.image-dialog-stage.cropping .image-resize-handle {
  display: none;
}

.image-crop-box {
  position: absolute;
  border: 1px solid #ffffff;
  outline: 1px solid #0969da;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.image-crop-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text);
  opacity: 0.75;
}

.image-dialog-dims {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text);
  opacity: 0.7;
}

.image-dialog-controls {
  width: 360px;
  flex-shrink: 0;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.image-dialog-controls fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px 10px;
  margin: 0;
}

.image-dialog-controls legend {
  font-size: 12px;
  font-weight: bold;
  padding: 0 4px;
}

.image-dialog-controls label {
  font-size: 13px;
}

.image-field label {
  display: block;
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 4px;
}

.image-field input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Alle drei Abschnitte (Größe, Auflösung, Drehen & Zuschneiden) benutzen
   dasselbe Raster: gleich hohe, gleich breite Schaltflächen mit einer
   zweiten, zurückgenommenen Zeile. */
.image-btn-grid {
  display: grid;
  gap: 6px;
}

.image-btn-grid button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--tab-bg);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
}

/* Der innere Schatten verdoppelt den Rahmen optisch, ohne die Border-Breite zu
   ändern — sonst würde der Button beim Auswählen um 1 px springen. */
.image-btn-grid button.active {
  background: var(--image-accent-tint);
  border-color: var(--image-accent);
  box-shadow: inset 0 0 0 1px var(--image-accent);
  font-weight: bold;
}

.image-btn-grid button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Häkchen nur in den echten Auswahlgruppen: "Ausschnitt wählen" ist ein Modus,
   der an- und ausgeht, keine getroffene Wahl. */
.image-size-row button.active::after,
.image-resolution-row button.active::after {
  content: "✓";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 10px;
  line-height: 1;
  font-weight: bold;
  color: var(--image-accent);
}

/* Symbol und Text stehen nebeneinander in der ersten Zeile des Buttons. */
.image-opt-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.image-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Gestufte Balken: die Stufen oberhalb der gewählten bleiben blass, so lässt
   sich die relative Schärfe an der Zahl der kräftigen Balken ablesen. */
.image-quality-icon rect {
  fill: currentColor;
}

.image-quality-icon[data-quality="1"] rect:nth-of-type(n + 2),
.image-quality-icon[data-quality="2"] rect:nth-of-type(n + 3) {
  opacity: 0.3;
}

.image-size-row { grid-template-columns: repeat(4, 1fr); }
.image-transform-row { grid-template-columns: repeat(2, 1fr); }
.image-resolution-row { grid-template-columns: repeat(3, 1fr); }

.image-sub {
  font-size: 11px;
  font-weight: normal;
  opacity: 0.7;
  white-space: nowrap;
}

/* Schätzung läuft noch — der Wert daneben ist veraltet. */
.image-sub.pending {
  opacity: 0.4;
  font-style: italic;
}

.image-width-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}

/* Metadaten: der Haken sagt, was passiert, die Zeile darunter, worum es geht —
   und zeigt in Warnfarbe, wenn GPS und Kamera im Bild bleiben sollen. */
.image-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.image-check:has(input:disabled) {
  opacity: 0.5;
  cursor: default;
}

.image-meta-summary {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.7;
}

.image-meta-summary.warn {
  color: #bc4c00;
  opacity: 1;
}

body.dark .image-meta-summary.warn {
  color: #e0a04a; /* das Orange des hellen Themes verschwindet auf dunklem Grund */
}

.image-width-row input {
  width: 72px;
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---------- Größe in der Vorschau ziehen ---------- */

.preview-img-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

.preview-img-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #0969da;
  border: 2px solid var(--bg);
  cursor: ew-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.15s;
}

/* Auch beim Tastaturfokus zeigen — ein unsichtbarer Griff, der den Fokus hat,
   wäre die schlechteste aller Varianten. */
.preview-img-wrap:hover .preview-img-handle,
.preview-img-wrap.resizing .preview-img-handle,
.preview-img-handle:focus-visible {
  opacity: 1;
}

.image-resize-handle:focus-visible,
.preview-img-handle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.preview-img-badge {
  position: absolute;
  right: 0;
  top: 0;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.5;
  background: rgba(9, 105, 218, 0.9);
  color: #ffffff;
  border-radius: 0 0 0 4px;
  pointer-events: none;
}

.image-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--tab-bg);
  flex-shrink: 0;
}

.image-dialog-error {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #cf222e;
}

.image-dialog-footer button {
  padding: 6px 16px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.image-dialog-footer button.primary {
  background: #0969da;
  border-color: #0969da;
  color: #ffffff;
  font-weight: bold;
}
