/**
 * ALM Prix Essence - Carte interactive
 * Thèmes clair + sombre via [data-theme].
 */

.alm-gas-app {
	--alm-gas-bg: #ffffff;
	--alm-gas-bg-alt: #f7f7f5;
	--alm-gas-border: #e5e5e0;
	--alm-gas-text: #1a1a1a;
	--alm-gas-text-muted: #707070;
	--alm-gas-accent: #1d72ef;
	--alm-gas-accent-hover: #155dc5;
	--alm-gas-green: #1d9e75;
	--alm-gas-orange: #d85a30;
	--alm-gas-red: #c42525;
	--alm-gas-green-bg: #e1f5ee;
	--alm-gas-orange-bg: #faeadf;
	--alm-gas-red-bg: #fceaea;
	--alm-gas-shadow: 0 2px 8px rgba(0,0,0,0.08);
	--alm-gas-radius: 8px;
	--alm-gas-sidebar-width: 380px;

	position: relative;
	display: flex;
	flex-direction: row;
	width: 100%;
	height: var(--alm-gas-height, 75vh);
	background: var(--alm-gas-bg);
	color: var(--alm-gas-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.4;
	border-radius: var(--alm-gas-radius);
	overflow: hidden;
	box-shadow: var(--alm-gas-shadow);
	box-sizing: border-box;
}

.alm-gas-app[data-theme="dark"] {
	--alm-gas-bg: #1a1a1a;
	--alm-gas-bg-alt: #222222;
	--alm-gas-border: #333333;
	--alm-gas-text: #f0f0f0;
	--alm-gas-text-muted: #a0a0a0;
	--alm-gas-accent: #4a9eff;
	--alm-gas-accent-hover: #6fb3ff;
	--alm-gas-green: #5dcaa5;
	--alm-gas-orange: #f0997b;
	--alm-gas-red: #f09595;
	--alm-gas-green-bg: #0f4d3c;
	--alm-gas-orange-bg: #5a2e19;
	--alm-gas-red-bg: #4d1919;
	--alm-gas-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.alm-gas-app *,
.alm-gas-app *::before,
.alm-gas-app *::after {
	box-sizing: border-box;
}

/* ---------- Loading overlay ---------- */

.alm-gas-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: var(--alm-gas-bg);
	z-index: 1000;
	color: var(--alm-gas-text-muted);
	font-size: 13px;
	transition: opacity 0.25s;
}

.alm-gas-app.is-loaded .alm-gas-loading {
	opacity: 0;
	pointer-events: none;
}

.alm-gas-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--alm-gas-border);
	border-top-color: var(--alm-gas-accent);
	border-radius: 50%;
	animation: alm-gas-spin 0.8s linear infinite;
}

@keyframes alm-gas-spin {
	to { transform: rotate(360deg); }
}

/* ---------- Sidebar ---------- */

.alm-gas-sidebar {
	width: var(--alm-gas-sidebar-width);
	flex: 0 0 var(--alm-gas-sidebar-width);
	display: flex;
	flex-direction: column;
	background: var(--alm-gas-bg);
	border-right: 1px solid var(--alm-gas-border);
	overflow: hidden;
}

.alm-gas-sidebar-header {
	display: flex;
	gap: 8px;
	padding: 14px;
	border-bottom: 1px solid var(--alm-gas-border);
	position: relative;
}

.alm-gas-search {
	flex: 1;
	position: relative;
}

.alm-gas-search-input {
	width: 100%;
	height: 38px;
	padding: 0 12px;
	font-size: 14px;
	font-family: inherit;
	background: var(--alm-gas-bg-alt);
	color: var(--alm-gas-text);
	border: 1px solid var(--alm-gas-border);
	border-radius: var(--alm-gas-radius);
	outline: none;
	transition: border-color 0.15s;
}

.alm-gas-search-input:focus {
	border-color: var(--alm-gas-accent);
}

.alm-gas-search-input::placeholder {
	color: var(--alm-gas-text-muted);
}

.alm-gas-search-results {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	background: var(--alm-gas-bg);
	border: 1px solid var(--alm-gas-border);
	border-radius: var(--alm-gas-radius);
	max-height: 240px;
	overflow-y: auto;
	display: none;
	z-index: 10;
	box-shadow: var(--alm-gas-shadow);
}

.alm-gas-search-results.is-visible {
	display: block;
}

.alm-gas-search-result {
	padding: 10px 12px;
	cursor: pointer;
	border-bottom: 1px solid var(--alm-gas-border);
	font-size: 13px;
}

.alm-gas-search-result:last-child {
	border-bottom: none;
}

.alm-gas-search-result:hover {
	background: var(--alm-gas-bg-alt);
}

.alm-gas-search-submit {
	height: 38px;
	padding: 0 14px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	background: var(--alm-gas-bg-alt);
	color: var(--alm-gas-text);
	border: 1px solid var(--alm-gas-border);
	border-radius: var(--alm-gas-radius);
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.alm-gas-search-submit:hover {
	background: var(--alm-gas-bg);
	border-color: var(--alm-gas-accent);
	color: var(--alm-gas-accent);
}

.alm-gas-locate-btn {
	width: 38px;
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--alm-gas-bg-alt);
	color: var(--alm-gas-text);
	border: 1px solid var(--alm-gas-border);
	border-radius: var(--alm-gas-radius);
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, border-color 0.15s;
}

.alm-gas-locate-btn:hover {
	background: var(--alm-gas-bg);
	border-color: var(--alm-gas-accent);
	color: var(--alm-gas-accent);
}

.alm-gas-locate-btn.is-active {
	background: var(--alm-gas-accent);
	color: white;
	border-color: var(--alm-gas-accent);
}

/* ---------- Fuel tabs ---------- */

.alm-gas-fuel-tabs {
	display: flex;
	padding: 10px 14px 0;
	gap: 4px;
	border-bottom: 1px solid var(--alm-gas-border);
}

.alm-gas-fuel-tab {
	flex: 1;
	padding: 8px 4px;
	background: transparent;
	color: var(--alm-gas-text-muted);
	border: none;
	border-bottom: 2px solid transparent;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s;
}

.alm-gas-fuel-tab:hover {
	color: var(--alm-gas-text);
}

.alm-gas-fuel-tab.is-active {
	color: var(--alm-gas-accent);
	border-bottom-color: var(--alm-gas-accent);
}

/* ---------- Filters ---------- */

.alm-gas-filters {
	display: flex;
	gap: 8px;
	padding: 10px 14px;
	border-bottom: 1px solid var(--alm-gas-border);
}

.alm-gas-filters select {
	flex: 1;
	min-width: 0;
	height: 34px;
	padding: 0 8px;
	font-size: 12px;
	font-family: inherit;
	background: var(--alm-gas-bg-alt);
	color: var(--alm-gas-text);
	border: 1px solid var(--alm-gas-border);
	border-radius: 6px;
	cursor: pointer;
}

/* ---------- Filter checkbox (Exclure Costco, etc.) ---------- */

.alm-gas-filter-check {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px 10px;
	font-size: 12px;
	color: var(--alm-gas-text-muted);
	border-bottom: 1px solid var(--alm-gas-border);
	cursor: pointer;
	user-select: none;
}

.alm-gas-filter-check input[type="checkbox"] {
	margin: 0;
	accent-color: var(--alm-gas-accent);
	cursor: pointer;
}

.alm-gas-filter-check:hover {
	color: var(--alm-gas-text);
}

/* ---------- Stats ---------- */

.alm-gas-stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0;
	padding: 12px 14px;
	border-bottom: 1px solid var(--alm-gas-border);
}

.alm-gas-stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.alm-gas-stat-label {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--alm-gas-text-muted);
}

.alm-gas-stat-value {
	font-size: 15px;
	font-weight: 600;
	color: var(--alm-gas-text);
}

.alm-gas-stat-value.is-min { color: var(--alm-gas-green); }
.alm-gas-stat-value.is-max { color: var(--alm-gas-red); }

/* ---------- List ---------- */

.alm-gas-list-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 14px 6px;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--alm-gas-text-muted);
}

.alm-gas-list-title {
	font-weight: 600;
}

.alm-gas-list {
	flex: 1;
	overflow-y: auto;
	padding: 0 14px 14px;
}

.alm-gas-list-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	margin-bottom: 6px;
	background: var(--alm-gas-bg-alt);
	border: 1px solid transparent;
	border-radius: 6px;
	cursor: pointer;
	transition: border-color 0.15s;
}

.alm-gas-list-item:hover {
	border-color: var(--alm-gas-accent);
}

.alm-gas-list-item-info {
	min-width: 0;
	flex: 1;
}

.alm-gas-list-item-name {
	font-size: 13px;
	font-weight: 500;
	color: var(--alm-gas-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.alm-gas-list-item-address {
	font-size: 11px;
	color: var(--alm-gas-text-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	margin-top: 1px;
}

.alm-gas-list-item-price {
	font-size: 14px;
	font-weight: 600;
	padding: 3px 7px;
	border-radius: 4px;
	flex-shrink: 0;
}

.alm-gas-list-item-price.is-low {
	background: var(--alm-gas-green-bg);
	color: var(--alm-gas-green);
}

.alm-gas-list-item-price.is-mid {
	background: var(--alm-gas-orange-bg);
	color: var(--alm-gas-orange);
}

.alm-gas-list-item-price.is-high {
	background: var(--alm-gas-red-bg);
	color: var(--alm-gas-red);
}

/* ---------- Map ---------- */

.alm-gas-map-wrapper {
	flex: 1;
	position: relative;
	min-width: 0;
}

.alm-gas-map {
	position: absolute;
	inset: 0;
}

.alm-gas-attribution {
	position: absolute;
	bottom: 0;
	left: 0;
	padding: 4px 8px;
	font-size: 10px;
	color: var(--alm-gas-text-muted);
	background: rgba(255, 255, 255, 0.85);
	z-index: 5;
	pointer-events: auto;
}

.alm-gas-app[data-theme="dark"] .alm-gas-attribution {
	background: rgba(26, 26, 26, 0.85);
}

.alm-gas-attribution a {
	color: var(--alm-gas-accent);
	text-decoration: none;
}

.alm-gas-attribution a:hover {
	text-decoration: underline;
}

/* ---------- MapLibre overrides ---------- */

.alm-gas-map .maplibregl-popup-content {
	font-family: inherit;
	font-size: 13px;
	padding: 12px 14px;
	border-radius: var(--alm-gas-radius);
	min-width: 220px;
}

.alm-gas-app[data-theme="dark"] .maplibregl-popup-content {
	background: var(--alm-gas-bg);
	color: var(--alm-gas-text);
}

.alm-gas-app[data-theme="dark"] .maplibregl-popup-tip {
	border-top-color: var(--alm-gas-bg);
	border-bottom-color: var(--alm-gas-bg);
}

.alm-gas-popup-name {
	font-weight: 600;
	margin-bottom: 2px;
}

.alm-gas-popup-address {
	color: var(--alm-gas-text-muted);
	font-size: 12px;
	margin-bottom: 8px;
}

.alm-gas-popup-prices {
	margin: 4px 0;
}

.alm-gas-popup-price-row {
	display: flex;
	justify-content: space-between;
	padding: 4px 8px;
	font-size: 13px;
	border-radius: 4px;
}

.alm-gas-popup-price-row + .alm-gas-popup-price-row {
	margin-top: 2px;
}

.alm-gas-popup-price-row.is-active {
	background: var(--alm-gas-bg-alt);
	font-weight: 500;
}

.alm-gas-popup-price-label {
	color: var(--alm-gas-text-muted);
}

.alm-gas-popup-price-row.is-active .alm-gas-popup-price-label {
	color: var(--alm-gas-text);
}

.alm-gas-popup-price-value {
	font-weight: 600;
}

.alm-gas-popup-updated {
	margin-top: 8px;
	font-size: 11px;
	color: var(--alm-gas-text-muted);
	line-height: 1.4;
}

.alm-gas-popup-updated.is-stale {
	color: #a32d2d;
	font-weight: 500;
}

.alm-gas-app[data-theme="dark"] .alm-gas-popup-updated.is-stale {
	color: #f09595;
}

.alm-gas-popup-action {
	display: inline-block;
	margin-top: 10px;
	font-size: 12px;
	color: var(--alm-gas-accent);
	text-decoration: none;
}

.alm-gas-popup-action:hover {
	text-decoration: underline;
}

/* ---------- Bouton géoloc flottant (mobile uniquement) ---------- */

.alm-gas-map-locate-fab {
	display: inline-flex !important;
	position: absolute !important;
	top: 12px !important;
	left: 12px !important;
	z-index: 6 !important;
	padding: 9px 14px !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 6px !important;
	font-family: inherit !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	line-height: 1 !important;
	background: #ffffff !important;
	background-image: none !important;
	color: #1d72ef !important;
	border: 1px solid #d5d5d0 !important;
	border-radius: 20px !important;
	cursor: pointer !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	height: auto !important;
	min-height: 0 !important;
	width: auto !important;
}

.alm-gas-map-locate-fab svg {
	display: block !important;
	flex-shrink: 0;
}

.alm-gas-map-locate-fab:hover:not(:disabled) {
	background: #f8fafe !important;
	border-color: #1d72ef !important;
	transform: translateY(-1px);
}

.alm-gas-map-locate-fab:active {
	background: #eef5ff !important;
	transform: none;
}

.alm-gas-app[data-theme="dark"] .alm-gas-map-locate-fab {
	background: #2a2a2a !important;
	color: #7aa7ff !important;
	border-color: #3a3a3a !important;
}

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

@media (max-width: 768px) {
	/* Sur mobile, on oublie le flex horizontal : la carte a une hauteur fixe
	   raisonnable, et la sidebar a sa propre hauteur fixe avec scroll interne
	   pour éviter les sauts de layout quand le nombre d'items change (zoom/pan
	   sur la carte → la liste filtrée par viewport varie, sans cap la page
	   "saute" et l'utilisateur perd le focus sur la carte). */
	.alm-gas-app {
		display: block;
		height: auto;
	}

	.alm-gas-map-wrapper {
		position: relative;
		width: 100%;
		height: 55vh;
		min-height: 360px;
	}

	.alm-gas-sidebar {
		width: 100%;
		flex: none;
		max-height: 360px;
		border-right: none;
		border-top: 1px solid var(--alm-gas-border);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.alm-gas-stats {
		padding: 10px 14px;
	}

	.alm-gas-list {
		padding: 0 14px 10px;
		max-height: none;
	}
}
