@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

:root {
  /* Bool field */
  --frontmatter-toggle-background: #15c2cb;
  --frontmatter-toggle-secondaryBackground: #adadad;

  /* Errors field */
  --frontmatter-error-background: rgba(255, 85, 0, 0.2);
  --frontmatter-error-border: #f50;
  --frontmatter-error-foreground: #0e131f;

  .vscode-dark {
    --frontmatter-error-foreground: #fff;
  }

  /* List add field */
  --frontmatter-field-border: #222733;
  --frontmatter-field-borderActive: #15c2cb;

  .vscode-dark {
    --frontmatter-field-border: rgba(255, 255, 255, 0.5);
    --frontmatter-field-borderActive: #009aa3;
  }

  /* List field */
  --frontmatter-list-border: #adadad;

  .vscode-dark {
    --frontmatter-list-border: #404551;
  }

  /* Select field */
  --frontmatter-select-foreground: #0e131f;
}

.loader {
  animation: spinner 1.5s linear infinite;
}

@-webkit-keyframes spinner {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

@keyframes spinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

[type='checkbox']:checked {
  background-image: none;
}

[type='checkbox']:checked:after {
  content: '\2713';
  font-size: 14px;
  position: absolute;
  top: -1px;
  left: 2px;
  color: white;
}

.autoform {
  @apply py-4;

  h2 {
    @apply mb-2 text-sm;
  }

  form {
    .ant-form-item-has-error .ant-form-item-control-input {
      @apply relative;
    }

    .ant-form-item-has-error {
      label {
        &::after {
          content: ' *';
          @apply text-[var(--vscode-editorError-foreground)];
        }
      }
    }

    .ant-form-item-has-error input {
      @apply border border-red-400;
    }

    .ant-form-item-has-error .ant-form-item-children-icon {
      @apply absolute right-1 top-1 text-[var(--vscode-editorError-foreground)];

      svg {
        @apply h-4 w-4;
      }
    }

    .errors {
      > div {
        @apply border;
      }

      ul {
        @apply list-disc bg-opacity-50 py-4 pl-6 pr-4;
      }
    }

    input[type='submit'] {
      @apply mt-4 inline-flex w-auto items-center rounded-[2px] border border-transparent bg-[var(--frontmatter-button-background)] px-[11px] py-[4px] text-[var(--vscode-button-foreground)];
      font-family: var(--vscode-font-family);
      font-size: var(--vscode-font-size, 13px);

      &:hover {
        @apply bg-[var(--frontmatter-button-hoverBackground)];
      }

      &:focus {
        @apply outline-none;
      }

      &:disabled {
        @apply opacity-50;
      }
    }

    > .fields {
      > div > label:first-of-type {
        color: var(--frontmatter-text);
      }

      > div:not(:first-child) > label:first-of-type {
        margin-block-start: 2rem;
        border-block-start: 1px solid var(--frontmatter-border);
        padding-block-start: 2rem;
      }
    }
  }

  .ant-list.ant-list-bordered {
    @apply border border-gray-300;
  }

  .ant-btn-dashed {
    @apply mt-2 flex items-center justify-center border border-dashed border-gray-300 py-1;

    &:hover {
      @apply border-teal-900 text-teal-900;
    }
  }

  .ant-input:hover,
  .ant-input-focused,
  .ant-input:focus {
    @apply border-teal-600;
  }

  .ant-btn-ghost:focus,
  .ant-btn-ghost:hover {
    @apply border-teal-700 text-teal-600;
  }

  .ant-switch-checked {
    @apply bg-teal-500;
  }

  .ant-switch {
    @apply bg-gray-400;

    margin: 0;
    padding: 0;
    font-size: 14px;
    font-variant: tabular-nums;
    line-height: 1.5715;
    list-style: none;
    font-feature-settings: 'tnum';
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    min-width: 44px;
    height: 22px;
    line-height: 22px;
    vertical-align: middle;
    border: 0;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;

    &.ant-switch-checked {
      @apply bg-teal-500;

      .ant-switch-handle {
        left: calc(100% - 20px);
      }
    }

    .ant-switch-handle {
      position: absolute;
      top: 2px;
      left: 2px;
      width: 18px;
      height: 18px;
      transition: all 0.2s ease-in-out;

      &::before {
        position: absolute;
        inset: 0;
        background-color: #fff;
        border-radius: 9px;
        box-shadow: 0 2px 4px #00230b33;
        transition: all 0.2s ease-in-out;
        content: '';
      }
    }

    .ant-switch-inner {
      display: block;
      margin: 0 7px 0 25px;
      color: #fff;
      font-size: 12px;
      transition: margin 0.2s;

      svg {
        display: none;
      }
    }
  }

  .ant-input-number {
    @apply border;

    box-sizing: border-box;
    font-variant: tabular-nums;
    list-style: none;
    font-feature-settings: 'tnum';
    position: relative;
    width: 100%;
    min-width: 0;
    color: #000000d9;
    font-size: 14px;
    line-height: 1.5715;
    background-color: #fff;
    background-image: none;
    transition: all 0.3s;
    display: inline-block;
    width: 90px;
    margin: 0;
    padding: 0;

    &.ant-input-number-focused {
      @apply border-teal-600;
    }
  }

  .ant-input-number-handler {
    position: relative;
    display: block;
    width: 100%;
    height: 50%;
    overflow: hidden;
    color: #00000073;
    font-weight: 700;
    line-height: 0;
    text-align: center;
    border-left: 1px solid #d9d9d9;
    transition: all 0.1s linear;
  }

  .ant-input-number-handler-wrap {
    position: absolute;
    top: 0;
    right: 0;
    width: 22px;
    height: 100%;
    background: #fff;
    opacity: 0;
    transition: opacity 0.24s linear 0.1s;
  }

  .ant-input-number-input {
    @apply px-2 py-1;

    width: 100%;
    height: 30px;
    text-align: left;
    background-color: transparent;
    border: 0;
    outline: 0;
    transition: all 0.3s linear;
    appearance: textfield !important;
  }

  .ant-input-number:hover .ant-input-number-handler-wrap,
  .ant-input-number-focused .ant-input-number-handler-wrap {
    opacity: 1;
  }
}

.vscode-dark .autoform {
  form {
    label {
      @apply text-whisper-900;
    }

    input[type='submit'] {
      @apply rounded-[2px] text-vulcan-500;
    }
  }

  .ant-list.ant-list-bordered {
    @apply border-vulcan-100;
  }

  .ant-btn-dashed {
    @apply border-vulcan-50;

    &:hover {
      @apply border-teal-900 text-teal-400;
    }
  }
}

.experimental form {
  [type='text'],
  [type='email'],
  [type='url'],
  [type='password'],
  [type='number'],
  [type='date'],
  [type='datetime-local'],
  [type='month'],
  [type='search'],
  [type='tel'],
  [type='time'],
  [type='week'],
  [multiple],
  textarea,
  select {
    color: var(--vscode-input-foreground);
    background-color: var(--vscode-input-background);
    border: 1px solid var(--vscode-panel-border);
    font-size: var(--vscode-font-size);
    @apply rounded;

    &::placeholder {
      color: var(--vscode-input-placeholderForeground);
    }

    &:focus {
      outline: 1px solid var(--vscode-focusBorder);
      border-color: transparent;
      outline-offset: 0;
    }
  }

  &[data-type='preview'] {
    input {
      @apply rounded-none;
    }
  }

  .autoform {
    form {
      label {
        color: var(--frontmatter-secondary-text);
      }

      input[type='submit'] {
        color: var(--vscode-button-foreground);
        background-color: var(--vscode-button-background);
        @apply rounded;

        &:hover {
          background-color: var(--vscode-button-hoverBackground);
        }
      }
    }

    .ant-list.ant-list-bordered {
      border-color: var(--frontmatter-border);
    }

    .ant-btn-dashed {
      border-color: var(--frontmatter-border);

      &:hover {
        @apply border-teal-900 text-teal-400;
      }
    }
  }
}

.qa__bot {
  > div {
    @apply space-y-4;
  }

  li {
    @apply space-y-2;
  }

  pre code {
    white-space: pre-wrap;
  }

  .question {
    @apply relative ml-auto mr-3 w-5/6 rounded-full rounded-br-none bg-teal-900 px-4 py-2 text-whisper-500;

    &:after {
      --size: 1rem;
      content: '';
      position: absolute;
      bottom: 0;
      height: var(--size);
      width: var(--size);
      z-index: 2;
      right: calc(var(--size) * -1);
      border-bottom-right-radius: 8rem;
      background: radial-gradient(
        circle at top right,
        rgba(0, 0, 0, 0) 0,
        rgba(0, 0, 0, 0) var(--size),
        #009aa3 var(--size)
      );
    }
  }

  .answer {
    @apply break-all rounded border border-teal-100 border-opacity-20 p-4 pb-0;
  }
}

.chatbox {
  textarea {
    border: 0;
    outline: 0;

    &:focus {
      border: 0 !important;
      outline: 0 !important;
      box-shadow: none !important;
    }
  }
}

.dots {
  &:after {
    display: inline-block;
    animation: ellipsis 1.25s infinite;
    content: '.';
    width: 1em;
    text-align: left;
    height: 20px;
  }
}

@keyframes ellipsis {
  0% {
    content: '';
  }
  25% {
    content: '.';
  }
  50% {
    content: '..';
  }
  75% {
    content: '...';
  }
  100% {
    content: '';
  }
}
