@import '../../styles/common';
@import '../../Modal/styles/animation';
@import 'mixin';

.rs-drawer-wrapper {
  position: fixed;
  z-index: @zindex-drawer;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

// Container that the drawer scrolls within
.rs-drawer {
  display: none;
  overflow: hidden;
  position: fixed;
  z-index: @zindex-drawer;
  box-shadow: var(--rs-drawer-shadow);
  // Prevent Chrome on Windows from adding a focus outline. For details, see
  // https://github.com/twbs/bootstrap/pull/10951.
  outline: 0;

  // Kill the scroll on the body
  &-open&-has-backdrop {
    overflow: hidden;
  }

  // Drawer sizes
  &-left,
  &-right {
    top: 0;
    height: 100%;

    &.rs-drawer-lg {
      .drawer-content-width(@drawer-horizontal-lg);
    }

    &.rs-drawer-md {
      .drawer-content-width(@drawer-horizontal-md);
    }

    &.rs-drawer-sm {
      .drawer-content-width(@drawer-horizontal-sm);
    }

    &.rs-drawer-xs {
      .drawer-content-width(@drawer-horizontal-xs);
    }
  }

  &-top,
  &-bottom {
    width: 100%;

    &.rs-drawer-lg {
      .drawer-content-height(@drawer-vertical-lg);
    }

    &.rs-drawer-md {
      .drawer-content-height(@drawer-vertical-md);
    }

    &.rs-drawer-sm {
      .drawer-content-height(@drawer-vertical-sm);
    }

    &.rs-drawer-xs {
      .drawer-content-height(@drawer-vertical-xs);
    }
  }

  // Full page
  &-full {
    @max-width: ~'calc(100% - @{drawer-full-size-margin})';
    @max-height: @max-width;

    &.rs-drawer-top,
    &.rs-drawer-bottom {
      .drawer-content-height(@max-height);

      .rs-drawer-content {
        height: 100%;
      }
    }

    &.rs-drawer-left,
    &.rs-drawer-right {
      .drawer-content-width(@max-width);
    }
  }

  // Drawer directions
  &-right {
    right: 0;
  }

  &-left {
    left: 0;
  }

  &-top {
    top: 0;
  }

  &-bottom {
    bottom: 0;
  }
}

// Make sure drawer can be show in Safari.
.rs-drawer-open .rs-drawer {
  overflow: visible;
}

.rs-drawer-dialog {
  position: relative;
  width: 100%;
  height: 100%;

  .rs-drawer-shake & {
    animation: 0.3s linear shakeHead;
  }
}

.rs-drawer-content {
  position: absolute;
  background-color: var(--rs-bg-overlay);
  outline: 0;
  width: 100%;
  height: 100%;

  .high-contrast-mode({
    background-color: var(--rs-drawer-bg);
  });
}

.rs-drawer-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: @zindex-drawer-background;
  background-color: var(--rs-bg-backdrop);

  // Fade for backdrop
  &.rs-anim-fade {
    opacity: 0;
    transition: opacity 0.3s ease-in;
  }

  &.rs-anim-in {
    opacity: 1;
  }
}

// Drawer header
// Top section of the modal title.
.rs-drawer-header {
  .clearfix();

  position: relative;
  padding: 20px 40px 20px 60px;
  border-bottom: 1px solid var(--rs-border-primary);
  display: flex;

  .rs-drawer-header-close {
    position: absolute;
    left: 15px;
    top: 23px;
  }
}

.rs-drawer-title {
  flex-grow: 1;
  flex-shrink: 1;
  margin: 0;
  color: var(--rs-text-heading);
  font-weight: normal;
  font-size: @modal-title-font-size;
  line-height: 36px; // same as default button height
  .ellipsis-basic();
}

.rs-drawer-actions {
  .clearfix(); // clear it in case folks use .pull-* classes on buttons

  flex-shrink: 0;
  text-align: right; // right align buttons
  border-top: none;
  margin-left: auto;

  .rs-drawer-title ~ & {
    margin-left: 10px;
  }

  // Properly space out buttons
  .rs-btn + .rs-btn {
    margin-left: 10px;
    margin-bottom: 0; // account for input[type="submit"] which gets the bottom margin like all other inputs
  }
  // but override that for button groups
  .rs-btn-group .rs-btn + .rs-btn {
    margin-left: -1px;
  }
  // and override it for block buttons as well
  .rs-btn-block + .rs-btn-block {
    margin-left: 0;
  }
}

// Drawer body
.rs-drawer-body {
  position: relative;
  padding: 30px 60px;
  height: 100%;
  overflow: auto;

  .rs-drawer-header + & {
    height: calc(100% - 76px);
  }

  &-close {
    position: absolute;
    left: 15px;
    top: 25px;

    .rs-drawer-header ~ .rs-drawer-body & {
      display: none;
    }
  }
}

// Measure scrollbar width for padding body during modal show/hide
.rs-drawer-scrollbar-measure {
  position: absolute;
  top: -9999px;
  width: 50px;
  height: 50px;
  overflow: scroll;
}

// Footer (for actions)
// todo rs-drawer-footer has been deprecated, remove the styles once the component API is removed
.rs-drawer-footer {
  .clearfix(); // clear it in case folks use .pull-* classes on buttons

  text-align: right; // right align buttons
  border-top: none;
  margin: 0 @drawer-content-spacing @drawer-content-spacing;

  // Properly space out buttons
  .rs-btn + .rs-btn {
    margin-left: 10px;
    margin-bottom: 0; // account for input[type="submit"] which gets the bottom margin like all other inputs
  }
  // but override that for button groups
  .rs-btn-group .rs-btn + .rs-btn {
    margin-left: -1px;
  }
  // and override it for block buttons as well
  .rs-btn-block + .rs-btn-block {
    margin-left: 0;
  }
}
