@use '../mixins';

.media-attachment-media {
  @include mixins.button-reset;

  // Entirely to ensure that images are centered if they aren't full width of bubble
  text-align: center;
  position: relative;

  overflow: hidden;
  height: 100%;
  width: 100%;
  border-radius: 2px;
  padding: 2px;

  & > .attachment-content {
    object-fit: var(--gallery-image-object-fit);
    width: 100%;
    height: 100%;
    border-radius: 2px;

    // redundant with attachment-container, but we get cursor flashing on move otherwise
    cursor: pointer;
  }

  & > .video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    width: 48px;
    height: 48px;
    background-color: var(--videoPlayBtnBg);
    border: 2px solid var(--videoPlayBtnBorder);
    border-radius: 24px;

    &:hover {
      background-color: var(--videoPlayBtnBgHover);
    }

    & > .video-play-btn-icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);

      height: 36px;
      width: 36px;
      @include mixins.color-svg('./images/play.svg', var(--videoPlayBtnIcon));
    }
  }
}

.media-attachment-media.broken > .attachment-content {
  font-size: 22px;
  padding: 10px;
  color: var(--colorDanger);
  background-color: lightgrey;
  margin-bottom: 0;
}

.media-attachment-audio {
  margin: 2px;
  padding: 4px;
  background-color: rgba(130, 130, 130, 0.08);
  & > .heading {
    & > .name {
      font-size: 17px;
      display: inline-block;
      font-weight: bold;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      max-width: calc(100% - 90px);
    }
    & > span.date {
      float: inline-end;
      color: grey;
    }
  }

  &.broken {
    .name {
      color: var(--colorDanger);
    }
  }
}

.media-attachment-generic {
  @include mixins.button-reset;

  display: flex;
  flex-direction: row;
  width: calc(100% - 5px);
  padding: 5px;
  align-items: center;
  position: relative;

  $size_width: 70px;
  $date_width: 120px;

  &:hover {
    background: var(--galleryFileRowHover);
    border-radius: 5px;
  }

  & > .file-icon {
    background: url('./images/file-gradient.svg') no-repeat center;
    height: 49px;
    $file-icon-width: 42px;
    width: $file-icon-width;

    // So we can center the extension text inside this icon
    display: flex;
    flex-direction: row;
    align-items: center;

    & > .file-extension {
      font-size: 8px;
      line-height: 13px;
      letter-spacing: 0.1px;
      text-transform: uppercase;

      // Along with flow layout in parent item, centers text
      text-align: center;
      width: $file-icon-width;
      margin-inline-start: auto;
      margin-inline-end: auto;

      // We don't have much room for text here, cut it off without ellipse
      overflow-x: hidden;
      white-space: nowrap;
      text-overflow: clip;

      color: var(--messageAttachmentIconExtentionColor);
      font-family: monospace;
    }
  }

  & > .name {
    flex-grow: 1;
    //width: calc(100% - $size_width - $date_width);
  }
  & > .size {
    width: $size_width;
    flex-shrink: 0;
  }
  & > .date {
    width: $date_width;
    flex-shrink: 0;
  }

  & > .name {
    color: var(--messageAttachmentFileInfo);
    font-size: 14px;
    line-height: 18px;

    // Handling really long filenames - cut them off
    overflow-x: hidden;
    display: inline-block;
    white-space: pre-line;
    user-select: text;
    position: relative;
    word-break: break-all;

    .highlight {
      background-color: var(--colorPrimary);
      color: white;
      border-radius: 1.8px;
    }
  }

  & > .date {
    color: var(--messageAttachmentFileInfo);
    font-size: 14px;
    line-height: 18px;
    text-align: end;
  }

  & > .size {
    color: var(--messageAttachmentFileInfo);
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.3px;
    margin-top: 3px;
    text-align: end;
  }

  &.broken {
    & > .file-icon {
      cursor: unset;
    }
    .name,
    .file-extension {
      color: var(--colorDanger);
    }
  }
}

.media-attachment-webxdc {
  @include mixins.button-reset;

  display: flex;
  flex-direction: row;
  margin: 3.5px 3px;

  &:hover {
    background-color: var(--galleryWebxdcItem);
    border-radius: calc(44px * 0.07); // same radius as webxdc icon
  }

  & > .icon {
    height: 44px;
    width: 44px;
    border-radius: 7%;
  }

  & > .text-part {
    flex-grow: 1;
    margin-inline-start: 8px;
    // The width of the icon plus our 8px margin
    max-width: calc(100% - 37px);

    & > .name {
      color: var(--messageAttachmentFileInfo);
      font-size: 14px;
      line-height: 18px;
      font-weight: 300;
      margin-top: 2px;
    }

    & > .summary {
      color: var(--messageAttachmentFileInfo);
      font-size: 11px;
      line-height: 16px;
      letter-spacing: 0.3px;
      margin-top: 3px;
    }

    & > .name,
    .summary {
      // Handling really long names - cut them off
      overflow-x: hidden;
      user-select: text;
      position: relative;
      word-break: break-all;
    }
  }

  &.broken {
    & > .icon {
      background-color: var(--colorDanger);
    }
    .name {
      color: var(--colorDanger);
    }
  }
}

#gallery-tabpanel-webxdc_apps .item {
  overflow: hidden;
  padding-inline-end: 3px;
}
