@use '../abstract/_all';
@use '../abstract/breakpoints';
@use '../abstract/fonts';
@use '../abstract/mixins';
@use '../abstract/setup';

$input-padding-x: 14px;
$input-padding-y: 14px;
input:focus,
textarea:focus {
  outline: none;
  border: 1px solid setup.$c-primary;
}
.form {
  width: 100%;
}
.form-control[disabled],
.form-control[readonly],
fieldset[disabled] .form-control {
  background-color: transparent;
  opacity: 1;
}
.textarea {
  height: 100px;
  padding: 10px;
  box-sizing: border-box;
}
label {
  font-size: setup.$text-md;
}
select {
  background-color: setup.$c-white;
  border-color: setup.$c-middle-grey;
  border-radius: setup.$form-radius;
  color: setup.$c-primary;
}
.select {
  max-width: 100%;
  appearance: none;
  align-items: center;
  border-radius: setup.$form-radius;
  box-shadow: none;
  display: inline-flex;
  justify-content: flex-start;
  position: relative;
  vertical-align: top;
  select {
    cursor: pointer;
    display: block;
    max-width: 100%;
    outline: 0;
    &:hover {
      opacity: 0.6;
    }
  }
  label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: setup.$btn-padding;
    z-index: 1;
  }
  &::after {
    border: 1px solid setup.$c-primary;
    border-radius: setup.$form-radius;
    border-right: 0;
    border-top: 0;
    content: ' ';
    height: 8px;
    margin-top: -6px;
    pointer-events: none;
    position: absolute;
    top: 50%;
    right: 20px;
    transform: rotate(-45deg);
    transform-origin: center;
    width: 8px;
  }
  &:not(.is-multiple) {
    height: 48px;
  }
  &:not(.is-multiple, .is-loading)::after {
    border-color: setup.$c-primary;
  }
  select::-ms-expand {
    display: none;
  }
  select[disabled]:hover,
  fieldset[disabled] select:hover {
    border-color: setup.$c-light-grey;
  }
  select:not([multiple]) {
    padding-right: 45px;
  }
  select[multiple] {
    height: auto;
    padding: 0;
  }
  select[multiple] option {
    padding: 0 40px;
  }
  &:not(.is-multiple, .is-loading):hover::after {
    border-color: setup.$c-primary;
  }
  &.select-label {
    select {
      padding-left: 100px;
    }
  }
  &.select-box {
    height: auto;
    select {
      background-color: setup.$c-middle-grey;
      min-width: 24px;
      width: 100%;
      height: 24px;
      padding: 0 16px 0 8px;
      font-size: setup.$text-input-d;
      border-radius: setup.$form-radius;
      border: none;
      text-align: center;
    }
    &::after {
      display: block;
      right: 6px;
      width: 5px;
      height: 5px;
      margin-top: -3px;
    }
  }
  &.select-flat,
  &.select-flat-no-icon {
    width: max-content;
    label {
      z-index: 0;
      left: 0;
    }
    select {
      border: none;
      padding-left: 0;
      background: none;
      padding-right: 40px;
    }
    &::after {
      right: 0;
    }
  }
  &.select-flat-no-icon {
    padding-right: 8px;
    &::after {
      content: none;
    }
  }
  &.select-secondary-rd {
    width: max-content;
    &:hover {
      opacity: 0.5;
    }
    label {
      z-index: 0;
      left: 0;
    }
    &::after {
      display: none;
    }
    select {
      border-radius: setup.$obj-radius;
      border: 1px solid setup.$c-primary;
      padding: 6px 2px 4px;
      min-width: 100px;
      text-align: center;
      background: none;
      height: 32px;
      font-size: setup.$text-input-m;
      opacity: 0;
      @media (min-width: breakpoints.$break-sm) {
        padding: 14px 2px;
        height: 48px;
        font-size: setup.$text-input-d;
      }

      &:hover {
        opacity: 0;
      }
    }
    &.select:not([multiple]),
    &.select:not(.is-multiple) {
      height: 32px;
      @media (min-width: breakpoints.$break-sm) {
        height: 48px;
      }
    }
    &.select select:not(.is-multiple),
    &.select select:not([multiple]) {
      padding: 6px 2px 4px;
      height: 32px;
      width: 100px;
      @media (min-width: breakpoints.$break-sm) {
        width: 120px;
        padding: 14px 2px;
        height: 48px;
      }
    }
    .btn-secondary-rd {
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  .select-secondary-rd {
    .btn.btn-secondary-rd {
      padding: 9px 2px 4px;
      &:hover {
        opacity: 0.5;
      }
      @media (min-width: breakpoints.$break-sm) {
        padding: 16px 2px 14px;
      }
    }
  }
  &.select-size {
    width: max-content;
    label {
      z-index: 0;
      left: 0;
    }
    select {
      border-radius: setup.$obj-radius;
      padding-left: 16px;
      background: none;
      padding-right: 40px;
      border-color: setup.$c-primary;
      &:hover {
        opacity: 0.6;
      }
    }
  }
}
.input,
.textarea,
.select select {
  border: 1px solid transparent;
  appearance: none;
  align-items: center;
  box-shadow: none;
  display: inline-flex;
  justify-content: flex-start;
  padding: 14px 16px;
  position: relative;
  vertical-align: top;
  border-radius: setup.$form-radius;
  height: 48px;
  box-sizing: border-box;
  background-color: transparent;
  border-color: setup.$c-middle-grey;
  color: setup.$c-primary;
  max-width: 100%;
  width: 100%;
  font-size: setup.$text-input-m;
  line-height: 1;
  @media (min-width: breakpoints.$break-sm) {
    font-size: setup.$text-input-d;
  }
  &.validation-error {
    border-color: setup.$c-error;
  }
}
.validation-error-messages {
  color: setup.$c-error;
  font-weight: 500;
  svg {
    path {
      fill: setup.$c-error;
    }
  }
}
.validation-error-wrap {
  min-height: 24px;
}
.input-line {
  border-top: 1px solid transparent;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  background-color: transparent;
  padding-left: 0;
  border-bottom: 1px solid setup.$c-primary;
}
.input-notouch {
  @include mixins.font-regular;
  pointer-events: none;
  border-color: setup.$c-middle-grey;
  padding: 24px 0;
}
.inputmini {
  //todo revisar
  border-color: setup.$c-middle-grey;
  color: setup.$c-primary;
  max-width: 100%;
  width: 58px;
  align-items: center;
  border: 1px solid setup.$c-middle-grey;
  box-shadow: none;
  display: inline-flex;
  height: 34px;
  font-size: setup.$text-md;
  margin-left: 10px;
  text-align: center;
  justify-content: flex-start;
  line-height: 1.5;
  padding: calc(0.375em - 1px) calc(0.625em - 1px) calc(0.375em - 1px) calc(0.625em - 1px);
  position: relative;
  vertical-align: top;
}
.input-btn {
  .input {
    display: inline-block;
    width: calc(60% - 100px);
  }
  .btn {
    display: inline-block;
    height: 48px;
    margin-left: -3px;
    width: 100px;
  }
}
.input-gray {
  padding-left: 40px;
  background: rgb(0 0 0 / 5%);
  border-radius: setup.$obj-radius;
  border: none;
}
input::input-placeholder {
  color: setup.$c-middle-grey;
  transform: translate3d(0, 0, 0);
}
.checkbox-text {
  float: left;
  label {
    display: inline-block;
  }
  input {
    display: inline-block;
    margin-right: 10px;
  }
}
.info-text {
  color: setup.$c-dark-grey;
  margin-top: 4px;
  width: 100%;
  float: left;
}
.form-text {
  right: 16px;
  right: 0;
  left: auto;
  position: absolute;
  top: 0;
  min-width: 50px;
  height: 48px;
  box-sizing: border-box;
  display: table;
  span {
    vertical-align: middle;
    display: table-cell;
    padding-right: 16px;
    padding: 12px;
  }
}
.form-text-svg {
  svg {
    display: inline-block;
    padding: 12px;
    box-sizing: initial;
  }
}
.form-input-label-2,
.error-zone {
  font-family: fonts.$font-family-form;
  position: relative;
  label {
    font-size: setup.$text-input-d;
  }

  .validation-error-messages {
    width: calc(100% - 40px);
  }
  .help {
    font-family: fonts.$font-family-form;
    position: relative;
    line-height: 1.5;
    font-size: setup.$text-input-d;
    margin-top: 0;
    padding-top: 2px;
    margin-bottom: 4px;
    width: calc(100% - 50px);
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
  }
  .input-text {
    color: setup.$c-dark-grey;
    margin-top: 4px;
    line-height: 1;
  }
  .info-text {
    color: setup.$c-dark-grey;
    margin-top: 4px;
    width: auto;
    position: absolute;
    right: 0;
  }
  & > input,
  & > label,
  & > textarea {
    font-family: fonts.$font-family-form;
    padding: 16px;
    font-weight: normal;
  }
  & > label {
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    font-weight: normal;
    margin-top: 1px;
    margin-bottom: 0;
    line-height: 1.1;
    color: setup.$c-dark-grey;
    border-radius: setup.$obj-radius;
    transition: all 0.1s ease-in-out;
    pointer-events: none;
  }
  & input::input-placeholder {
    color: transparent;
  }
  & input:input-placeholder {
    color: transparent;
  }
  & input::placeholder {
    color: transparent;
  }
  & input:not(:placeholder-shown) {
    padding-top: calc(#{$input-padding-y} + #{$input-padding-y} * (2 / 3));
    padding-bottom: calc(#{$input-padding-y} / 3 + 3px);
  }
  & input:not(:placeholder-shown) ~ label {
    padding-top: calc(#{$input-padding-y} / 3 + 1px);
    padding-bottom: calc(#{$input-padding-y} / 3);
    font-size: setup.$text-sm;
    color: setup.$c-dark-grey;
  }
  & input::-webkit-list-button,
  & input::-webkit-calendar-picker-indicator {
    display: none;
    opacity: 0;
  }
  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus,
  textarea:-webkit-autofill,
  textarea:-webkit-autofill:hover,
  textarea:-webkit-autofill:focus,
  select:-webkit-autofill,
  select:-webkit-autofill:hover,
  select:-webkit-autofill:focus {
    border: 1px solid setup.$c-middle-grey;
    -webkit-text-fill-color: setup.$c-primary;
    box-shadow: 0 0 0 1000px setup.$c-white inset;
    transition: background-color 5000s ease-in-out 0s;
  }
  &.input-line .input {
    border: none;
  }
  input:-ms-input-placeholder {
    color: setup.$c-dark-grey !important;
  }
  input {
    background-color: setup.$c-white;
  }
  &.has-ico-pre,
  .has-ico-pre {
    &.btn,
    & > input,
    & > label {
      padding-left: setup.$btn-padding * 3;
    }
    .form-icon {
      top: 0;
      left: 0;
    }
    .ico-pre {
      height: 45px;
      position: absolute;
      top: 0;
      right: auto;
      left: 0;
      box-sizing: border-box;
      margin: 0 15px;
      cursor: pointer;
      align-items: center;
      display: inline-flex;
      justify-content: center;
    }
  }
  &.has-ico-post,
  .has-ico-post {
    &.btn,
    & > input,
    & > label {
      padding-right: setup.$btn-padding * 3;
    }
    .form-icon {
      padding: setup.$btn-padding;
      top: 0;
      right: 0;
      left: auto;
    }
    .ico-post {
      height: 45px;
      position: absolute;
      top: 0;
      right: 0;
      left: auto;
      box-sizing: border-box;
      margin: 0 15px;
      cursor: pointer;
      align-items: center;
      display: inline-flex;
      justify-content: center;
    }
  }
}

.form-input-label-2 {
  &.required {
    label::after {
      content: ' *';
    }
  }
}

.is-error {
  .input,
  label,
  .help {
    color: setup.$c-error !important;
  }
  .input {
    border: 1px solid setup.$c-error;
  }
  .input-prefix :nth-child(1)::placeholder {
    color: setup.$c-error;
  }
  svg {
    g {
      stroke: setup.$c-error !important;
    }
    path {
      fill: setup.$c-error !important;
    }
  }
}
.ok-input {
  .input,
  label,
  .help {
    color: setup.$c-success !important;
  }
  .input {
    border: 1px solid setup.$c-success;
    color: setup.$c-success;
  }
  .input-prefix :nth-child(1)::placeholder {
    color: setup.$c-success;
  }
  .input-line {
    border-top: 1px solid transparent;
    border-left: 1px solid transparent;
    border-right: 1px solid transparent;
    border-bottom: 1px solid setup.$c-success;
    color: setup.$c-success;
  }
}
.disabled-input {
  pointer-events: none;
  opacity: 0.4;
}
.form-input-label {
  font-family: fonts.$font-family-form;
  position: relative;
  margin-bottom: 24px;
  & > input,
  & > label {
    font-family: fonts.$font-family-form;
    padding: 16px;
    font-weight: normal;
  }
  & > label {
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    font-weight: normal;
    margin-top: 1px;
    margin-bottom: 0;
    line-height: 1.1;
    color: setup.$c-dark-grey;
    border-radius: setup.$btn-radius;
    transition: all 0.1s ease-in-out;
    pointer-events: none;
  }
  & input::input-placeholder {
    color: transparent;
  }
  & input:input-placeholder {
    color: transparent;
  }
  & input::placeholder {
    color: transparent;
  }
  & input:not(:placeholder-shown) {
    padding-top: calc(#{$input-padding-y} + #{$input-padding-y} * (2 / 3));
    padding-bottom: calc(#{$input-padding-y} / 3 + 3px);
  }
  & input:not(:placeholder-shown) ~ label {
    padding-top: calc(#{$input-padding-y} / 3 + 1px);
    padding-bottom: calc(#{$input-padding-y} / 3);
    font-size: setup.$text-sm;
    color: setup.$c-dark-grey;
  }
  & input::-webkit-list-button,
  & input::-webkit-calendar-picker-indicator {
    display: none;
    opacity: 0;
  }
  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus,
  textarea:-webkit-autofill,
  textarea:-webkit-autofill:hover,
  textarea:-webkit-autofill:focus,
  select:-webkit-autofill,
  select:-webkit-autofill:hover,
  select:-webkit-autofill:focus {
    border: 1px solid setup.$c-middle-grey;
    -webkit-text-fill-color: setup.$c-primary;
    box-shadow: 0 0 0 1000px setup.$c-white inset;
    transition: background-color 5000s ease-in-out 0s;
  }
  &.input-line .input {
    border: none;
  }
}
//deprecated
.form-input-prefix {
  display: flex;
  .input-prefix {
    width: 52px;
    display: inline-block;
    margin-right: 8px;
  }
  .input-prefix .input {
    padding-left: 0;
    padding-right: 0;
    text-align: center;
  }
  .form-input-label,
  .form-input-label-2 {
    display: inline-block;
    width: calc(100% - 60px);
  }
}
.form-prefix {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  > :not(.select):nth-child(1) {
    flex: 0 0 75px;
  }
  > :nth-child(2) {
    flex: 5 0 130px;
  }
  > .btn {
    flex: 1 0 auto;
  }
}
.input-line-v2 {
  position: relative;
  display: flex;
  padding-right: 64px;
  .input,
  .input:focus,
  .textarea,
  .textarea:focus {
    @include mixins.font-regular;
    padding: 12px 0 4px;
    height: auto;
    border: none;
    border-bottom: 1px solid setup.$c-primary;
  }
  .input::input-placeholder {
    @include mixins.font-regular;
    text-overflow: inherit;
    line-height: initial;
    white-space: pre;
    overflow-wrap: normal;
    -webkit-user-modify: read-only !important;
    overflow: hidden;
  }
}
@supports (-ms-ime-align: auto) {
  .form-input-label-2 > label {
    display: none;
  }
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .form-input-label-2 > label {
    display: none;
  }
}
.has-light {
  .form-input-label input,
  .form-input-label-2 input {
    background-color: transparent;
  }
  input,
  label {
    color: setup.$c-white;
  }
  .form-input-label,
  .form-input-prefix {
    & > label {
      color: setup.$c-white;
    }
    & input::input-placeholder {
      color: transparent;
    }
    & input:input-placeholder {
      color: transparent;
    }
    & input::placeholder {
      color: transparent;
    }
    & input:not(:placeholder-shown) ~ label {
      color: setup.$c-white;
    }
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    textarea:-webkit-autofill,
    textarea:-webkit-autofill:hover,
    textarea:-webkit-autofill:focus,
    select:-webkit-autofill,
    select:-webkit-autofill:hover,
    select:-webkit-autofill:focus {
      border: 1px solid setup.$c-white;
      -webkit-text-fill-color: setup.$c-white;
      box-shadow: 0 0 0 1000px setup.$c-primary inset;
    }
    .input,
    .textarea,
    .select select {
      background-color: transparent;
      border-color: setup.$c-white;
      color: setup.$c-white;
    }
  }
  .form-input-label-2 .info-text,
  .error-zone .info-text {
    color: setup.$c-white;
  }
  .input-prefix {
    input::input-placeholder {
      color: setup.$c-white;
      transform: translate3d(0, 0, 0);
      opacity: 0.7;
    }
  }
}
@supports (-ms-ime-align: auto) {
  .form-input-label > label {
    display: none;
  }
  .formlabel input:-ms-input-placeholder {
    color: setup.$c-dark-grey;
  }
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .form-input-label > label {
    display: none;
  }
  .formlabel input:-ms-input-placeholder {
    color: setup.$c-dark-grey !important;
  }
}

.form-postcode {
  flex-wrap: wrap;
  gap: 8px;

  > :not(.select):nth-child(1) {
    flex: 0 0 200px;
  }

  > :nth-child(2) {
    flex: 1 0 auto;
  }

  .form-input-label-2 .help {
    width: 100%;
  }
}

.form-input-mobile {
  position: absolute;
  z-index: 1;
  width: calc(100% - 40px);
  max-width: 450px;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}
