/**
 * Header Communications popout (messages + notifications).
 */

/* Header messages + notifications (logged-in) */
.itm-header-alerts {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	position: relative;
	z-index: 1101;
}

.itm-header-alert {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid var(--itm-border);
	border-radius: 50%;
	background: var(--itm-bg-elevated, #fff);
	color: var(--itm-heading);
	text-decoration: none;
	cursor: pointer;
	transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, background 0.2s;
}

.itm-header-alert:hover,
.itm-header-alert:focus-visible {
	border-color: var(--itm-accent);
	color: var(--itm-accent);
	background: rgba(var(--itm-accent-rgb), 0.06);
	box-shadow: 0 4px 14px rgba(var(--itm-accent-rgb), 0.15);
	opacity: 1;
}

.itm-header-alert i {
	font-size: 1rem;
}

.itm-header-alert-count {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: var(--itm-btn-radius, 4px);
	background: var(--itm-accent);
	color: #fff;
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	pointer-events: none;
	box-shadow: 0 2px 6px rgba(var(--itm-accent-rgb), 0.35);
}

.itm-header-alert-count.is-empty {
	display: none;
}

.itm-header-alert-menu {
	position: relative;
}

.itm-header-alert-menu.is-open .itm-header-alert {
	border-color: var(--itm-accent);
	color: var(--itm-accent);
	background: rgba(var(--itm-accent-rgb), 0.06);
	box-shadow: 0 4px 14px rgba(var(--itm-accent-rgb), 0.15);
}

.itm-header-alert-dropdown {
	position: absolute;
	top: calc(100% + 12px);
	right: 0;
	width: min(360px, calc(100vw - 24px));
	z-index: 1200;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px) scale(0.98);
	transform-origin: top right;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
	pointer-events: none;
}

.itm-header-alert-menu.is-open .itm-header-alert-dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.itm-header-alert-dropdown[hidden] {
	display: block !important;
}

.itm-header-alert-menu:not(.is-open) .itm-header-alert-dropdown[hidden] {
	visibility: hidden;
	pointer-events: none;
}

.itm-header-alert-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	max-height: min(72vh, 520px);
	background: var(--itm-bg-elevated, #fff);
	border: 1px solid var(--itm-border);
	border-radius: 16px;
	box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
	overflow: hidden;
}

.itm-header-alert-panel::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: linear-gradient(90deg, var(--itm-accent), rgba(var(--itm-accent-rgb), 0.45));
}

.itm-header-alert-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 16px 12px;
	border-bottom: 1px solid var(--itm-border);
	position: relative;
	z-index: 2;
}

.itm-header-alert-tabs {
	display: flex;
	gap: 0;
	padding: 0 12px;
	border-bottom: 1px solid var(--itm-border);
	background: color-mix(in srgb, var(--itm-bg-elevated, #fff) 92%, #f8fafc);
}

.itm-header-alert-tab {
	appearance: none;
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-height: 42px;
	padding: 0.45rem 0.5rem;
	border: 0;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: var(--itm-text-muted);
	font: inherit;
	font-size: 0.86rem;
	font-weight: 700;
	cursor: pointer;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.itm-header-alert-tab:hover,
.itm-header-alert-tab:focus-visible {
	color: var(--itm-heading);
	outline: none;
}

.itm-header-alert-tab.is-active {
	color: var(--itm-accent);
	border-bottom-color: var(--itm-accent);
}

.itm-header-alert-tab-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.25rem;
	height: 1.25rem;
	padding: 0 0.35rem;
	border-radius: 999px;
	background: rgba(var(--itm-accent-rgb), 0.12);
	color: var(--itm-accent);
	font-size: 0.7rem;
	font-weight: 800;
	line-height: 1;
}

.itm-header-alert-tab-count.is-empty {
	display: none;
}

.itm-header-alert-pane[hidden] {
	display: none !important;
}

.itm-header-alert-pane.is-active {
	display: block;
}

.itm-header-alert-pane.is-loading {
	opacity: 0.65;
	pointer-events: none;
}

.itm-header-alert-head-actions {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.itm-header-alert-clear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 32px;
	padding: 0 10px;
	border: 1px solid var(--itm-border, rgba(15, 23, 42, 0.12));
	border-radius: 999px;
	background: transparent;
	color: var(--itm-text-muted);
	font-size: 0.78rem;
	font-weight: 650;
	line-height: 1;
	cursor: pointer;
}

.itm-header-alert-clear:hover,
.itm-header-alert-clear:focus-visible {
	color: var(--itm-heading, #0f172a);
	border-color: rgba(15, 23, 42, 0.28);
	background: rgba(15, 23, 42, 0.04);
}

.itm-header-alert-clear:disabled {
	opacity: 0.55;
	cursor: wait;
}

.itm-header-alert-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 800;
	color: var(--itm-heading);
	letter-spacing: -0.02em;
}

.itm-header-alert-subtitle {
	display: block;
	margin-top: 2px;
	font-size: 0.8rem;
	color: var(--itm-text-muted);
}

.itm-header-alert-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--itm-border, rgba(15, 23, 42, 0.12));
	border-radius: 50%;
	background: #fff;
	color: var(--itm-heading, #0f172a);
	cursor: pointer;
	flex-shrink: 0;
	font-size: 1.35rem;
	line-height: 1;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.itm-header-alert-close:hover,
.itm-header-alert-close:focus-visible {
	background: rgba(15, 23, 42, 0.06);
	color: var(--itm-heading, #0f172a);
}

.itm-header-alert-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 6px 0;
	scrollbar-width: thin;
}

.itm-header-alert-body.is-loading {
	opacity: 0.65;
	pointer-events: none;
}

.itm-header-alert-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	width: 100%;
}

.itm-header-alert-item {
	position: relative;
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	width: 100%;
	flex: 0 0 auto;
	border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.itm-header-alert-item:last-child {
	border-bottom: 0;
}

.itm-header-alert-item .itm-header-alert-item-link {
	flex: 1;
	min-width: 0;
	padding-right: 4px;
}

.itm-header-alert-item-actions {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px 10px 8px 0;
	flex-shrink: 0;
}

.itm-header-alert-item-dismiss {
	appearance: none;
	border: 0;
	background: transparent;
	color: #64748b;
	font-size: 1.2rem;
	line-height: 1;
	width: 28px;
	height: 28px;
	padding: 0;
	cursor: pointer;
	border-radius: 4px;
}

.itm-header-alert-item-dismiss:hover,
.itm-header-alert-item-dismiss:focus-visible {
	color: #0f172a;
	background: rgba(15, 23, 42, 0.06);
	outline: none;
}

.itm-header-alert-item-dismiss:disabled {
	opacity: 0.5;
	cursor: wait;
}

.itm-header-alert-item-link {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 16px;
	color: inherit;
	text-decoration: none;
	transition: background 0.15s ease;
}

.itm-header-alert-item-link:hover {
	background: rgba(var(--itm-accent-rgb), 0.06);
	opacity: 1;
}

.itm-header-alert-item.is-unread .itm-header-alert-item-link {
	background: rgba(var(--itm-accent-rgb), 0.04);
}

.itm-header-alert-avatar {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	overflow: hidden;
}

.itm-header-alert-avatar img {
	display: block;
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 50%;
}

.itm-header-alert-avatar--fallback {
	display: grid;
	place-items: center;
	background: #f1f5f9;
	color: #64748b;
	font-size: 0.9rem;
}

.itm-header-alert-item-body {
	min-width: 0;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.itm-header-alert-item-title {
	font-size: 0.88rem;
	font-weight: 650;
	color: var(--itm-heading);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.itm-header-alert-item-excerpt {
	font-size: 0.8rem;
	color: var(--itm-text-muted);
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.itm-header-alert-item-time {
	font-size: 0.72rem;
	color: var(--itm-text-muted);
	opacity: 0.85;
}

.itm-header-alert-item-dot {
	width: 8px;
	height: 8px;
	margin-top: 6px;
	border-radius: 50%;
	background: var(--itm-accent);
	flex-shrink: 0;
}

.itm-header-alert-empty {
	padding: 28px 20px;
	text-align: center;
	color: var(--itm-text-muted);
}

.itm-header-alert-empty i {
	display: block;
	margin-bottom: 0.55rem;
	font-size: 1.35rem;
	opacity: 0.7;
}

.itm-header-alert-empty p {
	margin: 0;
	font-size: 0.9rem;
}

.itm-header-alert-foot {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.55rem;
	padding: 12px 16px 14px;
	border-top: 1px solid var(--itm-border);
	background: color-mix(in srgb, var(--itm-bg-elevated, #fff) 88%, #f8fafc);
}

.itm-header-alert-native {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	width: 100%;
	min-height: 36px;
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--itm-border, rgba(0, 0, 0, 0.12));
	border-radius: 8px;
	background: #fff;
	color: var(--itm-ink, #1a1a1a);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
}

.itm-header-alert-native:hover:not(:disabled) {
	background: #f8fafc;
}

.itm-header-alert-native:disabled {
	opacity: 0.75;
	cursor: default;
}

.itm-header-alert-native[hidden] {
	display: none !important;
}

.itm-header-alert-view-all {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	font-size: 0.86rem;
	font-weight: 700;
	color: var(--itm-accent);
	text-decoration: none;
}

.itm-header-alert-view-all:hover {
	opacity: 0.85;
}

@media (max-width: 640px) {
	.itm-header-alert-dropdown {
		position: fixed;
		top: 72px;
		right: 12px;
		left: 12px;
		width: auto;
	}

	body.admin-bar .itm-header-alert-dropdown {
		top: 104px;
	}
}
