/* ==========================================================================
   Config
   ========================================================================== */
@use "sass:math";

$top-bar-height: 114px;
$top-bar-height-medium: 74px;
$top-bar-main-breakpoint: medium;
$top-bar-dropdown-bottom-margin: 27px !default;
$top-bar-zindex: 500 !default;
$top-bar-notification-height: 42px;

/* ==========================================================================
   Styles
   ========================================================================== */
.gui-top-bar {
  height: $top-bar-height;
  padding: 0;
  z-index: $top-bar-zindex;
  position: relative;

  @include respond-to($top-bar-main-breakpoint) {
    height: $top-bar-height-medium;
  }

  .gui-top-bar__wrapper {
    background: #fff;
    border-bottom: 1px solid $color-border-base;
    padding: $layout-spacing-base * 0.5 math.div($layout-spacing-base, 1.5);
    width: 100%;
  }

  .gui-top-bar__wrapper--fixed {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
  }

  .gui-top-bar__inner {
    min-height: 53px;
    position: relative;

    @include respond-to($top-bar-main-breakpoint) {
      display: flex;
      align-items: center;
    }
  }

  .gui-top-bar__content {
    position: static;
    display: flex;
    align-items: center;
  }

  .gui-top-bar__content--left {
    @include respond-to($top-bar-main-breakpoint) {
      position: absolute;
      top: 0;
      bottom: 0;
    }

    .gui-top-bar__cell:last-child {
      flex-grow: 1;
    }
  }

  .gui-top-bar__content--center {
    justify-content: center;

    @include respond-to($top-bar-main-breakpoint) {
      margin: 0 auto;
    }
  }

  .gui-top-bar__content--right {
    justify-content: flex-end;

    @include respond-to($top-bar-main-breakpoint) {
      padding-right: $layout-spacing-base;
      position: absolute;
      top: 0;
      bottom: 0;
      right: 0;
      order: 3;
    }
  }

  .gui-top-bar__cell {
    padding: 0 $layout-spacing-base 0 0;
    display: flex;
    align-items: center;

    img {
      display: block;
    }

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

  .gui-top-bar__cell--bordered {
    padding-left: $layout-spacing-base;
    border-left: 1px solid $color-border-base;
  }

  .gui-top-bar__action {
    fill: $neutral-dark;
    padding: math.div($layout-spacing-base, 2.5);
  }

  .gui-item-settings .gui-button {
    display: block;
    padding: math.div($layout-spacing-base, 2.5)
      math.div($layout-spacing-base, 1.55);
  }

  .gui-top-bar__action--collapse-left {
    margin-left: 0;
  }

  .gui-top-bar__action--collapse-right {
    margin-right: 0;
  }

  .gui-top-bar__drop-down {
    background: #fff;
    overflow: scroll;
    position: absolute;
    height: calc(100vh - #{$top-bar-height+$top-bar-dropdown-bottom-margin});
    inset: $top-bar-height - ($layout-spacing-base * 0.5) 0 auto 0;
    z-index: 999;
    padding-bottom: $layout-spacing-base;

    @include respond-to($top-bar-main-breakpoint) {
      max-width: 400px;
      top: $top-bar-height-medium - ($layout-spacing-base * 0.5);
      height: calc(
        100vh - #{$top-bar-height-medium+$top-bar-dropdown-bottom-margin}
      );
    }
  }

  &.gui-top-bar--has-notification {
    .gui-top-bar__drop-down {
      height: calc(
        100vh - #{$top-bar-height+$top-bar-dropdown-bottom-margin+$top-bar-notification-height}
      );

      @include respond-to($top-bar-main-breakpoint) {
        height: calc(
          100vh - #{$top-bar-height-medium+$top-bar-dropdown-bottom-margin+$top-bar-notification-height}
        );
      }
    }
  }

  &--dark {
    .gui-top-bar__wrapper {
      background: $neutral-dark;
      border-color: $neutral-dark;
      color: white;
    }

    .gui-top-bar__action {
      fill: white;
    }

    .gui-top-bar__cell--bordered {
      border-color: $neutral-base;
    }

    .gui-avatar__initials {
      color: black;
    }

    .gui-dropdown__action {
      color: $neutral-dark;
    }
  }
}

.gui-top-bar-light-grey {
  .gui-top-bar__wrapper {
    @apply bg-neutral-98 border-neutral-90 text-neutral-20;
  }

  .gui-top-bar__cell--bordered {
    @apply border-neutral-90;
  }
}

.gui-top-bar__content--right.gui-top-bar__content--collapse {
  padding-right: 0;
}

.gui-top-bar__content--left.gui-top-bar__content--collapse {
  padding-left: 0;
}

.gui-top-bar__group {
  display: flex;
  margin: 0 math.div($layout-spacing-base, 1.33);
}

.gui-top-bar__group--collapse {
  margin: 0;
}

.gui-top-bar__group > * {
  margin: 0 $layout-spacing-base * 0.25;
}

.gui-top-bar--has-notification,
.gui-top-bar--has-notification .gui-top-bar__wrapper {
  height: $top-bar-height + $top-bar-notification-height;

  @include respond-to($top-bar-main-breakpoint) {
    height: $top-bar-height-medium + $top-bar-notification-height;
  }
}

.gui-top-bar--has-notification {
  .gui-notification {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
  }

  .gui-top-bar__inner {
    width: 100%;
    top: $top-bar-notification-height;
  }
}
