@use "sass:color";

// EXTENDED INPUT TYPES
input[type="text"],
input[type="color"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="email"],
input[type="tel"],
input[type="week"],
input[type="month"],
input[type="time"],
select,
option {
  position: relative;
  display: block;
  border: 1px solid #dfdfdf;
  outline: none;
  width: 100%;
  height: 2.5rem;
  padding: 10px 1.5rem;
  border-radius: 5px;
  transition: all 0.3s ease;
  font-size: 1rem;

  &:hover {
    // border: none;
    // outline: none;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }

  &::placeholder {
    font-size: 1rem;
    color: #8a8a8a;
  }
}

// COLOR INPUT SPECIFIC
input[type="color"] {
  height: 2.5rem;
  cursor: pointer;
}

// DATE/TIME INPUTS SPECIFIC
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="time"] {
  min-width: 12rem;
}

// RANGE INPUT
input[type="range"] {
  width: 100%;
  height: 2.5rem;
  padding: 0 1rem;
  margin: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;

  &::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.5rem;
    background: #dfdfdf;
    border-radius: 5px;
    border: none;
    transition: all 0.3s ease;
  }

  &::-moz-range-track {
    width: 100%;
    height: 0.5rem;
    background: #dfdfdf;
    border-radius: 5px;
    border: none;
    transition: all 0.3s ease;
  }

  &::-ms-track {
    width: 100%;
    height: 0.5rem;
    background: #dfdfdf;
    border-radius: 5px;
    border: none;
    color: transparent;
    transition: all 0.3s ease;
  }

  &::-webkit-slider-thumb {
    appearance: none;
    width: 1.2rem;
    height: 1.2rem;
    background: #261cb7;
    border-radius: 50%;
    border: 2px solid #fff;
    margin-top: -0.35rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }

  &::-moz-range-thumb {
    width: 1.2rem;
    height: 1.2rem;
    background: #261cb7;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }

  &::-ms-thumb {
    width: 1.2rem;
    height: 1.2rem;
    background: #261cb7;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }

  &::-webkit-slider-runnable-track {
    background: linear-gradient(
      to right,
      #261cb7 0%,
      #261cb7 var(--range-progress, 0%),
      #dfdfdf var(--range-progress, 0%),
      #dfdfdf 100%
    );
  }

  &::-ms-fill-lower {
    background: #261cb7;
    border-radius: 5px;
  }

  &::-ms-fill-upper {
    background: #dfdfdf;
    border-radius: 5px;
  }

  &:hover {
    &::-webkit-slider-thumb {
      background: #0942ff;
      transform: scale(1.1);
    }
    &::-moz-range-thumb {
      background: #0942ff;
      transform: scale(1.1);
    }
    &::-ms-thumb {
      background: #0942ff;
      transform: scale(1.1);
    }
  }

  &:focus {
    border: 1px solid #dfdfdf;
    outline: none;

    &::-webkit-slider-thumb {
      box-shadow: #d2e2fb 0px 0px 0px 2px;
    }
    &::-moz-range-thumb {
      box-shadow: #d2e2fb 0px 0px 0px 2px;
    }
    &::-ms-thumb {
      box-shadow: #d2e2fb 0px 0px 0px 2px;
    }
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;

    &::-webkit-slider-thumb {
      background: #8a8a8a;
    }
    &::-moz-range-thumb {
      background: #8a8a8a;
    }
    &::-ms-thumb {
      background: #8a8a8a;
    }
    &::-webkit-slider-runnable-track {
      background: #dfdfdf;
    }
    &::-moz-range-track {
      background: #dfdfdf;
    }
    &::-ms-track {
      background: #dfdfdf;
    }
  }
}

// NUMBER
input[type="number"] {
  position: relative;
  display: block;
  border: 1px solid #dfdfdf;
  outline: none;
  width: 100%;
  height: 2.5rem;
  padding: 10px 1.5rem;
  border-radius: 5px;
  transition: all 0.3s ease;
  font-size: 1rem;

  &:hover {
    border: 1px solid #ccc;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }

  &::placeholder {
    font-size: 1rem;
    color: #8a8a8a;
  }

  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  -moz-appearance: textfield;
}

// FILE INPUT
input[type="file"] {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid #dfdfdf;
  border-radius: 5px;
  transition: all 0.3s ease;
  font-size: 1rem;

  &:hover {
    border: 1px solid #ccc;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }

  &::file-selector-button {
    padding: 0.5rem 1rem;
    border: none;
    background: #261cb7;
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: #0942ff;
    }
  }
}

// TEXTAREA
textarea {
  position: relative;
  display: block;
  border: 1px solid #dfdfdf;
  outline: none;
  width: 100%;
  min-height: 6rem;
  padding: 10px 1.5rem;
  border-radius: 5px;
  font-size: 1rem;
  resize: both;
  transition: all 0.1s ease;

  &:hover {
    border: 1px solid #ccc;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }

  &::placeholder {
    font-size: 1rem;
    color: #8a8a8a;
  }
}

// BUTTON INPUTS
input[type="button"],
input[type="submit"],
input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  padding: 0 1.5rem;
  border: none;
  border-radius: 5px;
  background: #261cb7;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;

  &:hover {
    background: #0942ff;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #8a8a8a;
  }
}

// SEARCH INPUT
input[type="search"] {
  position: relative;
  display: block;
  border: 1px solid #dfdfdf;
  outline: none;
  width: 100%;
  height: 2.5rem;
  padding: 10px 1.5rem;
  border-radius: 5px;
  transition: all 0.3s ease;

  &:hover {
    border: 1px solid #ccc;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
  }
}

select {
  position: relative;
  display: block;
  width: 100%;
  height: 2.5rem;
  padding: 0 2.5rem 0 1.5rem;
  border: 1px solid #dfdfdf;
  border-radius: 5px;
  background: white;
  appearance: none;
  transition: all 0.3s ease;

  &:before {
    content: "\f030";
    font-family: "mastorsIcons" !important;
    speak: never;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;

    font-family: "mastorsIcons" !important;
    position: absolute;
    right: 1rem;
    width: 1rem;
    aspect-ratio: 1;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #8a8a8a;
    transition: transform 0.3s ease;
  }

  &:hover {
    border: 1px solid #ccc;
  }

  &:focus {
    box-shadow: #d2e2fb 0px 0px 0px 2px;
    border: 1px solid #dfdfdf;
    outline: none;
    &:before {
      transform: translateY(-50%) rotate(180deg);
    }
  }
}

// Variables for consistent theming
$primary: #007bff;
$success: #28a745;
$danger: #ff6b6b;
$warning: #ffc107;
$border-color: #ccc;
$text-color: #999;
$text-active: #666;
$shadow: rgba(0, 0, 0, 0.1);
$transition: all 0.3s ease;

// Mixins for reusable effects
@mixin glow-effect {
  box-shadow: 0 0 15px rgba($primary, 0.3);
  transition: $transition;
}

@mixin placeholder-style($bg, $color) {
  background: $bg;
  color: $color;
}

// Base input container styles
.input-container {
  position: relative;
  width: 100%;
  display: flex;
  outline: none;
  align-items: center;
  transition: $transition;

  &.border-all {
    border: 1px solid $border-color;
  }

  &.shadow {
    box-shadow: 0 2px 4px $shadow;
  }

  &.rounded {
    border-radius: 12px;
  }

  &.large {
    width: 400px;
  }

  .input-field {
    border: none;
    outline: none;
    width: 100%;
    padding: 14px 14px 14px 24px;
    font-size: 16px;
    border: none;
    outline: none;
    background: transparent;
    transition: $transition;

    &:focus {
      border-color: $primary;
      background: transparent;
      outline: none;
    }

    &:not(:placeholder-shown) + .placeholder-text {
      top: 0;
      transform: translateY(-50%);
      font-size: 12px;
      color: $text-active;
      outline: none;
    }
  }

  .placeholder-text {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: $text-color;
    pointer-events: none;
    transition: $transition;
    padding: 0 4px;
    background: white;
    font-size: 0.9rem;
    font-weight: 500;

    &.adjusted {
      top: -12px;
      font-size: 0.9rem;
      padding: 3px 8px;
      border-radius: 4px;
    }
  }

  .input-field:focus + .placeholder-text {
    top: 0;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: $text-active;
    outline: none;
  }

  // Style Variations
  &.outline {
    border: 2px solid $primary;
    border-radius: 8px;

    &:hover {
      @include glow-effect;
    }
  }

  &.soft-glow {
    border: 1px solid color.adjust($primary, $lightness: -10%);
    border-radius: 10px;
    @include glow-effect;

    .placeholder-text {
      @include placeholder-style(
        color.adjust($primary, $lightness: 40%),
        $primary
      );
    }

    &:hover {
      box-shadow: 0 0 20px rgba($primary, 0.4);
    }
  }

  &.pill {
    border: 2px solid $success;
    border-radius: 50px;

    .placeholder-text {
      @include placeholder-style(
        color.adjust($success, $lightness: 40%),
        $success
      );
    }

    &:hover {
      box-shadow: 0 0 15px rgba($success, 0.3);
    }
  }

  &.underline {
    border-bottom: 3px solid $danger;
    background: transparent;

    .placeholder-text {
      @include placeholder-style(
        color.adjust($danger, $lightness: 40%),
        $danger
      );
      border-radius: 0 6px 6px 0;
      transform: translateX(-10px);
      padding: 0 0.5rem;
    }

    &:hover {
      border-bottom-width: 4px;
    }
  }

  &.floating-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 20px $shadow;

    .input-field {
      border: none;
      outline: none;
      padding-top: 22px;
    }

    .placeholder-text {
      @include placeholder-style(#ffffff, #333);
      top: -14px;
      left: 14px;
      padding: 0 0.5rem;
    }

    &:hover {
      box-shadow: 0 8px 25px rgba($shadow, 0.15);
    }
  }

  &.neon-edge {
    border: 2px solid transparent;
    border-radius: 8px;
    background: linear-gradient(#fff, #fff),
      linear-gradient(45deg, #ff00ff, #00ffff, #ff00ff);
    background-clip: padding-box, border-box;
    position: relative;

    &:after {
      content: "";
      position: absolute;
      top: -4px;
      left: -4px;
      right: -4px;
      bottom: -4px;
      background: linear-gradient(45deg, #ff00ff, #00ffff);
      filter: blur(8px);
      z-index: -1;
      opacity: 0.7;
    }

    .placeholder-text {
      @include placeholder-style(
        color.adjust($warning, $lightness: 40%),
        color.adjust($warning, $lightness: -100%)
      );
      padding: 0 0.5rem;
      border-radius: 3px;
    }
  }

  &.minimal-accent {
    border-left: 5px solid $warning;
    background: #fff;

    .placeholder-text {
      @include placeholder-style(
        color.adjust($warning, $lightness: 40%),
        color.adjust($warning, $lightness: -40%)
      );
      padding: 0 0.5rem;
    }

    &:hover {
      box-shadow: 0 0 15px rgba($warning, 0.2);
    }
  }
}
