/* File previews and upload feedback stay within the existing upload cards. */
#listingForm .listing-media-upload-preview {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-top: 10px;
}

#listingForm .listing-media-upload-preview[hidden] {
  display: none !important;
}

#listingForm .listing-media-upload-preview-visual {
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(88px, 15vw, 150px);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f2;
}

#listingForm .listing-media-upload-preview-visual img,
#listingForm .listing-media-upload-preview-visual video,
#listingForm .listing-media-upload-pdf {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border: 0;
  background: #f4f7f2;
}

#listingForm .listing-media-upload-file-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

#listingForm .listing-media-upload-preview-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

#listingForm .listing-media-upload-filename {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

#listingForm .listing-media-preview-open {
  flex: 0 0 auto;
  color: #27614e;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#listingForm .listing-media-upload-progress {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
}

#listingForm .listing-media-upload-progress-track {
  display: block;
  flex: 1 1 auto;
  height: 7px;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ece6;
}

#listingForm .listing-media-upload-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #1e6b54;
  transition: width .12s linear;
}

#listingForm .listing-media-upload-progress-percent {
  flex: 0 0 38px;
  color: #315d4d;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#listingForm .media-upload-card>[role=status].is-success {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #176447;
}

#listingForm .media-upload-card>[role=status].is-error {
  color: #a33e32;
}

#listingForm .media-upload-card>[role=status].is-uploading {
  color: #315d4d;
}

#listingForm .listing-media-upload-check {
  display: inline-grid;
  flex: 0 0 18px;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2f2e8;
  color: #176447;
  font-size: 12px;
  font-weight: 700;
}

#listingForm .listing-media-upload-status-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

#listingForm .listing-media-upload-retry {
  flex: 0 0 auto;
  margin-left: 5px;
  padding: 5px 9px;
  font-size: 11px;
}

.listing-media-panel .media-plan-pdf {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100% - 28px);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  background: #fff;
}

.listing-media-plan-error {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 18px;
  color: var(--ink);
  text-align: center;
}

.listing-media-plan-error a {
  color: #27614e;
  text-decoration: underline;
}

@media (max-width: 600px) {
  #listingForm .listing-media-upload-preview {
    gap: 6px;
    margin-top: 7px;
  }

  #listingForm .listing-media-upload-preview-visual {
    height: clamp(82px, 24vw, 120px);
  }

  #listingForm .listing-media-upload-preview-details {
    align-items: flex-start;
    gap: 6px;
  }
}

#listingForm .media-upload-card>[role=status].is-uploading::before {
  content: '';
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border: 2px solid #b8cfc1;
  border-top-color: #1e6b54;
  border-radius: 50%;
  animation: listing-media-upload-spin .8s linear infinite;
}

@keyframes listing-media-upload-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  #listingForm .media-upload-card>[role=status].is-uploading::before {
    animation: none;
    border-top-color: #1e6b54;
  }
}

#listingForm .listing-media-upload-video-wrap {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #dfeae2, #f4f7f2 52%, #c7d9ce);
}

#listingForm .listing-media-upload-preview-visual .listing-media-upload-video-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0 0 0 3px;
  transform: translate(-50%, -50%);
  border: 1px solid #ffffffa8;
  border-radius: 50%;
  background: #17362de8;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

#listingForm .listing-media-upload-preview-visual .listing-media-upload-video-play[hidden] {
  display: none !important;
}

#listingForm .listing-media-upload-video-wrap video {
  position: relative;
  z-index: 1;
  background: transparent;
}

#listingForm .listing-media-upload-video-play { z-index: 2; }

#listingForm .listing-media-upload-pdf {
  background: #fff;
}

@media (prefers-reduced-motion: reduce) {
  #listingForm .listing-media-upload-progress-fill { transition: none; }
}
/* Keep the original card height: the selected file preview occupies the dropzone. */
#listingForm .media-upload-card.has-attached-media {
  position: relative;
}

#listingForm .media-upload-card.has-attached-media .media-file-dropzone {
  position: relative;
  flex: 1 1 auto;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 126px;
  padding: 12px;
}

#listingForm .media-upload-card.has-attached-media .media-file-dropzone .media-upload-icon,
#listingForm .media-upload-card.has-attached-media .media-file-dropzone>[data-owner-visual-copy] {
  display: none;
}

#listingForm .media-upload-card.has-attached-media .media-file-dropzone .file-upload-button {
  position: absolute;
  z-index: 4;
  top: 7px;
  right: 8px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

#listingForm .media-upload-card.has-attached-media>.field-note:not([role="status"]) {
  visibility: hidden;
}

#listingForm .media-upload-card.has-attached-media .listing-media-upload-preview {
  position: absolute;
  z-index: 3;
  top: 98px;
  right: 20px;
  left: 20px;
  gap: 4px;
  margin: 0;
}

#listingForm .media-upload-card.has-attached-media .listing-media-upload-preview-visual {
  height: 64px;
}

#listingForm .media-upload-card.has-attached-media.is-media-uploading .listing-media-upload-preview-visual {
  height: 44px;
}

#listingForm .media-upload-card.has-attached-media .listing-media-upload-preview-details {
  gap: 7px;
}

#listingForm .media-upload-card.has-attached-media .listing-media-upload-filename,
#listingForm .media-upload-card.has-attached-media .listing-media-preview-open {
  font-size: 11px;
  line-height: 1.15;
}

#listingForm .media-upload-card.has-attached-media>[role="status"] {
  position: absolute;
  z-index: 4;
  right: 20px;
  bottom: 17px;
  left: 20px;
  margin: 0;
  line-height: 1.2;
}

@media (max-width: 600px) {
  #listingForm .media-upload-card.has-attached-media .listing-media-upload-preview {
    top: 94px;
  }

  #listingForm .media-upload-card.has-attached-media .listing-media-upload-preview-visual {
    height: 58px;
  }

  #listingForm .media-upload-card.has-attached-media.is-media-uploading .listing-media-upload-preview-visual {
    height: 40px;
  }
}
