/*
 * 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.
 */

$num-columns: 4; /* keep in sync with WatchPane.capacity() */
$master-font-size: 0.75em;
$cell-size: 0.875em;
$head-spacing: 0.5em;
$body-spacing: 0.5em;
$pane-gap: 0.5em;
$header-spacing: 0.1875em; /* keep in sync with Toolbar.scss .kui--data-table-wrapper */

[kui-theme-style] .kui--watch-pane {
  height: 100%;

  display: grid;
  grid-template-columns: repeat($num-columns, 1fr);
  grid-column-gap: $pane-gap;
  background-color: var(--color-repl-background);

  &:not(:empty) {
    padding: $pane-gap;
  }

  .kui--sub-card {
    overflow-x: auto;
    display: flex;

    & > div {
      flex: 1;
    }

    // copied from componenets/Table/badges.scss
    .kui--data-table-wrapper {
      /* get overflow for grid; keep 8em in sync with TabContent Watching; 1em from ; 0.375em, 2px from margin-bottom in Card head */
      max-height: calc(8em - 0.6875em - 2 * 0.1875em - 0.375em - 2px);
      overflow-y: auto;
      padding: 0;

      .bx--data-table {
        font-size: $master-font-size;
        display: grid;
        grid-gap: 1px;
        grid-template-columns: repeat(auto-fill, $cell-size) !important;

        [data-tag='badge'] [data-tag='badge-circle'] {
          margin: 0;
          width: $cell-size;
          height: $cell-size;
          border-radius: 0;

          transition-property: filter;
          transition-timing-function: var(--transition-timing-function);
          transition-duration: var(--transition-duration);

          &:hover {
            filter: saturate(2) brightness(1.5);
            cursor: pointer;
          }
        }
      }

      .kui--data-table-toolbar.kui--data-table-toolbar-bottom {
        display: none;
      }
    }

    .bx--data-table-container {
      width: 100%;
      .bx--data-table {
        width: 100%;

        td.entity-name,
        td.kui--entity-name-secondary {
          width: 100%;
          max-width: 0;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .hide-with-sidecar {
          display: none;
        }
      }
    }
  }
}
