/* ═══════════════════════════════════════════
   Notification Bell & Panel (v2 — tabs + messaging)
   ═══════════════════════════════════════════ */

.notif-bell {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 9000;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba(30, 41, 59, 0.95);
	color: #94a3b8;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	transition: all 0.15s;
}
.notif-bell:hover { color: #ffd700; transform: scale(1.05); }
.notif-bell svg { width: 20px; height: 20px; }
.notif-badge {
	position: absolute; top: -2px; right: -2px;
	min-width: 18px; height: 18px; padding: 0 5px;
	border-radius: 9px; background: #ef4444; color: #fff;
	font-size: 10px; font-weight: 700;
	font-family: 'DM Sans', -apple-system, sans-serif;
	display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* ── Panel ── */
.notif-panel {
	position: fixed; top: 64px; right: 16px; z-index: 9001;
	width: 400px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 80px);
	background: #1e293b; border: 1px solid #334155; border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
	display: flex; flex-direction: column; overflow: hidden;
	transform: translateY(-8px) scale(0.96); opacity: 0; pointer-events: none;
	transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
}
.notif-panel--open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

/* ── Tabs ── */
.notif-tabs {
	display: flex; border-bottom: 1px solid #334155; flex-shrink: 0;
}
.notif-tab {
	flex: 1; padding: 10px 12px; border: none; background: transparent;
	color: #64748b; font-size: 12px; font-weight: 600; cursor: pointer;
	font-family: 'DM Sans', sans-serif; text-transform: uppercase; letter-spacing: 0.04em;
	transition: all 0.15s; position: relative;
}
.notif-tab:hover { color: #94a3b8; }
.notif-tab--active { color: #ffd700; }
.notif-tab--active::after {
	content: ''; position: absolute; bottom: 0; left: 16px; right: 16px;
	height: 2px; background: #ffd700; border-radius: 1px;
}
.notif-tab__badge {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
	background: #ef4444; color: #fff; font-size: 9px; font-weight: 700;
	margin-left: 5px; vertical-align: middle;
}

/* ── Search Bar ── */
.notif-search {
	padding: 8px 12px; border-bottom: 1px solid #334155; flex-shrink: 0;
}
.notif-search input {
	width: 100%; padding: 7px 10px 7px 32px; border: 1px solid #334155;
	border-radius: 8px; background: #0f172a; color: #e2e8f0;
	font-size: 12px; font-family: 'DM Sans', sans-serif; outline: none;
}
.notif-search input:focus { border-color: #6b4aa3; }
.notif-search input::placeholder { color: #475569; }
.notif-search { position: relative; }
.notif-search svg {
	position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
	width: 14px; height: 14px; color: #475569; pointer-events: none;
}

/* ── Header bar (context-dependent) ── */
.notif-toolbar {
	display: flex; align-items: center; justify-content: space-between;
	padding: 8px 12px; border-bottom: 1px solid #334155; flex-shrink: 0;
}
.notif-toolbar__title {
	font-family: 'Bungee', Impact, sans-serif; font-size: 12px;
	color: #ffd700; text-transform: uppercase; letter-spacing: 0.05em;
}
.notif-toolbar__actions { display: flex; gap: 6px; }
.notif-toolbar__btn {
	border: none; background: transparent; color: #6b4aa3;
	font-size: 11px; font-weight: 600; cursor: pointer;
	font-family: 'DM Sans', sans-serif; padding: 4px 8px; border-radius: 6px;
}
.notif-toolbar__btn:hover { color: #c9a0dc; background: rgba(107, 74, 163, 0.1); }
.notif-toolbar__btn--primary {
	background: #6b4aa3; color: #fff;
}
.notif-toolbar__btn--primary:hover { background: #7c5ab8; color: #fff; }

/* ── Scrollable body ── */
.notif-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

/* ── Notification Items ── */
.notif-empty {
	text-align: center; padding: 32px 16px; color: #475569; font-size: 13px;
}
.notif-item {
	display: flex; align-items: flex-start; gap: 10px;
	padding: 10px 14px; cursor: pointer; transition: background 0.1s;
	border-bottom: 1px solid rgba(51, 65, 85, 0.5); position: relative;
}
.notif-item:hover { background: rgba(107, 74, 163, 0.08); }
.notif-item--read { opacity: 0.55; }

.notif-icon {
	width: 32px; height: 32px; border-radius: 8px;
	display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.notif-icon svg { width: 16px; height: 16px; }
.notif-icon--info { background: rgba(100, 181, 246, 0.15); color: #64b5f6; }
.notif-icon--success { background: rgba(86, 212, 143, 0.15); color: #56d48f; }
.notif-icon--warning { background: rgba(255, 183, 77, 0.15); color: #ffb74d; }
.notif-icon--action { background: rgba(186, 104, 200, 0.15); color: #ba68c8; }
.notif-icon--reward { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
.notif-icon--assignment { background: rgba(107, 74, 163, 0.15); color: #c9a0dc; }
.notif-icon--reminder { background: rgba(255, 138, 101, 0.15); color: #ff8a65; }
.notif-icon--message { background: rgba(107, 74, 163, 0.15); color: #c9a0dc; }

.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; color: #e2e8f0; line-height: 1.3; }
.notif-body-text {
	font-size: 12px; color: #94a3b8; line-height: 1.4; margin-top: 2px;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-meta { font-size: 10px; color: #64748b; margin-top: 4px; }
.notif-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #6b4aa3; flex-shrink: 0; margin-top: 4px;
}

/* ── Thread list items ── */
.thread-item {
	display: flex; align-items: flex-start; gap: 10px;
	padding: 10px 14px; cursor: pointer; transition: background 0.1s;
	border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}
.thread-item:hover { background: rgba(107, 74, 163, 0.08); }
.thread-item--unread .thread-subject { color: #ffd700; font-weight: 700; }
.thread-avatar {
	width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	font-size: 13px; font-weight: 700; color: #fff;
	background: #6b4aa3; overflow: hidden;
}
.thread-avatar canvas { width: 32px !important; height: 32px !important; display: block; }
.thread-avatar--shared { background: #f59e0b; }
.thread-info { flex: 1; min-width: 0; }
.thread-subject { font-size: 13px; font-weight: 600; color: #e2e8f0; line-height: 1.3; }
.thread-preview { font-size: 11px; color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-meta { font-size: 10px; color: #475569; margin-top: 3px; }
.thread-badges { display: flex; gap: 4px; align-items: center; }
.thread-badge {
	font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 6px;
	text-transform: uppercase; letter-spacing: 0.03em;
}
.thread-badge--shared { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.thread-badge--count { background: rgba(107, 74, 163, 0.15); color: #c9a0dc; }

/* ── Thread detail view ── */
.thread-header {
	display: flex; align-items: center; gap: 8px;
	padding: 10px 12px; border-bottom: 1px solid #334155; flex-shrink: 0;
}
.thread-back {
	width: 28px; height: 28px; border: none; background: rgba(51, 65, 85, 0.5);
	border-radius: 6px; color: #94a3b8; cursor: pointer; display: flex;
	align-items: center; justify-content: center; flex-shrink: 0;
}
.thread-back:hover { color: #ffd700; background: rgba(51, 65, 85, 0.8); }
.thread-back svg { width: 16px; height: 16px; }
.thread-header-info { flex: 1; min-width: 0; }
.thread-header-subject { font-size: 13px; font-weight: 700; color: #e2e8f0; }
.thread-header-participants { font-size: 10px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread-messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px; }
.msg-row {
	display: flex; align-items: flex-end; gap: 6px; margin-bottom: 10px;
}
.msg-row--me { justify-content: flex-end; }
.msg-avatar {
	width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	font-size: 10px; font-weight: 700; color: #fff; background: #6b4aa3;
	overflow: hidden;
}
.msg-avatar canvas { width: 24px !important; height: 24px !important; display: block; }
.msg-bubble-wrap { max-width: 80%; }
.msg-bubble {
	padding: 8px 12px;
	border-radius: 12px; font-size: 13px; line-height: 1.5; word-wrap: break-word;
}
.msg-bubble--them {
	background: #334155; color: #e2e8f0; border-bottom-left-radius: 4px;
	margin-right: auto;
}
.msg-bubble--me {
	background: #6b4aa3; color: #fff; border-bottom-right-radius: 4px;
	margin-left: auto;
}
.msg-sender { font-size: 10px; font-weight: 600; color: #fbbf24; margin-bottom: 2px; }
.msg-time { font-size: 9px; color: rgba(255,255,255,0.4); margin-top: 3px; text-align: right; }
.msg-bubble--them .msg-time { color: #64748b; }

/* ── Reply input ── */
.thread-reply {
	display: flex; gap: 8px; padding: 10px 12px;
	border-top: 1px solid #334155; flex-shrink: 0;
}
.thread-reply input {
	flex: 1; padding: 8px 12px; border: 1px solid #334155; border-radius: 8px;
	background: #0f172a; color: #e2e8f0; font-size: 13px;
	font-family: 'DM Sans', sans-serif; outline: none;
}
.thread-reply input:focus { border-color: #6b4aa3; }
.thread-reply input::placeholder { color: #475569; }
.thread-reply button {
	padding: 8px 14px; border: none; border-radius: 8px;
	background: #6b4aa3; color: #fff; font-size: 12px; font-weight: 600;
	cursor: pointer; font-family: 'DM Sans', sans-serif;
	transition: background 0.15s; white-space: nowrap;
}
.thread-reply button:hover { background: #7c5ab8; }

/* ── Compose view ── */
.compose-form { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.compose-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.compose-input {
	width: 100%; padding: 8px 12px; border: 1px solid #334155; border-radius: 8px;
	background: #0f172a; color: #e2e8f0; font-size: 13px;
	font-family: 'DM Sans', sans-serif; outline: none;
}
.compose-input:focus { border-color: #6b4aa3; }
.compose-input::placeholder { color: #475569; }
.compose-textarea {
	width: 100%; min-height: 100px; padding: 10px 12px; border: 1px solid #334155;
	border-radius: 8px; background: #0f172a; color: #e2e8f0;
	font-size: 13px; font-family: 'DM Sans', sans-serif; outline: none;
	resize: vertical;
}
.compose-textarea:focus { border-color: #6b4aa3; }
.compose-textarea::placeholder { color: #475569; }

.compose-recipients-btn {
	width: 100%; padding: 8px 12px; border: 1px dashed #334155; border-radius: 8px;
	background: transparent; color: #94a3b8; font-size: 12px;
	cursor: pointer; font-family: 'DM Sans', sans-serif; text-align: left;
	transition: all 0.15s;
}
.compose-recipients-btn:hover { border-color: #6b4aa3; color: #c9a0dc; }
.compose-recipients-btn--selected { border-style: solid; border-color: #6b4aa3; color: #c9a0dc; }

.compose-toggle {
	display: flex; align-items: center; gap: 8px;
	font-size: 12px; color: #94a3b8; cursor: pointer;
}
.compose-toggle input { accent-color: #6b4aa3; }

.compose-actions {
	display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px;
}
.compose-send {
	padding: 8px 20px; border: none; border-radius: 8px;
	background: #6b4aa3; color: #fff; font-size: 13px; font-weight: 600;
	cursor: pointer; font-family: 'DM Sans', sans-serif;
}
.compose-send:hover { background: #7c5ab8; }
.compose-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Message Reactions ── */
.msg-reactions {
	display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
	margin-top: 2px; position: relative;
}
.msg-react-chip {
	display: inline-flex; align-items: center; gap: 2px;
	padding: 1px 6px; border-radius: 10px; border: 1px solid #334155;
	background: #0f172a; font-size: 12px; cursor: pointer;
	transition: all 0.12s; color: #94a3b8;
}
.msg-react-chip:hover { border-color: #6b4aa3; background: rgba(107, 74, 163, 0.15); }
.msg-react-chip--active { border-color: #6b4aa3; background: rgba(107, 74, 163, 0.2); color: #c9a0dc; }
.msg-react-count { font-size: 10px; font-weight: 600; }
.msg-react-add {
	width: 22px; height: 22px; border-radius: 50%; border: 1px dashed #334155;
	background: none; color: #475569; cursor: pointer; font-size: 12px;
	display: flex; align-items: center; justify-content: center;
	transition: all 0.12s;
}
.msg-react-add:hover { border-color: #6b4aa3; color: #c9a0dc; background: rgba(107, 74, 163, 0.1); }
.msg-react-picker {
	position: absolute; bottom: 28px; right: 0; z-index: 60;
	display: flex; gap: 2px; padding: 6px; background: #1e293b;
	border: 1px solid #334155; border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); flex-wrap: wrap; width: 180px;
}
.msg-react-picker-btn {
	width: 28px; height: 28px; border: none; border-radius: 6px;
	background: none; cursor: pointer; font-size: 16px;
	display: flex; align-items: center; justify-content: center;
}
.msg-react-picker-btn:hover { background: rgba(107, 74, 163, 0.2); }
@media (max-width: 480px) {
	.msg-react-picker { width: 160px; right: auto; left: 50%; transform: translateX(-50%); }
}

/* ── Reply TipTap Editor ── */
.thread-reply { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid #334155; flex-shrink: 0; align-items: flex-end; }
.thread-reply-editor {
	flex: 1; min-height: 36px; max-height: 120px; overflow-y: auto;
	border: 1px solid #334155; border-radius: 8px; background: #0f172a;
}
.thread-reply-editor .te-wrapper { border: none; background: transparent; border-radius: 8px; }
.thread-reply-editor .te-editor { min-height: 36px; }
.thread-reply-editor .te-editor .tiptap {
	padding: 8px 12px; color: #e2e8f0; min-height: 36px; outline: none;
	font-family: 'DM Sans', sans-serif; font-size: 13px; line-height: 1.4;
}
.thread-reply-editor .te-editor .tiptap p { margin: 0; }
.thread-reply-editor .te-editor .tiptap p.is-editor-empty:first-child::before {
	content: attr(data-placeholder); color: #475569; float: left; height: 0; pointer-events: none;
}
.thread-reply-editor .te-editor .tiptap strong { color: #ffd700; }
.thread-reply-editor .te-editor .tiptap em { color: #c9a0dc; }
.thread-reply-editor .te-editor .tiptap a { color: #818cf8; }
/* Bubble menu dark theme */
.thread-reply-editor .te-bubble,
.compose-editor-wrap .te-bubble {
	background: #1e293b; border-color: #334155;
}
.thread-reply-editor .te-bubble__btn,
.compose-editor-wrap .te-bubble__btn { color: #94a3b8; }
.thread-reply-editor .te-bubble__btn:hover,
.compose-editor-wrap .te-bubble__btn:hover { color: #e2e8f0; background: #334155; }
.thread-reply-editor .te-bubble__btn--active,
.compose-editor-wrap .te-bubble__btn--active { color: #ffd700; background: rgba(255, 215, 0, 0.1); border-color: #ffd700; }

/* Compose TipTap */
.compose-editor-wrap {
	flex: 1; min-height: 100px; border: 1px solid #334155; border-radius: 8px; background: #0f172a;
}
.compose-editor-wrap .te-wrapper { border: none; background: transparent; border-radius: 8px; }
.compose-editor-wrap .te-editor { min-height: 100px; }
.compose-editor-wrap .te-editor .tiptap {
	padding: 10px 12px; color: #e2e8f0; min-height: 100px; outline: none;
	font-family: 'DM Sans', sans-serif; font-size: 13px; line-height: 1.5;
}
.compose-editor-wrap .te-editor .tiptap p { margin: 0 0 4px; }
.compose-editor-wrap .te-editor .tiptap p.is-editor-empty:first-child::before {
	content: attr(data-placeholder); color: #475569; float: left; height: 0; pointer-events: none;
}

/* ── HTML in message bubbles ── */
.msg-bubble p { margin: 0 0 4px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble a { color: #818cf8; text-decoration: underline; }
.msg-bubble ul, .msg-bubble ol { padding-left: 16px; margin: 4px 0; }
.msg-bubble blockquote { border-left: 2px solid #475569; padding-left: 8px; margin: 4px 0; opacity: 0.8; }
.msg-bubble code { background: rgba(0,0,0,0.3); padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* ── Print ── */
@media print { .notif-bell, .notif-panel { display: none !important; } }

/* ── Mobile ── */
@media (max-width: 640px) {
	.notif-panel {
		position: fixed; top: 0; left: 0; right: 0; bottom: 0;
		width: 100%; max-width: 100%; height: 100%; max-height: 100%;
		border-radius: 0; border: none;
		transform: translateY(100%); opacity: 1;
	}
	.notif-panel--open { transform: translateY(0); }

	/* Thread detail fills entire panel on mobile */
	#notif-thread-detail, #notif-compose-view {
		position: absolute; top: 0; left: 0; right: 0; bottom: 0;
		z-index: 2; background: #1e293b;
	}

	/* Keep reply input above mobile keyboard */
	.thread-reply {
		position: sticky; bottom: 0; z-index: 5;
		background: #1e293b; padding-bottom: max(8px, env(safe-area-inset-bottom));
	}

	.thread-messages { padding-bottom: 8px; }
	.msg-bubble-wrap { max-width: 88%; }

	/* Compose form fills screen */
	.compose-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
