/* header */
#main-header {
	width: calc(100% - 250px);
	height: 60px;
	background-color: inherit;
	opacity: 0.95;
	position: fixed;
	top: 0;
	left: 250px;
	z-index: 999;

	padding: 0 40px;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;

}

#topbar {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px;
	position: relative; /* Ensure proper stacking context */
}

#breadcrumb span {
	font-size: 0.9em;
	color: #717171;
}

#topbar-title {
	font-size: 1em;
	font-weight: bold;
	color: #3b3b3b;
	/* rtl */
	direction: rtl;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;

	padding: 0 10px;
	display: none; /* hidden by default, shown on larger screens */
}

search {
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: 200px;
	margin: 0 80px;
	position: relative;
	
}
search i {
	color: #717171;
	font-size: .8em;
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
}
search input {
	width: 100%;
	padding: 3px 3px 3px 35px;
	border: 1px solid #ccc;
	border-radius: 20px;
	font-size: 1em;
}
search input:focus {
	outline:#2c65df;
	border-color: #3b3b3b;
	box-shadow: 0 0 5px rgba(59,59,59,0.2);
}	

#search-cancel {
	background: none;
	border: none;
	color: #717171;
	font-size: 1em;
	cursor: pointer;
	display: none; /* hidden by default */
	/* Enhanced mobile touch support */
	padding: 8px 12px;
	min-width: 44px;
	min-height: 44px;
	border-radius: 6px;
	transition: all 0.2s ease;
	-webkit-tap-highlight-color: rgba(0,0,0,0.1);
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	white-space: nowrap;
}
#search-cancel:hover {
	color: #3b3b3b;
	background-color: rgba(0,0,0,0.05);
}
#search-cancel:active {
	background-color: rgba(0,0,0,0.1);
	transform: scale(0.98);
}

#search-trigger {
	background: none;
	border: none;
	color: #717171;
	font-size: 1.2em;
	cursor: pointer;
	display: none; /* hidden by default, shown on small screens */
	/* Enhanced mobile touch support */
	padding: 12px;
	min-width: 44px;
	min-height: 44px;
	border-radius: 6px;
	transition: all 0.2s ease;
	-webkit-tap-highlight-color: rgba(0,0,0,0.1);
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}
#search-trigger:hover {
	color: #3b3b3b;
	background-color: rgba(0,0,0,0.05);
}
#search-trigger:active {
	background-color: rgba(0,0,0,0.1);
	transform: scale(0.98);
}

	/* Mobile view for screens smaller than 850px */
	@media (max-width: 849px) {
		#search-trigger {
			display: flex !important; /* Force display for mobile */
			align-items: center;
			justify-content: center;
			position: relative;
			z-index: 1001; /* Higher than header */
		}
		
		search {
			display: none; /* Hide desktop search */
		}
	}

	@media (max-width: 768px) {
		#main-header {
			width: 100%;
			left: 0;
			padding: 0 10px;
			z-index: 999; /* Ensure header stays on top */
		}
		
		#topbar {
			padding: 0 15px; /* More padding for better touch targets */
		}
		
		#breadcrumb {
			display: none; /* hide breadcrumb on small screens */
		}
		#topbar-title {
			display: block; 
		}

		search {
			display: none; /* hide search input on small screens */
			max-width: none;
		}

		search.active {
			display: flex;
			width: 100%;
		}

		#search-trigger {
			display: flex; /* Use flex for better alignment */
			align-items: center;
			justify-content: center;
			position: relative;
			z-index: 1000; /* Ensure button is clickable */
		}
		
	}

	/* Additional mobile optimizations for very small screens */
	@media (max-width: 480px) {
		#main-header {
			padding: 0 8px;
		}
		
		#topbar {
			padding: 0 8px;
		}
		
		#search-trigger {
			font-size: 1.1em;
			padding: 10px;
		}
		
		#search-cancel {
			font-size: 0.9em;
			padding: 8px 10px;
		}
		
		#topbar-title {
			font-size: 0.9em;
		}
	}

/* Dark mode styles for topbar/header */
body.dark-mode #main-header {
	background-color: #161b22;
	border-bottom: 1px solid #30363d;
}

body.dark-mode #breadcrumb span,
body.dark-mode #breadcrumb a {
	color: #8b949e;
}

body.dark-mode #breadcrumb a:hover {
	color: #58a6ff;
}

body.dark-mode #topbar-title {
	color: #e6edf3;
}

body.dark-mode search i {
	color: #8b949e;
}

body.dark-mode search input {
	background-color: #161b22;
	border-color: #30363d;
	color: #e6edf3;
}

body.dark-mode search input::placeholder {
	color: #8b949e;
}

body.dark-mode search input:focus {
	border-color: #58a6ff;
	box-shadow: 0 0 5px rgba(88, 166, 255, 0.3);
}

body.dark-mode #search-cancel {
	color: #8b949e;
}

body.dark-mode #search-cancel:hover {
	color: #58a6ff;
	background-color: rgba(255,255,255,0.05);
}

body.dark-mode #search-cancel:active {
	background-color: rgba(255,255,255,0.1);
}

body.dark-mode #search-trigger {
	color: #8b949e;
}

body.dark-mode #search-trigger:hover {
	color: #58a6ff;
	background-color: rgba(255,255,255,0.05);
}

body.dark-mode #search-trigger:active {
	background-color: rgba(255,255,255,0.1);
}