/*
 * We need to override trix.css’s image gallery styles to accommodate the
 * <action-text-attachment> element we wrap around attachments. Otherwise,
 * images in galleries will be squished by the max-width: 33%; rule.
*/
.trix-editor .trix-content .attachment-gallery {
  column-gap: 0.5rem;
}

trix-editor {
  padding-inline: 0;
}

.trix-content .attachment-gallery {
  gap: 0.5rem;
}

.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
  flex: 1 0 33%;
  padding: 0px !important;
}

.trix-content action-text-attachment .attachment {
  padding: 0 !important;
  max-width: 100% !important;
}

.messaging-body-content action-text-attachment {
  display: block;
  max-width: 50%;
}

.turbo-native .messaging-body-content action-text-attachment {
  max-width: 100%;
}

.messaging-body-content action-text-attachment img {
  width: 100%;
  height: auto;
}
trix-editor span[data-trix-cursor-target=left] {
  display: none !important;
}

trix-editor .attachment-gallery > .attachment {
  flex: 1 0 33% !important;
  padding: 0px !important;
  max-width: 47% !important;
}

trix-editor .attachment img {
  height: auto;
  width: 100%;
  max-width: none;
  background-color: black;
}

/* Attachment preview styling inside the message composer */
.messaging-composer-input .attachment {
  max-width: 200px !important;
  padding: 0.5rem !important;
  background-color: #f5f5f5;
  border-radius: 0.75rem;
  border: 1px solid #e5e5e5;
}

.messaging-composer-input .attachment img {
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: cover;
  border-radius: 0.5rem;
  background-color: transparent !important;
}

.messaging-composer-input .attachment__caption {
  font-size: 0.75rem;
  color: #737373;
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Undoes the single-line ellipsis above, which would clip the caption textarea while it is being edited */
.messaging-composer-input .attachment__caption--editing {
  white-space: normal;
  overflow: visible;
}

.messaging-composer-input .attachment__caption-editor {
  width: 100%;
  margin-bottom: 0;
  border: none;
  background: none;
  box-shadow: none;
  font-size: 0.75rem;
}

.messaging-composer-input .attachment__toolbar {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  left: auto;
  background: none;
  border: none;
  padding: 0;
}

.messaging-composer-input .attachment__toolbar .trix-button-row {
  display: flex;
  justify-content: flex-end;
}

.messaging-composer-input .attachment__toolbar .trix-button-group {
  margin: 0;
  border: none;
  box-shadow: none;
}

.messaging-composer-input .attachment__toolbar .trix-button--remove {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0;
  background-color: rgba(115, 115, 115, 0.7);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.messaging-composer-input .attachment__toolbar .trix-button--remove::before {
  content: "✕";
  font-size: 0.75rem;
  color: white;
}

.messaging-composer-input .attachment__toolbar .attachment__metadata-container {
  display: none;
}

.trix-content .attachment__caption-editor {
  height: 1.5rem !important;
  line-height: 1.5;
  margin-bottom: 1rem;
  border-radius: 3px;
  border: 1px solid #D4D4D4;
}

.trix-content > * > a {
  text-decoration: underline;
  color: #006DCB;
}