/**
 * G2C Chatbot — front-end styles
 * Premium B2B technology aesthetic. Brand colours injected via CSS variables.
 */

.g2c-chatbot {
	--g2c-accent: #fb7f2d;
	--g2c-accent-light: #fda862;
	--g2c-dark: #0B1220;
	--g2c-dark-2: #111827;
	--g2c-bg: #F8FAFC;
	--g2c-white: #FFFFFF;
	--g2c-text: #111827;
	--g2c-text-soft: #64748B;
	--g2c-border: #E2E8F0;
	--g2c-radius: 18px;
	--g2c-shadow: 0 24px 60px -12px rgba(11, 18, 32, 0.28), 0 8px 24px -8px rgba(11, 18, 32, 0.16);
	--g2c-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	position: fixed;
	right: clamp(16px, 4vw, 28px);
	bottom: clamp(16px, 4vw, 28px);
	z-index: 2147483000;
	font-family: var(--g2c-font);
	line-height: 1.5;
}

.g2c-chatbot *,
.g2c-chatbot *::before,
.g2c-chatbot *::after {
	box-sizing: border-box;
}

/* ---------- Launcher ---------- */
.g2c-launcher {
	position: relative;
	display: grid;
	place-items: center;
	width: 62px;
	height: 62px;
	margin-left: auto;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	color: var(--g2c-white);
	background: linear-gradient(140deg, var(--g2c-accent) 0%, var(--g2c-accent-light) 100%);
	box-shadow: 0 12px 28px -6px rgba(37, 99, 235, 0.55);
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.g2c-launcher:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 16px 34px -6px rgba(37, 99, 235, 0.6);
}

.g2c-launcher:focus-visible {
	outline: 3px solid var(--g2c-accent-light);
	outline-offset: 3px;
}

.g2c-launcher__icon {
	position: absolute;
	display: grid;
	place-items: center;
	transition: opacity 0.2s ease, transform 0.3s ease;
}

.g2c-launcher__icon--close {
	opacity: 0;
	transform: rotate(-45deg) scale(0.6);
}

.g2c-chatbot[data-state="open"] .g2c-launcher__icon--chat {
	opacity: 0;
	transform: rotate(45deg) scale(0.6);
}

.g2c-chatbot[data-state="open"] .g2c-launcher__icon--close {
	opacity: 1;
	transform: rotate(0) scale(1);
}

.g2c-launcher__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	display: grid;
	place-items: center;
	font-size: 11px;
	font-weight: 700;
	color: var(--g2c-white);
	background: #ef4444;
	border: 2px solid var(--g2c-white);
	border-radius: 10px;
	animation: g2c-pulse 2s ease-in-out infinite;
}

@keyframes g2c-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
	50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ---------- Teaser ---------- */
.g2c-teaser {
	position: relative;
	max-width: 260px;
	margin: 0 0 12px auto;
	padding: 12px 34px 12px 14px;
	font-size: 14px;
	color: var(--g2c-text);
	background: var(--g2c-white);
	border: 1px solid var(--g2c-border);
	border-radius: 14px 14px 4px 14px;
	box-shadow: var(--g2c-shadow);
	animation: g2c-rise 0.4s ease both;
}

.g2c-teaser__close {
	position: absolute;
	top: 6px;
	right: 8px;
	border: 0;
	background: none;
	font-size: 18px;
	line-height: 1;
	color: var(--g2c-text-soft);
	cursor: pointer;
}

/* ---------- Panel ---------- */
.g2c-panel {
	width: min(384px, calc(100vw - 32px));
	height: min(620px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	margin-bottom: 14px;
	background: var(--g2c-white);
	border-radius: var(--g2c-radius);
	box-shadow: var(--g2c-shadow);
	overflow: hidden;
	transform-origin: bottom right;
	transform: translateY(16px) scale(0.96);
	opacity: 0;
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}

.g2c-chatbot[data-state="open"] .g2c-panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* Header */
.g2c-panel__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 18px;
	color: var(--g2c-white);
	background: linear-gradient(135deg, var(--g2c-dark) 0%, var(--g2c-dark-2) 55%, #1b2a4a 100%);
}

.g2c-panel__avatar {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 12px;
	color: var(--g2c-white);
	background: linear-gradient(140deg, var(--g2c-accent), var(--g2c-accent-light));
}

.g2c-panel__meta {
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin-right: auto;
}

.g2c-panel__title {
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.g2c-panel__subtitle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.72);
}

.g2c-panel__subtitle::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.g2c-panel__actions {
	display: flex;
	gap: 2px;
}

.g2c-icon-btn {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: rgba(255, 255, 255, 0.85);
	cursor: pointer;
	transition: background 0.2s ease;
}

.g2c-icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.g2c-icon-btn:focus-visible { outline: 2px solid var(--g2c-accent-light); outline-offset: 1px; }

/* Messages */
.g2c-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 16px 8px;
	background:
		radial-gradient(120% 60% at 100% 0%, rgba(96, 165, 250, 0.07), transparent 60%),
		var(--g2c-bg);
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.g2c-messages::-webkit-scrollbar { width: 7px; }
.g2c-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.g2c-msg {
	max-width: 82%;
	padding: 10px 14px;
	font-size: 14px;
	border-radius: 16px;
	animation: g2c-rise 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.g2c-msg--bot {
	align-self: flex-start;
	color: var(--g2c-text);
	background: var(--g2c-white);
	border: 1px solid var(--g2c-border);
	border-bottom-left-radius: 5px;
}

.g2c-msg--user {
	align-self: flex-end;
	color: var(--g2c-white);
	background: linear-gradient(135deg, var(--g2c-accent), var(--g2c-accent-light));
	border-bottom-right-radius: 5px;
}

.g2c-msg--success {
	align-self: stretch;
	max-width: 100%;
	text-align: center;
	color: #065f46;
	background: #ecfdf5;
	border: 1px solid #a7f3d0;
	border-radius: 14px;
}

.g2c-msg--error {
	align-self: flex-start;
	color: #991b1b;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-bottom-left-radius: 5px;
}

/* Typing indicator */
.g2c-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 13px 14px;
	background: var(--g2c-white);
	border: 1px solid var(--g2c-border);
	border-radius: 16px;
	border-bottom-left-radius: 5px;
}

.g2c-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #cbd5e1;
	animation: g2c-bounce 1.2s infinite ease-in-out;
}

.g2c-typing span:nth-child(2) { animation-delay: 0.15s; }
.g2c-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes g2c-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* Input bar */
.g2c-inputbar {
	border-top: 1px solid var(--g2c-border);
	background: var(--g2c-white);
	padding: 12px;
}

.g2c-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-height: 168px;
	overflow-y: auto;
	padding-bottom: 2px;
}

.g2c-chip {
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 500;
	color: var(--g2c-accent);
	background: #eff4ff;
	border: 1px solid #dbe6ff;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.g2c-chip:hover {
	background: var(--g2c-accent);
	color: var(--g2c-white);
	transform: translateY(-1px);
}

.g2c-chip:focus-visible { outline: 2px solid var(--g2c-accent); outline-offset: 2px; }

.g2c-field {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.g2c-input {
	flex: 1 1 auto;
	max-height: 110px;
	padding: 11px 14px;
	font-family: inherit;
	font-size: 14px;
	color: var(--g2c-text);
	background: var(--g2c-bg);
	border: 1px solid var(--g2c-border);
	border-radius: 12px;
	resize: none;
	outline: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.g2c-input::placeholder { color: #94a3b8; }

.g2c-input:focus {
	border-color: var(--g2c-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.g2c-input.g2c-invalid {
	border-color: #ef4444;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.g2c-send {
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 12px;
	color: var(--g2c-white);
	background: linear-gradient(140deg, var(--g2c-accent), var(--g2c-accent-light));
	cursor: pointer;
	transition: transform 0.18s ease, opacity 0.18s ease;
}

.g2c-send:hover { transform: translateY(-1px); }
.g2c-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.g2c-send:focus-visible { outline: 2px solid var(--g2c-accent); outline-offset: 2px; }

.g2c-skip {
	flex: 0 0 auto;
	padding: 10px 14px;
	font-size: 13px;
	font-weight: 500;
	color: var(--g2c-text-soft);
	background: var(--g2c-bg);
	border: 1px solid var(--g2c-border);
	border-radius: 12px;
	cursor: pointer;
}

.g2c-skip:hover { color: var(--g2c-text); border-color: #cbd5e1; }

.g2c-captcha {
	display: flex;
	justify-content: center;
	padding: 4px 0 10px;
	min-height: 66px;
}

.g2c-submit {
	width: 100%;
	padding: 13px 16px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	color: var(--g2c-white);
	background: linear-gradient(135deg, var(--g2c-accent), var(--g2c-accent-light));
	border: 0;
	border-radius: 12px;
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
	box-shadow: 0 10px 22px -8px rgba(37, 99, 235, 0.6);
}

.g2c-submit:hover:not(:disabled) { transform: translateY(-1px); }
.g2c-submit:disabled { opacity: 0.6; cursor: default; }
.g2c-submit:focus-visible { outline: 2px solid var(--g2c-accent); outline-offset: 2px; }

.g2c-submit.is-loading {
	color: transparent;
	position: relative;
}

.g2c-submit.is-loading::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: var(--g2c-white);
	border-radius: 50%;
	animation: g2c-spin 0.7s linear infinite;
}

@keyframes g2c-spin { to { transform: rotate(360deg); } }

.g2c-branding {
	display: block;
	padding: 8px;
	text-align: center;
	font-size: 11px;
	color: var(--g2c-text-soft);
	text-decoration: none;
	background: var(--g2c-white);
	border-top: 1px solid var(--g2c-border);
}

.g2c-branding:hover { color: var(--g2c-accent); }

/* Restart link inside a message */
.g2c-restart {
	display: inline-block;
	margin-top: 8px;
	font-size: 13px;
	font-weight: 600;
	color: var(--g2c-accent);
	background: none;
	border: 0;
	cursor: pointer;
	text-decoration: underline;
}

/* ---------- Animations ---------- */
@keyframes g2c-rise {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	.g2c-chatbot {
		right: 12px;
		bottom: 12px;
	}

	.g2c-panel {
		width: calc(100vw - 24px);
		height: min(78vh, calc(100vh - 96px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.g2c-chatbot *,
	.g2c-chatbot *::before,
	.g2c-chatbot *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
