/* Global styles */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

/* MapLibre Controls */
.maplibregl-ctrl-group {
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.add-location-control {
	width: 30px;
	height: 30px;
	background: none;
	border: 0;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #333;
}

.add-location-control span {
	font-size: 20px;
	font-weight: bold;
	line-height: 1;
}

.add-location-control:hover {
	background-color: rgba(0, 0, 0, 0.05);
}

/* MapLibre Customizations */
.maplibregl-ctrl-scale {
	display: none;
}

/* Header buttons layout */
.header-buttons {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-left: auto;
}

.sidebar-header {
	display: flex;
	align-items: center;
	padding: 16px;
	position: sticky;
	top: 0;
	z-index: 10;
}

.sidebar-header h2 {
	font-size: 1.25rem;
	color: #2d3748;
	font-weight: 600;
	margin: 0;
	flex: 1;
}

.edit-button,
.close-button {
	width: 28px;
	height: 28px;
	background: none;
	border: 2px solid #4a5568;
	border-radius: 6px;
	color: #4a5568;
	font-size: 13px;
	font-weight: bold;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: all 0.2s ease;
	position: relative;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
	font-family:
		system-ui,
		-apple-system,
		sans-serif;
}

.close-button {
	font-size: 16px;
	line-height: 1;
	padding-bottom: 2px;
}

.edit-button:before,
.close-button:before {
	content: "";
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.3), transparent);
	transition: 0.5s;
}

.edit-button:hover,
.close-button:hover {
	background: #4a5568;
	color: white;
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.edit-button:hover:before,
.close-button:hover:before {
	left: 100%;
}

.edit-button:active,
.close-button:active {
	transform: translateY(1px);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Mobile optimizations */
body {
	overscroll-behavior: none;
}

.touch-device {
	-webkit-overflow-scrolling: touch;
}

/* Responsive adjustments */
@media (max-width: 768px) {
	.edit-button,
	.close-button {
		width: 24px;
		height: 24px;
		font-size: 11px;
		border-width: 1.5px;
		line-height: 1;
	}

	.close-button {
		font-size: 13px;
		padding-bottom: 1px;
	}

	.header-buttons {
		gap: 6px;
	}

	.sidebar-header {
		padding: 12px;
	}

	.sidebar-header h2 {
		font-size: 1.1rem;
	}
}

:root {
	--sheet-width: 100%;
	--button-size: 48px;
	--safe-area-inset-top: env(safe-area-inset-top, 0px);
	--safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 768px) {
	:root {
		--sheet-width: 400px;
	}
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Date slider control */
.date-slider-control {
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
	padding: 8px 12px;
	min-width: 200px;
}

.date-slider-container {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: center;
}

.date-slider-label {
	font-size: 12px;
	font-weight: 600;
	color: #333;
	text-align: center;
	min-height: 16px;
}

.date-slider {
	width: 100%;
	height: 4px;
	background: #ddd;
	border-radius: 2px;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.date-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	background: #f87221;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid white;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.date-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	background: #f87221;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid white;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.container {
	display: flex;
	width: 100%;
	height: 100vh;
}

/* Map styles */
#map {
	flex: 1;
	height: 100vh;
}

/* Sidebar styles */
.sidebar {
	width: var(--sheet-width);
	height: 100vh;
	background: white;
	position: fixed;
	right: 0;
	top: 0;
	box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
	transition: transform 0.3s ease-in-out;
	overflow-y: auto;
	transform: translateX(0);
	will-change: transform;
	z-index: 2000;
}

.sidebar.hidden {
	transform: translateX(100%);
}

.sidebar-header {
	padding: 20px 20px 0px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.sidebar-content {
	padding: 20px;
}

/* All close buttons share the base styles defined above */
.sheet-header .close-button {
	margin: -4px -4px -4px 0;
	width: 28px;
	height: 28px;
}

/* Hover styles already defined in shared button styles above */

/* Task filter tabs */
.task-filter-tabs {
	display: flex;
	gap: 8px;
	margin: 16px 0;
	padding: 0 16px;
}

.tab-button {
	flex: 1;
	padding: 8px 16px;
	border: 1px solid #e2e8f0;
	background: white;
	color: #4a5568;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	text-align: center;
}

.tab-button:hover {
	background: #f7fafc;
	border-color: #cbd5e0;
}

/* Form styles */
input[type="text"],
input[type="date"],
textarea,
select {
	width: 100%;
	padding: 10px;
	margin-bottom: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
}

textarea {
	height: 100px;
	resize: vertical;
}

.radio-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 8px;
}

.radio-label {
	display: flex;
	align-items: center;
	cursor: pointer;
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	transition:
		background-color 0.2s,
		border-color 0.2s;
}

.radio-label:hover {
	background-color: #f5f5f5;
	border-color: #bbb;
}

.radio-label input[type="radio"] {
	margin: 0 8px 0 0;
	cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
	font-weight: 500;
	color: #333;
}

.radio-label.active {
	background-color: #e3f2fd;
	border-color: #2196f3;
}

.completion-preview {
	display: block;
	color: #666;
	font-style: italic;
	margin-top: 5px;
	font-size: 13px;
}

.button {
	background: #f87221;
	color: white;
	padding: 10px 20px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
}

.button:hover {
	background: #dd661d;
}

.button-success {
	background: #65ab48;
}

.button-success:hover {
	background: #558f3c;
}

/* Task list styles */
#tasks-list {
	margin: 20px 0;
}

.task-item {
	padding: 12px;
	border: 1px solid #ddd;
	border-radius: 8px;
	margin-bottom: 8px;
	background: #fff;
	cursor: pointer;
	transition: all 0.2s ease;
}

.task-item:hover {
	background: #f8f9fa;
	border-color: #4caf50;
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.task-item.inactive {
	opacity: 0.7;
	background: #f1f3f4;
	border-color: #e9ecef;
}

.task-item.inactive .task-title {
	color: #6c757d;
}

.task-item.inactive:hover {
	background: #e9ecef;
	border-color: #6c757d;
}

.task-item.active {
	background: #fff3cd;
	border-color: #ffeaa7;
}

.task-item.active .task-title {
	color: #856404;
}

.task-item.active:hover {
	background: #ffeaa7;
	border-color: #ffc236;
}

.task-item.completed {
	background: #ebf5e9;
	border-color: #a5d68d;
}

.task-item.completed .task-title {
	color: #2c5a1e;
}

.task-item.completed:hover {
	background: #d4edda;
	border-color: #65ab48;
}

.task-item.postponed {
	background: #fff3cd;
	border-color: #ffeaa7;
}

.task-item.postponed .task-title {
	color: #856404;
}

.task-item.postponed:hover {
	background: #ffeaa7;
	border-color: #fd7e14;
}

.task-item.canceled {
	background: #f8d7da;
	border-color: #f5c6cb;
}

.task-item.canceled .task-title {
	color: #721c24;
}

.task-item.canceled:hover {
	background: #f5c6cb;
	border-color: #dc3545;
}

.task-item.previous {
	background: #e2e3e5;
	border-color: #d6d8db;
}

.task-item.previous .task-title {
	color: #495057;
}

.task-item.previous:hover {
	background: #d6d8db;
	border-color: #6c757d;
}

.task-content {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.task-text {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.task-title {
	font-weight: 600;
	font-size: 16px;
	color: #333;
	line-height: 1.3;
}

.task-meta {
	color: #666;
	font-size: 12px;
	line-height: 1.2;
}

.task-status {
	font-size: 12px;
	padding: 3px 8px;
	border-radius: 12px;
	background: #e9ecef;
}

.status-dot {
	font-size: 18px;
	line-height: 1;
	margin-top: 2px;
}

.status-dot.completed {
	color: #65ab48;
}

.status-dot.active {
	color: #ffc236;
}

.status-dot.inactive {
	color: #6c757d;
}

.status-dot.postponed {
	color: #fd7e14;
}

.status-dot.canceled {
	color: #dc3545;
}

.status-dot.previous {
	color: #6c757d;
}

/* Location marker styles */
.marker {
	border-radius: 50%;
	cursor: pointer;
	width: 24px;
	height: 24px;
	border: 3px solid white;
	box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
	transform-origin: center center;
	display: block;
}

.marker::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 8px;
	height: 8px;
	background-color: white;
	border-radius: 50%;
	transform-origin: center center;
}

/* Marker with active tasks (blue) */
.marker-active {
	background-color: #ffc236;
}

.marker-active:hover {
	background-color: #e6af31;
	transform: scale(1.2) translate(0, 0);
	box-shadow: 0 0 12px rgba(255, 194, 54, 0.6);
}

/* Marker with no active tasks (green) */
.marker-no-tasks {
	background-color: #65ab48;
}

.marker-no-tasks:hover {
	background-color: #558f3c;
	transform: scale(1.2) translate(0, 0);
	box-shadow: 0 0 12px rgba(101, 171, 72, 0.6);
}

/* Maintenance info styles */
#maintenance-info {
	background: #f8f9fa;
	padding: 15px;
	border-radius: 4px;
	margin-bottom: 20px;
}

h3 {
	margin: 20px 0 10px 0;
	color: #333;
}

/* Task filter tabs */
.task-filter-tabs {
	display: flex;
	margin: 0 0 15px 0;
	border-bottom: 1px solid #e9ecef;
}

.tab-button {
	background: none;
	border: none;
	padding: 8px 16px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
	color: #6c757d;
	border-bottom: 2px solid transparent;
	transition: all 0.2s ease;
	flex: 1;
	text-align: center;
}

.tab-button:hover {
	color: #495057;
	background: #f8f9fa;
}

.tab-button.active {
	color: #f87221;
	border-bottom-color: #f87221;
}

/* Location sheet styles */
.location-sheet {
	position: fixed;
	right: 0;
	top: 0;
	bottom: 0;
	width: var(--sheet-width);
	height: 100%;
	background: white;
	box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
	transition: transform 0.3s ease-in-out;
	overflow-y: auto;
	z-index: 3000;
	transform: translateX(0);
	padding-top: var(--safe-area-inset-top);
	padding-bottom: var(--safe-area-inset-bottom);
	-webkit-overflow-scrolling: touch;
}

.location-sheet.hidden {
	transform: translateX(100%);
}

.sheet-header {
	position: sticky;
	top: 0;
	padding: 16px;
	height: auto;
	min-height: 60px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	z-index: 1;
}

.sheet-header h2 {
	font-size: 18px;
	margin: 0;
}

.sheet-header p {
	font-size: 14px;
	color: #666;
	margin: 4px 0 0 0;
}

.sheet-content {
	padding: 16px;
	max-width: 100%;
}

.sheet-content input,
.sheet-content textarea {
	font-size: 16px; /* Prevents iOS zoom on focus */
	max-width: 100%;
	border-radius: 8px;
	padding: 12px;
}

.form-group {
	margin-bottom: 16px;
}

#task-start-date,
.form-group label[for="task-start-date"] {
	display: none;
}

.form-group label {
	display: block;
	margin-bottom: 8px;
	font-weight: 500;
	color: #333;
}

.coordinates-display {
	padding: 10px;
	background: #f8f9fa;
	border: 1px solid #e9ecef;
	border-radius: 4px;
	font-family: monospace;
}

.seasonal-tasks {
	margin-top: 30px;
}

.season-group {
	margin-bottom: 20px;
}

.form-actions {
	margin-top: 30px;
	display: flex;
	gap: 10px;
}

.button-secondary {
	background: #6c757d;
}

.button-secondary:hover {
	background: #5a6268;
}

.button-tertiary {
	background: #dc3545;
}

.button-tertiary:hover {
	background: #c82333;
}

#add-location-form textarea {
	min-height: 80px;
}

/* Add task button */
.add-task-button {
	width: 100%;
	background: linear-gradient(135deg, #f87221, #dd661d);
	border: none;
	border-radius: 8px;
	padding: 12px 20px;
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	margin-top: 10px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: all 0.2s ease;
	text-align: center;
	line-height: 1.4;
	color: white;
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.add-task-button:hover {
	background: linear-gradient(135deg, #ff8533, #e06d1f);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(248, 114, 33, 0.2);
}

.add-task-button:active {
	transform: translateY(1px);
	background: linear-gradient(135deg, #dd661d, #c55c1a);
	box-shadow: none;
}

@media (max-width: 480px) {
	.add-task-button {
		font-size: 14px;
		padding: 10px 16px;
	}
}

/* Task Sheet (left side) */
.task-sheet {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: white;
	box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
	transition: transform 0.3s ease-in-out;
	overflow-y: auto;
	z-index: 4000;
	transform: translateX(0);
	padding-bottom: var(--safe-area-inset-bottom);
	-webkit-overflow-scrolling: touch;
}

.task-sheet.hidden {
	transform: translateX(-100%);
}

/* Date selection sheet (right side) */
#date-selection-sheet {
	right: 0;
	left: auto;
	box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
	z-index: 5000;
}

#date-selection-sheet.hidden {
	transform: translateX(100%);
}

/* Task details styling */
.task-info {
	background: #f8f9fa;
	padding: 15px;
	border-radius: 8px;
	margin: 0;
}

.task-description-container {
	flex: 1;
	padding: 16px;
}

#task-description {
	margin: 0;
	font-size: 16px;
	line-height: 1.5;
	color: #1a202c;
	white-space: pre-wrap;
	font-weight: 500;
}

.task-info p {
	margin: 8px 0;
	font-size: 14px;
}

.task-info strong {
	color: #333;
}

/* Date selection options */
.date-options {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 10px 0;
}

.date-option {
	background: #f8f9fa;
	border: 1px solid #dee2e6;
	border-radius: 8px;
	padding: 16px 20px;
	text-align: left;
	cursor: pointer;
	font-size: 16px;
	font-weight: 500;
	transition: all 0.2s ease;
	width: 100%;
}

.date-option:hover {
	background: #e9ecef;
	border-color: #4caf50;
}

.date-option:active {
	background: #4caf50;
	color: white;
	transform: scale(0.98);
}

.location-info {
	padding: 0px;
	margin-bottom: 16px;
}

/* Markdown rendering styles */
.markdown-image {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	margin: 10px 0;
	display: block;
}

.location-images {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 10px;
	margin-top: 15px;
}

.location-images figure {
	margin: 0;
}

.location-images img {
	width: 100%;
	height: 150px;
	object-fit: cover;
	border-radius: 4px;
}

.location-images figcaption {
	font-size: 12px;
	color: #666;
	margin-top: 4px;
}

#task-info {
	min-height: 100px;
	font-size: 14px;
	line-height: 1.5;
	resize: vertical;
}

/* Mobile-specific styles */
@media (max-width: 767px) {
	.date-slider-control {
		min-width: 180px;
		padding: 6px 10px;
	}

	.date-slider-label {
		font-size: 11px;
	}

	.task-sheet {
		width: 100%;
		height: auto;
		max-height: 70vh;
		bottom: 0;
		top: auto;
		left: 0;
		right: auto;
		transform: translateY(0);
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	}

	.task-sheet.hidden {
		transform: translateY(100%);
	}

	.task-sheet .sheet-header {
		border-radius: 20px 20px 0 0;
	}

	#date-selection-sheet {
		right: auto;
		left: 0;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	}

	#date-selection-sheet.hidden {
		transform: translateY(100%);
	}

	.date-options {
		padding: 0;
	}

	.date-option {
		padding: 18px 16px;
		font-size: 16px;
	}
	.sidebar,
	.location-sheet {
		width: 100%;
		height: auto;
		max-height: 40vh;
		bottom: 0;
		top: auto;
		transform: translateY(0);
		border-radius: 20px 20px 0 0;
	}

	.location-sheet.picking {
		height: auto;
		max-height: 120px;
		background: rgba(255, 255, 255, 0.95);
		backdrop-filter: blur(8px);
		-webkit-backdrop-filter: blur(8px);
	}

	.location-sheet.picking .sheet-content {
		display: none;
	}

	.location-sheet.picking .sheet-header {
		border-bottom: none;
	}

	.sidebar.hidden,
	.location-sheet.hidden {
		transform: translateY(100%);
	}

	.sheet-header {
		border-radius: 20px 20px 0 0;
		padding: 14px;
	}

	.sheet-header .close-button {
		width: 24px;
		height: 24px;
		margin: -2px -2px -2px 0;
	}

	.form-actions {
		position: sticky;
		bottom: 0;
		background: white;
		padding: 16px;
		margin: 0 -16px;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	}

	.safe-area-bottom {
		height: var(--safe-area-inset-bottom);
	}

	.coordinates-display {
		font-size: 14px;
		word-break: break-all;
	}
}

/* Location selection feedback animation */
.location-feedback {
	position: absolute;
	width: 20px;
	height: 20px;
	margin-left: -10px;
	margin-top: -10px;
	border-radius: 50%;
	background: rgba(76, 175, 80, 0.3);
	animation: ripple 0.6s ease-out;
}

@keyframes ripple {
	from {
		transform: scale(1);
		opacity: 1;
	}
	to {
		transform: scale(3);
		opacity: 0;
	}
}
