/**
 * BW Points de vente — styles front-end.
 *
 * Ce fichier ne pose que la structure et des valeurs par défaut neutres.
 * Couleurs, tailles, bordures et ombres sont écrasées par le CSS
 * généré par les contrôles Elementor.
 */

/* ---------------------------------------------------------------------
 * Disposition
 * ------------------------------------------------------------------ */

.bwpdv {
	display: flex;
	gap: 20px;
	align-items: stretch;
	width: 100%;
}

.bwpdv-map {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	min-height: 240px;
	height: 520px;
	z-index: 1;
	background-color: #eef0f2;
}

.bwpdv--liste-droite {
	flex-direction: row-reverse;
}

.bwpdv-vide {
	padding: 24px;
	border: 1px dashed #c3c8ce;
	border-radius: 6px;
	color: #6b7280;
	font-size: 14px;
	text-align: center;
}

/* Le point de rupture pour la disposition côte à côte est réglable par
   instance (voir render() dans class-bwpdv-widget.php, qui génère un
   <style> scopé par ID) et n'est donc plus codé en dur ici. Un widget sans
   liste ou déjà en disposition empilée n'a pas besoin de cette règle. */

/* ---------------------------------------------------------------------
 * Liste latérale
 * ------------------------------------------------------------------ */

.bwpdv-liste {
	display: flex;
	flex-direction: column;
	flex: 0 0 320px;
	max-width: 320px;
	min-height: 0;
	overflow: hidden;
}

/* Disposition côte à côte, hauteur du contenu : la liste s'aligne en haut. */
.bwpdv--cote.bwpdv--liste-h-auto {
	align-items: flex-start;
}

.bwpdv--cote.bwpdv--liste-h-auto .bwpdv-liste__items {
	overflow: visible;
}

/* Disposition empilée : carte pleine largeur, liste au-dessus ou en dessous. */
.bwpdv--empile {
	flex-direction: column;
}

.bwpdv--liste-bas {
	flex-direction: column-reverse;
}

.bwpdv--empile .bwpdv-liste {
	flex: 0 0 auto;
	width: 100%;
	max-width: none;
}

.bwpdv--empile .bwpdv-liste__items {
	overflow-y: auto;
}

.bwpdv-liste__recherche {
	flex: 0 0 auto;
}

.bwpdv-recherche {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	font: inherit;
	line-height: 1.4;
}

.bwpdv-recherche-wrap {
	position: relative;
}

.bwpdv-liste__recherche .bwpdv-recherche-wrap {
	margin-bottom: 10px;
}

.bwpdv-recherche-haut .bwpdv-recherche-wrap {
	margin-bottom: 16px;
}

.bwpdv-geolocalisation-haut,
.bwpdv-liste__geolocalisation {
	margin-bottom: 10px;
}

.bwpdv-geolocalisation__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 9px 14px;
	border: 1px solid currentColor;
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.4;
	cursor: pointer;
}

.bwpdv-geolocalisation__button:hover,
.bwpdv-geolocalisation__button:focus-visible {
	background: rgba( 0, 0, 0, 0.06 );
}

.bwpdv-geolocalisation__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bwpdv-geolocalisation__button:disabled {
	opacity: 0.65;
	cursor: wait;
}

.bwpdv-geolocalisation__message {
	margin: 6px 0 0;
	font-size: 0.875em;
	line-height: 1.4;
}

/* Le bouton personnalisé évite d'afficher deux icônes d'effacement dans
   les navigateurs qui ajoutent leur propre bouton aux champs type="search". */
.bwpdv-recherche::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.bwpdv-recherche-wrap .bwpdv-recherche {
	padding-right: 42px;
}

.bwpdv-recherche__clear {
	position: absolute;
	top: 50%;
	right: 6px;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	transform: translateY( -50% );
	background: transparent;
	color: currentColor;
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.bwpdv-recherche__clear:hover,
.bwpdv-recherche__clear:focus-visible {
	background: rgba( 0, 0, 0, 0.08 );
}

.bwpdv-recherche__clear:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

.bwpdv-recherche__clear[hidden] {
	display: none !important;
}

.bwpdv-liste__items {
	flex: 1 1 auto;
	/* min-height: 0 permet à la liste de défiler à l'intérieur de la hauteur
	   de la carte au lieu de repousser la colonne au-delà de celle-ci. */
	min-height: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-y: auto;
}

.bwpdv-liste__item {
	display: block;
	padding: 14px 16px;
	border-bottom: 1px solid #e5e7eb;
	cursor: pointer;
	transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Ne dépend pas du style navigateur de l'attribut [hidden], souvent écrasé
   par les feuilles de style de thèmes. */
.bwpdv-liste__item.bwpdv-liste__item--hidden,
.bwpdv-liste__vide.bwpdv-liste__vide--hidden {
	display: none !important;
}

.bwpdv-liste__item:last-child {
	border-bottom: 0;
}

.bwpdv-liste__item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.bwpdv-liste__nom {
	display: block;
	font-weight: 600;
	line-height: 1.3;
}

.bwpdv-liste__adresse {
	display: block;
	margin-top: 3px;
	font-size: 0.875em;
	line-height: 1.4;
	opacity: 0.75;
}

.bwpdv-liste__vide {
	padding: 16px;
	margin: 0;
	font-size: 0.9em;
	opacity: 0.7;
}

/* ---------------------------------------------------------------------
 * Marqueurs
 *
 * L'élément racine de l'icône Leaflet mesure 0 × 0 et porte le transform
 * de positionnement de Leaflet. `.bwpdv-marker-pos` recentre le marqueur
 * sur le point ; `.bwpdv-marker` reste libre pour Elementor.
 * ------------------------------------------------------------------ */

.bwpdv-marker-wrap {
	width: 0 !important;
	height: 0 !important;
	background: none;
	border: 0;
}

.bwpdv-marker-pos {
	position: absolute;
	top: 0;
	left: 0;
	transform: translate( -50%, -50% );
}

.bwpdv-marker-pos--pin {
	transform: translate( -50%, -100% );
}

.bwpdv-marker {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background-color: #1f2937;
	color: #fff;
	transform-origin: center center;
	transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
	cursor: pointer;
}

.bwpdv-marker-pos--pin .bwpdv-marker {
	transform-origin: center bottom;
}

.bwpdv-marker__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.bwpdv-marker__icon svg {
	display: block;
	width: 55%;
	height: 55%;
	fill: currentColor;
}

.bwpdv-marker__num {
	font-size: 0.8em;
	font-weight: 700;
	line-height: 1;
}

.bwpdv-marker__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}

/* Pointe façon épingle : hérite de la couleur de fond via border-top-color. */
.bwpdv-marker__tip {
	position: absolute;
	bottom: 0;
	left: 50%;
	width: 0;
	height: 0;
	border-left: 6px solid transparent;
	border-right: 6px solid transparent;
	border-top: 8px solid #1f2937;
	transform: translate( -50%, 100% );
	transition: border-top-color 0.15s ease;
}

/* ---------------------------------------------------------------------
 * Infobulle
 * ------------------------------------------------------------------ */

.bwpdv-popup-wrap .leaflet-popup-content-wrapper {
	border-radius: 6px;
	padding: 4px;
}

.bwpdv-popup-wrap .leaflet-popup-content {
	margin: 12px 14px;
	line-height: 1.5;
}

.bwpdv-popup {
	min-width: 220px;
}

.bwpdv-popup__nom {
	font-weight: 700;
	font-size: 1.05em;
	line-height: 1.3;
	margin-bottom: 6px;
}

.bwpdv-popup__ligne {
	margin-top: 3px;
	font-size: 0.9em;
}

.bwpdv-popup__actions {
	margin-top: 10px;
}

.bwpdv-popup__itineraire {
	display: inline-block;
	font-weight: 600;
	font-size: 0.9em;
	text-decoration: underline;
}

/* ---------------------------------------------------------------------
 * Boutons de zoom
 *
 * Les boutons de zoom de Leaflet sont de simples liens <a>. Beaucoup de
 * thèmes WordPress appliquent une réinitialisation globale sur `a` (bordure,
 * fond, dimensions, décoration de texte) qui écrase l'apparence par défaut
 * de Leaflet et produit des symboles +/- déformés ou illisibles.
 *
 * Deux groupes de règles, volontairement séparés par spécificité :
 *
 * 1. Propriétés structurelles jamais pilotées par Elementor (alignement,
 *    décoration, boîte). Scopées sous .bwpdv-map et protégées par
 *    !important : rien ne doit jamais les écraser, ni le thème ni un
 *    futur contrôle.
 * 2. Valeurs par défaut des propriétés QUE Elementor pilote (taille,
 *    couleurs, bordure). Sélecteur volontairement moins spécifique
 *    (une seule classe) pour perdre face au sélecteur `{{WRAPPER}} …`
 *    d'Elementor quelle que soit l'ordre de chargement des feuilles de
 *    style, tout en battant un reset générique de thème sur `a`.
 * ------------------------------------------------------------------ */

.bwpdv-map .leaflet-control-zoom a,
.bwpdv-map .leaflet-control-zoom a:link,
.bwpdv-map .leaflet-control-zoom a:visited {
	box-sizing: border-box !important;
	display: block !important;
	margin: 0 !important;
	padding: 0 !important;
	text-align: center !important;
	text-decoration: none !important;
	text-indent: 0 !important;
	vertical-align: baseline !important;
	white-space: nowrap !important;
	overflow: hidden !important;
	list-style: none !important;
	font-family: Arial, Helvetica, sans-serif !important;
	font-weight: 700 !important;
	background-image: none !important;
	cursor: pointer !important;
	-webkit-user-select: none;
	user-select: none;
}

.leaflet-control-zoom {
	border: 0;
}

.leaflet-control-zoom a {
	width: 30px;
	height: 30px;
	line-height: 30px;
	font-size: 18px;
	background-color: #fff;
	color: #333;
}

.leaflet-control-zoom-in {
	border-bottom: 1px solid #e5e7eb;
}

/* ---------------------------------------------------------------------
 * Filtres visuels du fond de carte
 *
 * Appliqués aux tuiles uniquement : les marqueurs et infobulles gardent
 * leurs couleurs de marque.
 * ------------------------------------------------------------------ */

.bwpdv--filtre-gris .leaflet-tile-pane {
	filter: grayscale( 100% );
}

.bwpdv--filtre-sepia .leaflet-tile-pane {
	filter: sepia( 65% ) saturate( 80% );
}

.bwpdv--filtre-contraste .leaflet-tile-pane {
	filter: contrast( 130% ) saturate( 110% );
}

.bwpdv--filtre-estompe .leaflet-tile-pane {
	filter: grayscale( 40% ) opacity( 65% );
}

.bwpdv--filtre-invert .leaflet-tile-pane {
	filter: invert( 100% ) hue-rotate( 180deg ) brightness( 95% ) contrast( 90% );
}

/* ---------------------------------------------------------------------
 * Teinte de couleur principale
 *
 * Une couche colorée est posée entre les tuiles (z-index 200) et les
 * marqueurs (z-index 600). Le mode de fusion et l'opacité viennent
 * d'Elementor. Les marqueurs et infobulles ne sont pas teintés.
 * ------------------------------------------------------------------ */

.bwpdv-map::after {
	content: none;
}

.bwpdv--teinte .bwpdv-map::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 450;
	pointer-events: none;
	mix-blend-mode: multiply;
}

/* ---------------------------------------------------------------------
 * Crédit du fond de carte
 *
 * La licence ODbL d'OpenStreetMap impose de conserver le crédit. « Discret »
 * l'atténue sans le supprimer ; « Masqué » le cache visuellement.
 * ------------------------------------------------------------------ */

.bwpdv--attr-discret .leaflet-control-attribution {
	opacity: 0.4;
	font-size: 9px;
	transform: scale( 0.9 );
	transform-origin: bottom right;
	transition: opacity 0.15s ease;
}

.bwpdv--attr-discret .leaflet-control-attribution:hover {
	opacity: 1;
}

.bwpdv--attr-masquee .leaflet-control-attribution {
	display: none;
}

/* ---------------------------------------------------------------------
 * Accessibilité
 * ------------------------------------------------------------------ */

@media ( prefers-reduced-motion: reduce ) {
	.bwpdv-marker,
	.bwpdv-liste__item,
	.bwpdv-marker__tip {
		transition: none;
	}
}
