/* 
 * Styles pour les composants checkbox et radio
 * SNCF Design System
 */

/* Styles communs pour les cases à cocher et boutons radio */
.form-field-input {
  margin-bottom: O;
  position: relative;
}

.form-field-input.field-type-checkbox,
.form-field-input.field-type-radio {
  margin-top: 0.5rem;
}

/* Styles spécifiques pour les checkbox */
.custom-checkbox {
  position: relative;
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  padding: 0;
}

.custom-checkbox input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkbox label {
  position: relative;
  padding-left: 24px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.4;
  margin: 0;
  display: inline-block;
  color: var(--wp--preset--color--text);
  font-weight: normal;
  user-select: none;
}

.custom-checkbox label:before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  height: 16px;
  border: 1px solid var(--wp--preset--color--primary);
  background-color: #fff;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.custom-checkbox label:after {
  content: '';
  position: absolute;
  left: 5px;
  top: 5px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  opacity: 0;
  transition: all 0.1s ease;
}

.custom-checkbox input[type='checkbox']:checked + label:before {
  background-color: var(--wp--preset--color--primary);
  border-color: var(--wp--preset--color--primary);
}

.custom-checkbox input[type='checkbox']:checked + label:after {
  opacity: 1;
}

.custom-checkbox input[type='checkbox']:focus + label:before {
  padding: 5px;
  border: solid 2px var(--wp--preset--color--primary);
}

.custom-checkbox input[type='checkbox']:disabled + label {
  color: #ccd7e0;
  cursor: not-allowed;
}

.custom-checkbox input[type='checkbox']:disabled + label:before {
  border-color: #ccd7e0;
  background-color: var(--wp--preset--color-light);
}

.custom-checkbox.checked label:before {
  background-color: var(--wp--preset--color--primary);
  border-color: var(--wp--preset--color--primary);
}

.custom-checkbox.checked label:after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

/* Styles pour l'état d'erreur des checkbox */
.custom-checkbox input[type='checkbox'].invalid + label:before {
  border-color: var(--wp--preset--color--error);
}

.checkbox-group-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.checkbox-group-preview-wrapper .form-field-input.field-type-checkbox {
  margin: 0;
  padding: 0;
}

.form-field-input [role='alert'],
.checkbox-group-preview-wrapper + [role='alert'] {
  display: block;
  margin-top: 0;
  min-height: 0;
}

.form-field-input [role='alert'] .show-error,
.checkbox-group-preview-wrapper + [role='alert'] .show-error,
.show-error {
  color: var(--wp--preset--color--error);
  font-size: 0.875rem;
  margin: 0;
  display: flex;
  align-items: flex-start;
}

.form-field-input [role='alert'] .show-error::before,
.checkbox-group-preview-wrapper + [role='alert'] .show-error::before,
.show-error::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  mask: url('../../../assets/icons/Vector.svg') no-repeat center;
  background-color: var(--wp--preset--color--error);
}

.form-field-input.has-error .custom-checkbox label:before,
.form-field-input.has-error .custom-radio label:before {
  border-color: var(--wp--preset--color--error);
}

/* Styles spécifiques pour les boutons radio */
.radio-group-container {
  margin-bottom: 1.5rem;
}

.radio-group-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.radio-options {
  display: flex;
  flex-direction: column;
}

.radio-options-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.radio-option {
  position: relative;
  margin-bottom: 0.5rem;
}

.custom-radio {
  position: relative;
  display: flex;
  align-items: flex-start;
  cursor: pointer;
}

.custom-radio input[type='radio'] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-radio label {
  position: relative;
  padding-left: 24px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.4;
  margin: 0;
  display: inline-block;
  color: #333;
  font-weight: normal;
  user-select: none;
}

.custom-radio label:before {
  content: '';
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--wp--preset--color--primary);
  background-color: var(--wp--preset--color--light);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.custom-radio label:after {
  content: '';
  position: absolute;
  left: 4px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 4px solid var(--wp--preset--color--primary);
  transform: scale(0);
  opacity: 0;
  transition: all 0.1s ease;
}

.custom-radio input[type='radio']:checked + label:before {
  background-color: var(--wp--preset--color--light);
  border-color: var(--wp--preset--color--primary);
}

.custom-radio input[type='radio']:checked + label:after {
  opacity: 1;
  transform: scale(1);
}

.custom-radio input[type='radio']:focus + label:before {
  border: 2px solid var(--wp--preset--color--primary);
}

.custom-radio input[type='radio']:disabled + label {
  color: #999;
  cursor: not-allowed;
}

.custom-radio input[type='radio']:disabled + label:before {
  border-color: #ccc;
  background-color: #f5f5f5;
}

.custom-radio.checked label:before {
  background-color: var(--wp--preset--color--error);
  border-color: var(--wp--preset--color--error);
}

.custom-radio.checked label:after {
  opacity: 1;
  transform: scale(1);
}

/* Styles pour l'état d'erreur des radio */
.custom-radio input[type='radio'].invalid + label:before {
  border-color: var(--wp--preset--color--error);
}

/* Styles pour l'état focus */
.custom-checkbox.focus label:before,
.custom-radio.focus label:before {
  border: solid 2px var(--wp--preset--color--primary);
  padding: 2px;
}

/* Description pour chaque option (checkbox et radio) */
.option-description,
.field-description {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #666;
  padding-left: 30px;
}

/* Styles pour le fieldset */
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
}

fieldset legend {
  font-weight: 500;
  margin-bottom: 0.5rem;
  padding: 0;
  color: #333;
}

/* Indicateur de champ requis */
.required {
  color: #db032a;
  margin-left: 3px;
}

/* Styles responsives */
@media (max-width: 768px) {
  .radio-options-inline {
    flex-direction: column;
  }
}
