/**
 * Copyright (c) HashiCorp, Inc.
 * SPDX-License-Identifier: BUSL-1.1
 */

$console-close-height: 35px;

.console-ui-panel {
  background: var(--token-color-palette-neutral-700);
  width: -moz-available;
  width: -webkit-fill-available;
  height: 0;
  min-height: 0;
  overflow: auto;
  position: fixed;
  bottom: 0;
  transition:
    min-height $speed $easing,
    transform $speed ease-in;
  will-change: transform, min-height;
  -webkit-overflow-scrolling: touch;
  z-index: 199;
}

.console-ui-panel-content {
  color: $white;
  display: flex;
  flex-direction: column;
  font-size: $size-7;
  font-weight: $font-weight-semibold;
  justify-content: flex-end;
  min-height: calc(100% - $console-close-height); // account for close button that is sticky positioned
  padding: $spacing-12 $spacing-12 $spacing-18;
  transition: justify-content $speed ease-in;

  pre,
  p {
    background: none;
    color: inherit;
    font-size: $size-7;
    min-height: 2rem;
    padding: 0;

    &:not(.console-ui-command):not(.CodeMirror-line) {
      padding-left: $spacing-20;
    }
  }

  .cm-s-hashi.CodeMirror {
    background-color: rgba($black, 0.5) !important;
    font-weight: $font-weight-normal;
    margin-left: $spacing-20;
    padding: $spacing-12 $spacing-20;
  }

  .console-ui-panel-intro {
    color: var(--token-color-palette-neutral-400);
  }
}

.console-ui-input {
  align-items: center;
  display: flex;

  input {
    background-color: rgba($black, 0.5);
    border: 1px solid var(--token-color-palette-neutral-500);
    border-radius: var(--token-side-nav-body-list-item-border-radius);
    caret-color: $white;
    color: $white;
    flex: 1 1 auto;
    font-family: $family-monospace;
    font-size: $size-6;
    font-weight: $font-weight-bold;
    outline: none;
    padding: $spacing-8;
    margin-right: $spacing-8;
    transition: background-color $speed;
  }
}

.console-ui-command {
  line-height: 2;
}

.console-ui-output {
  transition: background-color $speed ease-in-out;
  will-change: background-color;
  padding-right: $spacing-36;
  position: relative;
  background-color: rgba(#000, 0);
  color: var(--token-color-palette-neutral-400);
  &:hover {
    background-color: rgba(#000, 0.5);
  }
}

.console-ui-alert {
  margin-left: calc(#{$spacing-20} - 0.33rem);
  position: relative;
  color: var(--token-color-palette-neutral-400);

  svg {
    position: absolute;
    left: 0;
    top: 0;
  }

  &.console-ui-alert--error {
    // HDS tokens are not light enough on the dark background to pass a11y tests.
    // hex value for --token-color-foreground-critical
    color: lighten(#e52228, 20%);
  }
  &.console-ui-alert--success {
    // HDS tokens are not light enough on the dark background to pass a11y tests.
    // hex value for --token-color-foreground-success
    color: lighten(#008a22, 20%);
  }
}

.panel-open .console-ui-panel {
  box-shadow: $box-shadow-highest;
  min-height: 425px;
}

.main--console-open {
  padding-bottom: 425px;
}

.panel-open .console-ui-panel.fullscreen {
  bottom: 0;
  right: 0;
  min-height: 100vh;
  width: 100%;
}

.console-spinner.control {
  height: 21px;
  width: 21px;
  transform: scale(0.75);
  transform-origin: center;
  &::after {
    height: auto;
    width: auto;
    right: 0.25rem;
    left: 0.25rem;
    top: 0.25rem;
    bottom: 0.25rem;
  }
}

.console-close-button {
  position: sticky;
  top: $spacing-8;
  height: $console-close-height;
  display: flex;
  justify-content: flex-end;
  z-index: 210;

  button {
    margin-right: $spacing-8;
  }
}
