//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@import '../../globals/scss/functions';
@import '../../globals/scss/vars';
@import '../../globals/scss/typography';
@import 'theme';
@import 'functions';

/// UI shell product switcher
/// @access private
/// @group ui-shell
@mixin product-switcher {
  //--------------------------------------------------------------------------
  // Global Panel
  //--------------------------------------------------------------------------
  .#{$prefix}--panel--overlay {
    position: fixed;
    top: mini-units(6);
    right: 0;
    bottom: 0;
    z-index: 1000;
    width: mini-units(32);
    height: 100%;
    padding: 1rem 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: $shell-panel-bg-01;
    transform: translate3d(100%, 0, 0);
    transition: transform 0.11s cubic-bezier(0.2, 0, 0.38, 0.9);
    will-change: transform;
  }

  .#{$prefix}--panel--expanded {
    box-shadow: 0 8px 16px 0 rgba($carbon--black-100, 0.25);
    transform: translate3d(0, 0, 0);
  }

  //--------------------------------------------------------------------------
  // Switcher - Search
  //--------------------------------------------------------------------------
  .#{$prefix}--product-switcher__search {
    margin-bottom: mini-units(3);
    padding: 0 mini-units(2);
  }

  .#{$prefix}--search--shell input {
    background-color: $carbon--gray-20;
  }

  //--------------------------------------------------------------------------
  // Switcher - Buttons
  //--------------------------------------------------------------------------
  .#{$prefix}--product-switcher__subheader,
  .#{$prefix}--product-switcher__all-btn {
    @include type-style('body-short-01');

    padding: mini-units(1);
    color: $shell-panel-text-01;
  }

  .#{$prefix}--product-switcher__subheader {
    padding-left: mini-units(7);
  }

  .#{$prefix}--product-switcher__all-btn {
    padding-left: mini-units(7);
  }

  .#{$prefix}--product-switcher__all-btn,
  .#{$prefix}--product-switcher__back-btn {
    display: inline-block;
    width: 100%;
    color: $shell-header-link;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
  }

  .#{$prefix}--product-switcher__all-btn:hover,
  .#{$prefix}--product-switcher__back-btn:hover {
    text-decoration: underline;
  }

  .#{$prefix}--product-switcher__all-btn:focus,
  .#{$prefix}--product-switcher__back-btn:focus {
    outline: none;
    box-shadow: inset 0 0 0 3px $shell-header-link;
  }

  .#{$prefix}--product-switcher__back-btn {
    @include type-style('body-short-01');

    display: flex;
    align-items: center;
    padding: mini-units(1) mini-units(2);
  }

  .#{$prefix}--product-switcher__back-arrow {
    margin-right: mini-units(2);
    fill: $shell-header-link;
  }

  //--------------------------------------------------------------------------
  // Switcher - Product List
  //--------------------------------------------------------------------------
  .#{$prefix}--product-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
  }

  .#{$prefix}--product-list__item:hover {
    background: $carbon--gray-20;
  }

  .#{$prefix}--product-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    padding: mini-units(1) mini-units(2);
    text-decoration: none;
  }

  .#{$prefix}--product-link:focus {
    outline: none;
    box-shadow: inset 0 0 0 3px $shell-header-link;
  }

  .#{$prefix}--product-switcher__icon {
    margin-right: mini-units(2);
  }

  .#{$prefix}--product-link__name {
    @include type-style('body-short-01');

    margin-left: 0.25rem;
    color: $shell-header-text-02;
    font-weight: 400;
  }

  .#{$prefix}--product-switcher__product-list .#{$prefix}--overflow-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: mini-units(5);

    &.#{$prefix}--overflow-menu--open {
      display: flex;
    }
  }

  .#{$prefix}--product-switcher__product-list .#{$prefix}--overflow-menu > svg {
    fill: $shell-header-text-02;
  }

  .#{$prefix}--product-switcher__product-list .#{$prefix}--overflow-menu:hover {
    background: $carbon--gray-30;
  }

  .#{$prefix}--product-switcher__product-list
    .#{$prefix}--overflow-menu:hover
    > svg {
    fill: $shell-header-text-02;
  }

  .#{$prefix}--product-switcher__product-list .#{$prefix}--overflow-menu:focus {
    display: flex;
    outline: none;
    box-shadow: inset 0 0 0 3px $shell-header-link;
  }

  .#{$prefix}--product-switcher__product-list
    .#{$prefix}--overflow-menu-options__option:hover {
    background: $carbon--white-0;
  }

  .#{$prefix}--product-list__item:hover .#{$prefix}--overflow-menu {
    display: flex;
  }
}

@include exports('product-switcher') {
  @if feature-flag-enabled('ui-shell') {
    @include product-switcher;
  }
}
