.tmpl-popup-animation {
  animation: fadeInWithNavigation 0.3s ease-in-out;
}

.tmpl-popup-animation-2 {
  animation: fadeIn 0.3s ease-in-out;
}

.tmpl-popup-animation-reverse {
  animation: fadeOutWithNavigation 0.25s ease-in-out !important;
}

.tmpl-popup-animation-2-reverse {
  animation: fadeOut 0.3s ease-in-out;
}

.tmpl-error-message {
  color: $text-danger;
  font-size: $font-size-sm;
  line-height: $line-height-sm;
  font-weight: $font-weight-regular;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInWithNavigation {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes fadeOutWithNavigation {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

.tmpl-grid-toolbar-container {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  width: 100%;
  gap: $space-sm;
  font-family: $font-family-primary;

  .tmpl-global-search {
    flex: 1;
  }

  .tmpl-advanced-search-container {
    position: relative;
  }

  .tmpl-screen-view-container {
    background-color: $background-default;
    border: $border-width-sm solid $border-default;
    border-radius: $border-radius-md;
  }
  .tmpl-screen-view-wrapper {
    position: relative;
    display: inline-block;
    .tmpl-unsaved-indicator {
      position: absolute;
      top: -2px;
      right: -2px;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: $background-danger;
      z-index: 1000;
    }
  }
  .tmpl-advanced-popup {
    @extend .tmpl-popup-animation;
    position: absolute;
    right: 0;
    top: 42px;
    width: 650px;
    z-index: 3;
    background-color: $background-default;
    border: $border-width-sm solid $border-default;
    border-radius: $border-radius-md;
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.15);

    .tmpl-filter-container {
      max-height: 313px;
      overflow-y: auto;
      padding: 0 $space-lg $space-lg;

      .tmpl-filter {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 25px 25px;
        gap: $space-sm;
        align-items: center;
        color: $text-default;
        font-size: $font-size-sm;
        line-height: $line-height-sm;
        font-weight: $font-weight-regular;

        &:first-of-type {
          font-weight: $font-weight-semibold;
          font-size: $font-size-xs;
          line-height: $line-height-xs;
          letter-spacing: 0.5px;
          text-transform: uppercase;
          color: $text-secondary;
          padding: $space-md $space-lg;
          margin: 0 (-$space-lg);
          width: calc(100% + (2 * $space-lg));
          margin-bottom: $space-lg;
          position: sticky;
          top: 0;
          background-color: $background-default;
          box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
          z-index: 1001;
        }

        &.tmpl-filter-error {
          background-color: rgba($background-danger, 0.06);
          border-radius: $border-radius-md;
          padding: $space-sm $space-md;

          .tmpl-dropdown {
            border-color: $border-danger !important;
          }
        }

        &.tmpl-filter-border {
          position: relative;

          & > .tmpl-filter-id {
            position: absolute;
            transform: translate(-50%, -50%);
            top: 0;
            left: 0;
            z-index: 10;
            padding: 2px;
            font-size: $font-size-xxs;
            line-height: $line-height-xxs;
            font-weight: $font-weight-bold;
            color: $text-dark;
            background-color: $background-secondary;
            border: $border-width-sm solid $border-default;
            border-radius: $border-radius-md;
          }
        }

        .tmpl-advanced-input {
          input {
            height: $size-lg;
          }

          .k-radio-label {
            margin-left: 4px;
          }
        }

        .tmpl-advanced-ranged-input {
          max-width: 230px;
          height: $size-lg;
        }
      }

      .tmpl-criteria {
        display: inline-block;
        text-align: center;
        margin: $space-xl 0;
        /*   border: $border-width-sm solid $border-default;
        border-radius: $border-radius-sm; */
        font-size: $font-size-sm;
        line-height: $line-height-sm;
        font-weight: $font-weight-bold;
        color: $text-dark;
        min-width: 45px;
        cursor: pointer;
        position: relative;

        &:last-child {
          display: none;
        }

        &::before {
          content: "";
          position: absolute;
          top: -20px;
          left: 50%;
          height: 20px;
          width: 1.5px;
          transform: translateX(-50%);
          background-color: $border-default;
        }

        &::after {
          content: "";
          position: absolute;
          bottom: -20px;
          height: 20px;
          width: 1.5px;
          left: 50%;
          transform: translateX(-50%);
          background-color: $border-default;
        }
      }
    }

    .tmpl-action-container {
      display: flex;
      height: 65px;
      gap: $space-sm;
      align-items: center;
      justify-content: space-between;
      padding: 0 $space-lg;
      box-shadow: 0 0 8px 0 $boxshadow-primary;
      //  border-top: 1px solid hsla(0, 0%, 67%, 0.6);

      .k-button {
        height: $size-lg;
        border-radius: $border-radius-md;
      }

      .tmpl-criteria-input-container {
        border: $border-width-sm solid $border-default;
        border-radius: $border-radius-md;
        padding: $space-sm;

        .tmpl-criteria-input {
          font-size: $font-size-sm;
          line-height: $line-height-sm;
          font-weight: $font-weight-bold;
          color: $text-dark;
          outline: none;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          max-height: 34px;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        .tmpl-criteria-input-icon {
          height: 20px;
          width: 20px;
          padding: 2px;
        }
      }

      div {
        display: flex;
        align-items: center;
        gap: $space-sm;

        .tmpl-cancel-action {
          color: $text-danger;
          cursor: pointer;
          font-size: $font-size-md;
          line-height: $line-height-md;
          font-weight: $font-weight-regular;

          &:hover {
            color: $text-danger-hover;
          }
        }
      }
    }
  }

  .tmpl-export-container {
    flex: 0 0 32px;
    height: 100%;
    position: relative;

    .tmpl-export {
      height: 100%;
      width: 100%;
    }

    .tmpl-export-popup {
      @extend .tmpl-popup-animation;
      position: absolute;
      right: 3px;
      top: 42px;
      width: 320px;
      z-index: 10;
      background-color: $background-default;
      border: $border-width-sm solid $border-default;
      border-radius: $border-radius-md;
      box-shadow: 0 0 8px 0 $boxshadow-primary;
      padding: $space-md;

      .tmpl-export-scope-container {
        max-height: calc((#{$font-size-xs} + #{$space-xs} + 28px + #{$space-sm}) * 3);
        overflow-y: auto;
        scrollbar-width: thin;

        &::-webkit-scrollbar {
          width: 4px;
        }

        &::-webkit-scrollbar-thumb {
          background: $border-default;
          border-radius: 2px;
        }
      }

      .tmpl-export-scope-section {
        margin-bottom: $space-sm;

        .tmpl-export-scope-header {
          font-size: $font-size-xs;
          font-weight: $font-weight-semibold;
          color: $text-secondary;
          margin: 0 0 $space-xs 0;
        }
      }

      .tmpl-export-options-grid {
        display: flex;
        gap: $space-sm;
        overflow-x: auto;
        scrollbar-width: thin;

        &::-webkit-scrollbar {
          height: 4px;
        }

        &::-webkit-scrollbar-thumb {
          background: $border-default;
          border-radius: 2px;
        }

        .tmpl-export-option-card {
          flex: 0 0 auto;
          font-size: $font-size-xs;
          font-weight: $font-weight-semibold;
          color: $text-dark;
          display: flex;
          align-items: center;
          justify-content: center;
          text-align: center;
          padding: $space-xs $space-sm;
          border: $border-width-sm solid $border-default;
          border-radius: $border-radius-lg;
          cursor: pointer;
          transition: all 0.15s ease;
          white-space: nowrap;
          background: linear-gradient(
            to bottom,
            lighten($background-light, 9%),
            darken($background-light, 12%)
          );
          box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.6);

          &:hover {
            border-color: $border-primary;
            background: linear-gradient(
              to bottom,
              rgba($background-primary, 9%),
              rgba($background-primary, 12%)
            );
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 0.6);
          }

          &:active {
            transform: scale(0.97);
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
          }

          &--selected {
            border-color: $border-primary;
            background: linear-gradient(
              to bottom,
              rgba($background-primary, 0.12),
              rgba($background-primary, 0.06)
            );
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 0.4);
          }
        }
      }

      .tmpl-export-divider {
        padding-top: $space-sm;
        display: flex;
        justify-content: flex-end;
      }

      h4 {
        color: $text-dark;
        margin-bottom: $space-sm;
      }

      .tmpl-export-history-items-container {
        max-height: 200px;
        overflow-y: auto;

        .tmpl-export-history-item {
          display: flex;
          justify-content: space-between;
          align-items: center;
          gap: $space-sm;
          margin-bottom: 2px;
          padding-bottom: 2px;
          border-bottom: $border-width-sm solid $border-default;

          .tmpl-export-history-item-info {
            p {
              &:first-of-type {
                font-size: $font-size-sm;
                font-weight: $font-weight-regular;
                line-height: $line-height-sm;
                color: $text-dark;
              }

              &:last-of-type {
                font-size: $font-size-xxs;
                font-weight: $font-weight-medium;
                line-height: $line-height-xxs;
                color: $text-default;
              }
            }
          }

          .tmpl-export-history-item-action {
            display: flex;
            align-items: center;
          }
        }
      }
    }
  }

  .tmpl-setting-container {
    flex: 0 0 32px;
    height: 100%;
    position: relative;

    .tmpl-setting {
      height: 100%;
      width: 100%;
    }

    .tmpl-setting-popup {
      @extend .tmpl-popup-animation;
      position: absolute;
      right: 0;
      top: 42px;
      width: 200px;
      z-index: 3;
      background-color: $background-default;
      border: $border-width-sm solid $border-default;
      border-radius: $border-radius-md;
      box-shadow: 0 0 8px 0 $boxshadow-primary;

      div {
        padding: $space-sm;
        cursor: pointer;
        transition: background-color 0.25s ease-in-out;
        color: $text-dark;
        cursor: pointer;
        font-size: $font-size-md;
        line-height: $line-height-md;
        font-weight: $font-weight-regular;

        &:first-of-type {
          border-bottom: $border-width-sm solid $border-default;
        }

        &:hover {
          background-color: $background-secondary;
        }
      }
    }

    .tmpl-columnchooser-popup {
      @extend .tmpl-popup-animation-2;
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      margin: auto;
      width: calc(80vw * 0.66);
      max-width: 900px;
      height: fit-content;
      max-height: 85vh;
      z-index: 4;
      background-color: $background-default;
      border: none;
      border-radius: $border-radius-lg;
      padding: 0;
      box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.08);
      display: flex;
      flex-direction: column;
      overflow: hidden;

      .tmpl-chooser-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: $space-lg $space-xl;
        border-bottom: $border-width-sm solid $border-light;
        flex-shrink: 0;

        h2 {
          color: $text-dark;
          font-size: $font-size-xxl;
          font-weight: $font-weight-semibold;
          line-height: $line-height-xxl;
          letter-spacing: -0.2px;
        }

        & > div {
          display: flex;
          align-items: center;
          gap: $space-sm;
        }
      }

      .tmpl-chooser-body {
        display: flex;
        font-size: $font-size-sm;
        line-height: $line-height-sm;
        gap: 0;
        flex: 1;
        min-height: 0;
        overflow: hidden;

        & > div {
          height: 400px;
          overflow-y: auto;
          position: relative;

          // Smooth scrollbar
          &::-webkit-scrollbar {
            width: 4px;
          }

          &::-webkit-scrollbar-track {
            background: transparent;
          }

          &::-webkit-scrollbar-thumb {
            background-color: $border-default;
            border-radius: $border-radius-md;

            &:hover {
              background-color: $border-secondary;
            }
          }

          &:first-of-type {
            flex: 0 0 30%;
            padding: $space-md;
            border-right: $border-width-sm solid $border-light;

            display: flex;
            flex-direction: column;

            .tmpl-column {
              height: 28px;
              align-items: center;
              padding: 2px $space-sm;
              border-radius: $border-radius-sm;
              transition: background-color 0.15s ease;
              white-space: nowrap;
              border-bottom: $border-width-sm solid $border-light;

              &:last-child {
                border-bottom: none;
              }

              &:hover {
                background-color: $background-secondary;
              }
            }
          }

          &:last-of-type {
            flex: 1;
            padding: 0 $space-md;
            background-color: $background-light;

            .tmpl-chooser-setting-container {
              min-height: $size-lg;
              display: flex;
              align-items: center;
              justify-content: space-between;
              background-color: $background-default;
              padding: $space-sm $space-md;
              margin-bottom: $space-sm;
              border-radius: $border-radius-md;
              border: $border-width-sm solid $border-light;
              transition: border-color 0.15s ease, box-shadow 0.15s ease;

              &:hover {
                border-color: $border-default;
                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
              }

              .tmpl-chooser-setting-label {
                flex: 1;
                display: flex;
                align-items: center;
                gap: $space-sm;

                p {
                  font-weight: $font-weight-regular;
                  color: $text-dark;
                }
              }

              & > div {
                display: flex;
                align-items: center;
                gap: $space-lg;

                .k-i-close {
                  cursor: pointer;
                }
              }
            }
          }

          .tmpl-search-container {
            height: 50px;
            border-bottom: $border-width-sm solid $border-light;
            padding-bottom: $space-md;
            margin-bottom: $space-md;
            position: sticky;
            top: 0;
            background-color: $background-default;
            width: 100%;
            z-index: 1;

            .tmpl-search {
              height: $size-lg;
              border-radius: $border-radius-md;
            }
          }

          .tmpl-title {
            padding: $space-md 0;
            border-bottom: $border-width-sm solid $border-light;
            margin-bottom: $space-md;
            position: sticky;
            top: -1px;
            background-color: $background-light;
            width: 100%;
            z-index: 1;

            p {
              font-size: $font-size-lg;
              line-height: $line-height-lg;
              font-weight: $font-weight-semibold;
              color: $text-secondary;
              text-transform: uppercase;
              letter-spacing: 0.5px;
            }
          }
        }
      }

      .tmpl-no-result {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: $space-xl;
        color: $text-default;
        font-size: $font-size-md;
      }
    }
  }

  .tmpl-screen-view {
    width: 225px;
    height: 30px;

    & > button {
      border: none;
      color: $text-secondary;
      font-size: $font-size-sm;
      font-weight: $font-weight-regular;
      line-height: $line-height-sm;

      &:first-of-type {
        width: calc(100% - 40px);
        height: 100%;
      }

      &:last-of-type {
        width: 40px;
        height: 100%;
      }
    }
  }

  .tmpl-reset {
    flex: 0 0 32px;
    height: 100%;
  }

  .tmpl-quick-filter-container {
    flex: 0 0 32px;
    height: 100%;
    position: relative;

    .tmpl-quick-filter {
      height: 100%;
      width: 100%;
    }

    .tmpl-quick-filter-popup {
      @extend .tmpl-popup-animation;
      position: absolute;
      right: 0;
      top: 42px;
      width: 225px;
      z-index: 3;
      background-color: $background-default;
      border: $border-width-sm solid $border-default;
      border-radius: $border-radius-sm;
      box-shadow: -10px 0 50px rgba(0, 0, 0, 0.15);

      .tmpl-dropdown-container {
        padding: $space-sm;

        span {
          &:first-of-type {
            color: $text-secondary;
            font-size: $font-size-md;
            font-weight: $font-weight-regular;
            line-height: $line-height-md;
          }
        }

        &:not(:last-of-type) {
          border-bottom: $border-width-sm solid $border-default;
        }
      }
    }
  }

  .tmpl-group-filter-container {
    height: 100%;
    position: relative;

    .tmpl-group-filter-popup {
      @extend .tmpl-popup-animation-2;
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      margin: auto;
      width: 550px;
      max-width: 90vw;
      height: fit-content;
      z-index: 3;
      background-color: $background-default;
      border: none;
      border-radius: $border-radius-lg;
      padding: 0;
      box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.08);
      overflow: hidden;

      .tmpl-group-filter-popup-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: $space-xl;
        border-bottom: $border-width-sm solid $border-light;

        h2 {
          font-size: $font-size-xxl;
          line-height: $line-height-xxl;
          margin-bottom: $space-sm;
          font-weight: $font-weight-semibold;
          color: $text-dark;
          letter-spacing: -0.2px;
        }

        p {
          color: $text-secondary;
          font-size: $font-size-sm;
          font-weight: $font-weight-regular;
          line-height: $line-height-md;
          margin-bottom: 0;
        }
      }

      .tmpl-group-filter-popup-body {
        padding: $space-xl;

        .tmpl-dropdown-container {
          width: 40%;
          margin-bottom: $space-lg;

          .tmpl-dropdown {
            //border: $border-width-sm solid $border-default;
            border-radius: $border-radius-md;
            transition: border-color 0.15s ease;

            &:hover {
              border-color: $border-secondary;
            }

            &:focus-within {
              border-color: $border-primary;
            }
          }

          & > span {
            &:first-of-type {
              color: $text-dark;
              display: block;
              font-size: $font-size-sm;
              font-weight: $font-weight-medium;
              line-height: $line-height-sm;
              margin: 0 0 $space-sm;
            }
          }
        }

        .tmpl-group-filter-popup-footer {
          padding-top: $space-lg;
          border-top: $border-width-sm solid $border-light;
          display: flex;
          justify-content: flex-end;
          gap: $space-sm;
        }
      }
    }
  }
}

.tmpl-button-popup {
  border-radius: $border-radius-md;
  margin-top: 5px;
  max-height: 180px;
  overflow-y: auto;
}

.tmpl-screen-view-item {
  display: flex;
  width: 100%;
  height: 26px;
  padding: $space-sm;
  gap: $space-sm;
  align-items: center;
  transition: background-color 0.25s ease-in-out;
  &.tmpl-view-item-heighlight:hover {
    .tmpl-set-default {
      color: $text-light;
    }

    .tmpl-delete-icon {
      color: $text-light;
    }
  }
  &:hover {
    .tmpl-set-default {
      display: inline-flex;
    }

    .tmpl-delete-icon {
      display: inline-flex;
    }
  }

  .tmpl-screen-view-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tmpl-delete-icon {
    flex: 0 0 $size-sm;
    width: 20px;
    height: 20px;

    font-size: $font-size-sm;
    line-height: $line-height-sm;
    display: none;
  }

  .tmpl-set-default {
    flex: 0 0 $size-sm;
    width: 20px;
    height: 20px;

    font-size: $font-size-sm;
    line-height: $line-height-sm;
    display: none;
  }
}

.tmpl-screen-view-footer {
  padding: $space-sm;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.tmpl-screen-creater-popup {
  @extend .tmpl-popup-animation-2;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  width: 480px;
  max-width: 90vw;
  height: fit-content;
  z-index: 3;
  background-color: $background-default;
  border: none;
  border-radius: $border-radius-lg;
  padding: 0;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;

  .tmpl-screen-creater-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: $space-xl;
    border-bottom: $border-width-sm solid $border-light;

    h2 {
      font-size: $font-size-xxl;
      line-height: $line-height-xxl;
      font-weight: $font-weight-semibold;
      color: $text-dark;
      letter-spacing: -0.2px;
    }

    p {
      color: $text-secondary;
      font-size: $font-size-sm;
      font-weight: $font-weight-regular;
      line-height: $line-height-md;
      margin-bottom: 0;
    }
  }

  .tmpl-screen-creater-popup-body {
    padding: $space-xl;

    .tmpl-dropdown-container {
      width: 100%;
      margin-bottom: $space-lg;

      .tmpl-input {
        border-radius: $border-radius-md;
        transition: border-color 0.15s ease;

        input {
          height: 100%;
        }

        &:hover {
          border-color: $border-secondary;
        }

        &:focus-within {
          border-color: $border-primary;
        }
      }

      span {
        display: block;
        margin-bottom: $space-sm;
        font-size: $font-size-sm;
        font-weight: $font-weight-medium;
        line-height: $line-height-sm;
        color: $text-dark;
      }
    }

    .tmpl-screen-creater-popup-footer {
      padding-top: $space-lg;
      border-top: $border-width-sm solid $border-light;
      display: flex;
      justify-content: flex-end;
      gap: $space-sm;
    }
  }
}

.tmpl-dropdown {
  align-items: center;
  background-image: none;
  height: $size-lg;
  width: 100%;
  box-shadow: none !important;
  // border: $border-width-sm solid $border-default;
  border-radius: $border-radius-md;
  height: $size-lg;
}

.tmpl-button {
  text-align: center;
  box-shadow: none !important;
  height: $size-lg;
}

.tmpl-button-sm {
  text-align: center;
  box-shadow: none !important;
  height: $size-sm;
  width: $size-sm;
}

.tmpl-input {
  border-radius: $border-radius-md;
  padding: 5px 11px 5px 5px;
  box-shadow: none !important;
  height: $size-lg;
}

.tmpl-filter-applied {
  border-color: $border-danger !important;
}
