/*
 * form-image-upload component
 * Design reference: docs/design/figma-reference/screens/activity-creation/general-information-1-full.png
 * Figma dimensions: ~550 x 227 total
 *
 * All colors use CSS custom properties from the branding system
 * (site/snippets/app/branding-css.php). No hardcoded color values.
 *
 * Structure:
 *   .form-image-upload            — outer wrapper: single rounded dashed border, surface bg
 *     .form-image-upload-dropzone — top: dropzone with icon + text
 *     .form-image-list            — bottom: thumbnail row + "+ Eigenes Bild"
 *       (separated by solid 1px line using --ss-border)
 */

/* Outer wrapper — single rounded dashed border, surface (white) background */
.form-image-upload {
  border: 1.5px dashed var(--ss-border);
  border-radius: 12px;
  background: var(--ss-surface);
}

/* Invalid state — POIs require an image; mirror Bootstrap's .is-invalid look */
.form-image-upload.is-invalid {
  border-color: var(--bs-danger);
}

/* Dropzone area — centered icon + text */
.form-image-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  cursor: pointer;
}
.form-image-upload-dropzone.dragover {
  background: rgba(var(--bs-secondary-rgb), 0.05);
}

/* Thumbnail row — separated from dropzone by straight solid line */
.form-image-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--ss-border);
  border-radius: 0;
  padding: 8px 12px;
  background: transparent;
}
.form-image-list ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 6px;
}
.form-image-list ul li {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 53px;
}
.form-image-list ul li img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}

/* Selected / primary image highlight */
.form-image-list ul li img.selected {
  border-color: var(--bs-secondary);
}

/* Remove button */
.form-image-list ul li .img-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bs-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

/* Drag-reorder feedback */
.form-image-list ul li.dragging { opacity: 0.4; }
.form-image-list ul li.drag-over img { border-color: var(--bs-secondary); }

/* File input / "+ Eigenes Bild" button */
.form-image-list .file-input {
  position: relative;
  flex: 0 0 auto;
  margin-left: 10px;
}
.form-image-list .file-input input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  opacity: 0;
}
.form-image-list .file-input .btn-add {
  background: none;
  border: none;
  padding: 0 10px 0 0;
  appearance: none;
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
}
.form-image-list .file-input .btn-add svg {
  display: block;
  margin: 0 9px 0 0;
}

/* ── Variant B: Image preview (POI forms — dropzone-only mode) ── */

/* When has-preview is set, hide the dropzone and show the preview */
.form-image-upload.has-preview {
  display: flex;
  align-items: center;
}
.form-image-upload.has-preview .form-image-upload-dropzone {
  display: none;
}
.form-image-upload.has-preview .form-image-upload-preview {
  display: flex !important; /* override d-none */
  flex: 1;
  min-width: 0;
}

/* Preview container — horizontal row: thumbnail, info, change, remove */
.form-image-upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
}

/* 60x60 thumbnail */
.form-image-upload-preview-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* File info (name + size stacked) */
.form-image-upload-preview-info {
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow text truncation */
  flex: 1;
}
.form-image-upload-preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Change button */
.form-image-upload-preview-change {
  flex-shrink: 0;
  padding: 0;
  text-decoration: none;
}
.form-image-upload-preview-change:hover {
  text-decoration: underline;
}

/* Remove button — small round primary button */
.form-image-upload-preview-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: var(--ss-surface);
  border: none;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.form-image-upload-preview-remove:hover {
  opacity: 0.85;
}

/* Upload error message */
.form-image-upload .upload-error {
  padding: 4px 10px;
}
