//
// 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/vars';
@import '../../globals/scss/typography';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';

/// Content switcher styles
/// @access private
/// @group content-switcher
@mixin content-switcher {
  .#{$prefix}--content-switcher {
    display: flex;
    justify-content: space-evenly;
    width: 100%;
    height: rem(40px);
  }

  .#{$prefix}--content-switcher--disabled {
    cursor: not-allowed;
  }

  .#{$prefix}--content-switcher-btn {
    @include reset;
    @include type-style('body-short-01');
    @include focus-outline('reset');

    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: $carbon--spacing-03 $carbon--spacing-05;
    overflow: hidden;
    color: $text-02;
    white-space: nowrap;
    text-align: left;
    text-decoration: none;
    background-color: $ui-01;
    border: none;
    transition: all $duration--fast-01 motion(standard, productive);

    &:focus {
      z-index: 3;
      box-shadow: inset 0 0 0 2px $focus;
    }

    &:hover {
      cursor: pointer;
    }

    &:hover,
    &:active {
      z-index: 3;
      color: $text-01;
      background-color: $hover-ui;
    }

    &:disabled {
      color: $disabled-02;
      background-color: $disabled-01;
      pointer-events: none;

      &:hover {
        cursor: not-allowed;
      }
    }
  }

  .#{$prefix}--content-switcher--light .#{$prefix}--content-switcher-btn {
    background-color: $ui-02;

    &:hover {
      background-color: $hover-light-ui;
    }
  }

  .#{$prefix}--content-switcher-btn:first-child {
    border-top-left-radius: rem(4px);
    border-bottom-left-radius: rem(4px);
  }

  .#{$prefix}--content-switcher-btn:last-child {
    border-top-right-radius: rem(4px);
    border-bottom-right-radius: rem(4px);
  }

  .#{$prefix}--content-switcher-btn::before {
    position: absolute;
    left: 0;
    z-index: 2;
    display: block;
    width: rem(1px);
    height: rem(16px);
    background-color: $content-switcher-divider;
    content: '';
  }

  .#{$prefix}--content-switcher-btn:first-of-type::before {
    display: none;
  }

  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn::before {
    background-color: $decorative-01;
  }

  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn:focus::before,
  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn:focus
    + .#{$prefix}--content-switcher-btn::before,
  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn:hover::before,
  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn:hover
    + .#{$prefix}--content-switcher-btn::before,
  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher--selected::before,
  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher--selected
    + .#{$prefix}--content-switcher-btn::before,
  .#{$prefix}--content-switcher-btn:focus::before,
  .#{$prefix}--content-switcher-btn:focus
    + .#{$prefix}--content-switcher-btn::before,
  .#{$prefix}--content-switcher-btn:hover::before,
  .#{$prefix}--content-switcher-btn:hover
    + .#{$prefix}--content-switcher-btn::before,
  .#{$prefix}--content-switcher--selected::before,
  .#{$prefix}--content-switcher--selected
    + .#{$prefix}--content-switcher-btn::before {
    background-color: transparent;
  }

  .#{$prefix}--content-switcher__icon {
    transition: fill $duration--fast-01 motion(standard, productive);
    fill: $text-02;
  }

  .#{$prefix}--content-switcher__icon + span {
    margin-left: $carbon--spacing-03;
  }

  .#{$prefix}--content-switcher__label {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .#{$prefix}--content-switcher-btn:hover .#{$prefix}--content-switcher__icon,
  .#{$prefix}--content-switcher-btn:focus .#{$prefix}--content-switcher__icon {
    fill: $text-01;
  }

  .#{$prefix}--content-switcher--light
    .#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected,
  .#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected {
    z-index: 3;
    color: $inverse-01;
    background-color: $ui-05;

    &:disabled {
      color: $disabled-02;
      background-color: $disabled-03;
    }
  }

  .#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected
    .#{$prefix}--content-switcher__icon {
    fill: $inverse-01;
  }
}

@include exports('content-switcher') {
  @include content-switcher;
}
