// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE in the project root for license information.

//
// Office UI Fabric
// --------------------------------------------------
// Panel styles

$Panel-width-lightDismiss: 272px;
$Panel-width-sm: 340px;
$Panel-width-md: 643px;
$Panel-width-lg: 940px;
$Panel-margin-md: 48px;
$Panel-margin-lg: 428px;
$Panel-margin-xl: 176px;
$CommandBarHeight: 40px;
$CommandButtonLightBlue: #b5d8f4;
$CommandButtonLighterBlue: #d7eaf9;
$CommandButtonDarkBlue: #07288b;
$CommandButtonBlue: #2488D8;

// The panel covers the entire screen.
.ms-Panel {
  bottom: 0;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: $ms-zIndex-Panel;
  display: none;
  pointer-events: none;

  // Overlay used within panel
  .ms-Overlay {
    z-index: $ms-zIndex-back;
    display: none;
    pointer-events: none;
    opacity: 1;
    cursor: pointer;
    transition: opacity $ms-duration3 $ms-ease1;
  }
}

// The panel itself, where the content goes.
.ms-Panel-main {
  background-color: $ms-color-white;
  bottom: 0;
  position: fixed;
  right: 0;
  top: 0;
  display: none;
  z-index: $ms-zIndex-front;
  width: 100%;

  // Medium screens and up - (anchored right, fixed width)
  @media (min-width: $ms-screen-md-min) {
    border-left: 1px solid $ms-color-neutralLight;
    border-right: 1px solid $ms-color-neutralLight;
    pointer-events: auto;
    width: $Panel-width-sm;
    @include drop-shadow(-30px, 0px, 30px, -30px, .2);
    left: auto;
  }

  .ms-CommandBar {
    outline: 1px solid transparent;

    // The commandbar is not displayed by default on md+ screens
    @media (min-width: $ms-screen-md-min) {
      display: none;
    }
  }

  .ms-CommandBarItem {
    margin-left: 8px;

    .ms-CommandBarItem-commandText {
      display: inline-block;
    }
  }

  .ms-CommandBar-mainArea {
    padding-left: 0;
    margin-left: -1px;
    overflow: hidden;
  }
}

//== Modifier: Light Dismiss on small screens (fixed width)
// Note: This panel should only be used for dropdown menus on small screens.
.ms-Panel.ms-Panel--lightDismiss {
  .ms-Panel-main {
    border-left: 1px solid $ms-color-neutralLight;
    border-right: 1px solid $ms-color-neutralLight;
    width: $Panel-width-lightDismiss;
    @include drop-shadow(-30px, 0px, 30px, -30px, .2);
  }

  // Commands and content inner are not displayed
  // Note: Replace with a dropdown contextual menu.
  .ms-Panel-commands,
  .ms-Panel-contentInner {
    display: none;
  }

  // Animations -- Default (anchored right)
  &.ms-Panel-animateIn {
    .ms-Panel-main {
      @include ms-u-slideLeftIn40;
    }

    .ms-Overlay {
      @include ms-u-fadeIn200;
    }
  }
  
  &.ms-Panel-animateOut {
    .ms-Panel-main {
      @include ms-u-slideRightOut40;
    }
    .ms-Overlay {
      @include ms-u-fadeOut200;
    }
  }
}

//== Modifier: Left anchored panel (anchored left, fixed width)
// Note: This panel variant should only be used for left nav.
.ms-Panel.ms-Panel--left {
  .ms-Panel-main {
    right: auto;
    left: 0;
    border-left: 1px solid $ms-color-neutralLight;
    border-right: 1px solid $ms-color-neutralLight;
    width: $Panel-width-lightDismiss;
    @include drop-shadow(-30px, 0px, 30px, 30px, .2);
  }

  // Commands and content inner are not displayed
  // Note: Replace with a leftnav menu.
  .ms-Panel-commands,
  .ms-Panel-contentInner {
    display: none;
  }
  
  // Animations -- Default (anchored right)
  &.ms-Panel-animateIn {
    .ms-Panel-main {
      @include ms-u-slideLeftIn40;
    }

    .ms-Overlay {
      @include ms-u-fadeIn200;
    }
  }
  
  &.ms-Panel-animateOut {
    .ms-Panel-main {
      @include ms-u-slideRightOut40;
    }
    .ms-Overlay {
      @include ms-u-fadeOut200;
    }
  }

  // Animations - Left panel (anchored left)
  &.ms-Panel-animateIn {
    .ms-Panel-main {
      @include ms-u-slideRightIn40;
    }

    .ms-Overlay {
      @include ms-u-fadeIn200;
    }
  }

  &.ms-Panel--left.ms-Panel-animateOut {
    .ms-Panel-main {
      @include ms-u-slideLeftOut40;
    }
    .ms-Overlay {
      @include ms-u-fadeOut200;
    }
  }
}

//== Modifier: Small panel (anchored right, fixed width)
//
.ms-Panel.ms-Panel--sm {
  .ms-Panel-main {
    width: 100%;

    @media (min-width: $ms-screen-md-min) {
      width: $Panel-width-sm;
    }
  }
}

//== Modifier: Medium, Large, Extra Largs panels (anchored right, fluid width)
//
.ms-Panel.ms-Panel--md,
.ms-Panel.ms-Panel--lg,
.ms-Panel.ms-Panel--xl {
  .ms-Panel-main {
    @media (min-width: $ms-screen-lg-min) {
      left: $Panel-margin-md;
      width: auto;
    }
  }
}

//== Modifier: Medium panel (anchored right, fixed width)
//
.ms-Panel.ms-Panel--md {
  .ms-Panel-main {
    @media (min-width: $ms-screen-xl-min) {
      left: auto;
      width: $Panel-width-md;
    }
  }
}

//== Modifier: Large panel (anchored right, fluid width)
//
.ms-Panel.ms-Panel--lg {
  .ms-Panel-main {
    @media (min-width: $ms-screen-xxl-min) {
      left: $Panel-margin-lg;
    }
  }
}

//== Modifier: Large fixed panel (anchored right, fixed width)
//
.ms-Panel.ms-Panel--lg.ms-Panel--fixed {
  .ms-Panel-main {
    @media (min-width: $ms-screen-xxl-min) {
      left: auto;
      width: $Panel-width-lg;
    }
  }
}

//== Modifier: XLarge panel (anchored right, fluid width)
//
.ms-Panel.ms-Panel--xl {
  .ms-Panel-main {
    @media (min-width: $ms-screen-xxl-min) {
      left: $Panel-margin-xl;
    }    
  }
}

//== State: When the panel is open.
//
.ms-Panel.is-open {
  display: block;

  .ms-Panel-main {
    opacity: 1;
    pointer-events: auto;
    display: block;
  }

  .ms-Overlay {
    display: block;
    pointer-events: auto;

    @media screen and (-ms-high-contrast: active) {
      opacity: 0;
    }
  }

  &.ms-Panel-animateIn {
    .ms-Panel-main {
      @include ms-u-fadeIn100;
    }
  }

  &.ms-Panel-animateOut {
    .ms-Panel-main {
      @include ms-u-fadeOut100;
    }

    .ms-Overlay {
      display: none;
    }
  }

  // Medium screens and up
  @media (min-width: $ms-screen-md-min) {
    // Animations -- Default (anchored right)
    &.ms-Panel-animateIn {
      .ms-Panel-main {
        @include ms-u-slideLeftIn40;
      }

      .ms-Overlay {
        @include ms-u-fadeIn200;
      }
    }
    
    &.ms-Panel-animateOut {
      .ms-Panel-main {
        @include ms-u-slideRightOut40;
      }
      .ms-Overlay {
        @include ms-u-fadeOut200;
      }
    }

    // Animations - Left panel (anchored left)
    &.ms-Panel--left.ms-Panel-animateIn {
      .ms-Panel-main {
        @include ms-u-slideRightIn40;
      }

      .ms-Overlay {
        @include ms-u-fadeIn200;
      }
    }

    &.ms-Panel--left.ms-Panel-animateOut {
      .ms-Panel-main {
        @include ms-u-slideLeftOut40;
      }
      .ms-Overlay {
        @include ms-u-fadeOut200;
      }
    }

    // Animate overlay to full opacity, activate pointer events
    .ms-Overlay {
      cursor: pointer;
      opacity: 1;
      pointer-events: auto;
    }

    &.ms-Panel-animateIn,
    &.ms-Panel--left.ms-Panel-animateIn {
      .ms-Overlay {
        @media screen and (-ms-high-contrast: active) {
          opacity: 0;
          animation-name: none;
        }
      }
    }
  }
}

// The close button in the top right (x)
.ms-Panel-closeButton {
  @include button-reset();
  position: absolute;
  right: 8px;
  top: 0;
  height: $CommandBarHeight;
  width: $CommandBarHeight;
  line-height: $CommandBarHeight;
  outline: 0;
  padding: 0;
  color: $ms-color-neutralSecondary;
  font-size: $ms-font-size-m;

  &:hover {
    color: $ms-color-neutralPrimary;
  }
}

// Scrollable content area
.ms-Panel-contentInner {
  position: absolute;
  top: $CommandBarHeight;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 16px 20px;
  overflow-y: auto;

  @media (min-width: $ms-screen-lg-min) {
    padding: 0 32px 20px;
  }

  @media (min-width: $ms-screen-xxl-min) {
    padding: 0 40px 20px;
  }
}

// Header text at the top of the panel.
.ms-Panel-headerText {
  font-family: $ms-font-family-light;
  font-size: $ms-font-size-xl;
  color: $ms-color-neutralPrimary;
  margin: 10px 0;
  padding: 4px 0;
  line-height: 1;
  text-overflow: ellipsis;
  overflow: hidden;

  @media (min-width: $ms-screen-xl-min) {
    margin-top: 30px;
  } 
}

//== Modifier: Deprecated Animated commandbar
//
.ms-Panel.ms-Panel--animatedCommands {
  .ms-CommandBar {
    @media (min-width: $ms-screen-md-min) {
      display: block;
    }    
  }

  .ms-CommandBarItem {
    user-select: none;

    &:hover {
      background-color: $CommandButtonLighterBlue;
    }

    &:active {
      background-color: $CommandButtonLightBlue;

      .ms-CommandBarItem-icon {
        color: $CommandButtonDarkBlue;;
      }

      .ms-CommandBarItem-commandText {
        color: $ms-color-black;
      }
    }
  }

  .ms-CommandBarItem:first-child {
    background-color: $ms-color-themePrimary;
    box-shadow: inset 0 1px 0 0 $CommandButtonBlue;

    .ms-CommandBarItem-icon {
      color: $ms-color-white;
    }

    .ms-CommandBarItem-commandText {
      color: $ms-color-white;
    }

    .ms-CommandBarItem-linkWrapper {
      padding-left: 12px;
      padding-right: 12px;
      cursor: pointer;
    }

    &:hover {
      background-color: $ms-color-themeDark;
      box-shadow: none;

      .ms-CommandBarItem-icon {
        color: $ms-color-white;
      }

      .ms-CommandBarItem-commandText {
        color: $ms-color-white;
      }
    }
  }

  &.is-open {
    .ms-CommandBar {
      @include ms-u-slideDownIn20();
      animation-delay: 250ms;
    }

    @media (min-width: $ms-screen-md-min) {
      // Animate CommandBar in
      .ms-CommandBar {
        animation-delay: 500ms;
      }
    }
  }
}
