/* =========================================================
   EMAN GROUP — Contact attachments
   Matches the existing form: neutral, compact and ordered.
   ========================================================= */

.form-row--attachments {
  margin-top: 20px;
}

.attachment-heading {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 8px;
}

.attachment-title {
  color: inherit;
  font: inherit;
  font-weight: 700;
}

.form-optional {
  color: inherit;
  font-size: 0.9em;
  font-weight: 400;
  opacity: 0.62;
}

/* Upload control */
.attachment-uploader {
  display: grid;
  width: 100%;
  min-height: 0;
  padding: 14px;
  place-items: center;
  border: 1px solid var(--line, #d8dde6);
  border-radius: 10px;
  background: var(--surface, #fff);
  text-align: center;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.attachment-uploader:hover,
.attachment-uploader.is-dragover {
  border-color: var(--accent, #2f63f5);
}

.attachment-uploader.is-dragover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2f63f5) 14%, transparent);
}

.attachment-native-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.attachment-pick-button,
.attachment-add-more {
  display: inline-flex;
  min-height: 40px;
  padding: 9px 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--accent, #2f63f5);
  border-radius: 9px;
  background: var(--accent, #2f63f5);
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.attachment-pick-button:hover,
.attachment-add-more:hover {
  opacity: 0.9;
}

.attachment-pick-button:active,
.attachment-add-more:active {
  transform: translateY(1px);
}

.attachment-native-input:focus-visible + .attachment-pick-button,
.attachment-add-more:focus-visible,
.attachment-remove:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent, #2f63f5) 22%, transparent);
  outline-offset: 2px;
}

.attachment-pick-button svg,
.attachment-add-more svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.attachment-drop-text {
  margin: 8px 0 0;
  color: inherit;
  font-size: 13px;
  opacity: 0.72;
}

.attachment-limits {
  margin: 10px 0 0;
  color: inherit;
  font-size: 12px;
  opacity: 0.66;
}

.attachment-types {
  margin: 3px 0 0;
  color: inherit;
  font-size: 12px;
  opacity: 0.58;
}

.attachment-status {
  min-height: 18px;
  margin-top: 8px;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
}

.attachment-status.is-error {
  color: var(--danger, #b42318);
}

/* Selected files: always one ordered column */
.attachment-preview {
  margin-top: 8px;
}

.attachment-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-item {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 8px 9px;
  grid-template-columns: 38px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line, #d8dde6);
  border-radius: 9px;
  background: var(--surface, #fff);
}

.attachment-file-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line, #d8dde6);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0.78;
}

.attachment-file-info {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.attachment-file-name {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-file-meta {
  color: inherit;
  font-size: 12px;
  opacity: 0.6;
}

.attachment-remove {
  display: inline-flex;
  width: 34px;
  height: 34px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.58;
}

.attachment-remove:hover {
  border-color: var(--line, #d8dde6);
  opacity: 1;
}

.attachment-remove svg {
  width: 17px;
  height: 17px;
}

.attachment-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 9px;
}

.attachment-add-more {
  min-height: 36px;
  padding: 7px 12px;
  background: transparent;
  color: var(--accent, #2f63f5);
  font-size: 13px;
  box-shadow: none;
}

.form-row--attachments:has(.attachment-native-input[aria-invalid="true"]) .attachment-uploader {
  border-color: var(--danger, #b42318);
}

@media (max-width: 520px) {
  .attachment-uploader {
    padding: 12px;
  }

  .attachment-pick-button {
    width: 100%;
  }

  .attachment-item {
    grid-template-columns: 34px minmax(0, 1fr) 32px;
  }

  .attachment-file-icon {
    width: 34px;
    height: 34px;
  }

  .attachment-add-more {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .attachment-uploader,
  .attachment-pick-button,
  .attachment-add-more {
    transition: none;
  }
}

/* Graceful fallback where project CSS variables are unavailable. */
@supports not (color: color-mix(in srgb, black 50%, white)) {
  .attachment-uploader.is-dragover {
    box-shadow: 0 0 0 3px rgba(47, 99, 245, 0.14);
  }

  .attachment-native-input:focus-visible + .attachment-pick-button,
  .attachment-add-more:focus-visible,
  .attachment-remove:focus-visible {
    outline: 3px solid rgba(47, 99, 245, 0.22);
  }
}
