#search-input {
  width: 300px;
  padding: 6px;
  margin-left: auto;
  margin-right: auto;
}

#dialog-overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.8);
  cursor: zoom-out;
}

dialog.theater {
  display: flex;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
  max-width: 90vw; 
  max-height: 90vh; 
  margin: auto;
  pointer-events: all;
  flex: 0 1 auto;

  .node-view {
    overflow: hidden;
    position: static;
    max-width: 90vw;
    max-height: 90vh;
  }
}

dialog.markdown {
  display: flex;
  align-items: stretch;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  padding: 0em;

  #markdown-container {
    display: flex;
    flex-direction: row;
    gap: 0.5em;
    padding: 1em;
    align-items: center;
    height: 100%;
    cursor: default;
    pointer-events: all;
  }

  .editor-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1em;
    min-width: 420px;
    width: 40%;
    max-width: 70%;
    height: 100%;
    padding: 1em;
    border-radius: 0.5em;
    border: 1px solid black;
    background-color: var(--bg);
    pointer-events: all;
    overflow: auto;

    .top-container {
      display: flex;
      align-items: center;
      gap: 1em;

      .title {
        display: flex;
        flex: 1 0 auto;
        flex-direction: row;
        gap: 1em;

        input {
          background-color: var(--bg-alt);
          color: var(--white);
          width: 100%;
        }
      }

      .button-bar {
        display: flex;
        align-items: center;
        gap: 0.5em;

        svg.svg-close {
          width: 90%;
          height: 90%;
        }
      }
    }

    .content {
      display: flex;
      flex-direction: column;
      gap: 0.5em;
      flex: 1 0 auto;
      overflow-y: auto;

      textarea {
        flex: 1 0 auto;
        resize: none;
        padding: 1em;
        background-color: var(--bg-alt);
        color: var(--white);
        font-size: larger;
        outline: 1px solid black;
        border: unset;
        border-bottom-left-radius: 5px;
        border-top-right-radius: 5px;

        &:focus {
          box-shadow: 1px 1px 6px 0px black;
        }
      }
    }
  }

  .resizer {
    pointer-events: all;
    cursor: grab;

    &:active {
      cursor: grabbing;
    }
  }

  .preview-container {
    display: flex;
    flex: 1 1 auto;
    height: 100%;
    border-radius: 0.5em;
    border: 2px solid var(--bg);
    pointer-events: all;
    overflow: auto;
    align-items: stretch;
  }
}

dialog.markdown-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  margin: auto;
  min-width: 40%;
  height: 80%;

  #markdown-preview {
    border: 1px solid black;
    border-radius: 0.5em;
    overflow: hidden;
  }
}

dialog.transfer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  pointer-events: none;

  .tab-bar {
    position: fixed;
    top: 1em;
    right: 1em;
    display: flex;
    gap: 1em;
    pointer-events: all;
  }

  .import-container {
    display: flex;
    flex-direction: column;
    gap: 1em;
    padding: 1em;
    background-color: var(--bg);
    border-radius: 0.25em;
    pointer-events: all;
    max-height: 80%;
    min-width: 10em;
    min-height: 10em;

    .csv-container {
      display: flex;
      flex-direction: column;
      gap: 0.5em;
    }

    .no-file-container {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;

      svg {
        display: block;
        width: 60%;
        height: auto;
      }
    }

    #file-input {
      display: none;
    }

    .button-bar {
      display: flex;
      justify-content: space-between;
      gap: 2em;
    }

    .target-container {
      display: none;
      border: 1px solid var(--blackish);
      border-radius: 0.5em;
      overflow: hidden;

      &.show {
        display: flex;
        flex-direction: column;
      }

      .select-target-header {
        text-align: center;
        background-color: var(--blackish);
        padding: 0.3em;
        height: 30px;
        font-weight: bold;
      }

      ul {
        display: flex;
        flex-direction: column;
        align-items: stretch;

        li {
          display: flex;
          align-items: stretch;
          padding: 0.5em;
          border-bottom: 1px solid var(--blackish);
          background-color: var(--bg-alt);

          &:last-child {
            border-bottom: unset;
          }

          button {
            flex: 1;

            &:hover {
              background-color: var(--primary);
            }
          }
        }
      }
    }
  }

  .export-container {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    padding: 1em;
    background-color: var(--bg);
    border-radius: 0.25em;
    pointer-events: all;
    max-height: 80%;

    .export-btn {
      width: fit-content;
    }
  }

  .import-container,
  .export-container {
    .table-container {
      height: 90%;
      overflow: auto;
      display: flex;
      align-items: start;
      gap: 1em;
    }

    table {
      background-color: var(--blackish);
      border-spacing: 1px;
      border-radius: 0.5em;
      overflow: hidden;
    }

    tr {
      background-color: var(--bg-alt);
      padding: 0.5em;

      &:first-child th:first-child {
        border-top-left-radius: 0.5em;
      }

      &:first-child th:last-child {
        border-top-right-radius: 0.5em;
      }

      &:last-child td:first-child {
        border-bottom-left-radius: 0.5em;
      }

      &:last-child td:last-child {
        border-bottom-right-radius: 0.5em;
      }
    }

    tr.row-header {
      background-color: var(--blackish);
      position: sticky;
      z-index: 5;
      top: 0;
    }

    th {
      padding: 0.3em;
      height: 30px;
    }

    td {
      padding: 0.5em;

      button {
        width: 100%;
      }
    }

  }
}

dialog {
  /* dialog color uses canvasText so overwrite here  */
  color: var(--white);
  cursor: default;
  z-index: 1000;
  border: unset;
  background-color: transparent;
  animation-name: slide-up, fade-in;
  animation-duration: 500ms;
  animation-fill-mode: forwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(-120px);
  }

  to {
    transform: initial;
  }
}

dialog.picker {
  display: flex;
  flex-direction: column;
  gap: 1em;
  margin: auto;

  .items-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0.25em;
    gap: 1em;
    flex: 1 0 auto;
    height: 60vh;
    overflow: auto;
    padding-right: 1em;
  }

  .item {
    width: 300px;
    color: whitesmoke;
    background-color: var(--primary);
    font-size: 22px;
    padding: 8px;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    gap: 0.5em;
    align-items: center;
    margin-left: 2px;

    &.new {
      background-color: var(--secondary);
    }

    &.formula {
      background-color: #ae6126;
    }

    &.selected {
      filter: brightness(0.5);
    }

    &.admin {
      background-color: var(--error);
    }

    &.editor {
      background-color: var(--warn);
    }

    &.viewer {
      background-color: var(--success);
    }

    &.cursor {
      outline: 1px solid var(--white);
      filter: unset;
    }
  }
}

dialog.fast-scroll {
  position: relative;
  width: 100vw;
  height: 100vh;

  h1 {
    position: absolute;
    top: 2em;
    left: 2em;
    color: var(--teal);
  }

  .button-container {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    position: absolute;
    min-width: 120px;
  }

  button.fast-scroll {
    display: flex;
    flex: 1 0 auto;
    align-items: center;
    justify-content: start;
    gap: 0.4em;
    height: 32px;
    padding: 5px 8px;
    border-radius: 5px;

    .label {
      color: var(--success);
      margin-right: 1em;
      text-align: left;
    }

    .detail {
      margin-left: auto;
    }

    .svg-link {
      width: 1em;
      height: 1em;
    }
  }
}

dialog.formula-input {
  .sides-container {
    display: flex;
    justify-content: space-evenly;
    flex: 1;
    cursor: default;

    .outer {
      flex: 1;
      display: flex;
      justify-content: center;
      padding-top: 4em;

      &.outer-left {
        background-color: rgba(133, 141, 63, 0.4);
      }

      &.outer-right {
        background-color: rgba(71, 63, 141, 0.4);
      }
    }
  }

  ul {
    display: flex;
    flex-direction: column;
    gap: 1em;
  }

  .left {
    display: flex;
    flex-direction: column;
    gap: 2em;

    li.input-container {
      display: flex;
      align-items: center;
      gap: 1em;

      label {
        width: 6em;
        font-size: 2em;
        filter: brightness(0.5);
        transition: all 250ms ease-out;
      }

      button {
        filter: brightness(0.2);
        transition: all 250ms ease-out;
      }

      &:has(input:focus) {

        label,
        input,
        button {
          filter: unset;
        }
      }

      input {
        filter: brightness(0.2);
        transition: all 250ms ease-out;
        font-size: 1.5em;
        padding: 0.2em;
      }

      .custom-input {
        width: 2.2em;
        height: 2.2em;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: var(--dark-gray);
        border-radius: 50%;
        outline: 1px solid black;
        filter: brightness(0.5);

        &:hover,
        &.active {
          filter: unset;
        }

        svg {
          width: 1em;
          height: 1em;
        }
      }
    }
  }

  .right {
    display: flex;
    flex-direction: column;
    gap: 2em;

    li {
      display: flex;

      button {
        width: 12em;
        flex: 1;
        align-items: baseline;
        justify-content: space-between;

        &.active {
          background-color: var(--primary);
        }

        .name {
          font-size: 1.5em;
        }

        .identifier {
          color: var(--bg-active);
          font-size: 0.9em;
          font-weight: bold;
        }
      }
    }

    .info {
      margin-top: 2em;
      font-style: italic;
      color: var(--disabled-bg);
      padding-left: 1em;
      padding-right: 1em;
      max-width: 20em;
    }
  }
}

.formula-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: black;
  cursor: default;

  button.update-input {
    display: block;
    max-width: 7.5em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .action-bar {
    display: flex;
    gap: 1em;
    align-items: center;

    button.insert {
      pointer-events: all;

      svg {
        color: var(--bg-dark);
      }
    }
  }
}

dialog.formula-input,
dialog.formula-operator {
  pointer-events: all;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100vw;
  height: 100vh;
  padding: 1em;
  background-color: rgba(0, 0, 0, 0.8);
}

dialog.formula-operator {
  .content-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
    height: 100%;
    cursor: default;
    background-color: rgba(71, 63, 141, 0.4);
    background-image: linear-gradient(to right,
        rgb(10, 10, 10) 0%,
        rgba(71, 63, 141, 0.4) 50%,
        rgb(10, 10, 10) 100%);
    padding-top: 2em;
    padding-bottom: 2em;
  }

  .body {
    display: flex;
    flex: 0 1 auto;
    max-height: 80%;

    .ul-wrapper {
      max-height: 100%;
      flex: 0 1 auto;
      margin-top: 2em;
      overflow-y: auto;
      display: flex;
      justify-content: center;
      align-items: stretch;
    }

    ul {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 1em;

      .btn-operator {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        background-color: var(--secondary);
        border: 1px solid black;
        border-radius: 50%;
        font-size: 2em;
        line-height: 2;
        vertical-align: middle;
        text-align: center;
        pointer-events: all;
        cursor: pointer;
        color: var(--white);
        width: 2em;
        height: 2em;

        &:disabled {
          background-color: var(--disabled-bg);
          color: var(--disabled-fg);
        }

        &.active {
          background-color: var(--primary);
        }

        svg {
          width: 0.7em;
          height: 0.7em;
        }
      }
    }
  }
}
