@import '../helpers/helpers';

.header-wrapper {
  position: relative;
  z-index: $header;
  background: $blue-dark;

  &--search {
    z-index: $header;
  }
}

.header {
  @include make-container;
  @include make-container-max-widths;
  position: relative;
}

.header-top-wrapp {
  background-color: $white;

  &.header-switch-vat {
    .header-top-wrapp__container {
      display: flex;
      justify-content: space-between;
    }
  }
}

.header-top-wrapp__container {
  @include make-container;
  @include make-container-max-widths;
  padding-top: 12px;
  padding-bottom: 12px;
}

.header-inner {
  @include make-row;
  padding: 15px 0;
  align-items: center;
}

.header-logo {
  margin-top: -15px;
  padding-left: 15px;

  @include media-breakpoint-only(md) {
    margin-top: -5px;
  }

  @include media-breakpoint-down(sm) {
    margin-top: -17px;
  }
}

.header-logo--minicart {
  display: none;
}

.header-logo__link,
.header-logo__link-tp,
.header-logo_wickes {
  background: top left no-repeat;
  background-size: contain;
  display: block;
  overflow: hidden;
  text-indent: -100em;
}

.header-hamburg,
.header-mobileicon {
  display:  none;
}

.header-top-line {
  margin: 0;
  text-align: right;
}

.header-top-line__item {
  color: $white;
  display: inline-block;
  font-size: .75rem;
  line-height: 1rem;
  padding: 0 14px;

  &:last-child {
    border: 0;
    padding-right: 0;
  }

  .truncate {
    @include truncate;
    vertical-align: bottom;
    display: inline-block;
  }
}

.header-top-line_shop-list {
  position: relative;

  .header-top-line__link {
    .header-top-line__link-title {
      padding-left: 10px;
    }
  }

  &:hover {
    .btn {
      color: $blue;
      background-color: $white;
      border-color: $blue;
    }

    & > a {
      text-decoration: underline;
    }
  }

  .btn {

    .svg-inline--fa.fa-w-12.svg-inline--fa.fa-w-12 {
      height: 22px;
      width: 15px;
    }
  }
}

.header-top-line__link {
  display: flex;
  align-items: center;
  color: $blue-dark;
  text-decoration: none;

  &:hover,
  &:focus {
    color: $blue-dark;
  }

  & .btn_text {
    height: 16px;
    width: 18px;
  }
}

.header-search__wrapper {
  flex: 1;
  padding: 0 35px;
}

.search-wrapper--active {
  @include make-col-ready;
  display: block;
}

.header-search__overlay {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  height: 100%;
  opacity: .6;
  background: #000;
}

.header-search {
  position: relative;
}

.header-search__input {
  @include inputfield;
  border-color: $white;
  padding-right: 40px;
  border-radius: 25px;

  // ie11, edge remove default clear button
  // sass-lint:disable no-vendor-prefixes
  &::-ms-clear {
    display: none;
  }
}

.header-search__submit {
  position: absolute;
  top: 50%;
  right: 16px;
  padding: 0;
  color: $blue-dark;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5rem;
  border: 0;
  background: none;
  cursor: pointer;

  &:hover {
    color: $blue;
  }
}

.header-search__submit-label {
  position: relative;
  display: none;
  line-height: normal;
}

.header-search__submit-icon {
  position: relative;
  line-height: normal;

  & svg {
    height: 24px;
  }
}

.header-right-wrapp {
  color: #fff;
}

.header-right {
  padding: 0;
  margin: 0;
  list-style: none;
}

.header-right__item {
  position: relative;
  display: inline-block;
  padding: 0 14px;
}

.header-right__link {
  display: flex;
  flex-direction: column;
  color: #fff;
  text-decoration: none;
  text-align: center;

  &:hover,
  &:focus,
  &:active {
    background-color: transparent;
    color: $blue;
  }

  & .btn__text {
    height: 26px;
  }

  & svg {
    height: 24px;
  }

}

.touch-device .header-right__link.header-minicart__btn_link {
  background-color: transparent;
  color: $blue;
}

.header-right__link-title {
  margin-top: 4px;
}

.header-minicart-wrap {
  display: none;
}

.header-minicart {
  text-align: right;
}

.header-minicart__switcher {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.header-shop-list .svg-inline--fa.fa-w-12.svg-inline--fa.fa-w-12 {
  height: 22px;
  width: 15px;
}

.header-minicart__btn,
.header-hamburger-menu,
.header-shop-list {
  padding-left: 0;
  padding-right: 0;
}

button.header-minicart__btn {
  background: none;
  border: 0;
  box-shadow: none;
  outline: none;
  cursor: pointer;

  &:hover {
    .header-right__link-title {
      text-decoration: underline;
    }
  }
}

.header-shop-list {
  .icon {
    color: $white;
  }

  .icon-user {
    font-size: 1.1875rem;
  }
}

.header-minicart__btn-icon {
  vertical-align: top;
}

.header-minicart__counter {
  position: absolute;
  top: -(26px / 2);
  right: 7px;
  display: inline-block;
  padding: 0 5px;
  height: 24px;
  min-width: 24px;
  border-radius: (26px / 2);
  background-color: $red;
  color: $white;
  font-size: .625rem;
  font-weight: bold;
  line-height: 24px;
  text-align: center;
}

.header-hamburger-menu {
  padding: 8px 5px;
  background-color: transparent;
  border: 0;

  .fa-times {
    display: none;
  }

  .icon {
    vertical-align: top;
  }

  &_close-visible {
    &,
    &:hover,
    &:focus,
    &:active {
      background: $white;
      color: $blue;
    }

    .fa-bars {
      display: none;
    }

    .icon {
      background: url('../img/ic-menu.svg') left top no-repeat;
      vertical-align: top;
    }
  }
}

.user {
  &_desktop {
    position: relative;
    text-align: left;
  }

  &__popover {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: $popover;

    &-wrap {
      position: relative;
      margin-top: 16px;
      box-shadow: 4px 4px 16px 0 rgba(0, 0, 0, .25);

      &::before {
        content: '';
        position: absolute;
        right: 16px;
        top: -12px;
        border-right: 9px solid transparent;
        border-left: 9px solid transparent;
        border-bottom: 12px solid $white;
      }
    }

    .header-top-line__item:hover & {
      display: block;
    }

    &-actions {
      padding: 8px 0;
      border-top: 1px solid $gray;
    }

    .rewards-counter {
      @include line-height(20);
      @include font-size(12);
      position: relative;
      margin-left: 8px;
      font-weight: 500;
      min-width: 20px;
    }
  }

  &__popover-content {
    min-width: 224px;
    padding: 8px 16px;
    background: $white;
    border-radius: 4px;

    &_extended {
      width: 190px;
    }

    .icon-wrap {
      @include icon-wrap;
      margin-right: 8px;
      color: $blue-satin;
    }
  }

  &__action {
    @include normal-text;
    display: flex;
    align-items: center;
    position: relative;
    color: $gray-dark;
    font-weight: 500;
    text-decoration: none;
    padding-top: 8px;
    padding-bottom: 8px;

    &:hover {
      text-decoration: none;
      color: $blue;
    }

    &--account {
      margin-bottom: 8px;
    }
  }

  &__name {
    text-decoration: none;

    .touch-device & {
      pointer-events: none;
    }
  }

  &__logout {
    border-top: 1px solid $gray;
    padding-top: 8px;
  }

  .icon-logout {
    font-size: 1rem;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  &.user_desktop {
    .user__name {
      display: flex;
      align-items: center;
      color: $blue-dark;

      .btn__text {
        display: flex;
      }

      .custom-icon {
        width: 1.125rem;
        height: auto;

        path {
          fill: $blue-dark;
        }
      }

      .icon-user {
        width: auto;
        font-size: 1rem;
      }
    }
  }
}

.touch-device {
  .header {
    .tel-uri {
      color: inherit;
      text-decoration: underline;
    }
  }
}

.header-search__submit-icon--mobile {
  display: none;
}

@include media-breakpoint-up(md) {
  .header-logo__link,
  .header-logo__link-tp,
  .header-logo_wickes {
    background-image: url('../img/wickes-logo.svg');
    height: 92px;
    width: 130px;

    &_small {
      height: 72px;
      width: 109px;
    }
  }

  .header-logo__link-tp {
    background-image: url('../img/tradePro-logo_desk.png');
    margin-top: 13px;
    height: 79px;

    &_small {
      height: 78px;
    }
  }

  .header-top-line {
    display: flex;
    height: 22px;
    justify-content: flex-end;
    align-items: center;
  }

  .header-search__submit {
    transform: translateY(-50%);
  }

  .header-search__input {
    height: 48px;
  }

  .header-search__submit-label {
    display: inline;
    padding-left: 6px;
  }
}

@include media-breakpoint-up(lg) {
  .header-top-line__item {
    .truncate {
      max-width: 350px;
    }
  }
}

@include media-breakpoint-down(md) {
  .header-search__wrapper {
    padding: 0 20px;
  }

  .header-minicart__btn-label {
    display: none;
  }

  .header-inner {
    flex-wrap: unset;
    min-height: 76px;
    padding: 0;
    margin-left: 0;
  }

  .header-hamburg {
    display: flex;
    align-items: center;
  }

  .header-logo,
  .header-logo__link,
  .header-logo_wickes,
  .search-switcher {
    display: none;
  }

  .header-logo--minicart {
    display: block;
    position: relative;
    top: -9px;
    max-width: 100%;
    flex: 1;

    & .header-logo__link-tp,
    & .header-logo__link {
      display: block;
      background-image: url('../img/wickes-logo.svg');
      height: 53px;
      width: 82px;
      margin-left: 10px;
      margin-right: 15px;
    }

    & .header-logo__link-tp {
      margin-top: 21px;
      background-position-x: left;
      background-image: url('../img/tradePro-logo_desk.png');
    }
  }

  .header-right,
  .header-top-wrapp {
    display: none;
  }

  .header-top-wrapp {
    &.header-switch-vat {
      display: block;
      background-color: $blue-dark;

      .header-top-line {
        display: none;
      }

      .header-top-wrapp__container {
        justify-content: flex-end;
      }
    }
  }

  .header-mobileicon {
    width: auto;
    display: flex;
    align-items: center;
  }

  .header-right__link-title {
    display: none;
  }

  .header-minicart-wrap {
    display: block;
  }

  .header-minicart {
    @include make-col-ready;
    width: auto;
    display: flex;
    align-items: center;
    padding-left: 0;
  }

  .header-minicart__counter {
    display: inline-block;
    right: 11px;
    top: -6px;
    left: auto;
  }

  .header-minicart__btn,
  .header-shop-list {
    width: 40px;
    height: 40px;
    background-color: transparent;
    color: #fff;
    border: 0; // TODO: use better solution
  }

  .header-minicart__btn {
    display: flex;
    justify-content: center;

    svg {
      height: 22px;
    }
  }

  .header-hamburger-menu {
    .icon {
      margin-top: -1px;
    }
  }

  .header-minicart .icon {
    width: 32px;
  }
}

@include media-breakpoint-down(sm) {
  .header-search__wrapper {
    @include make-col(12);
    display: none;

    &.search-wrapper--active {
      display: block;
    }
  }

  .header-hamburg {
    flex: 1;
  }

  .search-switcher,
  .search-wrapper--active {
    display: block;
  }

  .header-search__input {
    padding-right: 56px;
  }

  .header-search__submit {
    top: 0;
    bottom: 0;
    right: 0;
    padding: 0 16px;
  }

  .header-search__submit-icon:not(.header-search__submit-icon--mobile) {
    display: none;
  }

  .header-search__submit-icon--mobile {
    display: block;
    color: $blue;
  }

  .header-search__wrapper {
    position: absolute;
    bottom: calc(-100% - 44px);
    padding: 0;
    margin-left: -15px;

    .header-search__overlay {
      display: block;
    }

    .header-search__input {
      padding: 60px 56px 60px 15px;
      font-size: 2rem;
      font-weight: 500;
      color: #0a3055;
      border: 0;
      border-radius: 0;

      &:focus {
        &::-webkit-input-placeholder {
          color: transparent;
        }
      }
    }
  }

  .btn-primary.search-switcher {
    transition: none;
    background-color: transparent;
    color: #fff;
  }

  .btn-primary.search--active {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    background-color: $blue;
    color: #fff;
    height: 76px;

    &::before {
      position: absolute;
      content: '';
      bottom: -9px;
      width: 0;
      height: 0;
      border-left: 10px solid transparent;
      border-right: 10px solid transparent;
      border-top: 10px solid $blue;
    }
  }

  .search-open {
    overflow: hidden;
  }

  .header-logo--minicart {
    top: -3px;
  }
}

@include media-breakpoint-only(md) {
  .header-top-line__item {
    padding: 0 10px;

    .truncate {
      max-width: 110px;
    }

    &--tel {
      max-width: 120px;
      height: 16px;
      vertical-align: bottom;
      text-align: left;

      &.yCmsComponent {
        @include truncate;
        max-width: 200px;

        .header-top-line__item-number {
          top: 0;
          left: 0;
        }
      }
    }

    &-number {
      position: relative;
      top: -8px;
    }
  }
}

@media screen and (max-width: 360px) {
  .header-logo--minicart {
    .header-logo__link,
    .header-logo__link-tp {
      width: 74px;
      margin-left: 0;
      margin-right: 0;
    }
  }
}

@include media-breakpoint-down(md) {
  .header-top-wrapp {
    transform: translate3d(0, 0, 0); /* safari rendering fix */
  }
}
