// Copyright (C) 2018 The Android Open Source Project
//
// 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 "widgets/theme";

.sidebar {
  --sidebar-padding-bottom: 40px;
  --sidebar-timing: 0.15s;
  grid-area: sidebar;
  z-index: 4;
  background-color: #262f3c;
  overflow: hidden;
  width: var(--sidebar-width);
  display: flex;
  position: relative;
  flex-direction: column;
  transition: margin-left var(--anim-easing) var(--sidebar-timing),
    visibility linear var(--sidebar-timing);
  > * {
    border-bottom: 1px solid #404854;
  }
  input[type="file"] {
    display: none;
  }
  > header {
    font-family: "Roboto Condensed", sans-serif;
    font-weight: 700;
    font-size: 24px;
    height: var(--topbar-height);
    line-height: var(--topbar-height);
    vertical-align: middle;
    padding: 0 12px;
    color: #fff;
    overflow: visible;
    .brand {
      height: 36px;
      margin-top: 4px;
    }
    &::before {
      z-index: 10;
    }
    &.canary::before,
    &.autopush::before {
      display: block;
      position: absolute;
      font-size: 10px;
      line-height: 5px;
      font-family: "Roboto", sans-serif;
      top: 7px;
      right: 48px;
    }
    &.canary::before {
      content: "CANARY";
      color: #ffd700;
    }
    &.autopush::before {
      content: "AUTOPUSH";
      color: #aed581;
    }
  }
  .sidebar-button {
    position: fixed;
    z-index: 5;
    background-color: #262f3c;
    height: var(--topbar-height);
    left: calc(var(--sidebar-width) - 50px);
    border-radius: 0 5px 5px 0;
    border-bottom: inherit;
    visibility: visible; // So stays visible when the sidebar is hidden.
    transition: left var(--anim-easing) var(--sidebar-timing);
    width: 48px;
    overflow: hidden;
    > button {
      vertical-align: middle;
    }
  }
  &.hide-sidebar {
    visibility: hidden;
    margin-left: calc(var(--sidebar-width) * -1);
    .sidebar-button {
      left: 0;
      background-color: transparent;
      border-radius: unset;
      border-bottom: none;
      color: #aaaaaa;
    }
  }
  .sidebar-scroll {
    overflow-y: auto;
    flex: 1;
    &::-webkit-scrollbar {
      width: 0.5em;
    }
    &::-webkit-scrollbar-track {
      background-color: #19212b;
      border-radius: 2px;
    }
    &::-webkit-scrollbar-thumb {
      background: #b4b7ba6e;
      border-radius: 2px;
    }
    > .sidebar-scroll-container {
      position: relative;
      min-height: 100%;
      padding-bottom: var(--sidebar-padding-bottom);

      > section {
        @include transition();
        padding: 20px 0;
        max-height: 80px;
        .section-header {
          cursor: pointer;
          > h1,
          > h2 {
            letter-spacing: 0.25px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin: 0 12px;
          }
          > h1 {
            color: #fff;
            font-size: 15px;
          }
          > h2 {
            @include transition();
            color: rgba(255, 255, 255, 0.5);
            font-size: 12px;
            margin-top: 8px;
            font-weight: 400;
          }
          &:before {
            @include material-icon("expand_more");
            float: right;
            color: rgba(255, 255, 255, 0.3);
            margin-right: 12px;
            margin-top: -4px;
          }
        }
        &:hover {
          background-color: #373f4b;
        }
        &.expanded {
          background-color: #19212b;
          max-height: unset;
          .section-header {
            h2 {
              opacity: 0;
            }

            &:before {
              content: "expand_less";
            }
          }

          .section-content {
            pointer-events: inherit;
            opacity: 1;
          }
        }
      }

      .section-content {
        pointer-events: none;
        @include transition();
        opacity: 0;
        color: #b4b7ba;
        a {
          color: #b4b7ba;
        }
        ul {
          list-style-type: none;
          margin: 0;
          padding: 0;
        }
        li {
          @include transition();
          a {
            line-height: 24px;
            font-size: 14px;
            padding: 4px 12px;
            text-decoration: none;
            display: block;
            &.pending {
              color: rgba(255, 255, 255, 0.3);
              &::after {
                content: " ";
                display: inline-block;
                vertical-align: middle;
                box-sizing: border-box;
                width: 18px;
                height: 18px;
                margin-left: 10px;
                border-radius: 50%;
                border: 2px solid #b4b7ba;
                border-color: #b4b7ba transparent;
                animation: pending-spinner 1.25s linear infinite;
              }
              @keyframes pending-spinner {
                0% {
                  transform: rotate(0deg);
                }
                100% {
                  transform: rotate(360deg);
                }
              }
            }
            &[disabled] {
              text-decoration: line-through;
            }
          }
          .material-icons {
            margin-right: 10px;
            font-size: 20px;
          }
          &:hover {
            background-color: #373f4b;
          }
          .trace-file-name {
            white-space: break-spaces;
            font-family: "Roboto Condensed", sans-serif;
            word-break: break-all;
            font-weight: 300;
            letter-spacing: 0;
            margin-top: -10px;
            color: #fff;
          }
        }
      }
    }
  }

  .sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 2px 10px;
    display: grid;
    height: -var(--sidebar-padding-bottom);
    grid-template-columns: repeat(4, min-content);
    grid-gap: 10px;

    > button {
      color: hsl(217, 39%, 94%);
      i {
        font-size: 24px;
      }

      &:hover {
        color: hsl(45, 100%, 48%);
      }
    }

    > .dbg-info-square {
      font-family: "Roboto Condensed", sans-serif;
      width: 24px;
      height: 24px;
      line-height: 24px;
      display: flex;
      justify-content: center;
      flex-direction: column;
      align-items: center;

      margin: 1px 0;
      background: #12161b;
      color: #4e71b3;
      border-radius: $pf-border-radius;
      font-size: 12px;
      text-align: center;
      &.green {
        background: #7aca75;
        color: #12161b;
      }
      &.amber {
        background: #ffc107;
        color: #333;
      }
      &.red {
        background: #d32f2f;
        color: #fff;
      }
      > div {
        font-size: 10px;
        line-height: 11px;
      }
    }

    .version {
      position: absolute;
      right: 8px;
      bottom: 3px;
      font-size: 12px;
      font-family: "Roboto Condensed", sans-serif;
      a {
        color: rgba(255, 255, 255, 0.5);
        text-decoration: none;
      }
      margin-top: 11px;
    }
  }
}

// Hide the footer when running integration tests, as the version code and the
// tiny text with pending queries can fail the screenshot diff test.
body.testing .sidebar-footer {
  visibility: hidden;
}

.keycap {
  background-color: #fafbfc;
  border: 1px solid #d1d5da;
  border-bottom-color: #c6cbd1;
  border-radius: 3px;
  box-shadow: inset 0 -1px 0 #c6cbd1;
  color: #444d56;
  display: inline-block;
  font-family: var(--monospace-font);
  vertical-align: middle;

  line-height: 20px;
  padding: 3px 7px;
}
