@use '../colors';
@use './top-bar-util';

.root {
  width: 100%;
  display: flex;
  justify-content: center;
  background: colors.$basic-white;
  height: var(--top-bar-height);
  flex-shrink: 0; // ВАЖНО: для использования в Modal
  &.inner-border-bottom {
    box-shadow: inset 0 -1px 0 colors.$basic-gray12;
  }
}

.size-s {
  @include top-bar-util.size-s;
}

.size-m {
  @include top-bar-util.size-m;
}

.size-xl {
  @include top-bar-util.size-xl;
}

.rounds-s {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.rounds-m {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.main {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: center;
  overflow: hidden;
  text-align: var(--top-bar-text-align, center);

  // когда нет кнопок
  &:first-child:last-child {
    margin: 0 var(--top-bar-gutter);
  }
}

.title {
  color: colors.$basic-gray87;
  font-size: var(--top-bar-title-size);
  line-height: var(--top-bar-title-height);
  font-weight: 600;

  // когда нет подзаголовка
  &:first-child:last-child {
    font-size: var(--top-bar-title-only-size, var(--top-bar-title-size));
    line-height: var(--top-bar-title-only-height, var(--top-bar-title-height));
  }
}

.subtitle {
  color: colors.$basic-gray38;
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  margin-top: -2px;
}

.title,
.subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.button-group {
  display: flex;
  align-items: center;
  width: 100%;
  &:not(.end) {
    .iconic {
      &:first-child:last-child {
        justify-content: flex-start;
        padding-left: var(--top-bar-gutter);
      }
      &:not(:last-child):first-child {
        justify-content: flex-start;
        padding-left: var(--top-bar-gutter);
      }
      &:not(:first-child):last-child {
        justify-content: flex-end;
        padding-right: var(--top-bar-gutter);
      }
    }
  }
  &.end {
    justify-content: flex-end;
    .iconic {
      &:first-child:last-child {
        justify-content: flex-end;
        padding-right: var(--top-bar-gutter);
      }
      &:not(:last-child):first-child {
        justify-content: flex-start;
        padding-left: var(--top-bar-gutter);
      }
      &:not(:first-child):last-child {
        justify-content: flex-end;
        padding-right: var(--top-bar-gutter);
      }
    }
    :not(.iconic) {
      justify-content: flex-end;
    }
  }
  &:not(.stub) {
    height: 100%;
  }
}

.button {
  background: transparent;
  border: 0;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  margin: 0;
  outline: 0;
  text-align: inherit;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0;
  &:hover {
    cursor: pointer;
  }
  &.iconic {
    color: colors.$basic-gray87;
    width: var(--top-bar-icon-button-width);
    &:hover {
      color: colors.$basic-gray54;
    }
  }
  &:not(.iconic) {
    color: colors.$basic-blue;
    width: 100%;
    padding: 0 var(--top-bar-gutter);
    &:hover {
      color: colors.$additional-deep-blue;
    }
  }
  &.stub {
    height: 0;
    overflow: hidden;
  }
  svg {
    // чтобы выравнивались по центру по вертикали
    display: block;
    flex-shrink: 0;
    fill: currentColor;
  }
}
