/* Path: Frontend/src/components/dashboard/shared/dashboard-topbar.module.scss */

.topbar {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 0.85rem;
	align-items: center;
	position: relative;
	z-index: 50;

	@include respond-max(mobile-narrow) {
		grid-template-columns: auto minmax(0, 1fr);
	}

	@media (max-width: 1023px) {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}

	@include respond(wide) {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}
}

.menuButton,
.iconButton {
	width: 2.75rem;
	height: 2.75rem;
	display: grid;
	place-items: center;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-soft);
	background: var(--surface-panel);
	color: var(--text-muted);
	box-shadow: var(--shadow-soft);
	cursor: pointer;
	transition:
		transform 0.2s ease,
		background-color 0.2s ease,
		border-color 0.2s ease;

	&:hover {
		transform: translateY(-1px);
		background: var(--surface-panel-strong);
		border-color: var(--border-strong);
	}

	svg {
		width: 1.15rem;
		height: 1.15rem;
		stroke: currentColor;
		fill: none;
		stroke-width: 1.8;
		stroke-linecap: round;
		stroke-linejoin: round;
	}
}

.menuButton {
	position: relative;
	z-index: 70;
}

.menuGlyph {
	position: relative;
	width: 1.1rem;
	height: 0.95rem;
	display: inline-block;
}

.menuLine {
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	border-radius: var(--radius-full);
	background: currentColor;
	transform-origin: center;
	transition:
		transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
		opacity 0.24s var(--transition-ease),
		top 0.38s cubic-bezier(0.22, 1, 0.36, 1),
		background-color 0.2s var(--transition-ease);

	&:nth-child(1) {
		top: 0.05rem;
	}

	&:nth-child(2) {
		top: 0.41rem;
	}

	&:nth-child(3) {
		top: 0.77rem;
	}
}

.menuButtonOpen {
	.menuLine {
		&:nth-child(1) {
			top: 0.41rem;
			transform: rotate(45deg);
		}

		&:nth-child(2) {
			opacity: 0;
			transform: scaleX(0.4);
		}

		&:nth-child(3) {
			top: 0.41rem;
			transform: rotate(-45deg);
		}
	}
}

@include respond(mobile) {
	.menuButton,
	.iconButton {
		width: 3rem;
		height: 3rem;
	}
}

.searchField {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	padding: 0 0.85rem;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-soft);
	background: var(--surface-panel-strong);
	box-shadow: var(--shadow-soft);

	input {
		width: 100%;
		padding: 0.82rem 0;
		border: none;
		background: transparent;
		outline: none;
		color: var(--text);
		font-size: 0.9rem;
	}
}

.searchToggle {
	display: none;
}

.searchDropdown {
	width: min(28rem, calc(100vw - 2rem));
}

.searchFieldSheet {
	margin-top: 0.15rem;
}

@include respond(mobile) {
	.searchField {
		padding: 0 1rem;

		input {
			padding: 0.95rem 0;
			font-size: 0.95rem;
		}
	}
}

.searchIcon {
	display: grid;
	place-items: center;
	color: var(--text-muted);

	svg {
		width: 1rem;
		height: 1rem;
		stroke: currentColor;
		fill: none;
		stroke-width: 1.8;
		stroke-linecap: round;
		stroke-linejoin: round;
	}
}

.actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.55rem;
	grid-column: 1 / -1;
	overflow-x: auto;
	overflow-y: visible;
	padding-bottom: 0.15rem;
	scrollbar-width: none;

	&::-webkit-scrollbar {
		display: none;
	}

	@include respond(wide) {
		grid-column: auto;
		justify-content: flex-end;
		overflow: visible;
		padding-bottom: 0;
	}
}

.menuGroup {
	position: relative;
	flex: 0 0 auto;
}

.mobileMenuBackdrop {
	display: none;
}

@media (max-width: 1023px) {
	.searchField {
		display: none;
	}

	.searchToggle {
		display: grid;
	}

	.actions {
		grid-column: auto;
		justify-content: flex-end;
		overflow: visible;
		padding-bottom: 0;
		gap: 0.45rem;
	}

	.menuGroup {
		position: static;
	}

	.mobileMenuBackdrop {
		display: block;
		position: fixed;
		inset: 0;
		border: none;
		padding: 0;
		background: hsl(0 0% 0% / 0.44);
		backdrop-filter: blur(3px);
		z-index: 70;
	}
}

.countBadge {
	position: absolute;
	top: -0.15rem;
	right: -0.15rem;
	min-width: 1.1rem;
	height: 1.1rem;
	display: grid;
	place-items: center;
	padding: 0 0.2rem;
	border-radius: var(--radius-full);
	background: var(--primary);
	color: var(--action-primary-text);
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 1;
	box-shadow: var(--shadow-soft);
}

.dropdown {
	position: absolute;
	top: calc(100% + 0.6rem);
	right: 0;
	width: min(22rem, calc(100vw - 2rem));
	display: grid;
	gap: 0.85rem;
	padding: 0.95rem;
	border-radius: var(--radius-xl);
	border: 1px solid var(--border-strong);
	background: var(--surface-raised);
	box-shadow: var(--shadow-elevated);
	backdrop-filter: blur(18px);
	z-index: 20;
}

@media (max-width: 1023px) {
	.dropdown {
		position: fixed;
		top: calc(env(safe-area-inset-top, 0rem) + 5.6rem);
		left: 1rem;
		right: 1rem;
		width: auto;
		max-height: calc(100dvh - env(safe-area-inset-top, 0rem) - 6.6rem);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 1rem;
		border-radius: max(var(--radius-xl), 1.25rem);
		box-shadow: 0 24px 64px hsl(220 35% 12% / 0.28);
		z-index: 80;
	}

	.searchDropdown {
		top: calc(env(safe-area-inset-top, 0rem) + 1rem);
	}

	.dropdownHeader {
		align-items: flex-start;
	}

	.dropdownList {
		gap: 0.8rem;
	}

	.dropdownItem {
		padding: 0.9rem;
	}

	.searchFieldSheet {
		display: flex;
	}
}

.dropdownHeader {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;

	strong {
		font-size: 1rem;
		line-height: 1.1;
	}
}

.dropdownHeaderActions {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	flex-shrink: 0;
}

.dropdownEyebrow {
	font-size: 0.72rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--text-muted);
	margin-bottom: 0.12rem;
}

.dropdownMeta {
	margin-top: 0.22rem;
	font-size: 0.8rem;
	color: var(--text-muted);
}

.dropdownLink {
	color: var(--primary);
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}

.mobileDropdownClose {
	display: none;
}

@media (max-width: 1023px) {
	.mobileDropdownClose {
		width: 2.35rem;
		height: 2.35rem;
		display: grid;
		place-items: center;
		border-radius: var(--radius-full);
		border: 1px solid var(--border-soft);
		background: var(--surface-panel);
		color: var(--text-muted);
		box-shadow: var(--shadow-soft);
		appearance: none;
		cursor: pointer;

		svg {
			width: 0.95rem;
			height: 0.95rem;
			stroke: currentColor;
			fill: none;
			stroke-width: 1.9;
			stroke-linecap: round;
			stroke-linejoin: round;
		}
	}

	.dropdownLink {
		display: none;
	}
}

.dropdownList {
	display: grid;
	gap: 0.65rem;
}

.emptyDropdownState {
	padding: 0.9rem;
	border-radius: var(--radius-md);
	border: 1px dashed var(--border-soft);
	background: var(--surface-panel);
	color: var(--text-muted);
	font-size: 0.85rem;
	line-height: 1.45;
}

.dropdownItem {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: start;
	gap: 0.7rem;
	padding: 0.8rem;
	border-radius: var(--radius-md);
	background: var(--surface-panel);
	border: 1px solid var(--border-soft);
	transition:
		transform 0.2s ease,
		border-color 0.2s ease,
		background-color 0.2s ease;

	&:hover {
		transform: translateY(-1px);
		border-color: var(--border-strong);
		background: var(--surface-panel-strong);
		text-decoration: none;
	}

	small {
		color: var(--text-muted);
		font-size: 0.74rem;
		white-space: nowrap;
	}
}

.dropdownButtonReset {
	width: 100%;
	text-align: left;
	appearance: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.itemCopy {
	min-width: 0;
	display: grid;
	gap: 0.2rem;

	strong {
		font-size: 0.92rem;
		line-height: 1.15;
	}

	p {
		font-size: 0.82rem;
		line-height: 1.35;
		color: var(--text-muted);
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
}

.itemTone,
.messageAvatar {
	width: 2.15rem;
	height: 2.15rem;
	border-radius: var(--radius-full);
	flex-shrink: 0;
}

.itemTone {
	display: inline-block;
	margin-top: 0.1rem;
	border: 1px solid var(--border-soft);
}

.tone-blue {
	background: var(--surface-info-emphasis);
}

.tone-yellow {
	background: var(--surface-warning-emphasis);
}

.tone-teal {
	background: var(--surface-success-emphasis);
}

.messageAvatar {
	display: grid;
	place-items: center;
	background: linear-gradient(135deg, var(--surface-accent-emphasis), var(--surface-info-emphasis));
	color: var(--text-accent-strong);
	font-size: 0.8rem;
	font-weight: 700;
	margin-top: 0.1rem;
}

.profile {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.4rem 0.5rem 0.4rem 0.8rem;
	border-radius: var(--radius-full);
	border: 1px solid var(--border-soft);
	background: var(--surface-panel);
	box-shadow: var(--shadow-soft);
	white-space: nowrap;
}

.profileCopy {
	min-width: 0;
}

.profileButton {
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	color: inherit;

	&:hover {
		text-decoration: none;
	}

	.profile {
		transition:
			transform 0.2s ease,
			border-color 0.2s ease,
			background-color 0.2s ease;
	}

	&:hover .profile,
	&:focus-visible .profile,
	&.profileButtonOpen .profile {
		transform: translateY(-1px);
		background: var(--surface-panel-strong);
		border-color: var(--border-strong);
	}
}

.profileChevron {
	display: grid;
	place-items: center;
	color: var(--text-muted);
	transition: transform 0.24s var(--transition-ease);

	svg {
		width: 0.95rem;
		height: 0.95rem;
		stroke: currentColor;
		fill: none;
		stroke-width: 1.9;
		stroke-linecap: round;
		stroke-linejoin: round;
	}
}

.profileButtonOpen .profileChevron {
	transform: rotate(180deg);
}

@include respond(mobile) {
	.profile {
		padding: 0.45rem 0.55rem 0.45rem 0.95rem;
	}
}

@media (max-width: 1023px) {
	.profile {
		padding: 0.4rem 0.55rem;
		gap: 0.55rem;
	}

	.profileCopy {
		display: none;
	}
}

.profileName {
	font-weight: 500;
	font-size: 0.9rem;
}

.profileRole {
	font-size: 0.85rem;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

@include respond-max(mobile-narrow) {
	.profileRole {
		display: none;
	}
}

.profileBadge {
	width: 2.2rem;
	height: 2.2rem;
	display: grid;
	place-items: center;
	overflow: hidden;
	border-radius: var(--radius-full);
	background: var(--surface-accent-emphasis);
	color: var(--text-accent-strong);
	font-weight: 600;
}

.profileMenuBadge {
	width: 2.2rem;
	height: 2.2rem;
	display: grid;
	place-items: center;
	overflow: hidden;
	border-radius: var(--radius-full);
	background: var(--surface-accent-emphasis);
	color: var(--text-accent-strong);
	font-size: 0.9rem;
	font-weight: 700;
	flex-shrink: 0;
}

.profileAvatarImage {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
