/* =============================================================================
   Global Chat Widget — WeAreInvictus210
   ============================================================================= */

/* ── Floating bubble (redesigned — gaming style) ──────────────────────────── */
.inv-chat-bubble {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	background: linear-gradient(135deg, #f59e0b, #d97706);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #000;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	animation: invBubbleBreathe 3s ease-in-out infinite;
	flex-direction: column;
	gap: 0;
	padding: 0;
	overflow: visible;
}

@keyframes invBubbleBreathe {
	0%, 100% { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35); }
	50%      { box-shadow: 0 4px 30px rgba(245, 158, 11, 0.55), 0 0 12px rgba(245, 158, 11, 0.2); }
}

.inv-chat-bubble:hover {
	transform: scale(1.08);
	animation: none;
	box-shadow: 0 6px 28px rgba(245, 158, 11, 0.5);
}

/* Pulse ring */
.inv-chat-bubble__pulse {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid rgba(245, 158, 11, 0.4);
	animation: invBubblePulse 2.5s ease-out infinite;
	pointer-events: none;
}

@keyframes invBubblePulse {
	0%   { transform: scale(1); opacity: 0.6; }
	100% { transform: scale(1.5); opacity: 0; }
}

/* Icon container */
.inv-chat-bubble__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 2px;
}

/* LIVE label */
.inv-chat-bubble__live {
	font-family: 'Rajdhani', sans-serif;
	font-size: 0.5rem;
	font-weight: 800;
	letter-spacing: 0.12em;
	color: #000;
	line-height: 1;
	margin-top: -2px;
}

/* Unread badge */
.inv-chat-bubble__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	background: #ef4444;
	color: #fff;
	font-size: 0.68rem;
	font-weight: 700;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #080d1a;
	line-height: 1;
	z-index: 3;
}

/* Mention pulse animation on bubble */
.inv-chat-bubble--mention {
	animation: invBubbleMention 0.6s ease-in-out 3;
}

@keyframes invBubbleMention {
	0%, 100% { transform: scale(1); }
	25%      { transform: scale(1.15); }
	50%      { transform: scale(0.95); }
	75%      { transform: scale(1.1); }
}

/* ── Widget card ───────────────────────────────────────────────────────────── */
.inv-chat-widget {
	position: fixed;
	bottom: 80px;
	right: 16px;
	width: calc(100vw - 32px);
	height: 70dvh;
	max-height: 420px;
	background: #111827;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 16px;
	z-index: 9998;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
	animation: invChatIn 0.2s ease;
}

@keyframes invChatIn {
	from { opacity: 0; transform: translateY(12px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 641px) {
	.inv-chat-widget {
		width: 320px;
		height: 420px;
		max-height: none;
		right: 24px;
		bottom: 88px;
	}
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.inv-chat-widget__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	flex-shrink: 0;
}

.inv-chat-widget__title {
	font-family: 'Rajdhani', sans-serif;
	font-size: 0.9rem;
	font-weight: 700;
	color: #f59e0b;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.inv-chat-widget__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.4);
	cursor: pointer;
	border-radius: 6px;
	transition: color 0.15s, background 0.15s;
}

.inv-chat-widget__close:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.06);
}

/* ── Messages area ─────────────────────────────────────────────────────────── */
.inv-chat-widget__messages {
	flex: 1;
	overflow-y: auto;
	padding: 10px 12px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

.inv-chat-empty {
	text-align: center;
	padding: 40px 14px;
	font-size: 0.78rem;
	color: #6b7494;
	margin: auto 0;
}

/* ── Single message ────────────────────────────────────────────────────────── */
.inv-chat-msg {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 8px;
	transition: background 0.12s;
	position: relative;
}

.inv-chat-msg:hover {
	background: rgba(255, 255, 255, 0.03);
}

/* ── Avatar with frame support ─────────────────────────────────────────────── */
.inv-chat-msg__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, #1a2540, #0d1424);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.7rem;
	color: #6b7494;
	overflow: visible;
	position: relative;
}

.inv-chat-msg__avatar-photo {
	width: 76%;
	height: 76%;
	object-fit: cover;
	border-radius: 50%;
	position: absolute;
	top: 12%;
	left: 12%;
	z-index: 1;
}

.inv-chat-msg__avatar-frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 2;
	pointer-events: none;
	object-fit: contain;
}

.inv-chat-msg__avatar-fallback {
	font-size: 0.7rem;
	color: #6b7494;
}

/* Fallback when no frame — show photo full size */
.inv-chat-msg__avatar-photo:only-child {
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
}

.inv-chat-msg__body {
	min-width: 0;
	flex: 1;
}

.inv-chat-msg__meta {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 1px;
}

/* ── Username with profile link ────────────────────────────────────────────── */
.inv-chat-msg__name {
	font-size: 0.72rem;
	font-weight: 600;
	color: #e2e8f0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 120px;
}

.inv-chat-msg__name-link {
	color: inherit;
	text-decoration: none;
	transition: color 0.12s;
}

.inv-chat-msg__name-link:hover {
	color: #f59e0b;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.inv-chat-msg__level {
	font-size: 0.58rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 1px 4px;
	border-radius: 3px;
	line-height: 1.3;
}

.inv-chat-msg__level--scout     { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }
.inv-chat-msg__level--commander { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.inv-chat-msg__level--warlord   { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

/* ── Role badges (admin / mod) ─────────────────────────────────────────── */
.inv-chat-msg__role {
	font-size: 0.58rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 1px 5px;
	border-radius: 3px;
	line-height: 1.3;
}

.inv-chat-msg__role--admin { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.inv-chat-msg__role--mod   { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

.inv-chat-msg__time {
	font-size: 0.6rem;
	color: #4b5563;
	margin-left: auto;
	white-space: nowrap;
}

.inv-chat-msg__text {
	font-size: 0.78rem;
	color: #c8cce8;
	line-height: 1.4;
	word-break: break-word;
}

/* Allow text selection only on devices with a mouse (desktop) */
@media (hover: hover) and (pointer: fine) {
	.inv-chat-msg__text {
		-webkit-user-select: text;
		user-select: text;
	}
}

/* ── @Mention highlights ───────────────────────────────────────────────────── */
.inv-chat-mention {
	color: #f59e0b;
	font-weight: 600;
}

.inv-chat-mention--self {
	background: rgba(245, 158, 11, 0.15);
	padding: 1px 3px;
	border-radius: 3px;
}

/* ── @Mention autocomplete dropdown ────────────────────────────────────────── */
.inv-chat-mention-list {
	position: absolute;
	bottom: 100%;
	left: 0;
	right: 0;
	background: #1a2234;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	padding: 4px;
	box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
	z-index: 10002;
	max-height: 180px;
	overflow-y: auto;
	margin-bottom: 4px;
}

.inv-chat-mention-item {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 6px 10px;
	background: none;
	border: none;
	color: #c8cce8;
	font-size: 0.78rem;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.1s;
	text-align: left;
}

.inv-chat-mention-item:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
}

.inv-chat-mention-item__avatar {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.inv-chat-mention-item__avatar--fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #1a2540, #0d1424);
	font-size: 0.6rem;
	color: #6b7494;
}

.inv-chat-mention-item__name {
	font-weight: 500;
}

/* ── /Command palette ──────────────────────────────────────────────────────── */
.inv-chat-cmd-palette {
	position: absolute;
	bottom: 100%;
	left: 0;
	right: 0;
	background: #1a2234;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	padding: 4px;
	box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
	z-index: 10002;
	margin-bottom: 4px;
}

.inv-chat-cmd-palette__item {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 8px 10px;
	background: none;
	border: none;
	color: #c8cce8;
	font-size: 0.78rem;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.1s;
	text-align: left;
}

.inv-chat-cmd-palette__item:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
}

.inv-chat-cmd-palette__icon {
	font-size: 0.9rem;
	flex-shrink: 0;
}

.inv-chat-cmd-palette__label {
	font-weight: 700;
	color: #f59e0b;
	font-family: 'Rajdhani', sans-serif;
}

.inv-chat-cmd-palette__desc {
	color: #6b7494;
	font-size: 0.7rem;
	margin-left: auto;
}

/* ── Lineup card embed in chat ─────────────────────────────────────────────── */
.inv-chat-lineup {
	margin-top: 4px;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: #0d1424;
}

.inv-chat-lineup__inner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	text-decoration: none;
	color: inherit;
	transition: background 0.12s;
}

.inv-chat-lineup__inner:hover {
	background: rgba(255, 255, 255, 0.04);
}

.inv-chat-lineup__portraits {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.inv-chat-lineup__portrait {
	width: 28px;
	height: 28px;
	border-radius: 6px;
	overflow: hidden;
	background: #1a2235;
	border: 1.5px solid #0d1424;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #2d3a52;
	font-size: 0.6rem;
}

.inv-chat-lineup__portrait img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.inv-chat-lineup__info {
	min-width: 0;
	flex: 1;
}

.inv-chat-lineup__title {
	font-size: 0.72rem;
	font-weight: 600;
	color: #e2e8f0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.inv-chat-lineup__footer {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 2px;
}

.inv-chat-lineup__tier {
	font-size: 0.55rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 1px 5px;
	border-radius: 3px;
	color: #fff;
	line-height: 1.4;
}

.inv-chat-lineup__view {
	font-size: 0.65rem;
	color: #f59e0b;
	font-weight: 500;
	margin-left: auto;
}

.inv-chat-lineup__loading,
.inv-chat-lineup__error {
	padding: 12px;
	text-align: center;
	font-size: 0.72rem;
	color: #6b7494;
}

/* ── Lineup search overlay ─────────────────────────────────────────────────── */
.inv-chat-lineup-search {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: #111827;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	z-index: 10003;
	display: flex;
	flex-direction: column;
	max-height: 260px;
}

.inv-chat-lineup-search__header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	flex-shrink: 0;
}

.inv-chat-lineup-search__input {
	flex: 1;
	height: 32px;
	padding: 0 10px;
	background: #0d1529;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 6px;
	color: #e2e8f0;
	font-size: 0.78rem;
	font-family: 'Inter', sans-serif;
	outline: none;
}

.inv-chat-lineup-search__input:focus {
	border-color: rgba(245, 158, 11, 0.4);
}

.inv-chat-lineup-search__close {
	width: 28px;
	height: 28px;
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.4);
	font-size: 1.2rem;
	cursor: pointer;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.12s;
}

.inv-chat-lineup-search__close:hover {
	color: #fff;
}

.inv-chat-lineup-search__results {
	overflow-y: auto;
	flex: 1;
	padding: 4px;
}

.inv-chat-lineup-search__item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	background: none;
	border: none;
	color: #c8cce8;
	font-size: 0.78rem;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.1s;
	text-align: left;
}

.inv-chat-lineup-search__item:hover {
	background: rgba(255, 255, 255, 0.06);
}

.inv-chat-lineup-search__portraits {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.inv-chat-lineup-search__portrait {
	width: 24px;
	height: 24px;
	border-radius: 4px;
	overflow: hidden;
	background: #1a2235;
	border: 1px solid #0d1424;
	position: relative;
}

.inv-chat-lineup-search__portrait img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.inv-chat-lineup-search__info {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	flex: 1;
}

.inv-chat-lineup-search__title {
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.inv-chat-lineup-search__tier {
	font-size: 0.55rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 1px 5px;
	border-radius: 3px;
	color: #fff;
	line-height: 1.4;
	flex-shrink: 0;
}

.inv-chat-lineup-search__empty {
	padding: 20px 12px;
	text-align: center;
	font-size: 0.75rem;
	color: #6b7494;
}

/* ── Input bar ─────────────────────────────────────────────────────────────── */
.inv-chat-widget__input {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	flex-shrink: 0;
}

.inv-chat-input {
	flex: 1;
	height: 36px;
	padding: 0 12px;
	background: #0d1529;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 8px;
	color: #e2e8f0;
	font-size: 16px; /* prevents iOS zoom on focus */
	font-family: 'Inter', sans-serif;
	outline: none;
	transition: border-color 0.15s;
}

.inv-chat-input:focus {
	border-color: rgba(245, 158, 11, 0.4);
}

.inv-chat-input::placeholder {
	color: #4b5563;
}

.inv-chat-input:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.inv-chat-send {
	width: 36px;
	height: 36px;
	background: #f59e0b;
	border: none;
	border-radius: 8px;
	color: #000;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	-webkit-user-select: none;
	user-select: none;
}

.inv-chat-send:hover {
	opacity: 0.85;
}

.inv-chat-send:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* ── Mute bar ──────────────────────────────────────────────────────────────── */
.inv-chat-mute-bar {
	display: none;
	padding: 8px 12px;
	background: rgba(239, 68, 68, 0.1);
	border-top: 1px solid rgba(239, 68, 68, 0.2);
	color: #ef4444;
	font-size: 0.72rem;
	font-weight: 500;
	text-align: center;
	flex-shrink: 0;
}

/* ── Guest CTA ─────────────────────────────────────────────────────────────── */
.inv-chat-widget__guest {
	padding: 12px;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	flex-shrink: 0;
	text-align: center;
}

.inv-chat-guest-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	padding: 0 20px;
	background: #f59e0b;
	color: #000;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	border-radius: 8px;
	text-decoration: none;
	transition: opacity 0.15s;
}

.inv-chat-guest-cta:hover {
	opacity: 0.85;
}

/* ── Admin context menu ────────────────────────────────────────────────────── */
.inv-chat-ctx {
	position: absolute;
	min-width: 150px;
	background: #1a2234;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	padding: 4px;
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
	z-index: 10000;
	overflow: hidden;
}

.inv-chat-ctx__header {
	padding: 6px 10px 4px;
	font-size: 0.6rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #6b7494;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	margin-top: 2px;
}

.inv-chat-ctx__item {
	display: block;
	width: 100%;
	padding: 7px 10px;
	background: none;
	border: none;
	color: #c8cce8;
	font-size: 0.75rem;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.1s, color 0.1s;
}

.inv-chat-ctx__item:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
}

.inv-chat-ctx__item--red {
	color: #ef4444;
}

.inv-chat-ctx__item--red:hover {
	background: rgba(239, 68, 68, 0.12);
	color: #f87171;
}

/* ── Toast notification (spam / error) ────────────────────────────────────── */
.inv-chat-toast {
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: 60px;
	padding: 8px 14px;
	background: rgba(239, 68, 68, 0.95);
	color: #fff;
	font-size: 0.72rem;
	font-weight: 600;
	border-radius: 8px;
	text-align: center;
	z-index: 10001;
	pointer-events: none;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.inv-chat-toast--visible {
	opacity: 1;
	transform: translateY(0);
}

/* ── System messages (ephemeral) ──────────────────────────────────────────── */
.inv-chat-system {
	text-align: center;
	font-size: 0.68rem;
	color: #6b7494;
	font-style: italic;
	padding: 4px 8px;
}

/* =============================================================================
   Chat inside Sidebar — Override fixed positioning
   ============================================================================= */

.inv-sidebar__chat-slot .inv-chat-widget {
	position: static !important;
	width: 100% !important;
	height: 100% !important;
	max-height: none !important;
	border-radius: 0 !important;
	border: none !important;
	box-shadow: none !important;
	animation: none !important;
	background: transparent;
}

.inv-sidebar__chat-slot .inv-chat-widget__header {
	padding: 10px 14px;
}

.inv-sidebar__chat-slot .inv-chat-widget__close {
	display: none;
}

.inv-sidebar__chat-slot .inv-chat-widget__messages {
	flex: 1;
	min-height: 0;
}

/* Hide the floating bubble when chat is in sidebar */
body.inv-sidebar-open .inv-chat-bubble {
	display: none !important;
}
