@import '../admin/variables.scss';

.cf-form {
  text-align: left;
  box-sizing: border-box;
  max-width: 100%!important;

  * {
    box-sizing: border-box;
  }

  &.cf-form-width-px {
    display: inline-block;
  }

  .cf-field-label {
    display: block;
    width: 100%;
  }
}

.cf-field-wrap {
  box-sizing: border-box;
//  padding: 0.25em;
  display: inline-block;
  vertical-align: top;
  width: 100%;
}

.cf-field-inner-wrap {
  box-sizing: border-box;
  padding: 0.5em;

  input[type="text"],
  select,
  textarea {
    width: 100%;
  }
}

.cf-form-header {
  padding: 0.5em;
  margin-bottom: 1em;

  .cf-form-name {
    margin: 0 0 0.5em 0;
    font-size: 1.3em;
    font-weight: 600;
  }
}

.cf-field-validation-message {
  padding: 0.8em 0 0;
  font-size: 0.8em;
  color: $chili-red;
  display: none;

  .cf-validation-error & {
    display: block;
  }
}

.cf-width-5 { width: 5%; display: inline-block; }
.cf-width-10 { width: 10%; display: inline-block; }
.cf-width-15 { width: 15%; display: inline-block; }
.cf-width-20 { width: 20%; display: inline-block; }
.cf-width-25 { width: 25%; display: inline-block; }
.cf-width-30 { width: 30%; display: inline-block; }
.cf-width-35 { width: 35%; display: inline-block; }
.cf-width-40 { width: 40%; display: inline-block; }
.cf-width-45 { width: 45%; display: inline-block; }
.cf-width-50 { width: 50%; display: inline-block; }
.cf-width-55 { width: 55%; display: inline-block; }
.cf-width-60 { width: 60%; display: inline-block; }
.cf-width-65 { width: 65%; display: inline-block; }
.cf-width-70 { width: 70%; display: inline-block; }
.cf-width-75 { width: 75%; display: inline-block; }
.cf-width-80 { width: 80%; display: inline-block; }
.cf-width-85 { width: 85%; display: inline-block; }
.cf-width-90 { width: 90%; display: inline-block; }
.cf-width-95 { width: 95%; display: inline-block; }
.cf-width-100 { width: 100%; }

@media (max-width: 480px) {
  .cf-width-5,
  .cf-width-10,
  .cf-width-15,
  .cf-width-20,
  .cf-width-25,
  .cf-width-30,
  .cf-width-35,
  .cf-width-40,
  .cf-width-45,
  .cf-width-50,
  .cf-width-55,
  .cf-width-60,
  .cf-width-65,
  .cf-width-70,
  .cf-width-75,
  .cf-width-80,
  .cf-width-85,
  .cf-width-90,
  .cf-width-95,
  .cf-width-100 { width: 100%; display: block; }

  .cf-option-label {
    display: block;
    margin-bottom: 1em;
  }
}

.cf-align-left {
  text-align: left;
}

.cf-align-center {
  text-align: center;
}

.cf-align-right {
  text-align: right;
}

.cf-form-footer {
  padding: 1em 0.5em;
}

/**
 * Themes
 */

$placeholder-color: #ccc;
$control-bg: #fafafa;
$control-color: #555;
$control-radius: 5px;
$label-color: #aaa;
$border-color: rgba(0,0,0,0.07);
$input-height: 3.4em;

.cf-form {
  .cf-recaptcha-container {
    margin: 1.6em 0 1em;
    padding: 0 0.5em;
  }

  .cf-wrapped-select__original {
    display: none;
  }

  .cf-wrapped-select {
    position: relative;
    width: 100%;
  }

  .cf-option-label {
    margin-right: 1.5em;
    vertical-align: middle;
    line-height: 2.4em;
  }

  .cf-submit {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
  }

  &.cf-form-submitted  {
    .cf-field-wrap,
    .cf-submit,
    .cf-recaptcha-container {
      display: none;
    }
  }

  .cf-form-messages {
    margin: 1em;
    opacity: 0;
    transition: opacity 0.1s ease-in;
  }
}

/**
 * Lite theme
 */
.cf-form.cf-form-theme-lite {
  font-size: 14px;
  padding: 1em;
  color: $control-color;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.12);

  .cf-label-text {
    display: inline-block;
    margin-bottom: 0.8em;
    margin-left: 0;
    color: $label-color;
    font-weight: 500;
  }

  .cf-form-description {
    color: $label-color;
  }

  .cf-wrapped-select__control {
    cursor: pointer;
    padding: 0 3em 0 0;
    border: 2px solid $border-color;
    border-radius: $control-radius;
    height: $input-height;
    background: $control-bg;
  }

  .cf-wrapped-select__options {
    display: none;
    position: absolute;
    background: white;
    width: calc(100% - 12px);
    z-index: 1;
    top: 100%;
    margin-top: -2px;
    left: 0;
    border: 1px solid $border-color;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.12);
  }

  .cf-wrapped-select__option {
    padding: 0.48em 1em;
    border-top: 1px solid $border-color;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;

    &:first-child {
      border: none;
    }

    &:hover {
      background: $control-bg;
    }
  }

  .cf-wrapped-select.cf-selected {
    .cf-wrapped-select__options {
      display: block;
    }
  }

  .cf-wrapped-select__arrow-box {
    display: block;
    width: 2.2em;
    height: 2.2em;
    position: absolute;
    top: 0.4em;
    right: 0.4em;
    bottom: 0.4em;
    margin: auto;
  }

  .cf-wrapped-select__current {
    line-height: $input-height;
    padding-left: 1.2em;
    color: $control-color;
  }

  .cf-wrapped-select__arrow-box:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    left: 0;
    top: 7px;
    bottom: 0;
    position: absolute;
    margin: auto;
    right: 0;
    border-color: $control-color transparent transparent transparent;
    border-width: 5px;
    border-style: solid;
  }

  input[type="text"],
  textarea {
    font-size: 14px;
    width: 100%;
    line-height: $input-height;
    padding: 0;
    padding-left: 1.2em;
    border: 2px solid $border-color;
    border-radius: $control-radius;
    background: $control-bg;
    box-shadow: none;

    &:focus {
      border-color: #337ab7;
    }
  }

  ::-webkit-input-placeholder {
    color: $placeholder-color;
  }

  ::-moz-placeholder {
    color: $placeholder-color;
  }

  :-ms-input-placeholder {
    color: $placeholder-color;
  }

  input[type="text"] {
    height: $input-height;
  }

  .cf-validation-error {
    input[type="text"],
    textarea,
    .cf-wrapped-select__control {
      border-color: $chili-red;
    }

    .cf-label-text {
      color: $chili-red;
    }
  }

  .cf-validation-success {
    input[type="text"],
    textarea,
    .cf-wrapped-select__control {
      border-color: $chili-green;
    }
  }

  .cf-form-footer {
    .cf-submit {
      text-decoration: none;
      padding: 0.7em 1.2em;
      color: #fff;
      background: $chili-green;
      border: none;
      border-radius: $control-radius;
      box-shadow: 0 3px 0 0 #18831e;
      transition: all 0.1s ease-in;

      &.cf-disabled {
        color: #ddd;
        box-shadow: none;
      }
    }
  }

  .cf-input-label-wrap {
    display: inline-block;
    vertical-align: middle;
  }

  .cf-field-type-radio {
    .cf-form-control {
      display: none;
    }

    .cf-option-label {
      cursor: pointer;
    }

    .cf-input-option-display {
      position: relative;
      display: inline-block;
      width: 22px;
      height: 22px;
      border: 3px solid $border-color;
      border-radius: 50%;
      background: #fff;
      vertical-align: middle;

      &:after {
        content: '';
        display: block;
        width: 0;
        height: 0;
        opacity: 0;
        border-radius: 50%;
        position: absolute;
        background: $chili-green;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
        transition: all 0.12s ease-in;
      }
    }

    .cf-form-control:checked + .cf-input-option-display {
      &:after {
        opacity: 1;
        width: 12px;
        height: 12px;
      }
    }
  }

  .cf-field-type-checkbox {
    .cf-form-control {
      display: none;
    }

    .cf-option-label {
      cursor: pointer;
    }

    .cf-input-option-display {
      position: relative;
      display: inline-block;
      width: 22px;
      height: 22px;
      border: 3px solid $border-color;
      border-radius: 0;
      background: #fff;
      vertical-align: middle;

      &:after {
        content: '';
        display: block;
        width: 0;
        height: 0;
        opacity: 0;
        border-radius: 0;
        position: absolute;
        background: $chili-green;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
        transition: all 0.12s ease-in;
      }
    }

    .cf-form-control:checked + .cf-input-option-display {
      &:after {
        opacity: 1;
        width: 12px;
        height: 12px;
      }
    }
  }
}

@media (max-width: 480px) {
  .cf-form.cf-form-theme-lite {
    font-size: 16px;
    border: none;
    box-shadow: none;
  }
}

/**
 * html5 theme
 */
.cf-form.cf-form-theme-html5 {
  .cf-validation-error {
    input[type="text"],
    textarea,
    select {
      border-color: $chili-red;
    }

    .cf-label-text {
      color: $chili-red;
    }
  }

  .cf-validation-success {
    input[type="text"],
    textarea,
    select {
      border-color: $chili-green;
    }
  }
}