/**
 * Paiement SogeCommerce dans le tunnel de réservation Amelia.
 *
 * Les couleurs et typographies reprennent les variables du thème lorsqu'elles
 * existent, avec une valeur de repli explicite : le plugin doit rester
 * présentable même installé sur un autre thème.
 *
 * @package SensTherapie\AmeliaSoge
 */

.stas-panel {
	--stas-accent: var(--st-accent, #8B5A8E);
	--stas-accent-deep: var(--st-accent-deep, #7C4A86);
	--stas-ink: var(--st-ink-2, #2E2433);
	--stas-muted: var(--st-muted, #6B5E72);
	--stas-line: var(--st-line, rgba(124, 74, 134, 0.12));
	--stas-card: var(--st-card, #FBF7F2);
	--stas-sans: var(--st-sans, 'Mulish', system-ui, sans-serif);
	--stas-serif: var(--st-serif, 'Cormorant Garamond', Georgia, serif);

	position: relative;
	z-index: 2;
	box-sizing: border-box;
	margin: 0 0 24px;
	padding: 24px;
	border: 1px solid var(--stas-line);
	border-radius: 16px;
	background: var(--stas-card);
	box-shadow: 0 24px 60px -40px rgba(80, 46, 90, 0.55);
	font-family: var(--stas-sans);
	color: var(--stas-ink);

	/*
	 * Le thème anime ses blocs en opacité et en translation. Un conteneur
	 * transformé devient le bloc de référence de tout élément positionné en
	 * « fixed », ce qui casserait la fenêtre d'authentification bancaire.
	 */
	transform: none;
	opacity: 1;
}

.stas-panel * {
	box-sizing: border-box;
}

.stas-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.stas-panel__title {
	margin: 0;
	font-family: var(--stas-serif);
	font-size: 25px;
	font-weight: 500;
	line-height: 1.15;
	color: var(--stas-ink);
	outline: none;
}

.stas-panel__title:focus-visible {
	outline: 2px solid var(--stas-accent);
	outline-offset: 4px;
}

.stas-panel__status {
	min-height: 20px;
	margin: 0 0 12px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--stas-muted);
}

.stas-panel__status--error {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 12px 14px;
	border-radius: 10px;
	background: rgba(190, 60, 60, 0.08);
	color: #9B2C2C;
	font-weight: 600;
}

/* L'information n'est jamais portée par la seule couleur. */
.stas-panel__status--error::before {
	content: "⚠";
	flex: none;
	font-size: 15px;
	line-height: 1.5;
}

.stas-panel__status--busy {
	color: var(--stas-accent-deep);
	font-weight: 600;
}

.stas-panel__amount {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	margin: 0 0 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--stas-line);
}

.stas-panel__amount-label {
	font-size: 14px;
	color: var(--stas-muted);
}

.stas-panel__amount-value {
	font-family: var(--stas-serif);
	font-size: 28px;
	font-weight: 600;
	color: var(--stas-ink);
}

.stas-panel__test {
	margin: 0 0 14px;
	padding: 9px 12px;
	border-radius: 8px;
	background: rgba(194, 145, 47, 0.14);
	color: #7A5A12;
	font-size: 13px;
	font-weight: 600;
}

.stas-panel__hold {
	margin: 14px 0 0;
	font-size: 13px;
	color: var(--stas-muted);
}

.stas-panel__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	flex-wrap: wrap;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid var(--stas-line);
}

.stas-panel__secure {
	flex: 1 1 260px;
	margin: 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--stas-muted);
}

.stas-panel__help {
	margin: 14px 0 0;
	font-size: 13.5px;
	color: var(--stas-muted);
}

.stas-panel__cancel {
	padding: 0;
	border: 0;
	background: none;
	color: var(--stas-muted);
	font-family: inherit;
	font-size: 13.5px;
	/* Le thème supprime le soulignement des liens : on le rétablit ici, un
	   bouton sans affordance visuelle passe inaperçu. */
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.stas-panel__cancel:hover {
	color: var(--stas-ink);
}

.stas-panel__cancel[disabled] {
	opacity: 0.5;
	cursor: default;
}

.stas-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 14px;
	padding: 15px 28px;
	border: 0;
	border-radius: 100px;
	background: var(--stas-accent);
	color: #fff;
	font-family: var(--stas-sans);
	font-size: 15.5px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 18px 38px -16px rgba(139, 90, 142, 0.95);
	transition: background-color 0.2s ease;
}

.stas-btn:hover,
.stas-btn:focus-visible {
	background: var(--stas-accent-deep);
	color: #fff;
}

.stas-btn[disabled] {
	opacity: 0.6;
	cursor: default;
}

/* Le thème force `img { display: block }`, ce qui désaligne les logos de
   cartes rendus par la bibliothèque bancaire. */
.stas-panel .kr-smart-form img,
.stas-panel .kr-embedded img {
	display: inline-block;
	vertical-align: middle;
}

.stas-panel .kr-form-error {
	margin-top: 10px;
	font-size: 13.5px;
	line-height: 1.5;
}

.stas-panel .kr-smart-form,
.stas-panel .kr-embedded {
	max-width: 100%;
}

/* ---------------------------------------------------------------------------
   Habillage du formulaire bancaire
   ---------------------------------------------------------------------------

   La feuille de styles de la passerelle est chargée en pied de page, donc APRÈS
   la nôtre : sans `!important`, aucune de ces règles ne s'appliquerait. On se
   limite aux couleurs, aux rayons et à la typographie — jamais à la disposition,
   qui reste entièrement pilotée par la banque. Un formulaire de carte dont on
   déplace les champs est un formulaire qu'on casse à la prochaine mise à jour.
   ------------------------------------------------------------------------ */

.stas-panel .kr-smart-form,
.stas-panel .kr-embedded,
.stas-panel .kr-smart-form input,
.stas-panel .kr-embedded input {
	width:100% !important;
	font-family: var(--stas-sans) !important;
}

/* Bouton de paiement : rouge vif par défaut, repris aux couleurs du thème. */
.stas-panel .kr-payment-button,
.stas-panel .kr-smart-form-single-payment-button button,
.stas-panel button.kr-payment-button {
	background: var(--stas-accent) !important;
	border: 0 !important;
	border-radius: 100px !important;
	box-shadow: 0 18px 38px -16px rgba(139, 90, 142, 0.95) !important;
	color: #fff !important;
	font-family: var(--stas-sans) !important;
	font-size: 15.5px !important;
	font-weight: 600 !important;
	letter-spacing: 0 !important;
	min-height: 52px !important;
	text-transform: none !important;
	transition: background-color 0.2s ease !important;
}

.stas-panel .kr-payment-button:hover,
.stas-panel button.kr-payment-button:hover {
	background: var(--stas-accent-deep) !important;
}

/* Champs : mêmes rayons et même trait que le reste du panneau. */
.stas-panel .kr-field,
.stas-panel .kr-pan,
.stas-panel .kr-expiry,
.stas-panel .kr-security-code,
.stas-panel .kr-installment-number,
.stas-panel .kr-field-wrapper {
	border-radius: 10px !important;
}

.stas-panel .kr-theme.kr-field:focus-within,
.stas-panel .kr-field:focus-within {
	border-color: var(--stas-accent) !important;
	box-shadow: 0 0 0 3px rgba(139, 90, 142, 0.14) !important;
}

/* Bandeau de choix du moyen de paiement. */
.stas-panel .kr-smart-form-list-section-name {
	color: var(--stas-muted) !important;
	font-family: var(--stas-sans) !important;
	font-size: 13px !important;
}

/* Message d'erreur de la banque : même langage visuel que les nôtres. */
.stas-panel .kr-form-error,
.stas-panel .kr-form-error span {
	color: #9B2C2C !important;
	font-family: var(--stas-sans) !important;
	font-size: 13.5px !important;
	line-height: 1.5 !important;
}

/* La fenêtre d'authentification forte n'est PAS reprise : elle appartient à la
   banque, et la retoucher ferait douter de son authenticité au moment précis
   où la cliente doit avoir confiance. */

/* ---------------------------------------------------------------------------
   Fenêtre d'authentification forte
   ------------------------------------------------------------------------ */

/*
 * La fenêtre 3-D Secure est positionnée en « fixed ». Si un ancêtre porte une
 * transformation CSS — ce que fait le thème sur ses blocs animés — elle serait
 * ancrée à ce bloc au lieu de la fenêtre du navigateur, et se retrouverait
 * tronquée dans une colonne étroite, à l'étape la plus délicate du parcours.
 */
.kr-popin-modal,
.kr-modal,
[class*="kr-popin"] {
	z-index: 2147483000 !important;
}

/* ---------------------------------------------------------------------------
   Tuile du moyen de paiement dans le tunnel
   ------------------------------------------------------------------------ */

/*
 * Amelia ne dessine une tuile QUE si plusieurs moyens de paiement sont actifs :
 * quand il n'en reste qu'un, il est sélectionné d'office et aucune tuile n'est
 * rendue. Ces règles ne servent donc que si l'exploitant conserve, par exemple,
 * le règlement sur place à côté de la carte.
 *
 * Le moyen de paiement réutilisé afficherait son logo d'origine. Il est masqué
 * et remplacé par un pictogramme neutre de carte bancaire. Les deux tunnels
 * (rendez-vous et événements) sont compilés séparément et n'emploient pas la
 * même convention : le premier suffixe la classe du conteneur, le second pose
 * le nom sur l'image elle-même. Les deux sont couverts.
 */
.am-fs__payments-main-button-mollie img,
.am-payments__method-button img.mollie,
.am-payments__method-button .mollie img {
	display: none !important;
}

.am-fs__payments-main-button-mollie > div::before {
	content: "";
	display: inline-block;
	width: 30px;
	height: 20px;
	margin-right: 10px;
	vertical-align: middle;
	background-image: url("../img/cb.svg");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

/*
 * Règle séparée : `:has()` n'est pas compris par les navigateurs les plus
 * anciens, et un sélecteur invalide invaliderait TOUTE la liste dans laquelle
 * il figure. Isolée, elle se contente d'être ignorée — le pictogramme ne
 * s'affiche pas, rien d'autre ne change.
 */
.am-payments__method-button:has(img.mollie) > div::before {
	content: "";
	display: inline-block;
	width: 30px;
	height: 20px;
	margin-right: 10px;
	vertical-align: middle;
	background-image: url("../img/cb.svg");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

/* ---------------------------------------------------------------------------
   Page de paiement dédiée
   ------------------------------------------------------------------------ */

.stas-page {
	max-width: 620px;
	margin: 0 auto;
	padding-block: 48px;
	padding-inline: 20px;
}

.stas-page__summary {
	margin: 0 0 22px;
	padding: 18px 20px;
	border: 1px solid var(--st-line, rgba(124, 74, 134, 0.12));
	border-radius: 14px;
	background: #fff;
}

.stas-page__summary dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 8px 18px;
	margin: 0;
	font-size: 14px;
}

.stas-page__summary dt {
	color: var(--st-muted, #6B5E72);
}

.stas-page__summary dd {
	margin: 0;
	font-weight: 600;
	color: var(--st-ink-2, #2E2433);
}

.stas-redirect {
	text-align: center;
}

/* ---------------------------------------------------------------------------
   Mobile
   ------------------------------------------------------------------------ */

@media (max-width: 640px) {
	.stas-panel {
		padding: 18px 16px;
		border-radius: 14px;
	}

	.stas-panel__title {
		font-size: 22px;
	}

	.stas-panel__amount-value {
		font-size: 24px;
	}

	.stas-panel__footer {
		flex-direction: column;
		align-items: stretch;
	}

	.stas-btn {
		width: 100%;
	}
}

/* ---------------------------------------------------------------------------
   Message d'issue affiché au-dessus du tunnel
   ------------------------------------------------------------------------ */

.stas-notice {
	box-sizing: border-box;
	margin: 0 0 20px;
	padding: 16px 20px;
	border-radius: 12px;
	border-left: 4px solid var(--st-gold, #C2912F);
	background: rgba(194, 145, 47, 0.10);
	font-family: var(--st-sans, 'Mulish', system-ui, sans-serif);
	color: var(--st-ink-2, #2E2433);
	transform: none;
	opacity: 1;
}

.stas-notice--late {
	border-left-color: #9B2C2C;
	background: rgba(190, 60, 60, 0.08);
}

.stas-notice__text {
	margin: 0;
	font-size: 14.5px;
	line-height: 1.6;
	font-weight: 600;
}

.stas-notice__phone {
	margin: 8px 0 0;
	font-size: 13.5px;
	color: var(--st-muted, #6B5E72);
}

/* ---------------------------------------------------------------------------
   Réaffichage du tunnel pendant le paiement
   ------------------------------------------------------------------------ */

/*
 * Amelia masque son bloc de paiement par `v-show="getReady && !getLoading"` et
 * lui substitue un squelette de chargement. Sur la branche que nous
 * interceptons, le drapeau de chargement est mis à vrai avant l'appel serveur
 * et n'est jamais remis à faux : sans ces règles, le tunnel resterait figé sur
 * son squelette derrière notre panneau.
 *
 * Le `!important` est indispensable : `v-show` écrit un `display: none` en
 * style en ligne, qui l'emporte sur toute règle de feuille de styles.
 *
 * .am-fs__payments     — tunnel rendez-vous
 * .am-payments         — tunnel événements (racine du composant)
 * .am-skeleton-payment — squelette commun aux deux
 */
html.stas-paying .am-fs__payments,
html.stas-paying .am-payments {
	display: block !important;
}

/* Le squelette ne porte pas le même nom dans les deux tunnels. */
html.stas-paying .am-skeleton-payment,
html.stas-paying .am-skeleton-ci,
html.stas-paying [class*="am-skeleton"] {
	display: none !important;
}

/* ---------------------------------------------------------------------------
   Préférences d'accessibilité
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.stas-panel,
	.stas-btn {
		transition: none !important;
	}
}
