/*
  Query Editor
  -------------------------------------
  Displays generated query from Query Builder
  User can manually type a query as well

  NOTE: Variables are located in query-maker.scss
*/
.query-editor {
  padding: 8px 8px 0 8px;
  border-radius: 0 $radius 0 0;
  background-color: $query-editor--bg;
  position: relative;
  z-index: 3; /* Minimum amount to obcure the toggle flip within Query Builder. Will fix later */
}
.query-editor--code {
  background-color: $query-editor--field-bg;
  border: 2px solid $query-editor--bg;
  border-bottom: 0;
  border-radius: $radius $radius 0 0;
  padding: 6px 8px;
  transition: border-color 0.25s ease, background-color 0.25s ease;

  &:hover {
    cursor: text;
  }

  &.focus {
    border-color: $c-pool;
  }

  &.read-only {
    background-color: $g3-castle;
  }
}
.query-editor--status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: $query-editor--status-height;

  /* Loading State */
  .loading-dots {
    bottom: $query-editor--templates-offset;
    left: ($query-editor--templates-offset + 10px);
    transform: translateY(50%);
  }
}
.query-status-output {
  flex: 1 0 0%;
  display: inline-block;
  color: $query-editor--status-default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
  line-height: $query-editor--status-height;
  font-size: 12px;
  font-family: $code-font;

  span.icon,
  .loading-spinner--container {
    margin-right: 5px;
  }

  .loading-spinner--container {
    top: 2px;
  }

  /* Error State */
  &.query-status-output--error {
    color: $query-editor--status-error;
  }
  /* Warning State */
  &.query-status-output--warning {
    color: $query-editor--status-warning;
  }
  /* Success State */
  &.query-status-output--success {
    color: $query-editor--status-success;
  }
}
.dropdown.query-editor--templates {
  margin: 0 4px 0 0;

  .dropdown-menu {
    left: initial;
    right: 0;
    width: $query-editor--templates-menu-width;
    min-width: $query-editor--templates-menu-width;
    max-width: $query-editor--templates-menu-width;
  }
}

.query-editor--status-actions {
  display: flex;
  align-items: center;

  > * {
    margin-right: 4px;
  }
}

/*
  Varmoji Flipper
  ------------------------------------------------------------------------------
  Handles the 3D flip transition between two states (isTemplating)
  Contents could in theory be anything
*/
.varmoji {
  transition: border-color 0.25s ease;
  border: 2px solid $query-editor--bg;
  border-top: 0;
  background-color: $query-editor--field-bg;
  border-radius: 0 0 $radius $radius;
  height: $query-editor--status-height;
  width: 100%;
  perspective: 1000px;
  transition: background-color 0.25s ease, border-color 0.25s ease;

  &:hover {
    cursor: text;
  }

  &.focus {
    border-color: $c-pool;
  }

  &.read-only {
    background-color: $g3-castle;
  }
}
.varmoji-container {
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
  position: relative;
  transform-origin: 100% #{$query-editor--status-height / 2};
}
.varmoji-front,
.varmoji-back {
  backface-visibility: hidden;
  width: 100%;
  height: $query-editor--status-height;
  position: absolute;
  top: 0;
  left: 0;
}
.varmoji-front {
  z-index: 3;
  transform: rotateX(0deg);
}
.varmoji-back {
  z-index: 2;
  transform: rotateX(180deg);
}
.varmoji.varmoji-rotated .varmoji-container {
  transform: rotateX(-180deg);
}

/*
  Template Drawer
  -------------------------------------
  Not sure if this needs its own stylesheet
*/

.template-drawer {
  height: $query-editor--status-height;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.template-drawer--item {
  margin-right: 2px;
  display: inline-block;
  font-family: $code-font;
  font-weight: 700;
  font-size: 12px;
  height: ($query-editor--status-height - 14px);
  line-height: ($query-editor--status-height - 14px);
  padding: 0 6px;
  background-color: $query-editor--field-bg;
  color: $c-comet;
  border-radius: $radius-small;
  cursor: pointer;
  transition: color 0.25s ease, background-color 0.25s ease;

  /* Selected State */
  &.template-drawer--selected {
    color: $g20-white;
    background-color: $c-star;
  }

  .divider {
    background: linear-gradient(to right, #00c9ff 0%, #22adf6 100%);
  }
}

.query-editor--dismiss {
  position: absolute;
  z-index: 3;
  top: -2px;
  right: -2px;
  width: 26px;
  height: 26px;
  outline: none;
  border-radius: 50%;
  background-color: $c-pool;
  transition: background-color 0.25s ease;
  border: 0;

  &:before,
  &:after {
    content: "";
    position: absolute;
    width: 14px;
    height: 3px;
    top: 50%;
    left: 50%;
    border-radius: 1px;
    background-color: $g20-white;
  }

  &:before {
    transform: translate(-50%, -50%) rotate(45deg);
  }

  &:after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  &:hover {
    background-color: $c-laser;
    cursor: pointer;
  }
}
