@use "../abstracts/variables" as *;
@use "../abstracts/mixins" as *;

// global input style

input,
textarea {
  width: 100%;
  padding: 4px 8px;
  border-radius: #{$border-radius-large};
  outline: 1px solid var(--input-border-color);
  outline-offset: -1px;
  border: none;
  background: var(--background-color-input);
  color: var(--input-text-color);

  &:focus,
  &:active {
    outline: 1px solid var(--border-color-accent);
    background: var(--background-color-input-focus);
  }

  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active {
    // Text styles
    -webkit-text-fill-color: var(--input-text-color) !important;
    caret-color: var(--input-text-color);

    // Background styles
    background: var(--background-color-solid) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--background-color-solid) inset !important;
  }

  // File input specific style adjustments
  &::file-selector-button {
    font-size: 14px;
    background: var(--background-color-secondary);
    border: none;
    outline: none;
    border-radius: #{$border-radius-small};
    padding: 2px;
    cursor: pointer;
  }
}

input[type="number"] {
  // Chrome, Safari, Edge, Opera
  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

.input-value {
  color: var(--input-text-color);
  font-size: var(--font-size-regular);
  font-weight: var(--font-weight-regular);
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rename-input {
  width: 100%;
  color: var(--input-text-color);
  font-size: var(--font-size-regular);
  font-weight: var(--font-weight-regular);
  outline: none;
  line-height: 26px;
  padding: 0 8px;
}

.input-error {
  border: 1px solid #f65648 !important;
  outline: none !important;
  color: #f65648;
}

.toggle-header-container {
  @include flex-center;
  padding: 6px 12px;
  margin: 6px 0;

  .toggle-header-item {
    width: 100%;
    text-align: center;
    padding: 4px 12px;
    border-radius: #{$border-radius-large};
  }

  .active {
    background: var(--background-color-button);
    color: var(--text-button-color);
  }
}

.search-wrapper {
  position: sticky;
  top: 0;
  padding: 0px 10px;
  width: 100%;
  z-index: 1;

  .search-container {
    @include flex-center;
    width: 100%;
    border-radius: #{$border-radius-extra-large};
    padding: 3px 2px;
    position: relative;
    border: 1px solid var(--border-color);
    background: var(--background-color-input-focus);

    .icon-container {
      @include flex-center;
      padding: 0 8px;
      position: absolute;
      width: fit-content;
      left: 0;
    }

    .search-input {
      width: 100%;
      color: var(--input-text-color);
      font-size: var(--font-size-regular);
      font-weight: var(--font-weight-regular);
      border: none;
      outline: none;
      background: transparent;
      padding-left: 36px;
    }

    .clear-button {
      @include flex-center;
      position: absolute;
      top: 4px;
      right: 4px;
      width: 21px;
      height: 21px;
      border: none;
      border-radius: #{$border-radius-large};
      cursor: pointer;
      background: transparent;

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

  .active {
    border: 1px solid var(--accent-color);
    background: var(--background-color-input-focus);
  }
}

.kebab-menu-container {
  position: relative;
  @include flex-center;

  .kebab-icon {
    @include flex-center;
  }

  .menu-list {
    position: absolute;
    left: 10px;
    top: 12px;
    background: var(--background-color);
    border-radius: #{$border-radius-small};
    box-shadow: var(--box-shadow-medium);
    z-index: 1;
    padding: 8px 4px;
    width: 170px;

    .menu-item {
      margin: 2px 0;
      padding: 2px 4px;
      cursor: pointer;
      border-radius: #{$border-radius-small};
      display: flex;
      gap: 2px;

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

      .icon-container {
        @include flex-center;
        height: 18px;
        width: 18px;

        path {
          stroke: var(--accent-color);
        }
      }
    }

    .selected {
      background: var(--highlight-accent-color);
      color: var(--accent-color);

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

    input {
      display: none;
    }
  }
}

.regularDropdown-container {
  width: 100%;
  min-width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: #{$border-radius-large};
  position: relative;
  cursor: pointer;

  .dropdown-header {
    height: 100%;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    border-radius: #{$border-radius-large};
  }

  .dropdown-options {
    position: absolute;
    width: 100%;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: #{$border-radius-large};
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    left: 0;
    top: 110%;
    padding: 4px;
    backdrop-filter: blur(8px);

    .dropdown-search {
      margin-bottom: 4px;
    }

    .option {
      padding: 2px 4px;
      cursor: pointer;
      flex-direction: row !important;
      border-radius: #{$border-radius-medium};

      &:hover {
        color: var(--highlight-text-color);
        background: var(--highlight-accent-color);
      }
    }
  }

  .icon {
    height: auto;
  }
}

.input.default {
  width: 100%;
  position: relative;
  @include flex-center;
  gap: 6px;

  .dropdown {
    height: 100%;
    background: var(--background-color-drop-down-gradient);
    border-radius: #{$border-radius-extra-large};
    padding: 1px 8px;
    outline: 1px solid var(--border-color);

    .active-option {
      line-height: 22px;
      color: var(--text-color);
      font-size: var(--font-size-small);
    }
  }
}

.eye-dropper-input-container {
  display: flex;
  align-items: center;

  .label {
    width: 40%;
  }

  .input-container {
    width: 60%;
    position: relative;
    @include flex-center;
    gap: 4px;

    .eye-picker-button {
      height: 24px;
      min-width: 36px;
      @include flex-center;
      border-radius: #{$border-radius-large};
      background: var(--background-color-drop-down-gradient);
      cursor: pointer;
    }

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

.multi-level-dropdown {
  position: relative;
  display: inline-block;

  .dropdown-button {
    width: 100%;
    background: var(--background-color) !important;
    border: 1px solid var(--border-color) !important;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: #{$border-radius-extra-large};
    transition: background-color 0.3s ease;

    .label {
      white-space: nowrap;
      overflow: hidden;
      max-width: 80%;
      text-overflow: ellipsis;
    }

    &:hover {
      background: #333333;
    }

    &.open {
      background: #333333;
    }
  }

  .dropdown-menu {
    position: absolute;
    top: 110%;
    right: -16px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: #{$border-radius-large};
    backdrop-filter: blur(18px);
    box-shadow: #{$box-shadow-medium};
    z-index: 1000;
    min-width: 200px;
    overflow: auto;
    max-height: 400px;

    .dropdown-content {
      display: flex;
      flex-direction: column;
      padding: 2px;

      .nested-dropdown {
        margin-left: 0;
      }
    }

    .loading {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 2px;
      /* slim progress bar */
      width: 100%;
      overflow: hidden;
      background: rgba(0, 0, 0, 0.05);
      /* optional track background */
    }

    .loading::before {
      content: "";
      position: absolute;
      top: 0;
      left: -50%;
      height: 100%;
      width: 50%;
      background: linear-gradient(to right, var(--accent-color), transparent);
      animation: loadingAnimation 1.2s linear infinite;
      border-radius: #{$border-radius-small};
    }

    @keyframes loadingAnimation {
      0% {
        left: -50%;
      }

      100% {
        left: 100%;
      }
    }

    .dropdown-item {
      display: block;
      padding: 4px 10px;
      text-decoration: none;
      color: var(--text-color);
      font-size: var(--font-size-regular);
      cursor: pointer;
      transition: background-color 0.3s ease;
      border-radius: #{$border-radius-large};

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

    .nested-dropdown {
      margin-left: 20px;

      .dropdown-trigger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 10px;
        cursor: pointer;
        font-size: var(--font-size-regular);
        color: var(--text-color);
        transition: background-color 0.3s ease;
        border-radius: #{$border-radius-large};

        .arrow-container {
          @include flex-center;
        }

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

        &.open {
          color: var(--text-button-color);
          background: var(--background-color-accent);
        }

        .icon {
          font-size: var(--font-size-small);
          margin-left: 5px;
        }
      }

      .submenu {
        margin-top: 5px;
        padding-left: 20px;
        border-left: 2px solid var(--border-color);
        display: flex;
        flex-direction: column;
        gap: 6px;
      }
    }
  }
}

.input-toggle-container {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .label {
    white-space: nowrap;
  }

  .check-box {
    height: 24px;
    width: 38px;
    background: var(--background-color);
    border-radius: #{$border-radius-large};
    position: relative;
    cursor: pointer;

    .check-box-style {
      position: absolute;
      height: 20px;
      width: 20px;
      top: 2px;
      left: 2px;
      background: var(--text-button-color);
      border-radius: #{$border-radius-circle};
      transition: left 0.3s ease;
    }

    input {
      display: none;
    }
  }
}

.input-range-container {
  @include flex-center;
  padding: 6px 12px;

  .label {
    width: 45%;
    white-space: nowrap;
  }

  .input-container {
    @include flex-center;
    width: 100%;

    input[type="range"] {
      -webkit-appearance: none;
      width: 100%;
      height: 6px;
      border-radius: #{$border-radius-medium};
      outline: none;
      margin: 12px 8px;
      cursor: pointer;

      &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        background: var(--background-color-accent);
        border-radius: #{$border-radius-circle};
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        transition: transform 0.2s ease;
        outline: 3px solid var(--accent-color);
        outline-offset: -3px;
        transform: translateY(-5px);

        &:hover {
          transform: scale(1.1) translateY(-5px);
        }
      }

      &::-moz-range-thumb {
        width: 16px;
        height: 16px;
        background: var(--accent-color);
        border: none;
        border-radius: #{$border-radius-circle};
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        transition: transform 0.2s ease;

        &:hover {
          transform: scale(1.2);
        }
      }

      &::-ms-thumb {
        width: 16px;
        height: 16px;
        background: var(--accent-color);
        border: none;
        border-radius: #{$border-radius-circle};
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
        cursor: pointer;
        transition: transform 0.2s ease;

        &:hover {
          transform: scale(1.2);
        }
      }

      &::-webkit-slider-runnable-track {
        height: 6px;
        background: var(--background-color-secondary);
        border-radius: #{$border-radius-medium};
      }

      &::-moz-range-track {
        height: 6px;
        background: var(--background-color-secondary);
        border-radius: #{$border-radius-medium};
      }

      &::-ms-track {
        height: 6px;
        background: var(--background-color-secondary);
        border-radius: #{$border-radius-medium};
        border: none;
      }

      &::-ms-fill-lower,
      &::-ms-fill-upper {
        background: var(--background-color-secondary);
        border-radius: #{$border-radius-medium};
      }

      &:disabled {
        background: var(--text-disabled);
        cursor: not-allowed;

        &::-webkit-slider-thumb {
          background: var(--background-color-accent);
          box-shadow: none;
          outline: 4px solid var(--text-disabled);
          outline: -4px;
        }

        &::-moz-range-thumb {
          background: var(--background-color-accent);
          box-shadow: none;
        }

        &::-ms-thumb {
          background: var(--background-color-accent);
          box-shadow: none;
        }

        &::-webkit-slider-runnable-track,
        &::-moz-range-track,
        &::-ms-track,
        &::-ms-fill-lower,
        &::-ms-fill-upper {
          background: var(--text-disabled);
        }
      }
    }

    .input-value {
      width: 42px;
      text-align: center;

      &::-webkit-inner-spin-button,
      &::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
      }
    }
  }
}

.value-field-container {
  margin-bottom: 6px;
  padding: 6px 12px;
  @include flex-space-between;

  .label {
    width: 40%;
  }

  .regularDropdown-container {
    width: 60%;
  }

  .default {
    width: 60%;
  }
}

.multi-email-invite-input-container {
  @include flex-space-between;
  gap: 20px;
  position: relative;

  .users-list-container {
    position: absolute;
    top: calc(100% + 8px);
    background: var(--background-color);
    backdrop-filter: blur(18px);
    padding: 12px;
    width: 100%;
    height: auto;
    max-height: 200px;
    border-radius: 8px;
    z-index: 100;
    outline: 1px solid var(--border-color);
  }

  .multi-email-invite-input {
    width: 100%;
    display: flex;
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: #{$border-radius-large};
    flex-wrap: wrap;
    overflow: auto;

    input {
      border: none;
      outline: none;
      background: transparent;
      width: 100%;

      &::placeholder {
        color: var(--text-disabled);
      }
    }

    .entered-emails {
      @include flex-center;
      gap: 2px;
      background: var(--background-color-gray);
      padding: 0 4px;
      border-radius: #{$border-radius-large};

      span {
        height: 14px;
        width: 14px;
        line-height: 12px;
        text-align: center;
        border-radius: #{$border-radius-small};
      }
    }
  }

  .invite-button {
    padding: 4px 12px;
    border-radius: #{$border-radius-large};
    background: var(--background-color-accent);
    color: var(--text-button-color);
  }

  .multi-email-invite-input.active {
    border: 1px solid var(--accent-color);
  }
}

.preview-selection-with-upload-wrapper {
  .input-header-container {
    padding: 6px 12px;
    @include flex-space-between;

    .arrow-container {
      transition: all 0.2s;
      @include flex-center;
    }
  }

  .upload-custom-asset-button {
    padding: 6px 12px;
    @include flex-space-between;

    .title {
      white-space: nowrap;
      width: 40%;
    }

    input {
      display: none;
    }

    .upload-button {
      width: 60%;
      background: var(--highlight-accent-color);
      color: var(--accent-color);
      padding: 3px 6px;
      border-radius: #{$border-radius-small};
      text-align: center;
    }
  }

  .canvas-wrapper {
    height: 150px;
    width: 100%;
    padding: 8px;
    padding-right: 4px;
    overflow: hidden;
    position: relative;

    .canvas-container {
      width: 100%;
      height: 100%;
      border-radius: #{$border-radius-small};
      background: var(--background-color-gray);
    }
  }
}
