@import '~@angular/material/theming';
@import "../../../../scss/variables";
@import "../../../../scss/mixins";
@import "../../../../scss/palettes";
@import "../../../../../public/css/variables";
@import "../../../../../public/css/functions";
@import "../../../../../public/css/mixins";
@import "~material-components-web/material-components-web";

:host {
  display: block;
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}

.knk-header {
  position: relative;
  min-height: 88px;
  padding: 0 0 0 25px;
  @include ng-theming {
    background-color: theme-get('color-secondary');
  }

  &:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    @include ng-theming($if: default) {
      background-color: #e7e9ea;
    }
    @include ng-theming($if: night) {
      background-color: #000000;
    }
  }

  &__segment {
    padding: 8px 0;
  }

  &__foundation {
    position: relative;
  }

  &__spacer {
    width: 1px;
    height: 100%;
    // background-color: #e7e9ea;
    @include ng-theming {
      background-color: theme-get('color-spacer');
    }
    transform: scale(1);
  }
}

ng-svg-icon.knk-header-logo::ng-deep svg {
  max-width: 50px;
  max-height: 58px;
  width: auto;
  height: auto;
  fill-rule: evenodd;
  clip-rule: evenodd;
}

.knk-header-icon {
  outline: 0;
  color: $knk-color-primary;

  &#{&}--menu {
    margin-left: 5px;
    font-size: 1em;
    line-height: 1.25;

    @include ng-theming {
      color: rgba(theme-get('color-font'), 0.5);
    }
  }
}

ng-svg-icon.knk-header-icon::ng-deep svg {
  max-width: 30px;
  max-height: 30px;
  width: auto;
  height: auto;
  stroke: none;
  fill: $knk-color-primary;
  fill-rule: evenodd;
  clip-rule: evenodd;
}

.knk-header-search {
  overflow: hidden;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: calc(100% - 80px);
  @include ng-theming {
    background-color: theme-get('color-secondary');
  }
  transition: left 0.25s linear;
  will-change: left;

  &__button {
    margin: 0;
    padding: 0;
    outline: 0;
    border: 0;
    cursor: pointer;
    background: transparent none;

    &--loupe {
      width: 80px;
      height: 100%;
      @include ng-theming {
        background-color: theme-get('color-secondary');
      }
      transition: background-color 0.25s linear;

      ng-svg-icon.knk-header-icon::ng-deep svg {
        max-width: 25px;
        max-height: 25px;
        transition: fill 0.25s linear;
        will-change: fill;
      }
    }
  }

  &__panel {
    height: 100%;
    padding: 0 20px 0 30px;
    @include ng-theming {
      background-color: theme-get('color-secondary');
    }
  }

  &__control {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    outline: 0;
    border: 0;
    background: transparent none;
    @include knk-font-default;
    @include knk-input-placeholder;
  }

  &--opened {
    left: 0;
  }

  &--opened &__button {
    &--loupe {
      @include ng-theming($if: default) {
        background-color: theme-get('color-primary');
      }
      @include ng-theming($if: night) {
        background-color: theme-get('color-background'); // background-color: #ffffff;
      }
      ng-svg-icon.knk-header-icon {
        &::ng-deep svg {
          @include ng-theming($if: default) {
            fill: #ffffff;
          }
          @include ng-theming($if: night) {
            fill: theme-get('color-primary');
          }
        }
      }
    }
  }
}

.knk-header-menu {
  margin: 0 0 0 15px;

  &__item {
    position: relative;
    display: inline-flex;
    margin-right: 20px;
    @include knk-font-default;
    @include ng-theming {
      color: theme-get('color-font');
    }
    text-decoration: none;

    /*&#{&}--last {
      margin-right: 0;
    }*/

    &:hover {
      text-decoration: none;
    }

    &.active {
      font-weight: bold;
      @include ng-theming {
        color: theme-get('color-primary');
      }

      & .knk-header-icon.knk-header-icon--menu {
        @include ng-theming {
          color: rgba(theme-get('color-primary'), 0.9);
        }
      }

      @media screen and (min-width: 1024px) {
        &:before {
          content: '';
          position: absolute;
          top: -250%;
          left: 50%;
          width: 120px;
          height: 0.8em;
          margin-left: -60px;
          border-radius: 20px;
          background: $knk-color-primary none;
          @include ng-theming($if: default) {
            box-shadow: 2px 3px 11px 0 lighten(theme-get('color-primary'), 20%);
          }
          @include ng-theming($if: night) {
            box-shadow: 2px 3px 11px 0 lighten(theme-get('color-secondary'), 20%);
          }
        }
      }
    }

    &.disabled {
      @include ng-theming {
        color: transparentize(theme-get('color-font'), 0.5);
      }
      pointer-events: none;
      cursor: default;
    }
  }

  &--published &__item {
    @include ng-theming {
      color: theme-get('color-primary');
    }
    margin-right: 1em;

    &.disabled {
      @include ng-theming {
        color: transparentize(theme-get('color-primary'), 0.5);
      }
    }
  }
}

.knk-button {
  &--knok {
    max-width: 150px;
    min-width: 150px;
    width: auto;
    height: 25px;
    margin: 0 15px;
    font-size: 14px;
    line-height: normal;
  }
}

ng-button-distorted.ng-button-distorted--knok.ng-button-distorted {
  max-width: 150px;
  min-width: 150px;
  width: auto;
  height: 25px;
  margin: 0 15px;

  &::ng-deep {
    .ng-button-distorted__label {
      font-size: 14px;
      line-height: normal;
    }

    .circle {
      width: 12px;
      height: 12px;

      &.top-left {
        top: 6px;
        left: 6px;
      }

      &.bottom-right {
        bottom: 6px;
        right: 6px;
      }
    }
  }
}

.knk-avatar {
  @include knk-avatar(46px);
}

.knk-pane-account {
  margin-left: 20px;

  &__balance {
    margin: 0 15px 0 5px;
    @include knk-font-default;
    @include ng-theming {
      color: theme-get('color-font');
    }

    div:first-child {
      font-weight: bold;
    }
  }

  &__profile {
    margin: 0 15px 0 5px;
    cursor: pointer;
  }

  &__avatar {
    position: relative;

    &:after {
      content: attr(data-counter);
      position: absolute;
      bottom: 50%;
      left: 50%;
      width: 20px;
      height: 20px;
      margin-bottom: 5px;
      margin-left: 5px;
      // border: solid 2px #ffffff;
      @include ng-theming {
        border: solid 2px theme-get('color-notification-count');
      }
      border-radius: 50%;
      background-color: $knk-color-primary;
      @include knk-font-default;
      font-size: 12px;
      font-weight: bold;
      line-height: 16px;
      color: #ffffff;
      text-align: center;
    }

    &--anonymous {
      &:after {
        content: none;
        display: none;
      }
    }
  }
}

.knk-header-profile-menu {
  &.mdc-menu {
    overflow: visible;
    min-width: 160px;
    margin-left: calc(100% + 0.4rem);
    transform: translateX(-100%);
    border-radius: 4px;
    @include ng-theming {
      border: solid 1px rgba(theme-get('color-primary'), 0.16);
      box-shadow: 0 0 12px 0 rgba(theme-get('color-black'), 0.3);
      background-color: theme-get('color-secondary');
    }

    &:before,
    &:after {
      content: '';
      position: absolute;
      pointer-events: none;
      border: solid transparent;
      height: 0;
      width: 0;
      bottom: 100%;
      right: 16px;
    }

    &:before {
      border-width: 0.8rem;
      margin: 1px -4px;
      @include ng-theming {
        border-bottom-color: rgba(theme-get('color-primary'), 0.16);
      }
    }

    &:after {
      border-width: 0.8rem;
      margin: 0 -4px;
      @include ng-theming {
        border-bottom-color: theme-get('color-secondary');
      }
      // border-bottom-color: #ffffff;
    }

    .mdc-switch__items {
      max-height: inherit;
    }
  }

  .mdc-list {
    padding: 10px 0;
  }

  .mdc-list-item {
    justify-content: flex-end;
    min-height: 34px;
    height: auto;
    margin: 0;
    padding: 0 20px 0 15px;
    @include knk-font-default;
    @include ng-theming {
      color: theme-get('color-menu-label');
    }

    &[aria-disabled="true"],
    &.disabled {
      @include ng-theming {
        color: transparentize(theme-get('color-font'), 0.5);
      }
      pointer-events: none;
      cursor: default;
    }

    /*&.active {
      &:before,
      &:after {
        background-color: $knk-color-primary;
      }

      &:before {
        z-index: 1;
        opacity: 0.08;
        transition: opacity 15ms linear;
      }

      &:after {
        transition: opacity 150ms linear;
      }
    }*/

    &__counter {
      display: inline-flex;
      justify-content: center;
      width: 18px;
      height: 18px;
      margin-right: 10px;
      border-radius: 50%;
      background-color: $knk-color-primary;
      font-size: 12px;
      font-weight: bold;
      line-height: 18px;
      color: #ffffff;
    }

    .mdc-switch {
      margin-left: 10px;
    }
  }

  .mdc-switch {
    .mdc-switch__native-control:enabled:checked ~ .mdc-switch__background:before {
      background-color: $knk-color-primary;
    }

    .mdc-switch__native-control:enabled:checked ~ .mdc-switch__background .mdc-switch__knob {
      background-color: $knk-color-primary;
    }

    .mdc-switch__knob {
      &:before {
        content: none;
        display: none;
      }
    }
  }
}

.dropdown-menu.dropdown-menu--header {
  z-index: 40;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  outline: 0;
  border: 0;

  .knk-header-dropdown-menu {
    left: 20px;
    right: auto;

    &__wrapper {
      left: auto;
      right: 8px;
    }
  }
}

.dropdown-menu.dropdown-menu--submenu {
  z-index: 40;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  outline: 0;
  border: 0;
}

.knk-header-dropdown-menu {
  position: relative;
  z-index: 40;

  &__wrapper {
    position: absolute;
    top: 15px;
    left: 0.4rem;
    z-index: 40;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    @include ng-theming {
      border: solid 1px rgba(theme-get('color-primary'), 0.16);
      box-shadow: 0 0 12px 0 rgba(theme-get('color-black'), 0.3);
      background-color: theme-get('color-secondary');
    }

    &:before,
    &:after {
      content: '';
      position: absolute;
      pointer-events: none;
      border: solid transparent;
      height: 0;
      width: 0;
      bottom: 100%;
      right: 16px;
    }

    &:before {
      border-width: 0.8rem;
      margin: 1px -4px;
      @include ng-theming {
        border-bottom-color: rgba(theme-get('color-shadow'), 0.10);
      }
    }

    &:after {
      border-width: 0.8rem;
      margin: 0 -4px;
      @include ng-theming {
        border-bottom-color: theme-get('color-secondary');
      }
    }
  }

  &__list {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 40;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 150px;
    max-height: 150px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 5px 0;
    @include ng-theming {
      background-color: theme-get('color-secondary');
    }
    list-style: none;
  }

  &__item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 34px;
    height: auto;
    margin: 0;
    padding: 0 20px 0 15px;
    outline: 0;
    border: 0;
    @include ng-theming {
      background-color: theme-get('color-secondary');
    }
    cursor: pointer;
    transition: background-color 0.25s linear;
    will-change: background-color;
    @include knk-font-default;
    @include ng-theming {
      color: theme-get('color-menu-label');
    }
    white-space: nowrap;
    text-decoration: none;

    &.active {
      font-weight: bold;
      @include ng-theming {
        color: theme-get('color-primary');
      }
    }

    &[aria-disabled="true"],
    &.disabled {
      @include ng-theming {
        color: transparentize(theme-get('color-font'), 0.5);
      }
      pointer-events: none;
      cursor: default;
    }

    &:hover {
      @include ng-theming {
        background-color: rgba(theme-get('color-primary'), 0.2);
      }
    }
  }
}
