/* KwkFormMaker — compléments au thème (structure alignée sur les formulaires PS natifs) */

.kwkformmaker-page--full-width {
  width: 100%;
  max-width: none;
}

.kwkformmaker-page--centered {
  width: 100%;
}

.kwkformmaker-page .kwkformmaker-description {
  color: var(--bs-secondary-color, #6c757d);
}

.kwkformmaker-messages {
  margin-bottom: 1rem;
}

.kwkformmaker-messages:empty {
  display: none;
}

.kwkformmaker-form .kwkfm-error-msg {
  display: none;
  color: var(--bs-danger, #dc3545);
  font-size: 0.875em;
  margin-top: 0.25rem;
}

.kwkformmaker-form .kwkfm-field.has-error .form-control,
.kwkformmaker-form .kwkfm-field.has-error .form-select,
.kwkformmaker-form .kwkfm-field.has-error .form-check-input {
  border-color: var(--bs-danger, #dc3545);
}

.kwkformmaker-form .kwkfm-field.has-success .form-control,
.kwkformmaker-form .kwkfm-field.has-success .form-select {
  border-color: var(--bs-success, #198754);
}

.kwkformmaker-form button.loading {
  opacity: 0.7;
  cursor: wait;
}

/* Espacement vertical entre les champs (+ 1em) */
.kwkformmaker-form .kwkfm-field {
  margin-bottom: calc(1rem + 1em);
}

.kwkformmaker-form .kwkfm-layout-row {
  margin-bottom: 1rem;
}

.kwkformmaker-form .kwkfm-layout-column > .kwkfm-field:last-child {
  margin-bottom: 1rem;
}

.kwkformmaker-form .kwkfm-product-image {
  display: inline-flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
}

.kwkformmaker-form .kwkfm-product-image__name {
  color: inherit;
  font-weight: 600;
}

.kwkformmaker-form .kwkfm-options--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}

.kwkformmaker-form .kwkfm-options--stacked .form-check {
  margin-bottom: 0.35rem;
}

.kwkformmaker-form .kwkfm-options--stacked .form-check:last-child {
  margin-bottom: 0;
}

.kwkformmaker-form .kwkfm-spinner {
  display: flex;
  max-width: 16rem;
}

.kwkformmaker-form .kwkfm-spinner .form-control {
  border-radius: 0;
  text-align: center;
}

.kwkformmaker-form .kwkfm-spinner__btn:first-child {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.kwkformmaker-form .kwkfm-spinner__btn:last-child {
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
}

.kwkformmaker-form .kwkfm-slider__value {
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.kwkformmaker-form .kwkfm-slider-range .form-range + .form-range {
  margin-top: 0.25rem;
}

.kwkformmaker-form .kwkfm-color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.kwkformmaker-form .kwkfm-color-option__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kwkformmaker-form .kwkfm-color-option__label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.375rem;
  cursor: pointer;
}

.kwkformmaker-form .kwkfm-color-option__swatch {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.kwkformmaker-form .kwkfm-color-option__input:checked + .kwkfm-color-option__label {
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.kwkformmaker-form .kwkfm-color-option__input:focus + .kwkfm-color-option__label {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
}

.kwkformmaker-form .kwkfm-rating {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 0.15rem;
}

.kwkformmaker-form .kwkfm-rating__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kwkformmaker-form .kwkfm-rating__star {
  margin: 0;
  cursor: pointer;
  font-size: 1.75rem;
  line-height: 1;
  color: currentColor;
}

.kwkformmaker-form .kwkfm-rating__star::before {
  content: "☆";
}

.kwkformmaker-form .kwkfm-rating__input:checked ~ .kwkfm-rating__star::before,
.kwkformmaker-form .kwkfm-rating__star:hover::before,
.kwkformmaker-form .kwkfm-rating__star:hover ~ .kwkfm-rating__star::before {
  content: "★";
}

.kwkformmaker-form .kwkfm-rating__input:focus + .kwkfm-rating__star {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.kwkformmaker-form .kwkfm-type-switch .form-switch {
  display: flex;
  align-items: center;
  column-gap: 1.5em;
  padding-left: 2.5em;
}

.kwkformmaker-form .kwkfm-type-switch .form-switch .form-check-input {
  flex: 0 0 auto;
  width: 2em;
  height: 1em;
  margin-left: -2.5em;
  margin-top: 0;
  border-radius: 2em;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(0,0,0,.25)'/%3e%3c/svg%3e");
  background-position: left center;
  background-repeat: no-repeat;
  background-size: contain;
  transition: background-position 0.15s ease-in-out;
}

.kwkformmaker-form .kwkfm-type-switch .form-switch .form-check-input:checked {
  background-color: var(--bs-primary, #0d6efd);
  border-color: var(--bs-primary, #0d6efd);
  background-position: right center;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch--with-labels {
  --kwkfm-switch-width: 5.5em;
  --kwkfm-switch-height: 1.75em;
  --kwkfm-switch-padding: 0.25em;
  position: relative;
  min-height: var(--kwkfm-switch-height);
  padding-left: calc(var(--kwkfm-switch-width) + 0.75em);
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch--with-labels .form-check-input {
  position: relative;
  z-index: 1;
  width: var(--kwkfm-switch-width);
  height: var(--kwkfm-switch-height);
  margin-left: calc((var(--kwkfm-switch-width) + 0.75em) * -1);
  background-position: left var(--kwkfm-switch-padding) center;
  background-size: calc(var(--kwkfm-switch-height) - (var(--kwkfm-switch-padding) * 2)) calc(var(--kwkfm-switch-height) - (var(--kwkfm-switch-padding) * 2));
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch--with-labels .form-check-input:checked {
  background-position: right var(--kwkfm-switch-padding) center;
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch-toggle-labels {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--kwkfm-switch-width);
  height: var(--kwkfm-switch-height);
  pointer-events: none;
  z-index: 2;
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch-toggle-labels__text {
  position: absolute;
  top: 50%;
  max-width: calc((var(--kwkfm-switch-width) - var(--kwkfm-switch-height)) - 0.65em);
  overflow: hidden;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  transform: translateY(-50%);
  white-space: nowrap;
  opacity: 0;
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch-toggle-labels__text--on {
  left: 0.45em;
}

.kwkformmaker-form .kwkfm-type-switch .kwkfm-switch-toggle-labels__text--off {
  right: 0.45em;
  color: var(--bs-secondary-color, #6c757d);
}

.kwkformmaker-form .kwkfm-type-switch .form-check-input:checked ~ .kwkfm-switch-toggle-labels .kwkfm-switch-toggle-labels__text--on,
.kwkformmaker-form .kwkfm-type-switch .form-check-input:not(:checked) ~ .kwkfm-switch-toggle-labels .kwkfm-switch-toggle-labels__text--off {
  opacity: 1;
}

.kwkformmaker-form .kwkfm-submit-footer {
  margin-top: 0.5rem;
}

.kwkformmaker-form .kwkfm-submit-footer--left {
  text-align: left;
}

.kwkformmaker-form .kwkfm-submit-footer--center {
  text-align: center;
}

.kwkformmaker-form .kwkfm-submit-footer--right {
  text-align: right;
}

/* Admin — grille liste des formulaires */
#kwkformmaker_forms_grid table.grid-table tbody tr td.column-actions .btn-group-action,
#kwkformmaker_forms_grid table.grid-table tbody tr td.action-type .btn-group-action {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

#kwkformmaker_forms_grid table.grid-table tbody tr td.column-actions .btn-group-inline.d-flex,
#kwkformmaker_forms_grid table.grid-table tbody tr td.action-type .btn-group-inline.d-flex {
  justify-content: flex-end !important;
}

/* Admin — édition formulaire (onglets BO) */
.kwkfm-tab-lock {
  line-height: 1;
}

.kwkfm-tab-merchant-bar .custom-control-label {
  font-weight: 500;
}

.kwkfm-admin-form .kwkfm-field-short {
  max-width: 420px;
}

.kwkfm-admin-form .kwkfm-field-medium {
  max-width: 560px;
}

.kwkfm-admin-form .kwkfm-localized-field textarea.form-control {
  min-height: 96px;
}

.kwkfm-admin-form .locale-input-group .js-locale-btn {
  min-width: 62px;
}

.kwkfm-admin-form .tab-pane > .form-group,
.kwkfm-admin-form .tab-pane > .card.mb-2 {
  margin-bottom: calc(1rem + 15px);
}

.kwkfm-admin-form .tab-pane .card .form-group.mb-2 {
  margin-bottom: calc(0.5rem + 15px);
}

.kwkfm-admin-form .tab-pane .form-group.mb-0 {
  margin-bottom: 0;
}

.kwkfm-admin-form .tab-pane > hr {
  margin-top: calc(1rem + 15px);
  margin-bottom: calc(1rem + 15px);
}

/* Admin builder */
.kwkfm-sortable .kwkfm-drag-handle {
  cursor: grab;
  user-select: none;
}

.kwkfm-sortable .kwkfm-drag-handle:active {
  cursor: grabbing;
}

.kwkfm-field-item {
  transition: background 0.15s;
}

.kwkfm-field-item.sortable-ghost {
  background: #e8f4fd;
  opacity: 0.6;
}
