@use "../../../styles/mixins";

.MessageMeta {
  cursor: var(--custom-cursor, pointer);
  user-select: none;

  position: absolute;
  right: 0;
  bottom: 0;

  display: flex;
  align-items: center;

  height: 1.25rem;
  padding: 0 0.25rem;
  border-radius: 0.625rem;

  line-height: 1;
  color: white;

  background: rgba(#999999, 0.6);

  .message-price,
  .message-time,
  .message-imported,
  .message-signature,
  .message-views,
  .message-replies,
  .message-translated,
  .message-pinned,
  .message-effect-icon {
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .message-price {
    display: inline-flex;
    align-items: center;
    margin-inline-end: 0.25rem;
  }

  .message-replies-wrapper {
    display: flex;
    align-items: center;
  }

  .message-time {
    margin-right: 0.25rem;
  }

  .message-views {
    margin-inline-start: 0.125rem;
  }

  .message-translated {
    margin-inline-end: 0.25rem;
  }

  .message-effect-icon {
    margin-inline-end: 0.25rem;
    color: var(--color-text);
    & > .emoji {
      width: 1rem !important;
      height: 1rem !important;
    }
  }

  .message-pinned {
    margin-inline-end: 0.1875rem;
  }

  .message-imported,
  .message-signature {
    overflow: hidden;
    max-width: 16ch; // Limit long text to 16 characters
    margin-right: 0.375rem;
    text-overflow: ellipsis;

    .emoji-small {
      width: 1rem !important;
      height: 1rem !important;
    }
  }

  .icon-channelviews {
    margin-right: 0.375rem;
    margin-left: 0.125rem;
    font-size: 1.125rem;
    line-height: inherit;
  }

  .icon-reply-filled {
    margin-right: 0.375rem;
    margin-left: 0.125rem;
    font-size: 0.75rem;
    line-height: inherit;
  }

  .has-solid-background & {
    color: rgba(var(--color-text-meta-rgb), 0.75);
    background: none;
  }

  .media.no-footer &,
  .Message .custom-shape &,
  .Message .invoice:not(.has-reactions).has-photo & {
    --color-accent-own: white;
    --color-accent: white;

    right: 0.25rem;
    bottom: 0.25rem;
    left: auto;

    height: 1.125rem;
    padding: 0 0.3125rem 0 0.375rem;

    color: white !important;

    opacity: 1;

    .MessageOutgoingStatus .icon {
      background: transparent;
    }
  }

  .media.no-footer &,
  .Message .invoice:not(.has-reactions).has-photo & {
    background: rgba(0, 0, 0, 0.2);
  }

  .Message .custom-shape & {
    @include mixins.action-message-bg;
  }

  .voice &[dir="rtl"] {
    right: auto !important;
    left: 0.25rem;
    padding: 0 0.375rem 0 0.3125rem;
  }

  // This is currently only supported in Firefox.
  // When attempting to combine with other selectors, the rule no longer applies anywhere except Firefox.
  .media:not(.text):dir(rtl) &,
  .Message .custom-shape:dir(rtl) & {
    right: auto !important;
    left: 0.25rem;
    padding: 0 0.375rem 0 0.3125rem;
  }

  .Message.own .has-solid-background & {
    color: var(--color-message-meta-own);
  }

  .MessageOutgoingStatus {
    flex-shrink: 0;
    margin-left: -0.1875rem;
    border-radius: 0.625rem;
    font-size: 1.1875rem;

    .Message.own & {
      color: var(--color-accent-own);
    }
  }

  .message-content.has-replies:not(.custom-shape) & {
    bottom: 3.375rem;
  }

  .message-content.has-replies.text:not(.custom-shape):not(.is-inverted-media) & {
    bottom: 3.1875rem;
  }

  &[dir="rtl"] {
    .message-views {
      order: 10;
    }
    .icon-channelviews {
      order: 9;
    }
  }
}

.Message:not(.own) {
  .custom-shape .with-subheader + .MessageMeta {
    bottom: 0.25rem;
  }
}
