/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

@use 'sass:math';

@import '../../variables';

$control-bar-width: 300px;

$icon-width: 100px;
$actual-icon-width: 520px;
$actual-icon-height: 400px;

@mixin sunk-panel {
  background: rgba($dark-gray1, 0.5);
  border-radius: $pt-border-radius;
  box-shadow: inset 0 1px 3px rgba($black, 0.32);
}

.load-data-view {
  //height: 100%;
  height: 100%;
  display: grid;
  grid-gap: $thin-padding 5px;
  grid-template-columns: 1fr $control-bar-width;
  grid-template-rows: 60px 1fr 28px;
  grid-template-areas:
    'navi navi'
    'main ctrl'
    'main next';

  &.load-data-continue-view {
    display: block;
    text-align: center;

    .spec-card {
      display: inline-block;
      vertical-align: top;
      position: relative;
      width: 440px;
      height: 120px;
      margin: 10px;
      text-align: left;

      .spec-card-icon {
        position: absolute;
        top: 26px;
        left: 20px;

        svg {
          width: 20px;
          height: 20px;
        }
      }

      .spec-card-header {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        padding-left: 36px;

        .spec-card-caption {
          font-size: 13px;
          line-height: 20px;
          font-weight: 400;
          color: $gray4;
        }
      }
    }
  }

  &.welcome {
    .main {
      height: 100%;
      padding: 0;
      overflow: auto;

      .ingestion-cards {
        @include sunk-panel;
        display: grid;
        gap: $thin-padding;
        grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
        grid-template-rows: repeat(auto-fill, 150px);
        padding: 10px;
        height: 100%;
      }

      .ingestion-card {
        position: relative;
        display: inline-block;
        vertical-align: top;
        text-align: center;

        & > * {
          user-select: none;
          pointer-events: none;
        }

        &.active::after {
          position: absolute;
          top: 0;
          right: 0;
          bottom: 0;
          left: 0;
          content: '';
          border: 2px solid $blue3;
          border-radius: $pt-border-radius;

          .#{$bp-ns}-dark & {
            border: 2px solid $blue4;
          }
        }

        &.disabled {
          opacity: 0.4;
        }

        img {
          width: $icon-width;
          height: $icon-width * math.div($actual-icon-height, $actual-icon-width);
          display: inline-block;
        }
      }
    }
  }

  &.partition,
  &.tuning,
  &.publish {
    grid-gap: 20px 40px;
    grid-template-columns: 1fr 1fr $control-bar-width;
    grid-template-areas:
      'navi navi navi'
      'main othr ctrl'
      'main othr next';

    .main,
    .other {
      overflow: auto;
      padding: 0 5px;
      margin: 0;
    }
  }

  .step-nav {
    grid-area: navi;
    overflow: hidden;
    position: relative;

    .step-nav-inner {
      position: absolute;
      width: 100%;
      height: 80px;
      overflow: auto;
      white-space: nowrap;
      padding: 5px 5px 0 5px;

      .step-section {
        display: inline-block;
        vertical-align: top;
        margin-right: $thin-padding;
      }

      .step-nav-l1 {
        height: 24px;
        font-weight: 600;
        color: #eeeeee;
      }

      .step-nav-l2 {
        height: 30px;
      }
    }
  }

  .main {
    grid-area: main;
    position: relative;
    margin: 0 5px;

    .inline-data,
    .raw-lines {
      position: absolute;
      width: 100%;
      height: 100%;
      white-space: pre;
    }

    .table-with-control {
      position: absolute;
      width: 100%;
      height: 100%;

      .table-control {
        position: absolute;
        width: 100%;
        top: 0;
        height: 30px;

        & > * {
          display: inline-block;
          margin-right: 15px;
        }

        .clearable-input {
          width: 250px;
        }
      }

      .ReactTable {
        position: absolute;
        width: 100%;
        top: 45px;
        bottom: 0;

        .rt-th {
          position: relative;

          &.selected::after {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            content: '';
            border: 2px solid $blue4;
            border-radius: $pt-border-radius;
          }

          .clickable {
            cursor: pointer;
          }

          &.timestamp {
            background: rgba($cobalt3, 0.44);
          }

          &.used {
            background: rgba($gray3, 0.3);
          }
        }

        .rt-td {
          &.timestamp {
            background: rgba($cobalt3, 0.16);
          }

          &.used {
            background: rgba($gray3, 0.16);
          }
        }
      }
    }
  }

  .other {
    grid-area: othr;
  }

  .control {
    position: relative;
    grid-area: ctrl;
    overflow: auto;
    padding: 0 5px;

    .optional {
      font-style: italic;
    }
  }

  .next-bar {
    grid-area: next;
    text-align: right;
    padding: 0 5px;

    .left {
      float: left;
    }
  }

  .column-name {
    font-weight: bold;
  }

  .edit-controls {
    background: rgba($gray3, 0.15);
    padding: 10px;
    border-radius: $pt-border-radius;
    margin-bottom: 15px;
  }

  .control-buttons {
    text-align: right;

    .#{$bp-ns}-button {
      margin-left: 15px;
    }
  }

  .center-message {
    position: absolute;
    width: 100%;
    height: 100% !important;
  }

  .parse-metadata {
    border-top: 1px solid $gray1;
  }

  .suspended-switch {
    position: absolute;
    bottom: 0;
    right: 5px;
  }
}
