/**
 * @file
 * Styles for form elements.
 */

form {
  margin: 0;
  padding: 0;
}

/**
 * Prevent regression due to explicit line-height and font-size applied to these
 * elements in normalize.css 7.0.0.
 */
button:not(.button),
input:not([type="file"], .form-text, .form-textarea) {
  line-height: 1.25em;
}

textarea,
input[type="search"],
input[type="number"],
input[type="email"] {
  line-height: normal;
}

select {
  font-size: 0.8125rem;
  line-height: 1.42902em;
  details & {
    line-height: 1.20324em;
  }
}

/**
 * Prevent regression due to fieldset styling that was removed in normalize.css
 * 6.0.0.
 */
fieldset {
  margin: 0 2px;
  padding: 0.35em 0.625em 0.75em;
  border: 1px solid #c0c0c0;
  &:not(.fieldgroup) {
    position: relative;
    min-width: 0;
    margin: 1em 0;
    padding: 30px 18px 18px;
    border-radius: 2px;
    background-color: #fcfcfa;
    & > legend {
      position: absolute;
      top: 10px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      font-size: 1em;
      font-weight: bold;
    }
  }
}

.fieldgroup {
  min-width: 0;
}

.form-item {
  margin: 0 0 20px;
}

.form-wrapper .container-inline {
  margin-bottom: 0.75em;
}

.form-datetime-wrapper {
  margin-bottom: 1.4em;
  & .container-inline {
    margin-bottom: -1.4em;
  }
}

/**
 * When a table row has a single form item, prevent it from adding unnecessary
 * extra spacing. If it has multiple form items, allow spacing between them,
 * overriding Classy.
 */
tr.odd .form-item,
tr.even .form-item {
  margin-top: 0.75em;
  margin-bottom: 0.75em;
}

td > .form-item:only-child {
  margin-top: 0;
  margin-bottom: 0;
}

.layout-region-node-secondary .form-item {
  margin: 0 0 10px;
}

.form-type-checkbox {
  margin-bottom: 10px;
  padding: 0;
}

.form-actions {
  margin-top: 20px;
  margin-bottom: 20px;
}

.label {
  display: table;
  margin: 0 0 0.1em;
  padding: 0;
  font-weight: bold;
  .form-item &.option {
    text-transform: none;
    & input {
      vertical-align: middle;
    }
  }
  .form-disabled & {
    color: #686868;
  }
}

.form-disabled input.form-date,
.form-disabled input.form-text,
.form-disabled input.form-tel,
.form-disabled input.form-time,
.form-disabled input.form-email,
.form-disabled input.form-url,
.form-disabled input.form-search,
.form-disabled input.form-number,
.form-disabled input.form-color,
.form-disabled input.form-file,
.form-disabled input.form-date,
.form-disabled textarea.form-textarea,
.form-disabled select.form-select {
  border-color: #d4d4d4;
  background-color: hsl(0, 0%, 0%, 0.08);
  box-shadow: none;
}

.form-item input.error,
.form-item textarea.error,
.form-item select.error {
  color: #a51b00;
  border-width: 1px;
  border-color: #e62600;
  background-color: hsl(15, 75%, 97%, 1);
  box-shadow: inset 0 5px 5px -5px #b8b8b8;
}

.form-item textarea.error + .cke {
  border-width: 1px;
  border-color: #e62600;
}

.form-item textarea.error + .ck-editor > .ck-editor__main {
  border: 1px solid #e62600;
}

.form-item input.error:focus,
.form-item textarea.error:focus,
.form-item select.error:focus {
  border-color: #e62600;
  outline: 0;
  background-color: #fcf4f2;
  box-shadow:
    inset 0 1px 3px rgb(0, 0, 0, 0.05),
    0 0 8px 1px #e62600;
}

.form-required::after {
  width: 7px;
  height: 7px;
  background-size: 7px 7px;
}

.form-item__error-message {
  margin-top: 0.15em;
  color: #e32700;
  .fieldset-wrapper > & {
    margin-top: 0;
  }
  .text-format-wrapper & {
    margin: 0;
    padding: 0.25em 0.666em 0;
    border: solid #ccc;
    border-width: 0 1px;
  }
}

/* Filter styles. */
ul.tips,
div.description,
.form-item .description {
  margin: 0.2em 0 0 0;
  color: #595959;
  font-size: 0.95em;
}

.form-item .description.error {
  margin-top: 0;
  color: #a51b00;
}

.filter-guidelines-restricted_html ul.tips li {
  margin: 0.25em 0 0.25em 1.5em; /* LTR */
}

ul.tips ul > li {
  margin: 0.25em 0 0.25em -2.7em; /* LTR */
  [dir="rtl"] & {
    margin: 0.25em 1.5em 0.25em 0;
  }
}

.form-type-radio .description,
.form-type-checkbox .description {
  margin-left: 1.5em; /* LTR */
}

[dir="rtl"] .form-type-radio .description,
[dir="rtl"] .form-type-checkbox .description {
  margin-right: 1.5em;
  margin-left: 0;
}

.form-text,
.form-textarea {
  border-radius: 2px;
  font-size: 1em;
  line-height: normal;
}

input.form-autocomplete,
input.form-text,
input.form-tel,
input.form-email,
input.form-url,
input.form-search,
input.form-number,
input.form-color,
input.form-file,
input.form-date,
input.form-time,
textarea.form-textarea {
  box-sizing: border-box;
  max-width: 100%;
  padding: 0.33em 0.4em 0.3em 0.5em; /* LTR */
  -webkit-transition:
    border linear 0.2s,
    box-shadow linear 0.2s;
  transition:
    border linear 0.2s,
    box-shadow linear 0.2s;
  color: #595959;
  border: 1px solid #b8b8b8;
  border-top-color: #999;
  border-radius: 2px;
  background: #fcfcfa;
  box-shadow: inset 0 1px 2px rgb(0, 0, 0, 0.125);
  font-size: 1em;
}

[dir="rtl"] textarea.form-textarea {
  padding: 0.33em 0.5em 0.3em 0.4em;
}

.form-text:focus,
.form-tel:focus,
.form-email:focus,
.form-url:focus,
.form-search:focus,
.form-number:focus,
.form-color:focus,
.form-file:focus,
.form-textarea:focus,
.form-date:focus,
.form-time:focus {
  border-color: #40b6ff;
  outline: 0;
  background-color: #fff;
  box-shadow:
    inset 0 1px 3px rgb(0, 0, 0, 0.05),
    0 0 8px #40b6ff;
}

.confirm-parent,
.password-parent {
  overflow: visible;
  width: auto;
}

.form-item-options-group-info-identifier,
.form-item-pass .description {
  clear: both;
}

/**
 * Limit extra long instances of select elements to the max width allowed to
 * avoid breaking layouts.
 */
select {
  max-width: 100%;
}

/**
 * Select element styles only for Webkit.
 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .form-select {
    padding: 1px 1.571em 1px 0.5em; /* LTR */
    cursor: pointer;
    -webkit-transition: all 0.1s;
    transition: all 0.1s;
    border: 1px solid #a6a6a6;
    border-radius: 0.143em;
    background:
      url(../../images/icons/333333/caret-down.svg) no-repeat 99% 63%,
      -webkit-linear-gradient(top, #f6f6f3, #e7e7df); /* LTR */

    text-shadow: 0 1px hsl(0, 0%, 100%, 0.6);
    font-size: 1em;
    -webkit-appearance: none;
    appearance: none;
    -webkit-font-smoothing: antialiased;
    line-height: 1.85em;
  }
  [dir="rtl"] select {
    padding: 1px 0.714em 1px 1.571em;
    background-position:
      1% 63%,
      0 0;
  }
  .form-select:hover {
    color: #1a1a1a;
    background-image:
      url(../../images/icons/333333/caret-down.svg),
      -webkit-linear-gradient(top, #fcfcfa, #e9e9dd);
  }
  .form-select:hover {
    box-shadow: 0 1px 2px hsl(0, 0%, 0%, 0.125);
  }
  select[multiple],
  select[multiple]:focus,
  select[multiple]:hover {
    background: -webkit-linear-gradient(top, #f6f6f3, #e7e7df);
    background: linear-gradient(to bottom, #f6f6f3, #e7e7df);
  }
}

/**
 * Improve spacing of cancel link.
 */
#edit-cancel {
  margin-left: 10px; /* LTR */
  [dir="rtl"] & {
    margin-right: 10px;
    margin-left: 0;
  }
}

@media screen and (max-width: 62em) {
  /* 992px */
  input.form-autocomplete,
  input.form-text,
  input.form-tel,
  input.form-email,
  input.form-url,
  input.form-search,
  input.form-number,
  input.form-color,
  input.form-file,
  textarea.form-textarea {
    width: 100%;
  }
}

/**
 * Improve form element usability on narrow devices.
 */
@media screen and (max-width: 600px) {
  input.form-autocomplete,
  input.form-text,
  input.form-tel,
  input.form-email,
  input.form-url,
  input.form-search,
  input.form-number,
  input.form-color,
  input.form-file,
  textarea.form-textarea {
    font-size: 1.2em;
    line-height: 1.2em;
  }
  input.form-number {
    width: auto;
  }
  form .field-multiple-table {
    margin: 0 0 0.75em;
  }
  .form-actions input,
  .form-wrapper input[type="submit"] {
    float: none;
    width: 100%;
    margin-top: 10px;
    margin-right: 0;
    margin-left: 0;
    padding-bottom: 6px;
  }
  .form-actions input:first-child,
  .form-wrapper input[type="submit"]:first-child {
    margin-top: 0;
  }
  details summary {
    overflow: hidden;
    box-sizing: border-box;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .password-strength {
    width: 100%;
  }
  div.form-item div.password-suggestions {
    float: none;
  }
  #dblog-filter-form .form-actions {
    float: none;
    padding: 0;
  }
  #edit-cancel {
    display: block;
    margin: 10px 0 0 0;
  }
  select {
    width: 100%;
  }
  .details .dropbutton-wrapper {
    width: auto;
  }
  .details .dropbutton-wrapper,
  .details .dropbutton-widget {
    position: relative;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
  }
  .form-actions input,
  .form-wrapper input[type="submit"] {
    display: inline-block;
    float: none;
    width: auto;
    margin: 0 10px 10px 0;
    padding-right: 43px;
    padding-left: 43px;
  }
  [dir="rtl"] .form-actions input,
  [dir="rtl"] .form-wrapper input[type="submit"] {
    margin-right: 0;
  }
  .button--danger {
    margin-left: 0;
  }
  .views-admin .form-actions input.form-submit {
    margin-top: 10px;
  }
}

/* Exceptions. */
#diff-inline-form select,
div.filter-options select {
  padding: 0;
}

/* Force fields inside multiple-cardinality tables to scale correctly. */
@media screen and (max-width: 60em) {
  .field-multiple-table input:not(.form-checkbox, .form-radio, .form-submit),
  .field-multiple-table select,
  .field-multiple-table textarea {
    width: 100%;
  }
}

/**
 * Force fields inside multiple-cardinality tables inside vertical tabs to scale
 * correctly.
 */
.vertical-tabs .field-multiple-table input:not(.form-checkbox, .form-radio, .form-submit),
.vertical-tabs .field-multiple-table select,
.vertical-tabs .field-multiple-table textarea {
  width: 100%;
}

/**
 * Prevent regression due to -webkit-appearance being set to button in
 * normalize.css 4.1.0.
 */
::-webkit-file-upload-button {
  -webkit-appearance: push-button;
}
