/**
 * AIFORYA Delivery Date Picker — sélecteur de date de livraison (page de commande).
 *
 * Contraintes tirées du relevé des plaintes utilisateurs sur cette catégorie :
 *  · « Calendar not responsive on mobile » — la grille doit tenir sur un écran étroit
 *    sans débordement horizontal, et les cibles tactiles faire au moins 44 px.
 *  · « Calendar appears behind the header / cut off » — le panneau est en flux normal,
 *    pas en position absolue : il ne peut pas passer sous un en-tête collant ni être
 *    rogné par un conteneur en overflow:hidden, ce qui est le cas de beaucoup de thèmes.
 *  · Les couleurs sont héritées du thème (currentColor) partout où c'est possible :
 *    une palette codée en dur jure sur la moitié des boutiques.
 */

.aiforya-ddp-field {
	position: relative;
}

.aiforya-ddp-display {
	cursor: pointer;
	background-image: none;
}

.aiforya-ddp-calendar {
	/* En flux, pas en absolu : voir l'en-tête de ce fichier. */
	margin-top: 8px;
	padding: 12px;
	border: 1px solid rgba( 0, 0, 0, 0.15 );
	border-radius: 6px;
	background: #fff;
	max-width: 340px;
	box-sizing: border-box;
	font-size: 14px;
	line-height: 1.4;
}

.aiforya-ddp-calendar[hidden] {
	display: none;
}

/* ── En-tête : mois précédent / libellé / mois suivant ───────────────────────────── */

.aiforya-ddp-entete {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
}

.aiforya-ddp-titre {
	font-weight: 600;
	text-align: center;
	flex: 1 1 auto;
}

.aiforya-ddp-nav {
	flex: 0 0 auto;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: 1px solid rgba( 0, 0, 0, 0.15 );
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.aiforya-ddp-nav:hover,
.aiforya-ddp-nav:focus-visible {
	background: rgba( 0, 0, 0, 0.05 );
}

/* ── Grille ──────────────────────────────────────────────────────────────────────── */

.aiforya-ddp-grille {
	display: grid;
	grid-template-columns: repeat( 7, 1fr );
	gap: 2px;
}

.aiforya-ddp-jour-entete {
	text-align: center;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	opacity: 0.6;
	padding: 4px 0;
}

.aiforya-ddp-case {
	/* 44 px : la cible tactile minimale recommandée. En dessous, le doigt rate la case
	   une fois sur trois sur mobile — et c'est là que se passe la majorité des commandes. */
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}

.aiforya-ddp-vide-case {
	cursor: default;
}

.aiforya-ddp-jour:hover:not( [disabled] ),
.aiforya-ddp-jour:focus-visible:not( [disabled] ) {
	border-color: currentColor;
}

.aiforya-ddp-indispo,
.aiforya-ddp-case[disabled] {
	opacity: 0.3;
	cursor: not-allowed;
	/* La barre oblique dit « indisponible » sans dépendre de la couleur seule — un
	   utilisateur daltonien ne distingue pas 30 % d'opacité d'un état normal. */
	background-image: linear-gradient(
		to top left,
		transparent calc( 50% - 1px ),
		currentColor calc( 50% - 1px ),
		currentColor calc( 50% + 1px ),
		transparent calc( 50% + 1px )
	);
}

.aiforya-ddp-choisi {
	background: currentColor;
	border-color: currentColor;
	font-weight: 700;
}

/* Le texte doit rester lisible sur le fond `currentColor` : on inverse par mélange
   plutôt que par une couleur fixe, pour suivre le thème quel qu'il soit. */
.aiforya-ddp-choisi {
	color: inherit;
}

.aiforya-ddp-jour.aiforya-ddp-choisi {
	box-shadow: inset 0 0 0 2px #fff;
}

/* ── Créneaux horaires ───────────────────────────────────────────────────────────── */

.aiforya-ddp-creneaux:empty {
	display: none;
}

.aiforya-ddp-creneaux {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid rgba( 0, 0, 0, 0.1 );
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.aiforya-ddp-creneaux-titre {
	flex: 1 0 100%;
	margin: 0 0 4px;
	font-size: 12px;
	font-weight: 600;
	opacity: 0.7;
}

.aiforya-ddp-creneau {
	min-height: 44px;
	padding: 0 12px;
	border: 1px solid rgba( 0, 0, 0, 0.2 );
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.aiforya-ddp-creneau:hover,
.aiforya-ddp-creneau:focus-visible {
	border-color: currentColor;
}

.aiforya-ddp-creneau.aiforya-ddp-choisi {
	font-weight: 700;
	box-shadow: inset 0 0 0 2px #fff;
}

.aiforya-ddp-vide {
	margin: 0;
	padding: 12px 0;
	text-align: center;
	opacity: 0.7;
}

/* ── Page de commande en blocs ───────────────────────────────────────────────────── */

/* Le select natif est masqué à l'œil mais RESTE dans le formulaire : c'est lui que
   WooCommerce valide et enregistre. `display:none` le sortirait de la soumission sur
   certains navigateurs, et `hidden` empêcherait React de le mettre à jour. On le retire
   donc du flux visuel sans le retirer du document. */
.aiforya-ddp-select-masque {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.aiforya-ddp-blocs {
	margin-top: 4px;
}

/* ⛔ CE QUI SUIT PORTE `!important`, ET C'EST MESURÉ, PAS PAR CONFORT (02/09/2026).
   La règle `.aiforya-ddp-select-masque` ci-dessus est correcte et PERDAIT quand même :
   relevé sur le vrai checkout en blocs, le select annoncé masqué faisait 50 px de haut,
   `opacity: 1`, `pointer-events: auto`. Les styles de WooCommerce Blocks gagnent la
   cascade, et le résultat était un calendrier INATTEIGNABLE À LA SOURIS — sans erreur
   JS, sans 404, avec un champ bien visible. Le seul contrôle qui pouvait le voir est un
   vrai clic (`elementFromPoint` rendait le libellé de WooCommerce, pas notre champ). */
.aiforya-ddp-woo-masque {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect( 0, 0, 0, 0 ) !important;
	white-space: nowrap !important;
	border: 0 !important;
	pointer-events: none !important;
}

/* Le champ mesuré faisait 22 px de haut — la moitié de la cible tactile annoncée.
   44 px est le minimum recommandé (WCAG 2.5.5 / 2.5.8), et c'est aussi le motif de
   « Calendar not responsive on mobile » dans le relevé des forums concurrents. */
.aiforya-ddp-blocs .aiforya-ddp-display {
	display: block;
	width: 100%;
	min-height: 44px;
	box-sizing: border-box;
	padding: 10px 12px;
}

.aiforya-ddp-blocs .aiforya-ddp-lbl {
	display: block;
	margin-bottom: 4px;
}

/* ── Écrans étroits ──────────────────────────────────────────────────────────────── */

@media ( max-width: 400px ) {
	.aiforya-ddp-calendar {
		max-width: 100%;
		padding: 8px;
	}

	.aiforya-ddp-case {
		font-size: 13px;
	}
}

/* ── Thème sombre du site, s'il y en a un ────────────────────────────────────────── */

@media ( prefers-color-scheme: dark ) {
	.aiforya-ddp-calendar {
		background: #1e1e1e;
		border-color: rgba( 255, 255, 255, 0.2 );
	}

	.aiforya-ddp-nav:hover,
	.aiforya-ddp-nav:focus-visible {
		background: rgba( 255, 255, 255, 0.1 );
	}

	.aiforya-ddp-jour.aiforya-ddp-choisi,
	.aiforya-ddp-creneau.aiforya-ddp-choisi {
		box-shadow: inset 0 0 0 2px #1e1e1e;
	}
}
