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

// global input style

input {
  width: 100%;
  padding: 2px 4px;
  border-radius: #{$border-radius-small};
  border: 1px solid var(--border-color);
  outline: none;
  background: transparent;

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

.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);
  border: 1px solid var(--accent-color);
  outline: none;
  border-radius: #{$border-radius-small};
  line-height: 26px;
  padding: 0 8px;
}

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

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

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

.search-wrapper {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  background: var(--background-color);
  z-index: 1;

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

    .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-color: transparent;
      padding-left: 36px;
    }

    .clear-button {
      @include flex-center;
      position: absolute;
      right: 4px;
      width: 24px;
      height: 24px;
      border: none;
      cursor: pointer;
      background-color: transparent;

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

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

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

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

  .menu-list {
    position: absolute;
    left: 10px;
    top: 12px;
    background-color: 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-color: var(--background-color-secondary);
      }

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

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

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

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

    input {
      display: none;
    }
  }
}

.regularDropdown-container {
  width: 100%;
  min-width: 80px;
  padding: 2px 4px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  position: relative;
  cursor: pointer;

  .dropdown-header {
    height: 100%;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 6px;
    background-color: var(--background-color);
  }

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

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

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

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

  .icon {
    height: auto;
  }
}

.input.default {
  width: 100%;
  position: relative;

  .dropdown {
    top: 2px;
    right: 2px;
    position: absolute;
    background: var(--highlight-accent-color);
    border-radius: #{$border-radius-small};
    padding: 1px 4px;

    .active-option {
      color: var(--accent-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: 24px;
      @include flex-center;
      border-radius: #{$border-radius-small};
      background: var(--background-color-secondary);
      cursor: pointer;
    }

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

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

  .dropdown-button {
    width: 100%;
    background-color: var(--background-color) !important;
    border: 1px solid var(--border-color) !important;
    padding: 5px 10px;

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

    // font-size: 12px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;

    &:hover {
      background-color: #333333;
    }

    &.open {
      background-color: #333333;
    }
  }

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

    .dropdown-content {
      display: flex;
      flex-direction: column;
      gap: 6px;

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

      padding: 10px;
    }

    .dropdown-item {
      display: block;
      padding: 5px 10px;
      text-decoration: none;
      color: var(--text-color);
      font-size: var(--font-size-regular);
      cursor: pointer;
      transition: background-color 0.3s ease;

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

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

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

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

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

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

        .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: 22px;
    width: 44px;
    background: var(--background-color-secondary);
    border-radius: #{$border-radius-large};
    position: relative;
    cursor: pointer;

    .check-box-style {
      position: absolute;
      height: 18px;
      width: 18px;
      top: 2px;
      left: 2px;
      background: var(--accent-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;
      background: var(--background-color-secondary);
      border-radius: #{$border-radius-medium};
      outline: none;
      margin: 12px 8px;
      cursor: pointer;

      &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        background: var(--primary-color);
        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(--primary-color);
          box-shadow: none;
          outline: 4px solid var(--text-disabled);
          outline: -4px;
        }

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

        &::-ms-thumb {
          background: var(--primary-color);
          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: 40px;
      text-align: center;
    }
  }
}

.labeled-button-container {
  @include flex-space-between;
  padding: 6px 12px;

  button {
    padding: 2px 32px;
    border: none;
    border-radius: #{$border-radius-large};
    color: var(--text-disabled);
    background: var(--accent-color);
    transition: all 0.2s;
    cursor: pointer;

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

.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;

  .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;
    max-height: 180px;
    overflow: auto;

    input {
      border: none;
      background: transparent;

      &::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};

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

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

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