/* GENERAL STYLES FOR FORMS */

/* FORM GROUPS */
.form-group {
  position: relative;
  display: flex;
  display: grid;
  grid-template-columns: 1fr 3fr;
  grid-gap: 5px;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 4px 0;
  border-left: 2px solid transparent;

  + .form-group {
    margin-top: 13px;
  }
}

.form-group__label {
  font-weight: 600;
  padding-top: 6px;
}

.form-group--required {

  .form-group__label::after {
    content: ' *';
    color: var(--color-error);
  }
}

.form-group--optional {
  .form-group__label::after {
    content: '';
  }
}

.form-group--submit .form-group__input {
  grid-column: 2;
}

@media (max-width: 768px) {
  .form-group--submit .form-group__input {
    grid-column: 1;
  }
}

.form-group--has-error {
  background-color: rgba(255, 0, 0, 0.1);

  input, textarea {
    border-color: var(--color-error) !important;
  }
}

@media (max-width: 768px) {
  .form-group {
    grid-template-columns: 1fr;
    align-items: baseline;
    margin-top: 17px;
    flex-direction: column;
  }
}

/* TEXT INPUTS */
input[type="text"],
input[type="search"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="email"],
input[type*="date"],
input[type*="time"],
select {
  /* from bulma.css */
  color: #363636;
  border-color: #dbdbdb;
  background-color: #f3f3f3;
  box-shadow: inset 0 1px 2px 1px rgba(50,50,50,.05);

  width: 100%;
  max-width: 600px;
  -webkit-appearance: none;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 1rem;
  font-family: var(--font-base);
  line-height: 1.5;
  padding: 4px 13px;
}

input[type="number"] {
  width: 100px;
}

input[type*="date"],
input[type*="time"],
.flatpickr-input[type="text"] {
  width: 50%;
  width: 250px;
}

/* BUTTON STYLE SEE default-layout.lucius */

/* TEXTAREAS */
textarea {
  width: 100%;
  height: 170px;
  max-width: 600px;
  line-height: 1.5;
  color: #363636;
  background-color: #f3f3f3;
  padding: 4px 13px;
  font-size: 1rem;
  font-family: var(--font-base);
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid #dbdbdb;
  border-radius: 2px;
  box-shadow: inset 0 1px 2px 1px rgba(50,50,50,.05);
  vertical-align: top;
}

/* SHARED STATE RELATED STYLES */

input,
select,
textarea {
  &:focus {
    border-color: #3273dc;
    box-shadow: 0 0 0 0.125em rgba(50,115,220,.25);
    outline: 0;
  }

  &[disabled] {
    background-color: #f3f3f3;
    color: #7a7a7a;
    box-shadow: none;
    border-color: #dbdbdb;
  }

  &[readonly] {
    background-color: #f5f5f5;
    border-color: #dbdbdb;
  }
}

/* OPTIONS */
select,
option {
  font-size: 1rem;
  line-height: 1.5;
  padding: 4px 13px;
  border: 1px solid #dbdbdb;
  border-radius: 2px;
  outline: 0;
  color: #363636;
  min-width: 200px;
  background-color: #f3f3f3;
  box-shadow: inset 0 1px 2px 1px rgba(50,50,50,.05);
}

@media (max-width: 425px) {

  select, option {
    width: 100%;
  }
}

/* CUSTOM LEGACY CHECKBOX AND RADIO BOXES */
input[type="checkbox"] {
  position: relative;
  height: 20px;
  width: 20px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: var(--color-lighter);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
input[type="checkbox"]:checked::before {
  background-color: var(--color-light);
}
input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

/* CUSTOM CHECKBOXES AND RADIO BOXES */
/* Completely replaces legacy checkbox and radiobox */
.checkbox,
.radio {
  position: relative;
  display: inline-block;

  [type="checkbox"],
  [type="radio"] {
    position: fixed;
    top: -1px;
    left: -1px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  label {
    display: block;
    height: 24px;
    width: 24px;
    background-color: #f3f3f3;
    box-shadow: inset 0 1px 2px 1px rgba(50, 50, 50, 0.05);
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    color: white;
    cursor: pointer;
  }

  label::before,
  label::after {
    position: absolute;
    display: block;
    top: 12px;
    left: 8px;
    height: 2px;
    width: 8px;
    background-color: var(--color-font);
  }

  :checked + label {
    background-color: var(--color-primary);
  }

  [type="checkbox"]:focus + label,
  [type="radio"]:focus + label {
    border-color: #3273dc;
    box-shadow: 0 0 0 0.125em rgba(50,115,220,.25);
    outline: 0;
  }

  :checked + label::before,
  :checked + label::after {
    content: '';
  }

  :checked + label::before {
    background-color: white;
    transform: rotate(45deg);
    left: 4px;
  }

  :checked + label::after {
    background-color: white;
    transform: rotate(-45deg);
    top: 11px;
    width: 13px;
  }

  [disabled] + label {
    pointer-events: none;
    border: none;
    opacity: 0.6;
    filter: grayscale(1);
  }
}

.radio::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border-radius: 4px;
  border: 2px solid white;
  z-index: -1;
}

/* CUSTOM FILE INPUT */
.file-input__label {
  cursor: pointer;
  display: inline-block;
  background-color: var(--color-primary);
  color: white;
  padding: 10px 17px;
  border-radius: 3px;
}

.file-input__input--hidden {
  display: none;
}
