/*START:___formulaire___*/
@use "../../abstracts/mixins" as *;
@use "../../vendors/bootstrap" as *;
@use "../../base" as *;

.flexible-form {
  .recap-tab-wrapper {
    position: sticky;
    top: 10vh;
  }

  #recapCard {
    max-width: max-content;
    min-width: 100%;
  }

  @media (width > 992px) {
    #recapCard {
      min-width: 400px;
    }
  }

  .form-check-label {
    display: grid;
    place-content: start;
    place-items: start;
    grid-template-areas: "figure" " text  ";
    grid-template-rows: auto 1fr;
    padding: 0;
    align-items: center;
    background: white;
    width: 100%;
    height: 100%;
  }

  .form-check-label span {
    grid-area: text;
  }

  input[type="number"]::-webkit-outer-spin-button,
  input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  input[type="number"] {
    -moz-appearance: textfield;
  }

  .form-check-input[type="checkbox"]:checked + .form-check-label,
  .form-check-input[type="radio"]:checked + .form-check-label {
    background-color: transparent;
    overflow: hidden;
  }
  .form-check-figure {
    grid-area: figure;
  }

  .form-check-price {
    font-size: var(--ev-space-s-m);
    color: var(--ev-primary);
    place-self: center end;
  }

  .quantity-wrapper {
    display: flex;
  }

  .quantity-btn.quantity-btn--minus {
    border-radius: 5px 0 0 5px;
  }

  .quantity-btn.quantity-btn--plus {
    border-radius: 0 5px 5px 0;
  }

  .quantity-wrapper .quantity-btn {
    background: transparent;
    border: 1px solid var(--ev-border-color);
    padding: 0.5rem 0.75rem;
  }

  .form-check-description {
    grid-area: description;
  }

  .quantity-wrapper {
    grid-area: btn;
  }

  .flexible-form .quantity-btn.quantity-btn--minus {
    border-right: none;
  }

  .flexible-form .quantity-btn.quantity-btn--plus {
    border-left: none;
  }

  .flexible-form .form-check-price {
    grid-area: price;
  }

  .form-check {
    position: relative;
  }

  .form-group.form-group--checkbox .form-check-text,
  .form-group.form-group--radio .form-check-text {
    grid-template-areas: "description price";
    align-items: center;
    column-gap: 1rem;
  }

  .flexible-form__container {
    border: 1px solid var(--ev-border-color);
    margin-top: var(--ev-space-xl);
  }

  .flexible-form__title-wrapper {
    background-color: transparent;
  }

  .flexible-form__container {
    padding: var(--ev-space-s-m);
  }

  .flexible-form__title-wrapper {
    padding: 0;
    text-align: center;
  }

  .form-check-figure {
    margin-block: 0;
  }

  .form-check-text {
    display: grid;
    place-items: start;
    place-content: space-between;
    width: 100%;
    grid-template-areas: "description description" "btn price";
    row-gap: 1rem;
    grid-area: text;
    margin-top: 1rem;
  }

  .form-help.p {
    display: block;
    margin-bottom: 0;
  }

  .ts-wrapper {
    min-height: 42px;
  }

  .ts-control {
    font-size: var(--ev-step-0) !important;
    padding: var(--input-padding-y) var(--input-padding-x) !important;
  }

  [role="combobox"] .item {
    line-height: 1.5 !important;
  }

  [type="file"] {
    opacity: 0;
    height: 76px;
  }

  .filepond--root::after {
    content: "";
    position: absolute;
    height: 1px;
    z-index: 2;
    width: 100%;
    bottom: -1px;
    background: var(--input-border-color);
    left: 0;
  }

  .required-group .filepond--root {
    border-color: var(--ev-danger);
  }

  .required-group .filepond--root::after {
    background: var(--ev-danger);
  }

  .filepond--credits {
    display: none;
  }

  .form-check {
    padding-left: 0;
  }

  .form-check-input[type="checkbox"],
  .form-check-input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
  }

  .form-check-label {
    padding: 10px 20px;
    margin: 5px;
    border: 1px solid var(--ev-border-color);
    border-radius: 5px;
    background-color: var(--ev-light);
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .form-check-input[type="radio"]:checked + .form-check-label,
  .form-check-input[type="checkbox"]:checked + .form-check-label {
    background-color: var(--ev-primary);
    border-color: var(--ev-primary);
    color: var(--ev-heading-color);
  }

  .form-check-input[type="radio"]:checked + .form-check-label *,
  .form-check-input[type="checkbox"]:checked + .form-check-label * {
    color: var(--ev-heading-color) !important;
  }

  .form-check-label:hover {
    border-color: #999;
  }
  .form-check-input[type="radio"]:focus + .form-check-label,
  .form-check-input[type="checkbox"]:focus + .form-check-label {
    outline: 2px dashed var(--ev-primary);
    outline-offset: 4px;
  }

  .invalid + .form-check-label {
    border-color: var(--ev-danger);
  }
  .container-fluid {
    padding-inline: var(--ev-grid-gutter);
    width: 100%;
  }

  @media (width > 992px) {
    .container-fluid {
      padding-inline: var(--ev-space-2xl);
    }
  }

  .form-check-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--ev-space-3xs-2xs);
  }

  .captcha-container {
    display: flex;
    margin-bottom: var(--ev-space-3xs-2xs);
    gap: var(--ev-space-3xs-2xs);
  }

  #refreshCaptchaBtn {
    padding: 0.5rem;
    line-height: 1;
  }

  .card-header {
    --ev-card-cap-color: var(--ev-heading-color);
  }

  .form-control[type="number"] {
    width: 80px;
  }

  .step__number {
    align-items: center;
  }

  .card-item:not(.d-none):not(:last-of-type) {
    border-bottom: 1px solid white;
    padding-bottom: var(--ev-space-2xs);
    margin-bottom: var(--ev-space-2xs);
  }

  .card-item.cart-item--not-selected {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    border-bottom: hidden !important;
  }

  .quantity {
    margin-right: 4px;
  }

  .form-check-label {
    margin-bottom: 0;
    color: var(--ev-text-color, rgb(31, 31, 31));
    font-weight: var(--ev-text-font-weight, normal);
  }

  .form-check {
    gap: var(--ev-space-xs, 1rem);
    place-items: start;
    margin-block: var(--ev-space-3xs);
  }

  .card-header {
    --ev-card-cap-bg: transparent;
    border-bottom: 2px solid white;
  }

  .card-wrapper .card {
    border-radius: var(--ev-border-radius);
    overflow: hidden;
  }

  .error-msg {
    margin-top: var(--ev-space-3xs-2xs) !important;
    display: inline-block;
  }

  .unit {
    font-size: 0.85rem;
  }

  .card-wrapper,
  .recap-tab-wrapper {
    display: grid;
    gap: var(--ev-grid-gutter, 1rem);
  }

  .card {
    --ev-card-cap-bg: var(--ev-primary-060, var(--ev-dark-100));
    --ev-card-bg: var(--ev-light);
    font-size: var(--ev-step--1, 1rem);

    &-item,
    &-header {
      display: flex;
    }

    &-item .card-unit {
      font-weight: var(--ev-heading-color);
    }

    &-header {
      font-weight: bold;

      .card-unit {
        color: var(--ev-primary, var(--ev-dark));
      }
    }

    &-unit {
      margin-left: auto;
    }
  }

  &__content {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  &__wrapper {
    width: 100%;
    grid-area: content;
  }

  .alert-message--form #check {
    fill: var(--ev-primary, var(--ev-dark));
  }

  &__title-wrapper {
    background-color: var(--ev-light);
    padding: var(--ev-space-m) var(--ev-grid-gutter);

    p:empty {
      display: none;
    }
  }

  &__container {
    @extend .container;
    display: grid;
    margin-top: var(--ev-space-2xl);
    gap: var(--ev-grid-gutter, 1rem);
    grid-template-areas: "step" "content";
  }

  @include media-breakpoint-up(sm) {
    &__container {
      grid-auto-flow: column;
      grid-template-columns: auto 1fr;
      grid-template-areas: "step content";
    }
  }

  &__steps {
    grid-area: step;

    .step-group {
      --step-color: hsl(
        var(--ev-light-hue),
        var(--ev-light-saturation),
        calc(var(--ev-light-lightness) - 18%)
      );
      position: relative;
      counter-reset: step;
      display: flex;
      flex-direction: column;
      width: fit-content;
      margin-right: auto;
      gap: 5rem;

      &::before {
        content: "";
        position: absolute;
        inset: 0;
        height: 100%;
        width: 1px;
        margin-inline: auto;
        background-color: var(--step-color);
        z-index: -1;
      }
    }

    .step {
      --step-gap: 5rem;
      border: 1px solid var(--step-color);
      display: block;
      width: 12px;
      aspect-ratio: 1/1;
      display: grid;
      place-content: center;
      font-weight: bold;
      line-height: 1;
      border-radius: 100vmax;
      background-color: var(--ev-body-bg);
      position: relative;

      &::before {
        counter-increment: step;
        content: "";
        line-height: 1;
        color: var(--step-color);
        font-weight: var(--ev-text-font-weight, normal);
        border-radius: 25px;
        background: var(--step-color);
        position: absolute;
        inset: -1px;
      }

      &:not(:last-of-type)::after {
        top: 100%;
      }

      &:last-of-type::after {
        bottom: 100%;
      }

      &.done,
      &.active {
        --step-color: var(--ev-primary, var(--ev-dark));
      }

      &.completed.done {
        background-color: var(--step-color);

        &::before {
          color: #fff;
          display: grid;
          place-content: center;
          font-size: 14px;
        }
      }

      &.done::after {
        height: var(--step-gap);
      }
    }
  }

  &__body {
    width: 100%;

    .row {
      --bs-gutter-x: var(--ev-grid-gutter, 1rem);
      --bs-gutter-y: var(--ev-grid-gutter, 1rem);
    }
  }

  .tab:not(:first-child) {
    display: none;
  }

  &__step {
    margin-bottom: var(--ev-space-m-l);

    &-title {
      @extend .h4;
      padding-bottom: var(--ev-space-s-m);
      position: relative;
    }

    &-title::after {
      content: "";
      left: 0;
      height: 4px;
      width: 40px;
      background: var(--ev-primary, var(--ev-dark));
      position: absolute;
      bottom: 0;
      border-radius: 100vmax;
    }

    &-subtitle::before {
      @extend .subtitle;
      content: "étape " attr(data-step-number);
      font-size: var(--ev-step--1, 0.85rem);
    }
  }

  &__step-descr {
    margin-block: var(--ev-space-xs);
  }

  @include media-breakpoint-down(sm) {
    &__container {
      flex-direction: column;
    }

    &__steps {
      margin-left: 0;

      .step-group {
        margin-right: none;
        gap: 10%;
        flex-direction: row;
        place-content: space-between;
        width: 100%;
      }

      .step-group::before {
        margin-inline: none;
        height: 1px;
        width: 100%;
        margin-block: auto;
      }

      .step::after {
        margin-inline: none;
        height: 1px;
        width: calc(var(--step-gap) / 2);
        margin-block: auto;
        inset: 0 !important;
        z-index: -1;
      }

      .step.completed::after {
        content: none;
      }

      .step::before {
        font-size: var(--ev-step--1);
      }

      .done::after {
        width: var(--step-gap);
        height: 1px !important;
      }

      .step {
        width: 12px;
        height: 12px;
      }
    }
  }

  &__recaptcha-info {
    margin-top: auto;
    padding-top: 2rem;
    font-weight: normal;
    font-size: var(--ev-step--1, 1em);

    * {
      font-size: var(--ev-step--1, 1em);
    }
  }

  .grecaptcha-badge {
    visibility: hidden;
  }

  .form-group:not(:last-child) {
    margin-bottom: var(--ev-space-s);
  }

  .input-group .btn {
    border-radius: var(--input-border-radius);
  }

  .resend-code {
    a {
      font-size: inherit;
      color: var(--ev-primary, var(--ev-dark));
    }
  }

  .row {
    margin-bottom: var(--ev-space-m-l);
    place-content: space-between;
  }
}

.form-page {
  margin-top: 0;
}

.form-page .flexible-form__title-wrapper {
  @extend .banner-bg;
}

.container-fluid .flexible-form__title-wrapper,
.container .flexible-form__title-wrapper {
  border-radius: var(--ev-border-radius);
}

.flexible-form__steps {
  margin-top: var(--ev-space-3xs);
}

.container-fluid .flexible-form .flexible-form__steps,
.container .flexible-form .flexible-form__steps {
  margin-left: 0;
}

.modal[data-form-id] {
  .modal-body {
    padding: 0;
  }

  .modal-header .btn-close {
    position: absolute;
    right: var(--ev-space-xs-s);
    top: var(--ev-space-xs-s);
    background: #00000021;
    border: none;
    z-index: 1;
  }

  .modal-header {
    padding: 0;
  }

  .modal-header .btn-close {
    width: 28px;
    height: 28px;
  }

  .icon.icon--close {
    opacity: 1;
    --icon-color: var(--ev-heading-color);
    --icon-height: 16px;
  }
}

.page-form-modal .flexible-form__container,
.page-form-modal .container {
  max-width: revert-layer;
}

/*END:___formulaire___*/
