/* CORE LAYOUT */
body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	margin: 0;
	display: flex;
	height: 100vh;
	overflow: hidden;
}

#sidebar {
	width: 450px;
	padding: 20px;
	box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
	display: flex;
	flex-direction: column;
	z-index: 10;
	box-sizing: border-box;
}

#resizer {
	width: 8px;
	margin: 0 -3px;
	cursor: col-resize;
	flex-shrink: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
	user-select: none;
	position: relative;
	background: transparent;
	transition: background 0.15s;
}

.resizer-handle {
	width: 2px;
	height: 32px;
	border-radius: 2px;
	background: rgba(0, 0, 0, 0.2);
	transition: background 0.15s, transform 0.15s, width 0.15s;
	pointer-events: none;
}

#resizer:hover .resizer-handle,
#resizer:active .resizer-handle {
	background: #2563eb;
	width: 4px;
	transform: scaleY(1.15);
}

#map {
	flex-grow: 1;
}

#groupsWrapper {
	flex-grow: 1;
	overflow-y: auto;
	padding-right: 5px;
}

/* SECTION CARDS */
.group-container {
	border-radius: 12px;
	padding: 12px;
	margin-bottom: 20px;
	border-left: 5px solid #2563eb;
	box-sizing: border-box;
	position: relative;
	overflow: visible;
}

.group-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
	cursor: grab;
}

body.blog-mode .group-header {
	cursor: default;
}

.group-title {
	font-weight: bold;
	flex-grow: 1;
	border: 1px solid transparent;
	outline: none;
	font-size: 18px;
	background: transparent;
}

.step-name-input {
	flex-grow: 1;
	border: 1px solid transparent;
	outline: none;
	background: transparent;
	font-family: inherit;
	font-size: inherit;
	font-weight: 500;
	resize: none;
}

body.blog-mode .step-name-input {
	font-size: 16px;
	font-weight: bold;
}

.trip-title-input {
	font-size: 1.5rem;
	font-weight: bold;
	border: none;
	outline: none;
	width: 100%;
	margin-bottom: 15px;
	padding: 5px;
	box-sizing: border-box;
	border-radius: 8px;
}

.step-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px;
	border-radius: 8px;
	margin-top: 8px;
	cursor: grab;
	font-size: 13px;
	line-height: 1.5;
	word-break: break-word;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	transition: all 0.2s ease;
}

body.blog-mode .step-item {
	cursor: default;
}

.step-item:hover {
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	transform: translateY(-1px);
}

/* Dragging Lift Effect (Sortable chosen/drag state) */
.step-item.sortable-chosen,
.group-container.sortable-chosen,
.pic-item.sortable-chosen {
	box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.25), 0 6px 12px -2px rgba(0, 0, 0, 0.15) !important;
	transform: scale(1.02) translateY(-2px) !important;
	opacity: 0.95;
	z-index: 10000;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.step-item.sortable-ghost,
.group-container.sortable-ghost,
.pic-item.sortable-ghost {
	opacity: 0.4;
	background: #e2e8f0;
}

.inter-step {
	font-size: 11px;
	color: #6b7280;
	padding: 8px 0 8px 35px;
	border-left: 2px dashed #cbd5e1;
	margin-left: 15px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 5px;
}

.mode-btn {
	border: 1px solid #ddd;
	background: white;
	cursor: pointer;
	font-size: 10px;
	border-radius: 4px;
	padding: 2px 6px;
}

.mode-btn.active {
	background: #2563eb;
	color: white;
	border-color: #2563eb;
}

/* SEARCH BOX & OVERLAY */
.search-box {
	position: relative;
	margin-top: 10px;
	width: 100%;
	box-sizing: border-box;
	z-index: 100;
}

.search-input {
	width: 100%;
	padding: 8px;
	border-radius: 8px;
	outline: none;
	font-size: 13px;
	box-sizing: border-box;
}

.suggestions {
	position: absolute;
	width: 100%;
	z-index: 9999;
	display: none;
	border-radius: 8px;
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
	top: 100%;
	left: 0;
	max-height: 250px;
	overflow-y: auto;
}

.sugg-item {
	padding: 10px;
	cursor: pointer;
	font-size: 12px;
}

.sugg-item:hover,
.sugg-item.selected {
	border-left: 4px solid #2563eb;
}

#total-summary {
	margin-top: 15px;
	padding: 15px;
	border-radius: 12px;
	font-weight: bold;
	cursor: pointer;
}

.btn-main {
	width: 100%;
	padding: 12px;
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-weight: bold;
	margin-bottom: 5px;
}

.btn-sec {
	flex: 1;
	padding: 8px;
	font-size: 11px;
	border-radius: 6px;
	cursor: pointer;
}

.btn-sec.off {
	filter: grayscale(100%);
	opacity: 0.5;
}

.custom-marker {
	color: white;
	border-radius: 50%;
	width: 34px;
	height: 34px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	border: 2px solid white;
	font-size: 16px;
}

.custom-marker img,
.sidebar-marker img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.sidebar-marker {
	color: white;
	border-radius: 50%;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 14px;
	border: 2px solid white;
	box-sizing: border-box;
	flex-shrink: 0;
	overflow: hidden;
}

.visibility-btn {
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
}

.visibility-btn.off {
	filter: grayscale(100%);
	opacity: 0.4;
}

.delete-btn {
	border: none;
	background: none;
	cursor: pointer;
	padding: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	line-height: 1;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.delete-btn:hover {
	transform: scale(1.15);
}

.overlay-title-input {
	font-size: 1.25rem;
	font-weight: bold;
	border: none;
	outline: none;
	width: 100%;
	resize: none;
	background: transparent;
	font-family: inherit;
	padding: 0;
	margin: 0;
	padding-right: 70px;
	box-sizing: border-box;
}

/* STEP OVERLAY */
#step-overlay {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	width: 90%;
	max-width: 600px;
	padding: 15px;
	border-radius: 12px;
	box-shadow: 10px 10px 20px 0px rgba(0, 0, 0, 0.6);
	z-index: 1000;
	display: none;
	max-height: 40vh;
	overflow-y: auto;
	box-sizing: border-box;
}

#step-overlay.active {
	display: block;
}

.pic-list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 10px;
}

.pic-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	border-radius: 8px;
	padding: 8px;
	cursor: grab;
	width: 160px;
	position: relative;
	box-sizing: border-box;
}

.pic-img {
	width: 100%;
	height: 100px;
	object-fit: cover;
	border-radius: 4px;
	margin-bottom: 5px;
	margin-right: 0;
	flex-shrink: 0;
}

.pic-actions {
	display: flex;
	gap: 5px;
	width: 100%;
	justify-content: space-between;
	margin-left: 0;
}

.pic-btn {
	cursor: pointer;
	font-size: 12px;
	padding: 4px;
	border-radius: 4px;
	flex: 1;
	display: flex;
	justify-content: center;
	align-items: center;
}

.pic-btn.off {
	filter: grayscale(100%);
	opacity: 0.4;
}

.pic-editor {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 5px;
	border-radius: 8px;
}

.pic-editor input {
	width: 100%;
	box-sizing: border-box;
	margin-bottom: 5px;
	padding: 4px;
	font-size: 11px;
}

.pic-editor label {
	font-size: 10px;
	font-weight: bold;
}

.overlay-close {
	position: absolute;
	top: 10px;
	right: 10px;
	cursor: pointer;
	border: none;
	background: none;
	font-size: 16px;
}

.step-thumbnail {
	width: 60px;
	height: 60px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
}

.map-pic-marker {
	background: none;
	border: none;
}

.map-pic-wrapper {
	position: absolute;
	bottom: 0;
	left: 0;
	transform: translate(-50%, -100%);
	padding: 2px;
	border-radius: 4px;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
	cursor: pointer;
	transition: transform 0.15s ease;
}

.map-pic-wrapper:hover {
	transform: translate(-50%, -105%) scale(1.1);
}

.map-pic-wrapper img,
.map-pic-wrapper video {
	height: 50px;
	width: auto;
	display: block;
	border-radius: 2px;
}

.video-thumb-container {
	position: relative;
	display: inline-block;
}

.video-thumb-badge {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 20px;
	color: white;
	text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
	pointer-events: none;
}

.date-input,
.time-input,
.duration-input {
	border-radius: 4px;
	padding: 2px 4px;
	font-size: 12px;
}

.duration-input {
	width: 80px;
	box-sizing: border-box;
}

.theme-select {
	outline: none;
	cursor: pointer;
}

.drawer-row {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	box-sizing: border-box;
}

.drawer-url-input {
	flex: 1 1 auto;
	min-width: 60px;
	font-size: 12px;
	padding: 2px 6px;
	border-radius: 4px;
	box-sizing: border-box;
}

/* BLOG MODE SPECIFIC HIDES */
body.blog-mode .theme-select,
body.blog-mode .footer-actions,
body.blog-mode .collapse-btn,
body.blog-mode .visibility-btn,
body.blog-mode .delete-btn,
body.blog-mode .mode-btn,
body.blog-mode .color-picker-input,
body.blog-mode .search-box,
body.blog-mode .btn-main,
body.blog-mode .clear-btn {
	display: none !important;
}

/* HIDE BLOG MODE TOGGLE BUTTON WHEN IN BLOG MODE WITHOUT EDIT PARAM */
body.hide-mode-toggle #btn-blog-mode {
	display: none !important;
}

/* CUSTOM MODAL OVERLAY STYLES */
#custom-modal-backdrop {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	z-index: 99999;
	justify-content: center;
	align-items: center;
}

#custom-modal-box {
	background: white;
	color: #111827;
	padding: 20px;
	border-radius: 12px;
	max-width: 500px;
	width: 90%;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
	box-sizing: border-box;
	max-height: 80vh;
	overflow-y: auto;
	position: relative;
	border: 1px solid #e5e7eb;
}

/* SIDEBAR HEADER & CONTROLS */
.sidebar-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 15px;
}

.sidebar-header .trip-title-input {
	margin-bottom: 0;
}

#lang-select {
	border: none;
	background: transparent;
	font-size: 20px;
	cursor: pointer;
	padding: 0 5px;
	outline: none;
}

#btn-blog-mode {
	width: 40px;
	flex: none;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 8px;
}

#total-summary .total-summary-inner {
	display: flex;
	justify-content: space-between;
}

.footer-actions {
	display: flex;
	gap: 5px;
	margin-top: 10px;
	flex-wrap: wrap;
}

/* CUSTOM MODAL ELEMENTS */
#custom-modal-title {
	margin-top: 0;
	font-size: 1.25rem;
}

#custom-modal-body {
	margin: 15px 0;
	font-size: 13px;
}

#custom-modal-buttons {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

/* CAROUSEL / LIGHTBOX MODAL */
#carousel-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.9);
	z-index: 100000;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

.carousel-close-btn {
	position: absolute;
	top: 20px;
	right: 20px;
	background: transparent;
	border: none;
	color: white;
	font-size: 32px;
	cursor: pointer;
	z-index: 100001;
	line-height: 1;
}

.carousel-nav-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: white;
	font-size: 28px;
	padding: 15px 18px;
	border-radius: 50%;
	cursor: pointer;
	z-index: 100001;
	transition: background 0.2s;
}

.carousel-nav-btn:hover {
	background: rgba(255, 255, 255, 0.4);
}

.carousel-prev-btn {
	left: 20px;
}

.carousel-next-btn {
	right: 20px;
}

.carousel-media-container {
	max-width: 90%;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

#carousel-img,
#carousel-video {
	max-width: 100%;
	max-height: 75vh;
	border-radius: 8px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
	transition: opacity 0.25s ease-in-out;
	opacity: 1;
	display: none;
}

#carousel-img {
	object-fit: contain;
}

#carousel-step-title {
	color: #ffffff;
	margin-top: 12px;
	font-size: 16px;
	font-weight: 600;
	text-align: center;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

#carousel-counter {
	color: rgba(255, 255, 255, 0.7);
	margin-top: 8px;
	font-size: 13px;
	font-weight: 500;
}

/* RESPONSIVE LAYOUT */

/* 1. Portrait Mode:
   - Stack layout vertically (sections panel top, map bottom)
   - Resizer spans full width horizontally
   - By default for fine pointer (computers), resizer is thin (8px height) */
@media (orientation: portrait),
(max-width: 768px) {
	body {
		flex-direction: column;
	}

	#sidebar {
		width: 100% !important;
		height: calc(100vh - 33.333vh);
		flex-shrink: 0;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	}

	#resizer {
		display: flex;
		width: 100%;
		height: 8px;
		margin: -3px 0;
		cursor: row-resize;
	}

	.resizer-handle {
		width: 32px;
		height: 2px;
		border-radius: 2px;
	}

	#resizer:hover .resizer-handle,
	#resizer:active .resizer-handle {
		height: 4px;
		width: 36px;
		transform: scaleX(1.15);
	}

	#map {
		width: 100% !important;
		height: 33.333vh;
		flex-grow: 1;
		flex-shrink: 1;
	}
}

/* 2. Coarse Pointer (Touch devices - always large hit target regardless of orientation or screen size) */
/* Landscape on Touch */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 769px) {
	#resizer {
		width: 28px !important;
		height: 100% !important;
		margin: 0 -12px !important;
		cursor: col-resize;
	}

	.resizer-handle {
		width: 5px !important;
		height: 44px !important;
		border-radius: 4px !important;
	}
}

/* Portrait on Touch (or any small device <= 768px): always 100% full width, 28px thick height */
@media (pointer: coarse) and (orientation: portrait),
(max-width: 768px) {
	#resizer {
		width: 100% !important;
		height: 28px !important;
		margin: -12px 0 !important;
		cursor: row-resize;
	}

	.resizer-handle {
		width: 44px !important;
		height: 5px !important;
		border-radius: 4px !important;
	}
}

/* 3. Blog Mode on Small Screens (@media max-width: 768px):
   - Sections panel takes full available height by default (100% height)
   - Map stays present below divider line (0 height initially, but fully expandable)
   - Resizer handle is always accessible across 100% full width to drag up the map anytime
   - Larger typography for improved readability on mobile devices */
@media (max-width: 768px) {
	body.blog-mode {
		flex-direction: column;
	}

	body.blog-mode #sidebar {
		width: 100% !important;
		height: 100vh;
		flex-shrink: 0;
	}

	body.blog-mode #resizer {
		display: flex !important;
		width: 100% !important;
		height: 28px !important;
		margin: -12px 0 !important;
		cursor: row-resize;
	}

	body.blog-mode .resizer-handle {
		width: 44px !important;
		height: 5px !important;
		border-radius: 4px !important;
	}

	body.blog-mode #map {
		display: block !important;
		width: 100% !important;
		height: 0px;
		min-height: 0;
		flex-grow: 1;
		flex-shrink: 1;
	}

	/* Bigger text in sections and steps for blog mode on small devices */
	body.blog-mode .group-title {
		font-size: 26px !important;
		font-weight: 700;
	}

	body.blog-mode .step-name-input {
		font-size: 20px !important;
		line-height: 1.5 !important;
	}

	body.blog-mode .step-item {
		font-size: 17px !important;
		padding: 14px !important;
	}

	body.blog-mode .trip-title-input {
		font-size: 1.8rem !important;
	}

	body.blog-mode .blog-note-text {
		font-size: 17px !important;
		line-height: 1.6 !important;
	}

	body.blog-mode .step-date-meta,
	body.blog-mode .section-date-meta {
		font-size: 15px !important;
	}
}