@import 'modules/app/viewports';

$width: 860px;
$titleMarginBottom: 10px;

.back-arrow {
  cursor: pointer;
}

.back-button {
  margin-top: 8px;
  margin-right: 15px;
  line-height: 30px;
  border: none;
}

.success-info__panel {
  position: absolute;
  top: 60px;
  right: 206px;
  color: var(--color-gray-888);
}

.attachment-icon {
  cursor: pointer;
  display: flex;
  margin: 0 0 0 5px;
}

.participants {
  display: flex;
  align-items: center;
  padding-right: 10px;

  app-cmf-gravatar {
    position: relative;
    top: 2px;
  }

  .ava-wrapper {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;

    width: 24px;
    height: 24px;

    background-color: var(--color-gray-fff);
    border-radius: 50%;

    transition: transform ease 0.3s;

    &.current-person {
      z-index: 10;
      margin-right: -4px;
    }
  }

  .active-users-wrapper {
    display: flex;
  }

  .ava-selection-wrapper {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;

    width: 24px;
    height: 24px;
    margin-right: -5px;

    border-radius: 50%;

    .ava-wrapper {
      .more-cnt {
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;

        width: 24px;
        height: 24px;

        background-color: var(--color-gray-eee);
        border-radius: 50%;
      }
    }
  }
}

wg-status-badge {
  cursor: default;
  user-select: none;
}

.active-users-menu-item {
  display: flex;
  gap: 10px;
  align-items: center;

  app-cmf-gravatar {
    position: relative;
    top: 8px;
  }
}

.document {
  @include viewport-laptop {
    max-width: 100%;
    margin-left: 0;
  }

  @include viewport-mobile {
    max-width: 100%;
    margin-left: 0;
  }

  /* Нужно делать внутри а не снаружи
  margin: 0 auto; */
  max-width: 100%;
  min-height: calc(100vh - 101px);
  padding-top: 0;
  padding-right: 30px;

  &.full-screen {
    .header-name {
      display: flex;
      justify-content: flex-start;
      width: 100%;
      margin-bottom: $titleMarginBottom;
    }

    .content .document-body {
      margin-left: 0;
    }

    .header {
      margin-left: 0;
    }

    .likes-and-labels-container {
      max-width: 98%;
      padding-left: 0;
    }
  }

  &.normal-screen {
    .header-name {
      display: flex;
      justify-content: center;
      width: 100%;
      margin-bottom: 10px;
    }

    .content .document-body {
      margin-left: 50px;
    }

    .header,
    .info-created-modified {
      margin-left: 50px;
    }

    wg-cmf-document-state {
      width: $width;
      margin: 0 auto;
      margin-bottom: $titleMarginBottom;
    }

    .draft-tip {
      width: $width;
      margin: 0 auto;
    }
  }

  &.dialog {
    .header-name {
      display: block;
    }
  }

  .doc-comments {
    display: block;
    width: 100%;
    min-width: $width;
  }

  .content .document-body {
    position: relative;
    display: block;
    font: var(--wiki-text-font);
    color: var(--user-content-color, var(--default-color));
  }

  .header {
    font: var(--default-font-h1);
    color: var(--wiki-font-h1-color);
  }

  &.history {
    min-height: min-content;

    .close {
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }

    .modified-by {
      font-size: 14px;
    }

    .mat-icon {
      cursor: pointer;
      width: 30px;
      height: 30px;
      font-size: 30px;
    }
  }

  &.dialog {
    position: relative;
    min-height: 100%;
    margin-top: -24px;
    padding-top: 5px;

    div.header {
      margin-top: 30px;
      margin-bottom: 10px;

      &.is-diff {
        margin-top: 0;
      }
    }

    .navbar-for-popup {
      position: sticky;
      z-index: 1;
      top: 0;

      display: flex;

      background-color: var(--color-gray-fff);

      &::before {
        content: '';

        position: absolute;
        top: -40px;

        width: 100%;
        height: 40px;

        background-color: var(--color-gray-fff);
      }

      div.info {
        position: static;
        align-items: flex-start;
        margin-right: 30px;
        margin-left: auto;

        .actions {
          padding-top: 0;
        }
      }

      .mat-icon {
        cursor: pointer;

        display: flex;
        align-items: center;
        justify-content: center;

        width: 40px;
        height: 40px;

        font-size: 30px;
        color: var(--color-gray-444);
      }
    }
  }
}

.modified-by {
  display: flex;
  justify-content: flex-end;
  padding-right: 35px;

  a {
    color: #888;
  }
}

.favorite-button {
  position: relative;
  top: -7px;
}

.open-settings-list-button {
  position: relative;
  top: 1px;
}

/* .full-view-change-button {
    position: relative;
    top: 2px;
} */

.header {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;

  &:hover {
    .name-edit-button {
      display: block;
    }
  }
}

.info-created-modified {
  margin-bottom: 10px;
  color: var(--color-gray-888);

  p {
    margin: 0;
  }
}

.global-icon {
  &.active {
    color: var(--accent-color-bg);
  }
}

.name-edit-button {
  cursor: pointer;
  display: none;
  padding-left: 10px;
}

frm-cmf-breadcrumbs.no-margin-right {
  margin-right: 0;
}

.info-item {
  position: relative;
  height: 100%;
}

.info {
  position: relative;
  top: -5px;

  display: flex;
  align-items: center;

  color: #888;

  background: var(--color-gray-fff);

  .public-button-wrap,
  .search-button-wrap,
  .viewed-button-wrap,
  .attachment-button-wrap,
  .global-icon__wrapper {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    app-cmf-doodle-icon {
      margin-left: 0;
      padding-left: 0;
    }
  }

  .attachment-button-wrap > button {
    cursor: pointer;

    display: flex;
    flex-flow: row nowrap;
    column-gap: 5px;

    margin: 0;
    padding: 0;

    background: none;
    border: none;

    app-cmf-doodle-icon {
      color: var(--color-gray-444);
    }

    span {
      font: var(--default-text-font);
      font-size: 13px;
      color: var(--color-gray-444);
    }
  }

  .search-button-wrap.confluence {
    display: none;
  }

  .info-item:first-child {
    margin-left: auto;
  }

  /* .info-item:not(:last-child) {
       margin-right: 30px;
  } */

  .actions {
    display: flex;
    align-items: center;
    padding-top: 15px;
    color: #000;
  }

  .viewed__button-wrap {
    display: flex;
    height: 40px;

    button {
      margin: auto;
    }

    .viewed__button.mat-button {
      padding: 0 5px;
      line-height: 30px;
    }
  }

  /* Фикс для кнопок тулбара документа "Опубликовать", "Сохранить черновик", "Отмена" */

  @media screen and (width <= 1800px) {
    background: none;

    .editing {
      display: flex;
      flex-flow: row wrap;
      justify-content: flex-end;

      max-width: 330px;
      margin-top: 38px;

      .participants {
        top: 3px;
        order: 1;
      }

      .success-info__panel {
        position: relative;
        top: unset;
        right: unset;
        left: 103px;

        order: 4;

        margin-right: auto;
        margin-bottom: -19px;
      }

      .search-button-wrap {
        order: 0;
      }

      .global-icon__wrapper {
        order: 2;
      }

      .mat-menu-trigger.mat-icon-button.mat-button-base {
        order: 3;
      }

      .btn-group {
        z-index: 2;

        display: flex;
        flex-flow: row nowrap;
        order: 4;

        background-color: var(--color-gray-fff);
      }
    }
  }
}

.viewed-menu-button {
  display: flex;
  gap: 5px;
  align-items: center;

  .person-gravatar {
    height: 36px;
  }
}

.invitation {
  width: 300px;
}

.position-relative-t3 {
  position: relative;
  top: 3px;
}

:host ::ng-deep h1,
:host ::ng-deep .tui-editor-contents *:not(table) {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;

  font-weight: 400;
  line-height: 26px;
}

:host ::ng-deep .tui-editor-contents b,
:host ::ng-deep .tui-editor-contents strong {
  font-weight: 700;
}

:host ::ng-deep h1,
:host ::ng-deep .tui-editor-contents h1 {
  margin-bottom: 40px;
  font-size: 45px;
  line-height: 50px;
}

:host ::ng-deep .tui-editor-contents h2 {
  margin-bottom: 28px;
  font-size: 35px;
  line-height: 40px;
}

:host ::ng-deep .tui-editor-contents h3 {
  margin-bottom: 22px;
  font-size: 30px;
  line-height: 35px;
}

:host ::ng-deep .tui-editor-contents p,
:host ::ng-deep .tui-editor-contents ul,
:host ::ng-deep .tui-editor-contents ol,
:host ::ng-deep .tui-editor-contents pre {
  margin-bottom: 22px;
  font-size: 17px;
}

:host ::ng-deep .tui-editor-contents ul,
:host ::ng-deep .tui-editor-contents ol {
  padding-left: 40px;
}

:host ::ng-deep .tui-editor-contents ul > li::before {
  margin-top: 10px;
  background-color: rgb(50 50 50);
}

:host ::ng-deep .tui-editor-contents a {
  word-break: break-all;
}

:host ::ng-deep .tui-editor-contents pre {
  overflow-x: auto;
}

.fixed-toolbar {
  position: sticky;
  z-index: 999;
  top: 0;
}

::ng-deep .CmfDocumentDialog {
  width: 90vw;
  height: 90vh;
}

::ng-deep .viewed__eye__icon {
  display: contents !important;
}

.public-button {
  background-color: var(--accent-color-bg); /* TODO: go to variable */
}

.button {
  padding: 0 5px;

  /* margin-left: 11px; */
  line-height: 30px;
  color: white;
}

.close-button {
  color: var(--default-color-black);
  background-color: var(--color-gray-eee);
}

.cancel-button {
  color: var(--default-color-black);
  background-color: transperent;
}

.centre {
  display: flex;
  align-items: center;
  justify-content: center;
}

@media print {
  .toolbar {
    margin: 0;
    padding: 0;
  }

  .document {
    max-width: 100%;
    margin: 0;
  }
}

.file-upload {
  display: none;
}

.likes-and-labels-container {
  clear: both;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-width: $width;
  padding: 20px 0;

  border-bottom: 1px solid rgb(223 225 230);

  -webkit-box-pack: justify;
}

.likes-wrapper {
  clear: both;
  overflow: hidden;
  display: flex;
  align-items: center;

  margin-top: 0;

  -webkit-box-align: center;

  span {
    padding-top: 2px;
    font-size: 12px;
    color: rgb(107 119 140);
  }
}

.like {
  display: flex;
  flex-direction: column;
  justify-content: center;

  max-width: 24px;
  max-height: 24px;
  padding: 0 5px;

  font-size: 14px;

  background-color: rgb(0 0 0 / 0%);
}

.like-choice {
  max-width: 38px;
  max-height: 38px;
  font-family: var(--default-font-emoji);
  font-size: 28px;
}

::ng-deep .like-menu {
  overflow: hidden;
  min-width: 24px;
  margin-top: -24px;
}

.like-icon {
  width: 14px;
  height: 14px;
  font-family: var(--default-font-emoji);

  .like {
    font-size: 14px;
  }
}

#like-button {
  margin-top: 4px;
  margin-right: 4px;
}

.labels-wrapper {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: flex-end;

  margin-right: 74px;

  // Выяснить актуальность full_screen для документа
  &.labels-margin {
    justify-content: center;
    margin-right: 98px;
  }

  .labels-tag {
    display: flex;
    align-items: center;

    .tag-list {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      align-items: baseline;

      .tag {
        cursor: pointer;

        display: flex;
        gap: 3px;

        padding: 2px 4px;

        font-size: 12px;
        color: #1f75cb;

        background-color: #e9f3fc;
        border-radius: 4px;

        .tag-remove-icon {
          display: flex;
          align-items: center;
          opacity: 0.7;

          &:hover {
            opacity: 1;
          }
        }
      }
    }

    .add-tag-icon {
      display: flex;
      justify-content: center;
    }

    .add-tag-btn:hover .add-tag-icon {
      color: var(--accent-color-bg);
    }
  }
}

.empty-label {
  font-size: 12px;
  color: var(--color-text-subtlest);
}

.hidden {
  display: none;
}

app-cmf-document-editor,
.text-preview,
.draft-info {
  &.normal-screen {
    width: 860px;
    margin: 0 auto;
  }
}

app-cmf-document-editor,
.text-preview,
.draft-info {
  &.full-screen {
    width: 100%;
  }
}

.disabled {
  cursor: not-allowed !important;

  /* TODO: !!! выпилить после добавления в директиву кнопок состояния disabled */
  color: rgb(0 0 0 / 26%) !important;
}

.text-preview {
  cursor: pointer;
  color: var(--color-gray-888);
}

.reference {
  cursor: pointer;

  display: flex;
  align-items: center;

  width: 200px;
  height: 100%;
  margin-top: 10px;
  margin-right: auto;

  &__trigger {
    padding: 0 20px;
    line-height: 34px;
    color: var(--color-gray-888);
    border-radius: 4px;

    &:hover,
    &:focus,
    &--active {
      color: inherit;
      background-color: var(--color-gray-eee);
    }
  }

  &__list__title {
    margin-bottom: 4px;
    color: var(--color-gray-888);
  }

  &__content-wrapper {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;

    width: 450px;
    max-height: 60vh;
    margin-top: 10px;
    padding: 10px;

    background-color: var(--color-gray-fff);
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 2px 2px 3px 0 rgb(25 25 25 / 25%);

    .list__item {
      display: flex;
      gap: 7px;
      align-items: center;

      &:not(:last-child) {
        margin-bottom: 10px;
      }

      .icon {
        display: flex;
        align-items: center;
      }

      .name {
        cursor: pointer;

        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;

        max-width: 60%;

        /* color: inherit; */
        color: var(--color-href);
        text-decoration: none;
        text-overflow: ellipsis;

        -webkit-line-clamp: 1;
        line-clamp: 1;
      }
    }
  }

  &__title {
    margin-top: 0;
    margin-bottom: 10px;
  }
}

.draft-info {
  font: var(--default-text-font);
  font-family: var(--default-font-family);
  line-height: var(--default-line-height);
  color: var(--color-gray-888);
}

.draft-tip {
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-start;
  justify-content: flex-start;

  padding: 6px 12px;

  border: 1px solid var(--color-gray-aaa, #aaa);
  border-radius: 5px;

  &.alert {
    border: 1px solid var(--default-color-red, #e31e24);
  }

  &.warn {
    border: 1px solid var(--default-color-orange, #ffc007);
  }

  &.decrypted {
    display: flex;
    justify-content: center;
    border: 1px solid var(--default-color-green, #61ce70);
  }

  &-buttons {
    display: flex;
    flex-flow: row nowrap;
    margin-left: auto;
  }

  &-text {
    overflow: hidden;
    max-width: calc(100% - 170px);
    text-overflow: clip;
    white-space: nowrap;
  }

  .href-button {
    cursor: pointer;

    font: var(--default-text-font);
    font-family: var(--default-font-family);
    line-height: var(--default-line-height);
    color: var(--color-href);
    text-decoration: underline;

    background: none;
    border: none;

    transition: opacity 0.2s ease;

    &:hover {
      opacity: 0.7;
    }
  }

  .status-change {
    pointer-events: none;
    cursor: default;
    user-select: none;

    display: inline-block;

    text-decoration: none;

    opacity: 1;

    transition: opacity 0.2s ease;

    &.clickable {
      pointer-events: all;
      cursor: pointer;

      &:hover {
        text-decoration: underline;
        opacity: 0.7;
      }
    }
  }
}

/** margin-right-level-1 */
.mr-1 {
  margin-right: 6px;
}

.page404 {
  position: relative;

  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: center;

  margin: 20vh auto;

  .page404-card {
    display: flex;
    flex-flow: column;
    justify-content: space-between;

    width: 530px;
    height: 300px;

    header {
      font: var(--wiki-font-h1);
    }

    main {
      font: var(--wiki-text-font);
    }
  }
}

@mixin actions-action {
  cursor: pointer;

  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;

  font: var(--default-text-font);
  font-size: var(--default-font-size);
  line-height: 1;
  color: var(--color-gray-444);

  background-color: transparent;
  border: none;
}

@mixin actions-action-wide {
  display: flex;
  flex-flow: row nowrap;
  gap: 2px;

  width: unset;
  min-width: 32px;
  padding: 0 5px;
}

@mixin actions-action-button {
  padding: 0 1.5px;

  button {
    white-space: nowrap;
  }
}

@mixin actions-btn-group {
  z-index: 2;

  display: flex;
  flex-flow: row nowrap;
  gap: 0;

  background-color: var(--color-gray-fff);
}

@mixin actions-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-item.actions > .btn-group {
  @include actions-btn-group;
}

.info-item.actions > .btn-group > .action,
.info-item.actions > .action {
  @include actions-action;

  &.action-wide {
    @include actions-action-wide;
  }

  &.action-button {
    @include actions-action-button;
  }

  app-cmf-icon,
  app-cmf-doodle-icon {
    @include actions-action-icon;
  }
}

.likes-margin {
  min-width: 150px;
  margin-left: 49px;
}

.line {
  border-bottom: 1px solid var(--color-gray-eee);
}

.buttons-wrapper {
  display: flex;
  flex: 1 0 0;
  justify-content: flex-end;
}

.draft-tip-buttons-right {
  display: flex;
  flex-flow: row nowrap;
}

app-cmf-document-editor.appearance-draft {
  padding: 0 0 40px 0;
}
