/**
 * GRACE Technology Bangladesh — plugin assets/css/chat.css
 *
 * Designed & developed by Ishraq Uddin Chowdhury <ishraq.uc@gmail.com>
 * Copyright (c) 2026 Ishraq Uddin Chowdhury. All rights reserved.
 * Unauthorized copying, modification or use without written permission is prohibited. See LICENSE.
 */

/*
 * GRACE chat widget (inc/chat.php + assets/js/chat.js).
 * Floating button bottom-right; on phones it docks above the fixed bottom action bar (and the calculator dock)
 * and follows the bar when it slides away. Panel: a card above the button on larger screens, a bottom sheet
 * on phones. Tokens from theme/grace/src/css/tokens.css (design standard) with fallbacks. Never green.
 */
.g-chat {
	--chat-gap: 20px;
	--chat-bottom: 24px;
	font-family: var(--font-body, inherit);
	color: rgb(var(--c-ink, 10 10 10));
}

/* ---------- Floating button ---------- */
.g-chat__fab {
	position: fixed;
	right: var(--chat-gap);
	bottom: calc(var(--chat-bottom) + env(safe-area-inset-bottom, 0px));
	z-index: 870;
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2, 8px);
	height: 56px;
	padding: 0 20px 0 16px;
	border: 0;
	border-radius: 28px;
	background: rgb(var(--c-emerald, 215 25 32));
	color: #fff;
	font-family: var(--font-display, inherit);
	font-size: var(--fs-small, 1rem);
	font-weight: var(--fw-bold, 700);
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 10px 24px -10px rgb(10 10 10 / 0.45), 0 2px 6px rgb(10 10 10 / 0.12);
	transition:
		transform var(--d-base, 250ms) var(--ease-standard, ease),
		background-color var(--d-fast, 150ms) ease,
		bottom var(--d-base, 250ms) var(--ease-standard, ease);
}

.g-chat__fab:hover {
	background: rgb(var(--c-forest, 168 20 26));
	transform: translateY(-1px);
}

.g-chat__fab:focus-visible {
	outline: 3px solid rgb(var(--c-ink, 10 10 10));
	outline-offset: 3px;
}

.g-chat__fab .g-chat__icon {
	width: 26px;
	height: 26px;
}

.g-chat.is-open .g-chat__fab {
	background: rgb(var(--c-ink, 10 10 10));
}

.g-chat__icon {
	flex: none;
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentcolor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------- Panel ---------- */
.g-chat__panel {
	position: fixed;
	right: var(--chat-gap);
	bottom: calc(var(--chat-bottom) + 56px + 12px + env(safe-area-inset-bottom, 0px));
	z-index: 990;
	display: flex;
	flex-direction: column;
	width: min(400px, calc(100vw - 2 * var(--chat-gap)));
	height: min(640px, calc(100vh - 140px));
	height: min(640px, calc(100dvh - 140px));
	border: 1px solid rgb(var(--c-line, 229 229 229));
	border-radius: var(--radius-md, 8px);
	background: #fff;
	box-shadow: 0 24px 48px -20px rgb(10 10 10 / 0.35), 0 2px 8px rgb(10 10 10 / 0.08);
	overflow: hidden;
	animation: g-chat-in 200ms var(--ease-standard, ease-out) both;
}

.g-chat__panel[hidden] {
	display: none;
}

.g-chat__panel:focus {
	outline: none;
}

.g-chat__panel:focus-visible {
	outline: 3px solid rgb(var(--c-emerald, 215 25 32));
	outline-offset: -3px;
}

.g-chat__head {
	display: flex;
	align-items: center;
	gap: var(--sp-3, 12px);
	padding: var(--sp-3, 12px) var(--sp-2, 8px) var(--sp-3, 12px) var(--sp-4, 16px);
	background: rgb(var(--c-ink, 10 10 10));
	color: #fff;
}

.g-chat__back:not([hidden]) + .g-chat__avatar {
	display: none;
}

.g-chat__avatar {
	display: grid;
	place-items: center;
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgb(var(--c-emerald, 215 25 32));
	font-family: var(--font-display, inherit);
	font-weight: 800;
	font-size: 1.125rem;
}

.g-chat__head-text {
	flex: 1;
	min-width: 0;
}

.g-chat__title {
	margin: 0;
	font-family: var(--font-display, inherit);
	font-size: var(--fs-body, 1rem);
	font-weight: var(--fw-bold, 700);
	line-height: var(--lh-snug, 1.4);
	color: #fff;
	letter-spacing: 0;
}

.g-chat__sub {
	margin: 2px 0 0;
	font-size: var(--fs-caption, 14px);
	line-height: var(--lh-snug, 1.4);
	color: rgb(255 255 255 / 0.78);
}

.g-chat__iconbtn {
	display: grid;
	place-items: center;
	flex: none;
	width: var(--hit, 44px);
	height: var(--hit, 44px);
	padding: 0;
	border: 0;
	border-radius: var(--radius-sm, 6px);
	background: transparent;
	color: #fff;
	cursor: pointer;
}

.g-chat__iconbtn:hover {
	background: rgb(255 255 255 / 0.12);
}

.g-chat__iconbtn:focus-visible {
	outline: 3px solid #fff;
	outline-offset: -3px;
}

.g-chat__iconbtn[hidden] {
	display: none;
}

.g-chat__offline {
	margin: 0;
	padding: var(--sp-2, 8px) var(--sp-4, 16px);
	background: rgb(var(--c-warn-soft, 254 243 199));
	color: rgb(var(--c-warn, 176 82 10));
	font-size: var(--fs-caption, 14px);
}

.g-chat__offline[hidden] {
	display: none;
}

.g-chat__body {
	flex: 1;
	min-height: 0;
	padding: var(--sp-4, 16px);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: rgb(var(--c-surface-2, 246 246 246));
	font-size: var(--fs-small, 0.95rem);
	line-height: var(--lh-snug, 1.5);
}

.g-chat__view[hidden] {
	display: none;
}

.g-chat__view:focus {
	outline: none;
}

.g-chat__bubble {
	margin: 0 0 var(--sp-4, 16px);
	padding: var(--sp-3, 12px) var(--sp-4, 16px);
	border: 1px solid rgb(var(--c-line, 229 229 229));
	border-radius: 2px var(--radius-md, 8px) var(--radius-md, 8px) var(--radius-md, 8px);
	background: #fff;
	max-width: 92%;
}

.g-chat__label {
	margin: 0 0 var(--sp-2, 8px);
	font-family: var(--font-display, inherit);
	font-size: var(--fs-caption, 14px);
	font-weight: var(--fw-semibold, 600);
	color: rgb(var(--c-muted, 85 85 85));
	letter-spacing: 0;
}

.g-chat__faqs {
	display: grid;
	gap: var(--sp-2, 8px);
	margin: 0 0 var(--sp-4, 16px);
	padding: 0;
	list-style: none;
}

.g-chat__faq {
	margin: 0;
}

.g-chat__q {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-3, 12px);
	width: 100%;
	min-height: var(--hit, 44px);
	padding: var(--sp-2, 8px) var(--sp-3, 12px) var(--sp-2, 8px) var(--sp-4, 16px);
	border: 1px solid rgb(var(--c-line, 229 229 229));
	border-radius: var(--radius-md, 8px);
	background: #fff;
	color: rgb(var(--c-ink, 10 10 10));
	font: inherit;
	font-weight: var(--fw-semibold, 600);
	text-align: left;
	cursor: pointer;
	transition: border-color var(--d-fast, 150ms) ease;
}

.g-chat__q:hover {
	border-color: rgb(var(--c-ink, 10 10 10));
}

.g-chat__q:focus-visible {
	outline: 3px solid rgb(var(--c-emerald, 215 25 32));
	outline-offset: 1px;
}

.g-chat__q .g-chat__icon {
	width: 18px;
	height: 18px;
	color: rgb(var(--c-emerald, 215 25 32));
	transition: transform var(--d-fast, 150ms) ease;
}

.g-chat__q[aria-expanded="true"] {
	border-color: rgb(var(--c-ink, 10 10 10));
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

.g-chat__q[aria-expanded="true"] .g-chat__icon {
	transform: rotate(45deg);
}

.g-chat__a {
	padding: var(--sp-3, 12px) var(--sp-4, 16px);
	border: 1px solid rgb(var(--c-ink, 10 10 10));
	border-top: 0;
	border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
	background: #fff;
}

.g-chat__a[hidden] {
	display: none;
}

.g-chat__a p {
	margin: 0 0 var(--sp-2, 8px);
}

.g-chat__a p:last-child {
	margin-bottom: 0;
}

.g-chat__a a {
	color: rgb(var(--c-forest, 168 20 26));
	text-decoration: underline;
	text-underline-offset: 2px;
}

.g-chat__empty {
	margin: 0 0 var(--sp-4, 16px);
	padding: var(--sp-3, 12px) var(--sp-4, 16px);
	border: 1px dashed rgb(var(--c-line, 229 229 229));
	border-radius: var(--radius-md, 8px);
	color: rgb(var(--c-muted, 85 85 85));
}

.g-chat__actions {
	display: grid;
	gap: var(--sp-2, 8px);
}

.g-chat .btn {
	min-height: var(--btn-h, 48px);
	white-space: normal;
}

.g-chat__ask {
	width: 100%;
}

.g-chat__quick {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--sp-2, 8px);
}

.g-chat__qbtn {
	padding-left: var(--sp-3, 12px);
	padding-right: var(--sp-3, 12px);
	background: #fff;
}

.g-chat__hint {
	margin: var(--sp-1, 4px) 0 0;
	font-size: var(--fs-caption, 14px);
	color: rgb(var(--c-muted, 85 85 85));
}

.g-chat__hint.is-warn {
	color: rgb(var(--c-warn, 176 82 10));
}

.g-chat__hint:empty {
	display: none;
}

/* ---------- Form ---------- */
.g-chat__form {
	display: grid;
	gap: var(--sp-3, 12px);
}

.g-chat__field {
	display: grid;
	gap: var(--sp-1, 4px);
}

.g-chat__field label {
	font-weight: var(--fw-semibold, 600);
	font-size: var(--fs-small, 0.95rem);
}

.g-chat .g-req {
	color: rgb(var(--c-emerald, 215 25 32));
}

.g-chat .g-opt {
	font-weight: 400;
	color: rgb(var(--c-muted, 85 85 85));
}

.g-chat__field input,
.g-chat__field select,
.g-chat__field textarea {
	width: 100%;
	min-height: var(--field-h, 48px);
	padding: 10px 12px;
	border: 1px solid rgb(var(--c-ink, 10 10 10) / 0.35);
	border-radius: var(--radius-sm, 6px);
	background: #fff;
	color: rgb(var(--c-ink, 10 10 10));
	font: inherit;
	font-size: max(16px, var(--fs-body, 1rem));
	line-height: 1.4;
	box-sizing: border-box;
}

.g-chat__field textarea {
	min-height: 96px;
	resize: vertical;
}

.g-chat__field .g-chat__filter {
	min-height: 44px;
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
	background: rgb(var(--c-surface-2, 246 246 246));
}

.g-chat__filter + select {
	margin-top: -5px;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.g-chat__field input:focus-visible,
.g-chat__field select:focus-visible,
.g-chat__field textarea:focus-visible {
	outline: 3px solid rgb(var(--c-emerald, 215 25 32) / 0.35);
	outline-offset: 0;
	border-color: rgb(var(--c-ink, 10 10 10));
}

.g-chat__field [aria-invalid="true"] {
	border-color: rgb(var(--c-error, 185 28 28));
	background: rgb(var(--c-error-soft, 254 226 226) / 0.35);
}

.g-chat__error {
	margin: 0;
	font-size: var(--fs-caption, 14px);
	color: rgb(var(--c-error, 185 28 28));
}

.g-chat__error:empty {
	display: none;
}

.g-chat__summary,
.g-chat__alert {
	margin: 0;
	padding: var(--sp-3, 12px);
	border-left: 4px solid rgb(var(--c-error, 185 28 28));
	border-radius: var(--radius-sm, 6px);
	background: rgb(var(--c-error-soft, 254 226 226));
	color: rgb(var(--c-error, 185 28 28));
	font-size: var(--fs-small, 0.95rem);
}

.g-chat__summary:focus {
	outline: none;
}

.g-chat__summary[hidden],
.g-chat__alert[hidden],
.g-chat__slow[hidden] {
	display: none;
}

.g-chat__alert p {
	margin: 0;
}

.g-chat__alert-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-2, 8px);
	margin-top: var(--sp-2, 8px) !important;
}

.g-chat__alert-actions [hidden] {
	display: none;
}

.g-chat__alert .btn {
	min-height: var(--hit, 44px);
	background: #fff;
}

.g-chat__slow {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--sp-2, 8px);
	margin: 0;
	color: rgb(var(--c-warn, 176 82 10));
	font-size: var(--fs-small, 0.95rem);
}

.g-chat__spinner {
	width: 16px;
	height: 16px;
	border: 2px solid currentcolor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: g-chat-spin 800ms linear infinite;
}

.g-chat__submit {
	width: 100%;
}

.g-chat__submit[aria-busy="true"] {
	cursor: progress;
	opacity: 0.8;
}

.g-chat__consent {
	margin: 0;
	font-size: var(--fs-caption, 14px);
	color: rgb(var(--c-muted, 85 85 85));
}

.g-chat__consent a {
	color: inherit;
	text-decoration: underline;
}

.g-chat .g-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Queued / success ---------- */
.g-chat__state {
	padding: var(--sp-5, 24px) var(--sp-4, 16px);
	border: 1px solid rgb(var(--c-line, 229 229 229));
	border-radius: var(--radius-md, 8px);
	background: #fff;
}

.g-chat__state p {
	margin: 0 0 var(--sp-3, 12px);
}

.g-chat__state-title {
	font-family: var(--font-display, inherit);
	font-size: var(--fs-lead, 1.125rem);
	font-weight: var(--fw-bold, 700);
	line-height: var(--lh-heading, 1.3);
}

.g-chat__state-title::before {
	content: "";
	display: block;
	width: 32px;
	height: 4px;
	margin-bottom: var(--sp-3, 12px);
	background: rgb(var(--c-emerald, 215 25 32));
}

.g-chat__state-actions {
	display: grid;
	gap: var(--sp-2, 8px);
}

/* Keep floating page bits out of the way while the panel is open on phones. */
@media (max-width: 767.98px) {

	.g-chat {
		--chat-gap: 16px;
		--chat-bottom: 16px;
	}

	/* Dock above the fixed bottom action bar (theme nav.css) and follow it when it slides away. */
	body.has-bottombar .g-chat {
		--chat-bottom: calc(var(--bottombar-h, 64px) + 12px);
	}

	body.has-bottombar:has(.g-bottombar.is-hidden) .g-chat {
		--chat-bottom: 16px;
	}

	body.has-calc-dock .g-chat {
		--chat-bottom: calc(var(--bottombar-h, 64px) + 64px + 12px);
	}

	/* Icon only on phones: a 56px round button. */
	.g-chat__fab {
		width: 56px;
		padding: 0;
		justify-content: center;
	}

	.g-chat__fab-label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.g-chat.is-open .g-chat__fab {
		display: none;
	}

	/* Dim the page behind the sheet; a tap on it closes the chat (chat.js). */
	.g-chat.is-open::before {
		content: "";
		position: fixed;
		inset: 0;
		z-index: 985;
		background: rgb(10 10 10 / 0.55);
	}

	/* Bottom sheet. */
	.g-chat__panel {
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		height: calc(100vh - 32px);
		height: calc(100dvh - 32px);
		border: 0;
		border-radius: 12px 12px 0 0;
		padding-bottom: env(safe-area-inset-bottom, 0);
		animation-name: g-chat-up;
	}

	html.g-chat-open,
	html.g-chat-open body {
		overflow: hidden;
	}
}

@keyframes g-chat-in {

	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

@keyframes g-chat-up {

	from {
		transform: translateY(24px);
		opacity: 0;
	}
}

@keyframes g-chat-spin {

	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {

	.g-chat__fab,
	.g-chat__q,
	.g-chat__q .g-chat__icon {
		transition: none;
	}

	.g-chat__panel {
		animation: none;
	}

	.g-chat__spinner {
		animation-duration: 2s;
	}
}

@media print {

	.g-chat {
		display: none !important;
	}
}

/* ---------- Larger screens: a 56px round icon that sits in the page gutter ----------
   The labelled pill covered the ISO badges at the bottom of the home hero (owner, 2026-11-10).
   The label now appears as a tooltip on hover / keyboard focus; the accessible name stays on the button. */
@media (min-width: 768px) {

	.g-chat {
		--chat-gap: 24px;
	}

	.g-chat__fab {
		width: 56px;
		padding: 0;
		justify-content: center;
	}

	.g-chat__fab-label {
		position: absolute;
		right: calc(100% + 12px);
		top: 50%;
		padding: 8px 12px;
		border-radius: 6px;
		background: rgb(var(--c-ink, 10 10 10));
		color: #fff;
		font-size: var(--fs-caption, 0.875rem);
		white-space: nowrap;
		opacity: 0;
		pointer-events: none;
		transform: translate(4px, -50%);
		transition: opacity var(--d-fast, 150ms) ease, transform var(--d-fast, 150ms) ease;
	}

	.g-chat__fab:hover .g-chat__fab-label,
	.g-chat__fab:focus-visible .g-chat__fab-label {
		opacity: 1;
		transform: translate(0, -50%);
	}

	.g-chat.is-open .g-chat__fab-label {
		display: none;
	}
}

/* Phones: hidden while the home hero's stats/ISO row is visible (chat.js adds .is-tucked). */
.g-chat.is-tucked .g-chat__fab {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(8px);
	transition: opacity var(--d-fast, 150ms) ease, transform var(--d-fast, 150ms) ease, visibility 0s linear var(--d-fast, 150ms);
}
