@use '../../00-settings/settings' as *;
@use '../../00-mixins/mixins' as *;
@use '../../11-base/forms/forms' as *;

input[type="text"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="email"],
input[type="url"] {
  @include field-base;

  &::placeholder {
    @include theme('color', 'help-text-color');

    opacity: .5;
    font-style: initial;
  }
}

input[type="password"] {
  [class*="cs--"] & {
    &,
    &:focus {
      padding-right: $field-icon-padding;
      background-image: svg-as-background('lock-closed', coloring('gray'), 24, 24);
      background-repeat: no-repeat;
      background-position: right .75rem center;

      &:disabled {
        background-image: svg-as-background('lock-closed', coloring('gray', -2), 24, 24);
      }
    }
  }
}

input[type="date"] {
  padding-right: 0;
  // Fixes vertical alignment on mobile safari.
  line-height: 2.4rem;

  &::-webkit-calendar-picker-indicator { // stylelint-disable-line selector-no-vendor-prefix
    @include theme('background-color', 'button-secondary-background');

    width: 1.2rem;
    height: 1.2rem;
    padding: .5rem;
    background-image: svg-as-background('calendar', coloring('gray'), 30, 30);

    &:hover {
      @include theme('background-color', 'button-secondary-hover-background');

      cursor: pointer;
    }
  }

  &::-webkit-inner-spin-button { // stylelint-disable-line selector-no-vendor-prefix
    margin-left: .5rem;
    -webkit-appearance: none; // stylelint-disable-line property-no-vendor-prefix
  }
}

.radio {
  @include choices-field-base('radio');

  &:hover {
    // Unchecked and hovered.
    label::before {
      @include theme('background-color', 'color-zero-ultralight', 'radio-background-color-hover');
      @include theme('border-color', 'color-zero', 'radio-border-color-hover');
    }

    // Checked and hovered.
    input[type="radio"]:checked + label::before {
      @include theme('background-color', 'color-zero-ultralight', 'radio-background-color-hover-and-checked');
      @include theme('border-color', 'color-primary', 'radio-border-color-hover-and-checked');
      @include theme('color', 'color-primary', 'radio-color-hover-and-checked');
    }
  }

  &:focus + label,
  input[type="radio"]:focus + label {
    @include focus-bare;
  }
}

.checkbox {
  @include choices-field-base('checkbox');

  &:hover {
    // Unchecked and hovered.
    label::before {
      @include theme('background-color', 'color-zero-ultralight', 'checkbox-background-color-hover');
    }

    // Checked and hovered.
    input[type="checkbox"]:checked + label::before {
      @include theme('background-color', 'color-zero-ultralight', 'checkbox-background-color-hover-and-checked');
      @include theme('border-color', 'color-primary', 'checkbox-border-color-hover-and-checked');
      @include theme('color', 'color-zero', 'checkbox-color-hover-and-checked');
    }
  }

  &:focus + label,
  input[type="checkbox"]:focus + label {
    @include focus-bare;
  }
}
