/*
 * Formulaire d'options d'une fiche à options (front/options-fiche.php), sur la fiche produit du thème Divi.
 *
 * La page reste celle du thème : polices et couleur du texte sont héritées, et les seules couleurs posées ici
 * sont celles que le thème emploie déjà (rouge des prix et des boutons, gris des bordures). Elles sont réunies
 * en jetons sur le formulaire pour qu'un changement de charte ne touche qu'ici.
 * Chargé sur les seules fiches à options (sc_cfg_fiche_charger_les_options()).
 *
 * © 2026 Blue Impakt (Melvin Perrottet). Licence GPL-2.0-or-later, voir LICENCE.txt.
 * Toute copie ou version modifiée redistribuée doit garder cette mention et la même licence.
 */
.sc-cfg-options {
	--sc-cfg-accent: #d02c30;        /* rouge des prix et des boutons du thème */
	--sc-cfg-accent-fond: #fdf2f2;   /* le même, très clair : choix coché */
	--sc-cfg-fort: #222;
	--sc-cfg-doux: #666;
	--sc-cfg-bord: #cfcfcf;
	--sc-cfg-erreur: #b3191e;        /* plus sombre que l'accent : lisible en petit texte (contraste 6,9:1 sur blanc) */
	--sc-cfg-rayon: 4px;
	margin: 8px 0 0;
}

/* Le style de Divi pour un élément affiché l'emporte sur l'attribut `hidden` : un champ masqué par sa condition
   doit le rester. */
.sc-cfg-options [hidden] {
	display: none !important;
}

.sc-cfg-masque {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Saisies courtes par deux, comme dans APF ; questions à choix, intertitres et commentaires sur toute la largeur. */
.sc-cfg-options__champs {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 20px 16px;
}
.sc-cfg-intertitre,
.sc-cfg-champ--choix,
.sc-cfg-champ--large {
	grid-column: 1 / -1;
}
@media (max-width: 600px) {
	.sc-cfg-options__champs {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Divi donne aux fieldset une bordure et une marge de formulaire WooCommerce : remis à zéro. */
.sc-cfg-options fieldset.sc-cfg-champ {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sc-cfg-intertitre__titre {
	margin: 8px 0 0;
	padding: 0 0 6px;
	border-bottom: 1px solid var(--sc-cfg-bord);
	font-size: 18px;
	line-height: 1.3;
}

.sc-cfg-champ__libelle {
	display: block;
	float: none; /* legend : sans cela, certains navigateurs le sortent du flux du fieldset */
	width: 100%;
	margin: 0 0 6px;
	padding: 0;
	color: var(--sc-cfg-fort);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
}
.sc-cfg-requis {
	margin-left: 2px;
	color: var(--sc-cfg-accent);
}

.sc-cfg-champ__aide {
	margin: -2px 0 8px;
	color: var(--sc-cfg-doux);
	font-size: 13px;
	line-height: 1.55;
}
.sc-cfg-intertitre .sc-cfg-champ__aide {
	margin-top: 6px;
}

/* Choix : une ligne par choix, cible d'au moins 44 px, prix calé à droite. */
.sc-cfg-champ__choix {
	display: grid;
	gap: 6px;
}
.sc-cfg-choix {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	margin: 0;
	padding: 8px 12px;
	border: 1px solid var(--sc-cfg-bord);
	border-radius: var(--sc-cfg-rayon);
	background: #fff;
	color: var(--sc-cfg-fort);
	font-size: 14px;
	line-height: 1.35;
	cursor: pointer;
}
.sc-cfg-choix:hover {
	border-color: #999;
}
.sc-cfg-choix:has(input:checked) {
	border-color: var(--sc-cfg-accent);
	background: var(--sc-cfg-accent-fond);
}
.sc-cfg-choix:has(input:focus-visible) {
	outline: 2px solid var(--sc-cfg-accent);
	outline-offset: 2px;
}
/* Divi cache ou redessine les cases de WooCommerce selon les modules : on garde la case du navigateur, à la couleur du thème. */
.sc-cfg-choix input[type="radio"],
.sc-cfg-choix input[type="checkbox"] {
	flex: none;
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--sc-cfg-accent);
	appearance: auto;
	-webkit-appearance: auto;
}
.sc-cfg-choix__libelle {
	flex: 1 1 auto;
}
.sc-cfg-choix__prix {
	flex: none;
	margin-left: auto;
	color: var(--sc-cfg-accent);
	font-weight: 600;
	white-space: nowrap;
}
.sc-cfg-choix__image {
	flex: none;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 2px;
}
.sc-cfg-choix__teinte {
	flex: none;
	width: 24px;
	height: 24px;
	border: 1px solid rgba(0, 0, 0, 0.25);
	border-radius: 50%;
}

/* Saisies : Divi donne aux champs de WooCommerce un fond gris sans bordure, peu visibles sur la fiche blanche. */
.sc-cfg-options input[type="text"],
.sc-cfg-options input[type="number"],
.sc-cfg-options textarea {
	box-sizing: border-box;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--sc-cfg-bord);
	border-radius: var(--sc-cfg-rayon);
	background: #fff;
	color: var(--sc-cfg-fort);
	font: inherit;
	font-size: 15px;
	line-height: 1.4;
}
.sc-cfg-options input::placeholder,
.sc-cfg-options textarea::placeholder {
	color: #8a8a8a;
	opacity: 1;
}
/* Divi retire le contour du focus des champs : il est rendu, à la couleur du thème. */
.sc-cfg-options input[type="text"]:focus-visible,
.sc-cfg-options input[type="number"]:focus-visible,
.sc-cfg-options textarea:focus-visible {
	border-color: var(--sc-cfg-accent);
	outline: 2px solid var(--sc-cfg-accent);
	outline-offset: 1px;
}

/* Erreurs */
.sc-cfg-champ__erreur {
	margin: 6px 0 0;
	padding: 0;
	color: var(--sc-cfg-erreur);
	font-size: 13px;
	font-weight: 600;
}
.sc-cfg-champ--erreur .sc-cfg-choix,
.sc-cfg-champ--erreur input,
.sc-cfg-champ--erreur textarea {
	border-color: var(--sc-cfg-erreur);
}

/* Totaux, comme APF : produit, options, total. */
.sc-cfg-options__totaux {
	margin: 24px 0 16px;
	padding: 12px 0 0;
	border-top: 1px solid var(--sc-cfg-bord);
}
.sc-cfg-options__total {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 3px 0;
	font-size: 15px;
}
.sc-cfg-options__total dt,
.sc-cfg-options__total dd {
	margin: 0;
	padding: 0;
	font-weight: 400;
}
.sc-cfg-options__total dd {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.sc-cfg-options__total--final {
	margin-top: 6px;
	padding-top: 8px;
	border-top: 1px solid var(--sc-cfg-bord);
	font-size: 18px;
}
.sc-cfg-options__total--final dt,
.sc-cfg-options__total--final dd {
	color: var(--sc-cfg-accent);
	font-weight: 700;
}

.sc-cfg-options__erreur {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-left: 3px solid var(--sc-cfg-erreur);
	background: #fbeeee;
	color: var(--sc-cfg-erreur);
	font-weight: 600;
}
.sc-cfg-options__erreur:empty {
	display: none;
}

.sc-cfg-options .sc-cfg-options__bouton {
	min-height: 44px;
}
.sc-cfg-options .sc-cfg-options__bouton[disabled] {
	opacity: 0.7;
	cursor: progress;
}
@media (max-width: 600px) {
	.sc-cfg-options .sc-cfg-options__bouton {
		width: 100%;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.sc-cfg-choix,
	.sc-cfg-options input,
	.sc-cfg-options textarea {
		transition: border-color 0.12s ease, background-color 0.12s ease;
	}
}
