@mixin firefox-only {
  @at-root {
    @-moz-document url-prefix() {
      & {
        @content;
      }
    }
  }
}

$color-primary: #005ea2;
$color-light: #c9c9c9;
$color-lighter: #f0f0f0;
$color-lightest: #fff;
$color-dark: #000;
$color-tooltip: #1b1b1b;

span[role="link"] {
  &:hover {
    text-decoration: underline;
    cursor: pointer;
  }
}

.builder-sidebar {
  .usa-accordion__content {
    padding-bottom: 0px;
  }

  .form-builder-panel {
    margin-bottom: 5px;
    .form-builder-group-header {
      .form-builder-group-heading {
        margin: 0;
      }
      .usa-accordion__button.builder-group-button {
        background-color: #f0f0f0;
      }
    }
    .usa-button {
      margin-right: 0;
      margin-top: 0;
      margin-bottom: 5px;
      justify-content: flex-start;
    }
  }
}

.builder-component {
  padding: 3px;
  margin: -3px -3px 20px -3px;

  & .formio-form-group {
    margin-bottom: 0;
  }

  & .component-btn-group {
    display: flex;
    flex-direction: row-reverse;
  }
}

.component-btn-group .component-settings-button.usa-button {
  margin: 3px;
}

.component-btn-group .usa-button.component-settings-button-paste {
  display: none;
}

.dropdown-menu {
  position: absolute;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0;
  font-size: 1rem;
  color: #212529;
  text-align: left;
  list-style: none;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.25rem 1rem;
  clear: both;
  font-weight: 400;
  color: #212529;
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
}

.dropdown-item:hover, .dropdown-item:focus {
  color: #1e2125;
  background-color: #e9ecef;
}

.dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid #e9ecef;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:focus,
.flatpickr-current-month input.cur-year:focus,
.flatpickr-days:focus {
  outline: 1px solid #2491ff !important;
}

.flatpickr-days {
  margin: 1px;
  width: 305.875px !important;
}

.flatpickr-day.selected {
  background: #0073EC !important;
}

.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover,
.flatpickr-day:focus,
.flatpickr-day.prevMonthDay:focus,
.flatpickr-day.nextMonthDay:focus {
  background-color: #71767a !important;
  color: $color-lightest !important;
}

.flatpickr-wrapper {
  display: block !important;
}

.formio-choices .usa-select {
  background-image: none;
  border: 1px solid #565c65;
}

.usa-form-group--month .usa-select {
  opacity: 1;
}

.formio-component-address .usa-checkbox {
  margin: 0.5em 0 0.3em;
}

.formio-component-survey .usa-radio {
  & .usa-radio__label {
    height: 20px;
    &:before {
      left: 50%;
      transform: translateX(-50%);
      margin: 0;
    }
  }
}

.formio-dialog.formio-dialog-theme-default {
  & .component-edit-container {
    padding: 0.6em;
  }

  & .formio-dialog-content {
    & .formio-dialog-close {
      right: 4px;
      top: 4px;

      &:before {
        font-size: 24px;
        line-height: 24px;
        color: #8a8a8a;
      }

      &:hover:before, :active:before {
        color: #6b6b6b;
      }
    }
  }
}

.formio-dialog-content .usa-label {
  padding-right: 30px;
  label {
    padding-right: 0;
  }
}

.formio-dialog-buttons {
  display: flex;
  justify-content: flex-end;
  margin: 0 -0.5rem;
}

.formio-form-group {
  margin-bottom: 20px;
  @media print {
    page-break-inside: avoid;
  }

  & > .usa-label > label {
    display: initial;
  }
}

.formio-hidden {
  margin: 0;
}

.formio-panel-content.usa-accordion__content {
  overflow: visible;
}

.formio-usa-card {
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-clip: border-box;
  border: 1px solid $color-dark;
  border-radius: .25rem;
}

.formio-usa-card-body {
  -webkit-flex: 1 1 auto;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  padding: 1.25rem;
}

.formio-usa-card-header {
  position: relative;
  display: flex;
  padding: .5rem;
  margin-bottom: 0;
  margin-top: 1px;
  border-bottom: 1px solid $color-dark;
  border-radius: .25rem .25rem 0 0;
  background-color: $color-lighter;
}

.formio-usa-card-title {
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.has-error .help-block {
  color: #b50909;
}

.has-success .help-block {
  color: #00a91c;
}

.input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  margin-top: 0.5rem;
  & .usa-input, .usa-textarea {
    position: relative;
    z-index: 1;
    width: 1%;
    min-width: 50px;
    flex-grow: 1;
    margin-top: 0;
  }
  & .usa-textarea {
    resize: vertical;
  }
  & .flatpickr-wrapper {
    display: flex;
    flex-grow: 1;
    & .usa-input {
      width: 100%;
    }
  }
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  text-align: center;
  white-space: nowrap;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
}

.input-group-prepend,
.input-group-append {
  display: flex;
  flex-shrink: 0;
}

.legend-wrapper {
  display: inline-block;
  margin-bottom: 6px;
  & > span {
    margin-right: 3px;
  }
}

.open-modal-button {
  font-weight: 400;
  color: $color-dark;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background-color: #f8f9fa;
  border: 2px solid #8a8a8a;
  padding: 0.375rem 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  border-radius: 0;

  &:hover {
    background-color: #f0f1f5;
  }
}

.progress {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  height: 1rem;
  overflow: hidden;
  font-size: .75rem;
  background-color: #e9ecef;
  border-radius: .25rem;
  .progress-bar {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    background-color: #007bff;
    transition: width .6s ease;
  }
}

.formio-tooltip__trigger {
  cursor: pointer;
}

.formio-tooltip__body {
  background-color: $color-tooltip;
  border-radius: 0.25rem;
  bottom: 0;
  color: #f0f0f0;
  display: none;
  font-size: 1rem;
  padding: 0.5rem;
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  width: auto;
  white-space: pre;
  z-index: 1000;

  &.formio-tooltip--is-set {
    display: block;
  }

  &--whitespace {
    white-space: normal;
    width: 250px;
  }

  &--right {
    top: auto;
    transform: translateX(0);
  }

  &--left {
    top: auto;
    left: 0;
    right: auto;
    transform: translateX(0);
  }

  &--bottom {
    bottom: auto;
    top: 0;
  }
}

.formio-tooltip__wrapper {
  position: relative;
  & > span {
    font-weight: normal;
  }
}

.wizard-page {
  margin: 20px 0;
}

.wizard-nav-container {
  display: flex;
  @media not all and (min-width: 30em) {
    flex-direction: column;
  }
  & li .usa-button {
    margin-bottom: 0.25em;
  }
}

.word-wrap {
  word-wrap: break-word;
}

/* USWDS overrides */

b, strong {
  font-weight: bold !important;
}

pre {
  background-color: #f0f0f0;
  padding: 1em;
}

ul.usa-sidenav {
  display: flex;
  flex-wrap: wrap;
  margin-top: 1px;
  border-bottom: 1px solid $color-dark;
}

.usa-sidenav__item {
  border-top: 0px;
}

.usa-input--error.usa-select, .usa-input--success.usa-select {
  height: auto;
}

.usa-accordion__button {
 &.non-collapsible-panel--button {
   background-image: none;

   &:hover {
      background-color: $color-lighter;
      cursor: auto;
   }
 }
}

.usa-table {
  width: 100%;
  caption {
    caption-side: top;
    color: $color-dark;
  }
  & td {
    background-color: inherit;
  }
}

.usa-checkbox__input:disabled + .usa-checkbox__label {
  color: #71767a !important;
}

.usa-fieldset .usa-legend {
  font-size: 1.5rem;
}

.usa-label {
  margin-top: 0 !important;
  margin-bottom: 0;
  max-width: 100% !important;
}

.usa-prose > p,
.usa-prose > ul li,
.usa-prose > ol li {
  max-width: 100% !important;
}

.usa-button + .has-error, .usa-button + .has-success {
  display: none;
}

.usa-radio__input:disabled:checked + .usa-radio__label::before {
  -webkit-box-shadow: 0 0 0 2px $color-light, inset 0 0 0 3px $color-lightest;
          box-shadow: 0 0 0 2px $color-light, inset 0 0 0 3px $color-lightest;
}

.usa-radio, .usa-checkbox {
  background: none !important;
}

.usa-step-indicator {
  margin-top: 1rem;

  & .usa-step-indicator__segments {
    outline-width: 1px !important;
    outline-offset: 2px !important;
    padding: 1px;

    & .usa-step-indicator__segment {
      max-width: none;
    }
  }
}

div[ref="modalContents"] .usa-form-group--error {
  margin-top: 0;
}

@media print {
  div[class*=":grid-col-1"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:8.3333333333%;
  }

  div[class*=":grid-col-2"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:16.6666666667%;
  }

  div[class*=":grid-col-3"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:25%;
  }

  div[class*=":grid-col-4"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:33.3333333333%;
  }

  div[class*=":grid-col-5"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:41.6666666667%;
  }

  div[class*=":grid-col-6"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:50%;
  }

  div[class*=":grid-col-7"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:58.3333333333%;
  }

  div[class*=":grid-col-8"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:66.6666666667%;
  }

  div[class*=":grid-col-9"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:75%;
  }

  div[class*=":grid-col-10"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:83.3333333333%;
  }

  div[class*=":grid-col-11"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:91.6666666667%;
  }

  div[class*=":grid-col-12"] {
    -webkit-box-flex:0;
      -ms-flex:0 0 auto;
          flex:0 0 auto;
    width:100%;
  }

  .usa-checkbox__input:checked:disabled + .usa-checkbox__label::before {
    background-image: none;
    background-color: $color-light;
    -webkit-box-shadow: 0 0 0 2px $color-light, inset 0 0 0 3px $color-lightest;
    box-shadow: 0 0 0 2px $color-light, inset 0 0 0 3px $color-lightest;
    -webkit-print-color-adjust: exact;
    text-indent: 0;
  }
}

.usa-button {
  &.formio-hidden {
    background-color: initial;
    border: none;
    box-shadow: none;
  }
}

.formio-choices .choices__list--dropdown .choices__list {
  width: 100%;
}