/* GATE Store Interactive Map Styles */

/* Map Container */
#gate-map {
	width: 100%;
	height: 600px;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	margin-bottom: 20px;
}

/* Map Controls */
.maplibregl-ctrl-group {
	border: none !important;
	border-radius: 4px !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.maplibregl-ctrl-group button {
	background: #fff !important;
	color: #333 !important;
	border: 1px solid #ddd !important;
	font-weight: bold !important;
	width: 30px;
	height: 30px;
}

.maplibregl-ctrl-group button:hover {
	background: #f8f9fa !important;
}

/* MapLibre draws its control glyphs as SVG background images, so recolour them rather
   than the text. */
.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
	filter: none;
}

/* Custom Markers */
/* MapLibre markers are plain DOM elements it positions with a transform, so the marker
   styling below is unchanged from the Leaflet divIcon it replaced. */
.custom-marker {
	background: transparent !important;
	border: none !important;
	width: 25px;
	height: 25px;
	line-height: 0;
	cursor: pointer;
}

.marker-inner {
	width: 25px;
	height: 25px;
	border-radius: 50%;
	border: 3px solid #fff;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
	position: relative;
	transition: all 0.2s ease;
}

.marker-inner:hover {
	transform: scale(1.1);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Marker Types - All Red */
.marker-default .marker-inner,
.marker-diesel .marker-inner,
.marker-fresh-kitchen .marker-inner,
.marker-car-wash .marker-inner,
.marker-fresh-kitchen-car-wash .marker-inner {
	background: linear-gradient(135deg, #ce0e2d, #a00b24);
}

/* Filter Container */
#map-controls {
	background: #fff;
	padding: 20px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	margin-bottom: 20px;
}

#map-controls h3 {
	margin: 0 0 15px 0;
	color: #333;
	font-size: 18px;
	font-weight: 600;
	display: flex;
	justify-content: space-between;
	align-items: center;
	min-height: 35px;
}

#map-controls h3 #clear-filter-btn {
	margin: 0;
	font-size: 14px;
	padding: 6px 16px;
}

/* Category Filters */
#category-filters {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 15px;
}

#category-filters .filter-categories-wrapper {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 15px;
}

#category-filters .filter-category-column {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.filter-section-header {
	margin: 0 0 8px 0;
	color: #495057;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.5px;
	background: #f8f9fa;
	padding: 12px 16px;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: flex;
	justify-content: space-between;
	align-items: center;
	user-select: none;
}

.filter-section-header:hover {
	background: #e9ecef;
}

.filter-section-header::after {
	content: "▼";
	font-size: 12px;
	transition: transform 0.2s ease;
}

.filter-section-header.collapsed::after {
	transform: rotate(-90deg);
}

.filter-section {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 0 12px 0;
	max-height: 500px;
	overflow: hidden;
	transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
	opacity: 1;
}

.filter-section.collapsed {
	max-height: 0;
	padding: 0;
	opacity: 0;
}

.filter-btn {
	padding: 8px 16px;
	border: 2px solid #e9ecef;
	background: #fff;
	color: #495057;
	border-radius: 20px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.filter-btn:hover {
	border-color: #ce0e2d;
	color: #ce0e2d;
}

.filter-btn.active,
.filter-btn.fuel-filter.active,
.filter-btn.service-filter.active,
.filter-btn.state-filter.active {
	background: #ce0e2d;
	border-color: #ce0e2d;
	color: #fff;
	box-shadow: 0 2px 8px rgba(206, 14, 45, 0.3);
}

.filter-btn.fuel-filter:hover,
.filter-btn.service-filter:hover,
.filter-btn.state-filter:hover {
	border-color: #ce0e2d;
	color: #ce0e2d;
}

.filter-btn.active:hover,
.filter-btn.fuel-filter.active:hover,
.filter-btn.service-filter.active,
:hover .filter-btn.state-filter.active:hover {
	color: #fff;
}

/* Store Count */
#store-count {
	font-size: 14px;
	color: #6c757d;
	font-weight: 500;
	margin: 0;
}

/* Popup Styles */
.store-popup {
	min-width: 250px;
	padding: 5px;
}

.store-popup h3 {
	margin: 0 0 10px 0;
	color: #ce0e2d;
	font-size: 16px;
	font-weight: 600;
	border-bottom: 2px solid #e9ecef;
	padding-bottom: 5px;
}

.store-popup p {
	margin: 5px 0;
	font-size: 14px;
	line-height: 1.4;
}

.store-popup strong {
	color: #495057;
}

.store-popup a {
	color: #495057;
	text-decoration: none;
}

.store-popup a:hover {
	border-bottom-style: solid;
	color: #a00b24;
}

/* Responsive Design */
@media (max-width: 768px) {
	#gate-map {
		height: 400px;
	}

	#map-controls {
		padding: 15px;
	}

	#category-filters .filter-categories-wrapper {
		grid-template-columns: 1fr;
		gap: 10px;
	}

	.filter-btn {
		padding: 6px 12px;
		font-size: 13px;
	}

	.store-popup {
		min-width: 200px;
	}
}

@media (max-width: 480px) {
	#gate-map {
		height: 350px;
	}

	.filter-btn {
		padding: 6px 12px;
		font-size: 13px;
	}
}

/* Loading State */
.map-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 200px;
	color: #6c757d;
	font-style: italic;
}

/* Error State */
.map-error {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 200px;
	color: #dc3545;
	font-weight: 500;
	text-align: center;
	padding: 20px;
}

/* MapLibre Popup Customization */
.maplibregl-popup-content {
	border-radius: 8px !important;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
	/* .store-popup supplies its own padding. */
	padding: 0 !important;
}

.maplibregl-popup-close-button {
	width: 26px;
	height: 26px;
	font-size: 18px;
	line-height: 1;
	color: #6c757d;
	border-radius: 0 8px 0 8px;
	background: transparent;
}

.maplibregl-popup-close-button:hover {
	background: #f8f9fa;
	color: #ce0e2d;
}

/* The tip is a CSS triangle, so it takes a border colour rather than a background. */
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
	border-bottom-color: #fff;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
	border-top-color: #fff;
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
	border-right-color: #fff;
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
	border-left-color: #fff;
}

/* Map Attribution */
/* Attribution for CARTO and OpenStreetMap must stay legible, it is a condition of
   CARTO's free tier. */
.maplibregl-ctrl-attrib {
	background: rgba(255, 255, 255, 0.8) !important;
	font-size: 11px !important;
	padding: 4px 8px !important;
}

.maplibregl-ctrl-attrib a {
	color: #495057;
}

/* Zoom Controls on Mobile */
@media (max-width: 768px) {
	.maplibregl-ctrl-top-left .maplibregl-ctrl-group {
		transform: scale(0.9);
		transform-origin: top left;
	}
}

/* Store Directory */
.store-directory {
	margin-top: 30px;
}

.store-directory h3 {
	margin: 0 0 20px 0;
	color: #ce0e2d;
	font-size: 20px;
	font-weight: 600;
}

/* Store Table */
.store-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.store-table tr {
	border-bottom: 1px solid #e0e0e0;
	transition: background-color 0.2s ease;
	cursor: pointer;
}

.store-table tr:hover {
	background-color: #f5f5f5;
}

.store-table tr:active {
	background-color: #ececec;
}

.store-table td {
	padding: 14px 12px;
	vertical-align: middle;
}

.store-table .store-name {
	font-weight: 600;
	color: #ce0e2d;
	width: 25%;
}

.store-table .address {
	width: 55%;
	color: #333;
}

.store-table .phone {
	white-space: nowrap;
	width: 20%;
	color: #666;
}

/* Clickable links in table */
.store-table a {
	color: inherit;
	text-decoration: none;
}

.store-table a:hover {
	color: #ce0e2d;
	border-bottom-style: solid;
}

.store-table .phone a:hover {
	color: #ce0e2d;
}

/* Loading State */
.list-loading {
	padding: 40px;
	text-align: center;
	color: #666;
	font-size: 16px;
}

/* Responsive Table */
@media (max-width: 1200px) {
	.store-table {
		font-size: 13px;
	}

	.store-table td {
		padding: 12px 10px;
	}

	.store-table .store-name {
		width: 30%;
	}

	.store-table .address {
		width: 50%;
	}

	.store-table .phone {
		width: 20%;
	}
}

/* Tablet */
@media (max-width: 768px) {
	.store-directory {
		margin-top: 20px;
		padding-top: 20px;
	}

	.store-directory h3 {
		font-size: 18px;
	}

	.store-table {
		font-size: 13px;
	}

	.store-table td {
		padding: 10px 8px;
	}

	.store-table .store-name {
		width: 35%;
	}

	.store-table .address {
		width: 45%;
		font-size: 12px;
	}

	.store-table .phone {
		width: 20%;
		font-size: 12px;
	}
}

/* Mobile - Card Layout */
@media (max-width: 600px) {
	.store-directory {
		margin-top: 20px;
		padding-top: 20px;
	}

	.store-directory h3 {
		font-size: 16px;
		margin-bottom: 15px;
	}

	/* Card layout for mobile */
	.store-table,
	.store-table tr {
		display: block;
		width: 100%;
	}

	.store-table tr {
		margin-bottom: 15px;
		border: 1px solid #e0e0e0;
		border-radius: 8px;
		padding: 15px;
		background: white;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	}

	.store-table tr:hover {
		background-color: #fafafa;
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	}

	.store-table td {
		display: block;
		width: 100%;
		padding: 5px 0;
		border: none;
		text-align: left;
	}

	.store-table .store-name {
		font-size: 16px;
		font-weight: 700;
		margin-bottom: 8px;
		padding-bottom: 8px;
		border-bottom: 2px solid #ce0e2d;
		width: 100%;
	}

	.store-table .address {
		font-size: 14px;
		color: #555;
		margin-bottom: 8px;
		line-height: 1.4;
		width: 100%;
	}

	.store-table .address:before {
		content: "📍 ";
		opacity: 0.7;
	}

	.store-table .phone {
		font-size: 14px;
		color: #ce0e2d;
		font-weight: 500;
		white-space: normal;
		width: 100%;
	}

	.store-table .phone:before {
		content: "📞 ";
		opacity: 0.7;
	}
}
