/* =========================================================
   Chat widget (front-end) — editorial, site-aligned
   ========================================================= */
:root { /* local tokens already inherited from :root */ }

.gj-chat-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	width: 52px;
	height: 52px;
	border-radius: 4px;
	border: none;
	background: var(--accent);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 20px rgba(255, 109, 41, 0.35);
	cursor: pointer;
	z-index: 9998;
	transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.gj-chat-launcher:hover {
	background: var(--accent-hover);
	transform: translateY(-2px);
	box-shadow: 0 12px 26px rgba(255, 109, 41, 0.45);
}
.gj-chat-launcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.gj-chat-launcher svg { display: block; }

/* subtle pulse ring — single orchestrated motion */
.gj-chat-launcher::after {
	content: '';
	position: absolute;
	inset: -6px;
	border-radius: 8px;
	border: 1px solid var(--accent);
	opacity: 0;
	animation: gj-chat-ring 3.2s var(--ease) infinite;
	pointer-events: none;
}
@keyframes gj-chat-ring {
	0% { transform: scale(0.85); opacity: 0.5; }
	70% { transform: scale(1.15); opacity: 0; }
	100% { transform: scale(1.15); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.gj-chat-launcher::after { animation: none; }
	.gj-chat-msg, .gj-chat-panel { animation: none; }
}

.gj-chat-panel {
	position: fixed;
	right: 24px;
	bottom: 88px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 112px);
	background: #ffffff;
	color: #1a1a1a;
	border-radius: 4px;
	border: 1px solid var(--line-strong);
	box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 9999;
	font-family: var(--font);
	animation: gj-chat-pop 0.2s var(--ease);
}
.gj-chat-panel[hidden] { display: none !important; }

@keyframes gj-chat-pop {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

.gj-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	background: var(--bg);
	color: var(--ink);
	border-bottom: 1px solid var(--line);
}
.gj-chat-header-left { display: flex; flex-direction: column; gap: 4px; position: relative; padding-left: 12px; }
/* echo of the site's heading accent rule */
.gj-chat-header-left::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0.15em;
	bottom: 0.15em;
	width: 2px;
	background: var(--accent);
	opacity: 0.9;
}
.gj-chat-title {
	font-family: var(--font-display);
	font-weight: 500;
	font-size: 18px;
	letter-spacing: 0.1px;
	color: var(--ink);
}
.gj-chat-status { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.gj-chat-dot {
	width: 7px; height: 7px; border-radius: 50%;
	background: #2ecc71;
	display: inline-block;
}
.gj-chat-close {
	background: none;
	border: 1px solid var(--line);
	color: var(--ink-2);
	font-size: 18px;
	cursor: pointer;
	line-height: 1;
	width: 28px; height: 28px;
	border-radius: 3px;
	display: flex; align-items: center; justify-content: center;
	transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.gj-chat-close:hover { border-color: var(--accent); color: var(--accent); }

.gj-chat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 18px;
	background: #fafafa;
	color: #1a1a1a;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scrollbar-width: thin;
	scrollbar-color: #c9ccd1 transparent;
}
.gj-chat-body::-webkit-scrollbar { width: 6px; }
.gj-chat-body::-webkit-scrollbar-thumb { background: #c9ccd1; border-radius: 3px; }

.gj-chat-msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 4px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	white-space: pre-wrap;
	position: relative;
	animation: gj-chat-msg-in 0.16s var(--ease);
	display: flex;
	gap: 10px;
	align-items: flex-start;
}
@keyframes gj-chat-msg-in {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}
.gj-chat-msg.visitor {
	align-self: flex-end;
	background: var(--accent);
	color: #fff;
	border-bottom-right-radius: 2px;
}
.gj-chat-msg.admin {
	align-self: flex-start;
	background: #fff;
	color: #1a1a1a;
	border: 1px solid #e3e5e8;
	border-bottom-left-radius: 2px;
}
.gj-chat-msg.system {
	align-self: center;
	background: transparent;
	color: #6b7280;
	font-size: 12px;
	text-align: center;
	max-width: 100%;
	padding: 4px 8px;
	display: block;
}
.gj-chat-avatar {
	flex: 0 0 auto;
	width: 24px; height: 24px;
	border-radius: 3px;
	background: #161316;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	display: flex; align-items: center; justify-content: center;
	font-family: var(--font-display);
}
.gj-chat-msg.visitor .gj-chat-avatar { background: rgba(255, 255, 255, 0.22); }
.gj-chat-msg > div { flex: 1 1 auto; min-width: 0; }
.gj-chat-msg .gj-chat-msg-meta {
	font-size: 10px;
	opacity: 0.65;
	margin-top: 4px;
	display: block;
	letter-spacing: 0.2px;
}
.gj-chat-msg img { max-width: 100%; border-radius: 3px; margin-top: 8px; display: block; }

.gj-chat-form { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.gj-chat-form input {
	padding: 10px 12px;
	border: 1px solid #d4d7dc;
	border-radius: 3px;
	font-size: 14px;
	font-family: var(--font);
	outline: none;
	transition: border-color 0.2s var(--ease);
	background: #fff;
	color: #1a1a1a;
}
.gj-chat-form input:focus { border-color: var(--accent); }
.gj-chat-form button {
	background: var(--accent);
	color: #fff;
	border: none;
	border-radius: 3px;
	padding: 10px 14px;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	transition: background 0.2s var(--ease);
}
.gj-chat-form button:hover { background: var(--accent-hover); }
.gj-chat-form button:disabled { opacity: 0.5; cursor: default; }

.gj-chat-footer {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 12px 14px;
	background: #fff;
	border-top: 1px solid #e6e8ec;
}
.gj-chat-footer input[type="text"] {
	flex: 1 1 auto;
	border: 1px solid #d4d7dc;
	border-radius: 3px;
	padding: 9px 12px;
	font-size: 14px;
	font-family: var(--font);
	outline: none;
	transition: border-color 0.2s var(--ease);
	background: #fff;
	color: #1a1a1a;
}
.gj-chat-footer input[type="text"]:focus { border-color: var(--accent); }
.gj-chat-icon-btn {
	background: none;
	border: 1px solid transparent;
	font-size: 16px;
	cursor: pointer;
	padding: 0;
	width: 32px; height: 32px;
	border-radius: 3px;
	color: #555;
	display: flex; align-items: center; justify-content: center;
	transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.gj-chat-icon-btn:hover { border-color: var(--line); background: #f4f4f4; color: var(--accent); }
.gj-chat-send-btn {
	background: var(--accent);
	color: #fff;
	border: none;
	border-radius: 3px;
	width: 34px; height: 34px;
	cursor: pointer;
	font-size: 15px;
	display: flex; align-items: center; justify-content: center;
	transition: background 0.2s var(--ease);
}
.gj-chat-send-btn:hover { background: var(--accent-hover); }
.gj-chat-send-btn:disabled { opacity: 0.4; cursor: default; }

.gj-chat-emoji-picker {
	position: absolute;
	bottom: 56px;
	left: 14px;
	right: 14px;
	background: #fff;
	border: 1px solid #d4d7dc;
	border-radius: 4px;
	padding: 10px;
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 2px;
	max-height: 170px;
	overflow-y: auto;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
	z-index: 10000;
	animation: gj-chat-pop 0.15s var(--ease);
}
.gj-chat-emoji-picker[hidden] { display: none !important; }
.gj-chat-emoji-picker button {
	background: none;
	border: none;
	font-size: 18px;
	cursor: pointer;
	padding: 4px;
	border-radius: 3px;
	transition: background 0.15s var(--ease);
}
.gj-chat-emoji-picker button:hover { background: #f1f3f6; }

.gj-chat-attach-preview {
	padding: 8px 14px;
	background: #f7f7f7;
	border-top: 1px solid #e6e8ec;
}
.gj-chat-attach-preview[hidden] { display: none !important; }
.gj-chat-attach-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #fff;
	color: #1a1a1a;
	padding: 4px 10px;
	border: 1px solid #d4d7dc;
	border-radius: 3px;
	font-size: 12px;
}
.gj-chat-attach-remove {
	background: none;
	border: none;
	color: #6b7280;
	cursor: pointer;
	font-size: 14px;
	padding: 0 2px;
	line-height: 1;
}
.gj-chat-attach-remove:hover { color: var(--accent-hover); }

.gj-chat-attachment {
	display: inline-block;
	margin-top: 6px;
	padding: 6px 10px;
	background: #f1f3f6;
	border: 1px solid #e3e5e8;
	border-radius: 3px;
	font-size: 12px;
	color: #1a1a1a;
}

@media (max-width: 480px) {
	.gj-chat-panel {
		right: 8px;
		bottom: 76px;
		width: calc(100vw - 16px);
		height: calc(100vh - 96px);
	}
	.gj-chat-launcher { right: 12px; bottom: 12px; }
}