/*
 * Copyright 2020 IBM Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import '../../scss/components/common/narrow-window';

$size: 0.25em;
$opacity: 0.1;
$opacity-hover: 0.2;
$border-width: 1px;
$border-color: transparent;
$border-color-hover: var(--color-base04);
$background-color: var(--color-base06);

.Resizer {
  & {
    opacity: $opacity;
    z-index: 1;
    background-clip: padding-box;
  }

  &:hover {
    transition: all 0.5s ease;
    opacity: $opacity-hover;
  }

  &.horizontal {
    height: $size;
    border-top: $border-width solid $border-color;
    border-bottom: $border-width solid $border-color;
    width: 100%;
    cursor: row-resize;
  }

  &.vertical {
    width: $size;
    border-left: $border-width solid $border-color;
    border-right: $border-width solid $border-color;
    cursor: col-resize;
  }

  &.disabled {
    cursor: not-allowed;
  }
  &.disabled:hover {
    border-color: transparent;
  }

  &.vertical,
  &.horizontal {
    display: flex;
    flex-direction: column;
    background: $background-color;

    &.disabled {
      display: none;
    }
    &:hover {
      border-color: $border-color-hover;
    }
  }
  .resizer-thumb-fill {
    flex: 1;
  }
  .resizer-thumb {
    flex-basis: 4em;
    background-color: var(--color-text-02);
    border: 1px solid transparent;
    border-radius: 0.9375em;
  }
  &:hover .resizer-thumb {
    background-color: var(--color-base0D);
  }
}

.SplitPane {
  .Pane {
    min-width: 0;

    /* see https://github.com/IBM/kui/issues/3914 */
    position: unset !important;
  }

  &.kui--sidecar-closed .Resizer.vertical {
    display: none;
  }
}

@include narrow-window {
  .SplitPane.vertical:not(.kui--sidecar-closed) {
    .Pane1 {
      flex: 0 !important;
    }
    .Resizer {
      /* see https://github.com/IBM/kui/issues/4179 */
      display: none;
    }
    .Pane2 {
      width: 100% !important;

      .toggle-sidecar-maximization-button {
        /* no need to maximize, if the sidecar is taking up the full screen */
        display: none;
      }
    }
  }
}
