/*
 * Copyright (C) 2017-2019 Dremio 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.
 */

:global {
  .mainContent .explorePage {
    overflow: auto;

    &.--collpase {
      .dremioSidebar {
        background-color: var(--fill--secondary);
        width: 36px;
      }

      .dremioSidebar__drag {
        display: none;
      }

      .dremioSidebarWrap .dremioSidebarWrap__inner .TreeBrowser {
        .TreeBrowser-heading {
          overflow: hidden;

          .TreeBrowser-tab {
            opacity: 0;
            order: 2;
          }
        }

        .resource-tree,
        .TreeBrowser-items {
          flex: 1;

          opacity: 0;
          pointer-events: none;
          overflow: hidden;
        }
      }

      .TreeBrowser__collapseButton {
        transform: rotate(180deg);
      }

      .sqlScripts {
        opacity: 0;
        overflow: hidden;
      }
    }
  }

  .dremioContent {
    display: grid;
    grid-template-rows: auto 1fr;
    width: 100%;

    &__header {
      border-left: 1px solid var(--border--neutral);
      border-bottom: 1px solid var(--border--neutral);
      align-items: center;
      display: flex;
      gap: 10px;
      height: 64px;
      justify-content: space-between;

      form {
        flex-grow: 1;
      }

      .input__container {
        font-size: 15px;
        border: none;

        > input::placeholder {
          color: var(--text--placeholder);
          font-style: italic;
        }
      }

      .validationError {
        margin-left: 8px;
      }
    }

    .code-view {
      height: fit-content;
      max-height: calc(100% - 16px);
      max-width: calc(100vw - 64px);
      margin: var(--dremio--spacing--1);
      overflow: auto;
      position: relative;

      &__header {
        display: none;
      }

      &__content {
        overflow: auto;

        &.error code {
          white-space: pre-wrap !important;
        }

        .inner-actions {
          display: flex;
          position: absolute;
          top: var(--dremio--spacing--05);
          right: var(--dremio--spacing--1);

          .dremio-icon-button {
            color: var(--icon--primary);
            dremio-icon {
              block-size: 24px !important;
              inline-size: 24px !important;
            }

            &:disabled {
              color: var(--icon--disabled);
            }

            &:hover {
              color: var(--icon--hover);
              background-color: var(--fill--primary--hover--alt);
              opacity: 1;
            }
          }
        }

        .language-sql {
          font-family: Consolas, "Fira Code";
        }
      }
    }

    &__spinner {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    &__actions {
      display: flex;
      justify-content: space-between;
      margin: 15px 10px 0;
      padding-bottom: 10px;
    }

    // Catalog, Graph, Reflections content area
    &__content {
      border-left: 1px solid var(--border--neutral);
      border-right: 1px solid var(--border--neutral);

      height: 100%;
      overflow: auto;
    }

    &__content-tabpanel {
      display: contents;
    }

    &__table {
      background: var(--fill--primary);
      display: grid;
      grid-template-rows: auto 1fr;
      overflow-y: hidden;
    }

    &__table.fullHeight {
      height: 100%;
    }

    &__main {
      overflow: auto;
    }
  }

  .dremioContent.--withTabs {
    grid-template-rows: 1fr;
  }

  // SQL content column is less than 1000px wide
  // Text will be removed from buttons
  .dremioContent__content.--minimal {
    .noText {
      display: none;
    }
  }
  .dremioContent__content.--minimal {
    .ExploreHeader__left,
    .dremioContent__table .left-controls {
      .btn.--outlined {
        min-width: 36px !important;
        width: 36px !important;
      }
    }
    .ExploreHeader__right {
      .show-hide-sql-btn {
        min-width: 32px !important;
        width: 32px !important;
      }
    }
  }

  // Data content area
  .mainContent {
    &.-default {
      .dremioContent__main {
        display: grid;
        grid-template-columns: auto 1fr auto;
        overflow: hidden;
      }

      .dremioContent__content {
        display: grid;
        grid-template-rows: auto auto auto 1fr;
        height: 100%;
        position: relative;
      }

      .dremioContent__content--withTabs {
        grid-template-rows: max-content auto auto auto 1fr;
      }
    }

    &.-details {
      .dremioContent__content {
        display: grid;
        grid-template-rows: auto 1fr;

        .dremioContent__table {
          grid-template-rows: 1fr;
          padding-left: 1px;
          padding-right: 4px;
        }
      }
    }

    &.-reflections,
    &.-graph {
      .dremioContent__content {
        max-height: unset !important;
        .dremioContent__table {
          height: 100%;
        }

        .dremioContent__table {
          grid-template-rows: auto auto 1fr;
        }
      }
    }

    &.-graph .dremioContent__content .dremioContent__table {
      position: relative;
    }
  }

  .dremioContent-rightCol {
    align-items: center;
    display: flex;
    margin-right: 5px;

    &__time {
      height: 100%;
    }

    &__shortcuts {
      p {
        display: block;
        text-transform: uppercase;
        border-bottom: 1px solid var(--text--primary);
      }

      .keyboard:hover {
        cursor: pointer;
      }
    }
  }

  .dremioSidebarWrap {
    height: 100%;
    opacity: 1;
    transition: 500ms ease opacity;
  }

  .dremioSidebarHeader {
    align-items: center;
    flex: 1 1 auto;
    display: flex;
    margin: 0 12px 16px;
    justify-content: space-between;
    transition: 300ms ease margin;

    &-nav {
      flex: 1 1 auto;
      max-width: 250px;
      opacity: 1;
      transition:
        300ms ease-out max-width,
        300ms ease opacity;
      visibility: visible;

      &__item {
        position: relative;
        text-transform: uppercase;
        width: 50%;
        padding: 20px 0;
        text-align: center;

        &::after {
          background-color: var(--color--brand--500);
          bottom: 0;
          content: "";
          height: 3px;
          left: 0;
          position: absolute;
          width: 100%;
        }
      }
    }
  }

  .keyboardShortcutTooltip {
    padding: 0 !important;
  }

  .tooltip-content {
    min-width: 260px;
    &__heading {
      text-transform: uppercase;
      font-size: 14px;
      padding: 10px;
    }

    .divider {
      background-color: var(--border--neutral);
      height: 1px;
      width: 100%;
    }

    &__list {
      padding: 10px;
      min-width: 160px;
      li {
        gap: 12px;
        display: flex;
        font-size: 14px;
        justify-content: space-between;
        align-items: center;

        &:not(:last-child) {
          margin-bottom: 10px;
        }

        span {
          background-color: var(--hover--chip);
          border-radius: 8px;
          display: inline-block;
          font-size: 14px;
          padding: 3px 8px;
          height: 24px;
        }
      }
    }
  }
}
