/* ── Locations — Header button ───────────────────────────────────────────── */

#app-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 200;
	padding: 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	pointer-events: none;
	max-width: 620px;
	margin: 0 auto;
}

#btn-locations,
#btn-share {
	pointer-events: auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
}

#btn-locations:active,
#btn-share:active {
	background: #f0f0f0;
}

#btn-locations svg,
#btn-share svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* ── Share panel ─────────────────────────────────────────────────────────────── */

#share-panel {
	position: fixed;
	inset: 0;
	z-index: 250;
	display: none;
	pointer-events: none;
}

#share-panel.is-open {
	display: block;
	pointer-events: auto;
}

#share-backdrop {
	position: absolute;
	inset: 0;
}

#share-card {
	position: absolute;
	top: 68px;
	right: 12px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
	padding: 14px 16px;
	width: min(320px, calc(100vw - 24px));
}

#share-label {
	font-size: 0.8em;
	font-weight: 600;
	color: #888;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin: 0 0 10px;
}

#share-url-row {
	display: flex;
	gap: 8px;
	align-items: center;
}

#share-url {
	flex: 1;
	min-width: 0;
	padding: 8px 10px;
	border: 1px solid #ddd;
	border-radius: 8px;
	font-size: 0.85em;
	background: #f5f5f5;
	color: #333;
	outline: none;
	cursor: default;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#btn-copy-link {
	flex-shrink: 0;
	padding: 8px 14px;
	border: none;
	border-radius: 8px;
	background: #007aff;
	color: #fff;
	font-size: 0.9em;
	font-weight: 600;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

#btn-copy-link:active {
	background: #005ecb;
}

#btn-copy-link.is-copied {
	background: #34c759;
}

/* ── Locations — Overlay ────────────────────────────────────────────────────── */

#locations-overlay {
	max-width: 620px;
	position: fixed;
	inset: 0;
	z-index: 300;
	display: none;
	pointer-events: none;
	margin: 0 auto;
}

#locations-overlay.is-open {
	display: block;
	pointer-events: auto;
}

/* Dimmed backdrop — tap to close */
#locations-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	transition: opacity 0.25s ease;
}

#locations-overlay.is-open #locations-backdrop {
	opacity: 1;
}

/* Slide-up panel */
#locations-panel {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 90%;
	background: #fff;
	border-radius: 16px 16px 0 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: translateY(100%);
	transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

#locations-overlay.is-open #locations-panel {
	transform: translateY(0);
}

/* ── Locations — Panel header ───────────────────────────────────────────────── */

#locations-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 16px 12px;
	border-bottom: 1px solid #eee;
	flex-shrink: 0;
}

#locations-header h2 {
	font-size: 1.1em;
	font-weight: 600;
	margin: 0;
	flex: 1;
	text-align: center;
}

#btn-close-locations,
#btn-edit-locations {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 1.1em;
	font-weight: 600;
	color: #007aff;
	padding: 4px 6px;
	border-radius: 6px;
	min-width: 48px;
	-webkit-tap-highlight-color: transparent;
}

#btn-close-locations {
	font-size: 1.3em;
	color: #555;
	text-align: left;
}

#btn-close-locations:active,
#btn-edit-locations:active {
	background: rgba(0, 122, 255, 0.1);
}

/* ── Locations — List ───────────────────────────────────────────────────────── */

#locations-list {
	list-style: none;
	overflow-y: auto;
	flex: 1;
	padding: 0;
	margin: 0;
}

.location-item {
	display: flex;
	align-items: center;
	padding: 0 16px;
	min-height: 52px;
	border-bottom: 1px solid #f0f0f0;
	gap: 10px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.1s;
}

.location-item:active {
	background: #f5f5f5;
}

.location-name {
	flex: 1;
	font-size: 1.2em;
	font-weight: 500;
}

/* Drag handle — hidden until edit mode */
.drag-handle {
	display: none;
	color: #aaa;
	font-size: 1.1em;
	cursor: grab;
	padding: 4px;
	touch-action: none;
}

/* Delete button — hidden until edit mode */
.delete-btn {
	display: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: none;
	background: #e53935;
	color: #fff;
	font-size: 0.95em;
	line-height: 1;
	cursor: pointer;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
}

/* Edit mode: reveal drag handles and delete buttons */
#locations-list.edit-mode .drag-handle {
	display: flex;
}

#locations-list.edit-mode .delete-btn {
	display: flex;
}

#locations-list.edit-mode .location-item {
	cursor: default;
}

/* SortableJS ghost + chosen states */
.location-item.sortable-ghost {
	opacity: 0.4;
}

.location-item.sortable-chosen {
	background: #f0f6ff;
}

/* ── Locations — Search bar ─────────────────────────────────────────────────── */

#locations-search-bar {
	flex-shrink: 0;
	padding: 12px 16px;
	border-top: 1px solid #eee;
	background: #fff;
	position: relative;
}

#search-input {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 22px;
	font-size: 16px;
	/* must be ≥16px to prevent iOS Safari auto-zoom on focus */
	background: #f5f5f5;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

#search-input:focus {
	border-color: #007aff;
	background: #fff;
}

/* Search results dropdown — positioned above the search bar */
#search-results {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: calc(100% + 4px);
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 12px;
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
	list-style: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	z-index: 10;
}

#search-results[hidden] {
	display: none;
}

.search-result-item {
	padding: 12px 16px;
	cursor: pointer;
	border-bottom: 1px solid #f0f0f0;
	font-size: 0.95em;
	-webkit-tap-highlight-color: transparent;
}

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

.search-result-item:active {
	background: #f0f6ff;
}

.search-result-empty {
	padding: 12px 16px;
	color: #999;
	font-size: 0.9em;
	text-align: center;
}

/* ── Footer refresh link ─────────────────────────────────────────────────────── */

.footer-refresh {
	margin-top: 0.5em;
}

.footer-link-btn {
	background: none;
	border: none;
	padding: 0;
	font-size: inherit;
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
	opacity: 0.7;
	-webkit-tap-highlight-color: transparent;
}

.footer-link-btn:active {
	opacity: 1;
}