/* Attachment uploader component (see static/js/attachment-uploader.js). */

.att-uploader {
  width: 100%;
}

.att-uploader__drop {
  width: 100%;
  min-height: 56px;
  border: 1px solid #738c79;
  border-radius: 6px;
  background: #eef4ef;
  color: #244333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(25, 45, 32, 0.12);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.att-uploader__action {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.att-uploader__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #dce9de;
  color: #28613b;
  font-size: 1.1rem;
}

.att-uploader__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.att-uploader__label {
  font-weight: 600;
  line-height: 1.2;
}

.att-uploader__hint {
  color: #59675d;
  font-size: 0.78rem;
  line-height: 1.2;
}

.att-uploader__requirement {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.att-uploader--required .att-uploader__requirement {
  border-color: #edc2bf;
  background: #fff1f0;
  color: #9b2922;
}

.att-uploader--optional .att-uploader__requirement {
  border-color: #c1ddc8;
  background: #edf7ef;
  color: #28613b;
}

.att-uploader__drop:hover,
.att-uploader__drop:focus {
  border-color: #42664c;
  background: #e5efe7;
  box-shadow: 0 2px 5px rgba(25, 45, 32, 0.17);
  outline: none;
}

.att-uploader--dragover .att-uploader__drop {
  border: 2px dashed #28613b;
  background: #dce9de;
  box-shadow: 0 0 0 2px rgba(40, 97, 59, 0.14);
}

.att-uploader--readonly .att-uploader__drop,
.att-uploader--readonly .att-tile__remove {
  display: none;
}

.att-uploader__message {
  margin-top: 6px;
  font-size: smaller;
}

.att-uploader__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.att-uploader__grid:empty {
  margin-top: 0;
}

.att-tile {
  position: relative;
  width: 150px;
  text-align: center;
}

.att-tile__preview {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 5px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.att-tile--done .att-tile__preview {
  cursor: pointer;
}

.att-tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.att-tile__icon {
  font-size: 2.6rem;
  color: #6c757d;
}

.att-tile__name {
  margin-top: 4px;
  font-weight: 500;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-tile__meta {
  font-size: 0.75rem;
  color: #777;
  min-height: 1em;
}

.att-tile__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.1rem;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
}

.att-tile__remove:hover {
  background: rgba(192, 57, 43, 0.9);
}

/* Takes the place of the remove button on saved images and PDFs while the list is read-only. */
.att-tile__download {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.85rem;
  text-decoration: none;
  z-index: 2;
}

.att-uploader--readonly .att-tile__download {
  display: flex;
}

.att-tile__download:hover {
  background: rgba(0, 123, 255, 0.9);
  color: #fff;
  text-decoration: none;
}

/* Progress and error state drawn over the preview. */
.att-tile__overlay {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
}

.att-tile--queued .att-tile__overlay,
.att-tile--uploading .att-tile__overlay,
.att-tile--error .att-tile__overlay {
  display: flex;
}

.att-tile--error .att-tile__overlay {
  background: rgba(160, 30, 30, 0.8);
}

.att-tile__track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.att-tile__bar {
  height: 100%;
  width: 0;
  background: #28a745;
  transition: width 0.15s linear;
}

.att-tile--error .att-tile__bar {
  background: #fff;
}

.att-tile__retry {
  display: none;
  padding: 2px 10px;
  border: 1px solid #fff;
  border-radius: 3px;
  background: transparent;
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
}

.att-tile--error .att-tile__retry {
  display: inline-block;
}

/* Smaller button for forms nested in a list, such as comment replies. */
.att-uploader--compact .att-uploader__drop {
  min-height: 35px;
  border-radius: 6px;
  padding: 5px 8px;
}

.att-uploader--compact .att-uploader__icon {
  width: 24px;
  height: 24px;
  font-size: 0.9rem;
}

.att-uploader--compact .att-uploader__hint {
  display: none;
}

.att-uploader--compact .att-uploader__requirement {
  padding: 3px 5px;
  font-size: 0.7rem;
}

/* Tiles shrink to the size of a comment attachment chip: small thumbnail, name and size beside it. */
.att-uploader--small .att-uploader__grid {
  justify-content: flex-start;
  gap: 6px 14px;
  margin-top: 8px;
}

.att-uploader--small .att-tile {
  display: grid;
  grid-template-columns: 36px minmax(0, 160px) auto;
  grid-template-areas:
    "preview name remove"
    "preview meta remove";
  align-items: center;
  column-gap: 8px;
  width: auto;
  max-width: 100%;
  text-align: left;
}

.att-uploader--small .att-tile__preview {
  grid-area: preview;
  width: 36px;
  height: 36px;
}

.att-uploader--small .att-tile__icon {
  font-size: 1.1rem;
}

.att-uploader--small .att-tile__name {
  grid-area: name;
  margin: 0;
  font-weight: 400;
}

.att-uploader--small .att-tile__meta {
  grid-area: meta;
  min-height: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-uploader--small .att-tile--error .att-tile__meta {
  color: #c0392b;
}

.att-uploader--small .att-tile__remove {
  grid-area: remove;
  position: static;
  width: 20px;
  height: 20px;
  font-size: 0.9rem;
  line-height: 20px;
}

/* The progress bar runs along the bottom of the small thumbnail; the text moves out of it. */
.att-uploader--small .att-tile__overlay {
  padding: 0;
  gap: 0;
  justify-content: flex-end;
}

.att-uploader--small .att-tile__status {
  display: none;
}

.att-uploader--small .att-tile__track {
  height: 4px;
  border-radius: 0;
}

/* A failed small tile is retried by clicking its thumbnail. */
.att-uploader--small .att-tile__retry {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: none;
  font-size: 0;
}

.att-uploader--small .att-tile__retry::before {
  content: "\21BB";
  font-size: 1.1rem;
  color: #fff;
}

/* Saved attachments (AttachmentUploader.renderChip): a thumbnail or type icon with the file name. */
.att-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.att-chip-row--large {
  justify-content: center;
  gap: 12px;
}

.att-chip {
  --att-chip-size: 36px;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 0.85em;
  vertical-align: middle;
}

.att-chip__open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #007bff;
  text-decoration: none;
}

.att-chip__open:hover {
  text-decoration: none;
}

.att-chip__open:hover .att-chip__name {
  text-decoration: underline;
}

.att-chip__download {
  flex: none;
  padding: 2px 4px;
  color: #6c757d;
  line-height: 1;
  text-decoration: none;
}

.att-chip__download:hover {
  color: #007bff;
  text-decoration: none;
}

.att-chip__thumb {
  flex: 0 0 var(--att-chip-size);
  width: var(--att-chip-size);
  height: var(--att-chip-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
  color: #6c757d;
  font-size: calc(var(--att-chip-size) * 0.5);
  overflow: hidden;
}

.att-chip__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.att-chip__name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The larger card used for an issue's own attachments; the download link sits on the thumbnail. */
.att-chip--large {
  flex-direction: column;
  align-items: stretch;
  width: 150px;
}

.att-chip--large .att-chip__open {
  flex-direction: column;
  gap: 4px;
}

.att-chip--large .att-chip__thumb {
  flex: none;
  width: 150px;
  height: 110px;
  font-size: 2.6rem;
}

.att-chip--large .att-chip__name {
  max-width: 100%;
  text-align: center;
}

.att-chip--large .att-chip__download {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.85rem;
}

.att-chip--large .att-chip__download:hover {
  background: rgba(0, 123, 255, 0.9);
  color: #fff;
}
