@import "../../../node_modules/govuk-frontend/dist/govuk/settings/index";
@import "../../../node_modules/govuk-frontend/dist/govuk/tools/index";
@import "../../../node_modules/govuk-frontend/dist/govuk/helpers/index";

.govuk-checkboxes__item {
  * {
    -webkit-box-sizing: content-box;
    -moz-box-sizing: content-box;
    box-sizing: content-box;
  }

  *:before,
  *:after {
    -webkit-box-sizing: content-box;
    -moz-box-sizing: content-box;
    box-sizing: content-box;
  }
}


.input-prefix-tag {
  height: 2.5rem;
  margin-top: 0;
  padding: 5px;
  border: 2px solid #0b0c0c;
  min-width: 3rem;
  text-align: center;
  background-color: #1d70b8;
  border-right: none;
  color: white;
}

.input-suffix-tag {
  height: 2.5rem;
  margin-top: 0;
  padding: 5px;
  border: 2px solid #0b0c0c;
  min-width: 3rem;
  text-align: center;
  background-color: #1d70b8;
  border-left: none;
  color: white;
}

.govuk-input:disabled, .govuk-textarea:disabled, .form-control:disabled, .form-control[readonly] {
  background-color: #e9ecef;
  opacity: 1;
};

@media screen and (max-width: 639px) {
  #reorder {
    display: none;
  }
  table.res-datagrid thead {
    border: none;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }

  table.res-datagrid tr {
    display: block;
  }

  table.res-datagrid td {
    display: block;
    width: 100%;
  }

  table.res-datagrid td::before {
    content: attr(data-label);
  }
  table.res-datagrid td:last-child {
    border-bottom: 10px;
  }

}

.govuk-details {
  margin-bottom: 0 !important;

  &__summary {
    font-weight: 400 !important;
  }

  &__summary-text,
  &__summary:hover &__summary-text {
    text-decoration: none;
  }
}

// Child components already show their own errors, so hide the duplicate container messages
.formio-component-datagrid,
.formio-component-editgrid,
.formio-component-datamap,
.formio-component-panel,
.formio-component-container,
.formio-component-fieldset {
  > [ref="messageContainer"] {
    display: none;
  }
}

// Form.io keeps hidden components in the DOM, so remove their layout contribution
.formio-hidden {
  display: none !important;
}

.small-button {
  padding: .25rem .5rem;
  font-size: .875rem;
  line-height: 1.5;
}


.govuk-form-input--error {
  border: $govuk-border-width-form-element solid $govuk-error-colour !important;

  &:focus {
    border-color: $govuk-input-border-colour !important;
    box-shadow: none !important;
  }
}


.dataGrid-hr {
  border-bottom: 2px solid #1d70b8;
  border-top: none
}

// Negative grid margins can cause horizontal scrolling at fractional zoom levels
.datagrid-tbody {
  overflow-x: hidden;
  overflow-x: clip;

  [ref="nested-fieldset"] {
    margin-left: 1px;
  }
}

.gov-accordion-no-bottom {
  border-bottom: none !important;
}

.js-enabled {
  @include govuk-media-query($from: mobile) {
    .govuk-tabs__panel--hidden {
      display: none;
    }
  }
}

.custom-table {
  @media (max-width: 768px) {
    display: block;
    overflow-y: scroll;
    max-height: 400px;
    overflow-x: auto;
    white-space: nowrap;
  }
}

.custom-th {
  position: sticky;
  top: 0;
  background: govuk-colour('white');
}

.custom-body {
  height: 100px;
  overflow-y: auto;
  overflow-x: hidden;
}

.govuk-select.auto-height {
  height: auto;
}

// govuk-frontend 5.4+ clips nested focus rings and borders in error groups
.govuk-form-group--error {
  .govuk-form-group {
    overflow: visible;
  }
}

// Keep disabled labels readable; dim only the box and tick.
.govuk-checkboxes__item .govuk-checkboxes__input:disabled + .govuk-checkboxes__label,
.govuk-radios__item .govuk-radios__input:disabled + .govuk-radios__label {
  opacity: 1;
  color: #505a5f;

  &::before {
    opacity: 0.5;
  }
}

// `::after` is the tick or dot and is hidden until checked, so dim it only then.
.govuk-checkboxes__item .govuk-checkboxes__input:disabled:checked + .govuk-checkboxes__label::after,
.govuk-radios__item .govuk-radios__input:disabled:checked + .govuk-radios__label::after {
  opacity: 0.5;
}

// Form.io's caption colour fails contrast.
.formio-component-signature .signature-pad-footer {
  color: #505a5f;
}

// Unstyled without Bootstrap, so give them a usable target size.
.formio-component-editgrid .editRow,
.formio-component-editgrid .removeRow {
  min-width: 44px;
  min-height: 44px;
  margin: 0 5px 5px 0;
  cursor: pointer;
}
