:root {
	--bg: #ffffff;
	--ink: #1d2733;
	--ink-soft: #5b6878;
	--line: #e7ebf0;
	--accent: #e8505b;
	--accent-ink: #ffffff;
	--shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
	--shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
	--radius: 12px;
	--topbar-h: 60px;
	--sidebar-w: 392px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	color: var(--ink);
	background: var(--bg);
	overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
	height: var(--topbar-h);
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 0 18px;
	border-bottom: 1px solid var(--line);
	background: #fff;
	position: relative;
	z-index: 1100;
}

.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.brand-dot {
	width: 14px; height: 14px; border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 0 4px rgba(232, 80, 91, .15);
}
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -.4px; }

/* Zona central: alterna entre la fila de filtros y la caja de busqueda */
.topbar-center {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
}
.filters-bar,
.search-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-width: 0;
}
.filters-bar[hidden],
.search-bar[hidden] { display: none; }

.icon-btn {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--ink-soft);
	border-radius: 50%;
	cursor: pointer;
	transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.search {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	max-width: 560px;
	display: flex;
	align-items: center;
}
.search-icon {
	position: absolute;
	left: 12px;
	color: var(--ink-soft);
	pointer-events: none;
}
.search input {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 8px 32px 8px 36px;
	font-size: 14px;
	font-family: inherit;
	color: var(--ink);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-soft); }
.search input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(232, 80, 91, .12);
}
.search-clear {
	position: absolute;
	right: 8px;
	width: 20px;
	height: 20px;
	border: none;
	background: var(--line);
	color: var(--ink);
	border-radius: 50%;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.search-clear:hover { background: #d4dae2; }

.filters {
	display: flex;
	align-items: center;
	gap: 8px;
	overflow-x: auto;
	flex: 1 1 auto;
	scrollbar-width: thin;
	padding: 4px 0;
}
.filters::-webkit-scrollbar { height: 4px; }
.filters::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.chip {
	--chip-color: var(--ink-soft);
	flex: 0 0 auto;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--ink);
	padding: 7px 14px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--chip-color); }
.chip--active {
	background: var(--chip-color);
	border-color: var(--chip-color);
	color: #fff;
}
.chip[data-category=""].chip--active { background: var(--ink); border-color: var(--ink); }

.topbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.toggle {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--ink-soft);
	cursor: pointer;
	user-select: none;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.near-btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	flex: 0 0 auto;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--ink);
	padding: 7px 13px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s, border-color .15s, color .15s;
}
.near-btn:hover { border-color: var(--accent); }
.near-btn--active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
.near-btn--loading { opacity: .6; pointer-events: none; }

.radius-select {
	flex: 0 0 auto;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--ink);
	padding: 7px 10px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
}

/* ---------- Layout ---------- */
.app {
	display: flex;
	height: calc(100vh - var(--topbar-h));
}

.sidebar {
	width: var(--sidebar-w);
	flex: 0 0 var(--sidebar-w);
	border-right: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	background: #fff;
}
.sidebar-head {
	padding: 14px 18px 10px;
	border-bottom: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.sidebar-head strong { font-size: 15px; }
.sidebar-sub { font-size: 12.5px; color: var(--ink-soft); }
.sidebar-head-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
/* Rango de fechas libre (inputs de calendario nativos) */
.date-filter {
	display: flex;
	gap: 8px;
	margin: 9px 0 3px;
}
.date-field {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}
.date-field span {
	font-size: 10.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .4px;
	color: var(--ink-soft);
}
.date-field input {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 6px 8px;
	font-size: 13px;
	font-family: inherit;
	color: var(--ink);
	background: #fff;
	cursor: pointer;
}
.date-field input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(232, 80, 91, .12);
}
/* Un extremo con fecha puesta se destaca. */
.date-field input.is-active { border-color: var(--accent); color: var(--accent); }

.date-clear {
	flex: 0 0 auto;
	border: none;
	background: none;
	color: var(--accent);
	font-size: 12.5px;
	font-weight: 700;
	cursor: pointer;
	padding: 2px 0;
	white-space: nowrap;
}
.date-clear:hover { text-decoration: underline; }

.cards {
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* ---------- Card ---------- */
.card {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 13px 14px;
	cursor: pointer;
	transition: box-shadow .15s, border-color .15s, transform .05s;
	background: #fff;
}
.card:hover, .card--hover {
	box-shadow: var(--shadow);
	border-color: #d4dae2;
}
.card--active {
	border-color: var(--accent);
	box-shadow: 0 0 0 2px rgba(232, 80, 91, .15);
}
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.tag {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .3px;
	color: #fff;
	padding: 3px 8px;
	border-radius: 6px;
}
.card-date { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.card-title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	margin: 0 0 6px;
	letter-spacing: -.2px;
}
.card-meta { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.price { font-size: 14px; font-weight: 700; }
.price--free { color: #2a9d8f; }
.card-dist {
	font-size: 12.5px;
	font-weight: 700;
	color: var(--accent);
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

/* Marcador "tu posicion" (punto azul estilo mapa) */
.my-location {
	width: 18px; height: 18px;
	border-radius: 50%;
	background: #1a73e8;
	border: 3px solid #fff;
	box-shadow: 0 0 0 4px rgba(26, 115, 232, .25), 0 1px 4px rgba(0, 0, 0, .3);
}

.cards-empty {
	text-align: center;
	color: var(--ink-soft);
	padding: 40px 20px;
	font-size: 14px;
}

/* ---------- Map ---------- */
.map-wrap { flex: 1 1 auto; position: relative; }
#map { position: absolute; inset: 0; background: #eef1f5; }

/* Boton "Buscar en esta zona" (aparece al mover/zoom el mapa) */
.search-area {
	position: absolute;
	top: 14px;
	left: 50%;
	z-index: 1000;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 9px 16px;
	background: #fff;
	color: var(--ink);
	border: 1px solid var(--line);
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	box-shadow: var(--shadow-lg);
	/* Oculto por defecto; .is-visible lo muestra con una pequena animacion. */
	opacity: 0;
	pointer-events: none;
	transform: translateX(-50%) translateY(-8px);
	transition: opacity .18s ease, transform .18s ease;
}
.search-area.is-visible {
	opacity: 1;
	pointer-events: auto;
	transform: translateX(-50%) translateY(0);
}
.search-area:hover { background: #f7f8fa; }
.search-area svg { color: var(--accent); }

/* Marcadores propios (divIcon) */
.evt-marker {
	width: 16px; height: 16px;
	border-radius: 50%;
	border: 2.5px solid #fff;
	box-shadow: 0 1px 4px rgba(16, 24, 40, .35);
	transition: transform .12s;
}
.evt-marker--active { transform: scale(1.5); z-index: 1000; }

/* Clusters */
.evt-cluster {
	background: var(--accent);
	color: #fff;
	border: 3px solid #fff;
	border-radius: 50%;
	box-shadow: var(--shadow-lg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 13px;
}

/* Popup */
.leaflet-popup-content { margin: 12px 14px; }
.popup-title { font-weight: 700; font-size: 14px; margin: 0 0 4px; }
.popup-meta { font-size: 12.5px; color: var(--ink-soft); }
.popup-link {
	display: inline-block;
	margin-top: 8px;
	color: var(--accent);
	font-weight: 700;
	font-size: 13px;
	text-decoration: none;
}

/* ---------- Responsive ---------- */
/* En pantallas pequenas compactamos la barra para que los chips respiren:
   "Cerca de mi" pasa a solo icono y se reducen huecos. */
@media (max-width: 640px) {
	.topbar { gap: 10px; padding: 0 12px; }
	.topbar-actions { gap: 8px; }
	.near-btn-label { display: none; }
	.near-btn { padding: 7px 9px; }
}

@media (max-width: 820px) {
	:root { --sidebar-w: 100%; }
	.app { flex-direction: column-reverse; }
	.sidebar {
		flex: 0 0 45%;
		height: 45%;
		border-right: none;
		border-top: 1px solid var(--line);
	}
	.map-wrap { flex: 1 1 55%; }
	.brand-name { display: none; }
}
