/*
 * XDEYE Store Locator - front-end styling.
 * --xsl-accent, --xsl-secondary, and --xsl-heading are set inline
 * per-instance from the plugin's Settings page (see class-shortcode.php):
 * accent drives buttons/highlights, secondary drives marker/icon badges
 * and the alternating list-row tint, heading drives store name text
 * color - each independently controllable.
 */

.xsl-locator {
	--xsl-accent: #2c7be5;
	--xsl-secondary: #7c3aed;
	--xsl-heading: #111827;
	--xsl-btn-text: #ffffff; /* text/icon color on accent-colored buttons - kept separate so it never accidentally inherits --xsl-heading or --xsl-text */
	--xsl-hover: #f3f4f6; /* hover background for secondary/text buttons, list rows, and dropdown options */
	--xsl-border: #e5e7eb;
	--xsl-text: #374151;
	--xsl-text-light: #6b7280;
	--xsl-radius: 12px;

	width: 100%;
	box-sizing: border-box;
	border: 1px solid var( --xsl-border );
	border-radius: var( --xsl-radius );
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: #fff;
}
.xsl-locator *,
.xsl-locator *::before,
.xsl-locator *::after {
	box-sizing: border-box;
}
/* The native [hidden] attribute (used for Make/Change My Store) would
   otherwise lose to .xsl-btn's own `display: inline-flex` below, since
   both are single-selector rules and ours loads after the UA stylesheet. */
.xsl-locator [hidden] {
	display: none !important;
}

/*
 * Store selector bar: "Your Store" dropdown (red until a store is picked,
 * green once one is), the radius filter, and the Make/Change my store
 * buttons. This sits above the discovery toolbar (GPS/postcode) since
 * it's the primary, authoritative control - see frontend.js file header
 * for why distance is always measured from whatever's selected here.
 */
.xsl-select-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 14px;
	padding: 16px 20px;
	border-bottom: 1px solid var( --xsl-border );
	background: #fff;
}
.xsl-select-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 200px;
}
.xsl-select-field label {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var( --xsl-text-light );
}
.xsl-locator .xsl-select {
	width: 100%;
	padding: 10px 36px 10px 14px;
	border: 1.5px solid var( --xsl-border );
	border-radius: 8px;
	font-size: 14px;
	color: var( --xsl-text );
	background:
		#fff
		url( 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7280" stroke-width="2"><path d="m6 9 6 6 6-6"/></svg>' )
		no-repeat right 12px center / 16px 16px;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}
.xsl-locator .xsl-select:focus {
	outline: none;
	border-color: var( --xsl-accent );
	box-shadow: 0 0 0 3px color-mix( in srgb, var( --xsl-accent ) 15%, transparent );
}
.xsl-locator .xsl-select:disabled {
	background-color: #f3f4f6;
	color: var( --xsl-text-light );
	cursor: not-allowed;
}

/* Red until a store is picked, green once one is - the "selector styling" requirement. */
.xsl-store-select-field.is-invalid .xsl-custom-select-trigger {
	border-color: #ef4444;
	background-color: #fef2f2;
}
.xsl-store-select-field.is-invalid label {
	color: #dc2626;
}
.xsl-store-select-field.is-valid .xsl-custom-select-trigger {
	border-color: #16a34a;
	background-color: #f0fdf4;
}
.xsl-store-select-field.is-valid label {
	color: #16a34a;
}

/*
 * Custom store-selector dropdown (built with jQuery in frontend.js): a
 * styled trigger button + floating listbox panel, matching the bordered/
 * shadowed look of the site's other dropdown fields. The real <select>
 * that holds the actual value is visually hidden (.xsl-sr-only) but
 * still present for keyboard/screen-reader users and native form
 * semantics.
 */
.xsl-custom-select {
	position: relative;
}
.xsl-custom-select-trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 14px;
	border: 1.5px solid var( --xsl-border );
	border-radius: 8px;
	background: #fff;
	font-size: 14px;
	font-family: inherit;
	color: var( --xsl-text );
	cursor: pointer;
	text-align: left;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}
.xsl-custom-select-trigger:focus {
	outline: none;
	border-color: var( --xsl-accent );
	box-shadow: 0 0 0 3px color-mix( in srgb, var( --xsl-accent ) 15%, transparent );
}
.xsl-custom-select-value {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.xsl-custom-select-chevron {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var( --xsl-text-light );
	transition: transform 0.15s ease;
}
.xsl-custom-select-trigger[aria-expanded="true"] .xsl-custom-select-chevron {
	transform: rotate( 180deg );
}
.xsl-custom-select-trigger:disabled {
	background-color: #f3f4f6;
	color: var( --xsl-text-light );
	cursor: not-allowed;
}

.xsl-custom-select-panel {
	position: absolute;
	top: calc( 100% + 6px );
	left: 0;
	right: 0;
	z-index: 40;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: #fff;
	border: 1px solid var( --xsl-border );
	border-radius: 10px;
	box-shadow: 0 10px 30px rgba( 0, 0, 0, 0.14 );
	max-height: 280px;
	overflow-y: auto;
}
.xsl-custom-select-option {
	padding: 9px 10px;
	border-radius: 6px;
	font-size: 14px;
	color: var( --xsl-text );
	cursor: pointer;
}
.xsl-custom-select-option:hover {
	background: var( --xsl-hover );
}
.xsl-custom-select-option.is-selected {
	background: color-mix( in srgb, var( --xsl-accent ) 12%, #fff );
	color: var( --xsl-accent );
	font-weight: 600;
}

.xsl-select-hint {
	margin: 0 20px 12px;
	font-size: 12px;
	color: var( --xsl-text-light );
	font-style: italic;
}
.xsl-select-hint:empty {
	display: none;
}
.xsl-select-hint.is-error {
	color: #dc2626;
	font-style: normal;
	font-weight: 600;
}

.xsl-your-store-badge {
	display: inline-block;
	margin-left: 8px;
	padding: 1px 7px;
	border-radius: 999px;
	background: color-mix( in srgb, var( --xsl-accent ) 12%, #fff );
	color: var( --xsl-accent );
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	vertical-align: middle;
}

/* Discovery toolbar (GPS / postcode) */
.xsl-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	padding: 16px 20px;
	border-bottom: 1px solid var( --xsl-border );
	background: #fafbfc;
}
.xsl-search-form {
	display: flex;
	gap: 8px;
	flex: 1;
	min-width: 220px;
	max-width: 420px;
}
.xsl-locator .xsl-input {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var( --xsl-border );
	border-radius: 8px;
	font-size: 14px;
	color: var( --xsl-text );
}
.xsl-locator .xsl-input:focus {
	outline: none;
	border-color: var( --xsl-accent );
	box-shadow: 0 0 0 3px color-mix( in srgb, var( --xsl-accent ) 15%, transparent );
}

.xsl-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	border: 1px solid transparent;
	cursor: pointer;
	white-space: nowrap;
	transition: filter 0.15s ease, background-color 0.15s ease;
}
.xsl-btn-primary {
	background: var( --xsl-accent );
	color: var( --xsl-btn-text );
}
.xsl-btn-primary svg {
	color: var( --xsl-btn-text );
}
.xsl-btn-primary:hover {
	filter: brightness( 0.92 );
}
.xsl-btn-primary:disabled {
	opacity: 0.6;
	cursor: default;
}
/*
 * Leaflet's own bundled CSS sets `.leaflet-popup-content a { color: #0078A8; }`
 * which - despite loading before this file - wins on pure CSS specificity
 * (one class + one element beats our plain `.xsl-btn-primary` single-class
 * rule above), making the Directions button's text/icon nearly invisible
 * against its own blue background. This re-qualified selector has higher
 * specificity (two classes) so it wins instead.
 */
.leaflet-popup-content .xsl-btn-primary,
.leaflet-popup-content .xsl-btn-primary svg {
	color: var( --xsl-btn-text );
}

/*
 * "Find Stores Near Me" turns green after it successfully finds a
 * location (GPS or postcode search both funnel through
 * showNearestStoresTo() in frontend.js) - a quick visual confirmation
 * that the search worked, separate from the "Your Store" selector's own
 * green/red state, which reflects whether a store is selected, not
 * whether the last search succeeded.
 */
.xsl-locate-btn.is-found {
	background: #16a34a;
}

.xsl-btn-secondary {
	background: #fff;
	border-color: var( --xsl-border );
	color: var( --xsl-text );
}
/* Same Leaflet-popup-link specificity fix as .xsl-btn-primary above. */
.leaflet-popup-content .xsl-btn-secondary {
	color: var( --xsl-text );
}
.xsl-btn-secondary:hover {
	background: var( --xsl-hover );
}
.xsl-btn-text {
	background: transparent;
	color: var( --xsl-text-light );
	padding: 10px 12px;
}
.xsl-btn-text:hover {
	color: var( --xsl-text );
	background: var( --xsl-hover );
}

/*
 * Flashing "live location" dot on the "Use My Location" button. The
 * pulsing ring uses --xsl-secondary rather than white/--xsl-accent so
 * it reads as its own distinct color against the button's accent-colored
 * background, instead of blending into it.
 */
.xsl-pulse-dot {
	position: relative;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.xsl-pulse-dot-core {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var( --xsl-secondary, #7c3aed );
	border: 1.5px solid #fff;
	z-index: 1;
}
.xsl-pulse-dot::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var( --xsl-secondary, #7c3aed );
	animation: xsl-pulse 1.6s ease-out infinite;
}
@keyframes xsl-pulse {
	0% {
		transform: scale( 0.6 );
		opacity: 0.7;
	}
	100% {
		transform: scale( 2.2 );
		opacity: 0;
	}
}

/* Body: sidebar + map */
.xsl-body {
	display: flex;
	min-height: 520px;
}
.xsl-sidebar {
	width: 360px;
	flex-shrink: 0;
	border-right: 1px solid var( --xsl-border );
	overflow-y: auto;
	max-height: 640px;
}
.xsl-sidebar-header {
	/* Only shown on mobile, where the sidebar becomes a slide-in drawer
	   (see the max-width: 782px block) and needs its own close control. */
	display: none;
}
.xsl-sidebar-backdrop {
	display: none;
}
.xsl-map-wrap {
	flex: 1;
	position: relative;
}
.xsl-map {
	width: 100%;
	height: 100%;
	min-height: 520px;
}

.xsl-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* Hamburger icon + toggle button: only relevant on mobile, hidden on
   desktop where the store list already sits inline next to the map. */
.xsl-menu-toggle {
	display: none;
	padding: 10px 12px;
}
.xsl-icon-pin {
	width: 16px;
	height: 16px;
	color: var( --xsl-text );
}

.xsl-loading,
.xsl-empty {
	padding: 32px 20px;
	text-align: center;
	color: var( --xsl-text-light );
	font-size: 14px;
}

/* Store list */
.xsl-store-list {
	display: flex;
	flex-direction: column;
}
.xsl-store-card {
	display: flex;
	gap: 12px;
	padding: 16px 20px;
	background: #fff;
	border-bottom: 1px solid var( --xsl-border );
	cursor: pointer;
	transition: background-color 0.15s ease;
}
/* Zebra striping: the first row (and every odd row after it) stays plain
   white; every second row gets a light tint of the secondary color so
   the list reads as distinct rows at a glance. */
.xsl-store-card:nth-child( even ) {
	background: color-mix( in srgb, var( --xsl-secondary ) 8%, #fff );
}
.xsl-store-card:hover {
	background: var( --xsl-hover );
}
.xsl-store-card.is-active {
	background: color-mix( in srgb, var( --xsl-accent ) 10%, #fff );
	border-left: 3px solid var( --xsl-accent );
	padding-left: 17px;
}
.xsl-store-icon {
	width: 44px;
	height: 44px;
	border-radius: 10px;
	background: var( --xsl-secondary );
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 15px;
	font-weight: 700;
	overflow: hidden;
}
.xsl-store-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.xsl-store-info {
	flex: 1;
	min-width: 0;
}
/*
 * Name + action icons share one row (space-between) instead of the
 * icons living in their own full-height flex column beside .xsl-store-info -
 * that separate column was squeezing/overlapping the address, phone, and
 * email lines on narrower widths ("style break"). Keeping everything in
 * one column with .xsl-store-info avoids that entirely.
 */
.xsl-store-title-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	margin: 0 0 3px;
}
.xsl-store-name {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: var( --xsl-heading );
}
.xsl-store-address {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	margin: 0 0 4px;
	font-size: 13px;
	color: var( --xsl-text-light );
	line-height: 1.4;
}
.xsl-store-address svg {
	width: 13px;
	height: 13px;
	flex-shrink: 0;
	margin-top: 2px;
	color: var( --xsl-text-light );
}
.xsl-store-meta {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	font-size: 12px;
}
.xsl-distance-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: 999px;
	background: #eef2ff;
	color: var( --xsl-accent );
	font-weight: 600;
}

/* "Open - Closes 6:00 PM" / "Closed - Opens 9:00 AM" status, shown in
   both the list card meta row and the map popup. */
.xsl-open-status {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-weight: 600;
}
.xsl-open-status.is-open {
	color: #16a34a;
}
.xsl-open-status.is-closed {
	color: #dc2626;
}
.xsl-open-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	flex-shrink: 0;
}
.xsl-popup .xsl-open-status {
	margin-bottom: 6px;
	font-size: 12px;
}

/* Small round icon-only action buttons (Visit Page / Directions), used
   in both the list card and repeated (as labeled buttons) in the popup. */
.xsl-icon-btn {
	width: 26px;
	height: 26px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: #f3f4f6;
	color: var( --xsl-text-light );
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.xsl-icon-btn svg {
	width: 14px;
	height: 14px;
}
.xsl-icon-btn:hover {
	background: #e5e7eb;
}
.xsl-icon-btn svg {
	width: 16px;
	height: 16px;
}
.xsl-icon-btn-accent {
	background: color-mix( in srgb, var( --xsl-accent ) 12%, #fff );
	color: var( --xsl-accent );
}
.xsl-icon-btn-accent:hover {
	background: color-mix( in srgb, var( --xsl-accent ) 22%, #fff );
}

.xsl-store-actions {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

/* Leaflet popup content */
.xsl-popup {
	font-family: inherit;
	min-width: 220px;
}
.xsl-popup-image {
	width: 100%;
	height: 110px;
	object-fit: cover;
	border-radius: 8px;
	margin-bottom: 8px;
}
.xsl-popup h3 {
	margin: 0 0 4px;
	font-size: 14px;
	color: var( --xsl-heading );
}
.xsl-popup p {
	margin: 0 0 6px;
	font-size: 12px;
	color: var( --xsl-text-light );
}
.xsl-popup-line {
	display: flex;
	align-items: flex-start;
	gap: 6px;
}
.xsl-popup-line svg {
	width: 13px;
	height: 13px;
	flex-shrink: 0;
	margin-top: 1px;
	color: var( --xsl-text-light );
}
.xsl-popup-line a {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	color: var( --xsl-text-light );
	text-decoration: none;
}
.xsl-popup-line a:hover {
	color: var( --xsl-accent );
}
.xsl-popup-line a:hover svg {
	color: var( --xsl-accent );
}
.xsl-popup-actions {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}
.xsl-popup-actions .xsl-btn {
	flex: 1;
}
.xsl-popup-actions .xsl-btn svg {
	width: 14px;
	height: 14px;
}
.xsl-popup .xsl-btn {
	padding: 6px 12px;
	font-size: 12px;
}

/* Custom Leaflet marker (icon or fallback pin) */
.xsl-marker-icon {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var( --xsl-secondary );
	border: 2px solid #fff;
	box-shadow: 0 2px 6px rgba( 0, 0, 0, 0.25 );
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.xsl-marker-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Store name label, permanently floating above each marker icon
   (overrides Leaflet's default tooltip look: no arrow, our own box). */
.xsl-locator .leaflet-tooltip.xsl-marker-label {
	background: #fff;
	color: #111827;
	border: 1px solid var( --xsl-border );
	border-radius: 6px;
	padding: 3px 9px;
	font-size: 12px;
	font-weight: 600;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.15 );
	white-space: nowrap;
}
.xsl-locator .leaflet-tooltip.xsl-marker-label::before {
	display: none;
}

/*
 * Mobile: the sidebar store list becomes a full-page slide-in drawer that
 * covers the entire locator (not just a partial-width panel) over the
 * map, opened with the location-pin button and closed via its own close
 * button, the backdrop, or picking a store (frontend.js toggles
 * .xsl-drawer-open on #xsl-locator).
 */
@media ( max-width: 782px ) {
	.xsl-body {
		position: relative;
		overflow: hidden;
	}
	.xsl-map {
		min-height: 70vh;
	}
	/* Leaflet's own panes/controls use internal z-indexes in the many
	   hundreds. Without this, those inner layers aren't contained to a
	   stacking context of their own and end up painting ABOVE our
	   higher-numbered sidebar/backdrop siblings, hiding the drawer
	   completely even though its CSS transform is correctly applied. */
	.xsl-map-wrap {
		z-index: 1;
	}

	.xsl-menu-toggle {
		display: inline-flex;
	}

	.xsl-sidebar {
		position: absolute;
		top: 0;
		left: 0;
		z-index: 9999;
		width: 100%;
		height: 100%;
		max-height: none;
		background: #fff;
		border-right: none;
		box-shadow: 4px 0 20px rgba( 0, 0, 0, 0.18 );
		transform: translateX( -100% );
		transition: transform 0.3s ease;
	}
	.xsl-locator.xsl-drawer-open .xsl-sidebar {
		transform: translateX( 0 );
	}

	.xsl-sidebar-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 14px 16px;
		font-size: 14px;
		font-weight: 600;
		color: var( --xsl-heading );
		border-bottom: 1px solid var( --xsl-border );
	}
	.xsl-sidebar-close {
		width: 32px;
		height: 32px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: none;
		border: none;
		font-size: 22px;
		line-height: 1;
		color: var( --xsl-text-light );
		cursor: pointer;
	}

	.xsl-sidebar-backdrop {
		display: block;
		position: absolute;
		inset: 0;
		z-index: 25;
		background: rgba( 17, 24, 39, 0.45 );
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.3s ease;
	}
	.xsl-locator.xsl-drawer-open .xsl-sidebar-backdrop {
		opacity: 1;
		pointer-events: auto;
	}

	/* Toolbar: hamburger + locate button share the first row, search
	   drops to its own full-width row underneath. */
	.xsl-toolbar {
		flex-wrap: wrap;
	}
	.xsl-search-form {
		max-width: none;
		flex-basis: 100%;
		order: 3;
	}

	/* Touch-friendly sizing: comfortably tappable targets, and 16px input
	   font-size stops iOS Safari from auto-zooming in on focus. */
	.xsl-locator .xsl-btn,
	.xsl-locator .xsl-input,
	.xsl-locator .xsl-select,
	.xsl-locator .xsl-custom-select-trigger {
		min-height: 44px;
		font-size: 16px;
	}
	.xsl-locate-label {
		font-size: 14px;
	}
	.xsl-store-card {
		padding: 14px 16px;
	}

	/* Store selector bar: stack the store dropdown, radius dropdown, and
	   Make/Change buttons into full-width rows instead of a cramped line. */
	.xsl-select-bar {
		flex-direction: column;
		align-items: stretch;
	}
	.xsl-select-field {
		min-width: 0;
	}
	.xsl-select-bar .xsl-btn {
		width: 100%;
	}
}
