/* ASR Chat Widget — vanilla port of ChatWidget.tsx with the new gold/charcoal palette. */

.asr-cw {
	--cw-gold: #d4a017;
	--cw-gold-soft: #e8b84a;
	--cw-ink: #111418;
	--cw-charcoal: #2b2f36;
	--cw-slate-100: #f1f5f9;
	--cw-slate-200: #e2e8f0;
	--cw-slate-300: #cbd5e1;
	--cw-slate-500: #64748b;
	--cw-slate-700: #334155;
	--cw-slate-800: #1e293b;
	--cw-amber-50: #fffbeb;
	--cw-amber-100: #fef3c7;
	--cw-amber-500: #f59e0b;
	--cw-amber-700: #b45309;
	--cw-red-50: #fef2f2;
	--cw-red-200: #fecaca;
	--cw-red-600: #dc2626;
	font-family: 'Inter', system-ui, sans-serif;
}

.asr-cw *, .asr-cw *::before, .asr-cw *::after { box-sizing: border-box; }

.asr-cw-trigger {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	border-radius: 9999px;
	background: var(--cw-gold);
	color: var(--cw-ink);
	border: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 70;
	box-shadow: 0 0 32px rgba(212,160,23,0.35), 0 10px 30px rgba(15, 23, 42, 0.18);
	transition: background 0.2s ease, transform 0.15s ease;
}
.asr-cw-trigger:hover { background: var(--cw-gold-soft); transform: scale(1.06); }
.asr-cw-trigger.is-open {
	background: var(--cw-charcoal);
	color: #fff;
	transform: rotate(90deg);
}
.asr-cw-trigger svg { width: 24px; height: 24px; }
.asr-cw-trigger::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 9999px;
	background: rgba(212,160,23,0.4);
	animation: asrCwPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
	pointer-events: none;
}
.asr-cw-trigger.is-open::after { display: none; }

@keyframes asrCwPing {
	75%, 100% { transform: scale(1.6); opacity: 0; }
}

.asr-cw-window {
	position: fixed;
	bottom: 96px;
	right: 24px;
	width: clamp(320px, 90vw, 400px);
	max-height: 70vh;
	background: #fff;
	border-radius: 18px;
	overflow: hidden;
	border: 1px solid var(--cw-slate-200);
	box-shadow: 0 25px 60px -20px rgba(15, 23, 42, 0.32);
	display: none;
	flex-direction: column;
	z-index: 70;
	animation: asrCwFadeUp 0.25s ease-out both;
}
.asr-cw-window.is-open { display: flex; }

@keyframes asrCwFadeUp {
	from { opacity: 0; transform: translateY(16px); }
	to   { opacity: 1; transform: translateY(0); }
}

.asr-cw-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	background: var(--cw-ink);
	color: #fff;
}
.asr-cw-head-left { display: flex; align-items: center; gap: 10px; }
.asr-cw-avatar {
	width: 34px;
	height: 34px;
	border-radius: 9999px;
	background: var(--cw-gold);
	color: var(--cw-ink);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.asr-cw-avatar svg { width: 16px; height: 16px; }
.asr-cw-title { line-height: 1.1; }
.asr-cw-title strong { display: block; font-size: 14px; font-weight: 600; }
.asr-cw-title span  { display: block; font-size: 11.5px; color: var(--cw-slate-300); margin-top: 3px; }

.asr-cw-reset {
	background: transparent;
	color: var(--cw-slate-300);
	border: 0;
	padding: 8px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.15s ease, background 0.15s ease;
}
.asr-cw-reset:hover { color: #fff; background: rgba(255,255,255,0.08); }
.asr-cw-reset svg { width: 16px; height: 16px; }

.asr-cw-disclaimer {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px 16px;
	background: var(--cw-amber-50);
	border-bottom: 1px solid var(--cw-amber-100);
	color: var(--cw-amber-700);
	font-size: 12px;
	line-height: 1.45;
}
.asr-cw-disclaimer svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--cw-amber-500); }

.asr-cw-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
}
.asr-cw-messages::-webkit-scrollbar { width: 6px; }
.asr-cw-messages::-webkit-scrollbar-thumb { background: var(--cw-slate-300); border-radius: 6px; }

.asr-cw-msg { display: flex; gap: 10px; }
.asr-cw-msg.is-user { flex-direction: row-reverse; }
.asr-cw-msg-avatar {
	width: 28px;
	height: 28px;
	border-radius: 9999px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #fff;
	background: var(--cw-gold);
}
.asr-cw-msg.is-user .asr-cw-msg-avatar { background: var(--cw-charcoal); color: var(--cw-gold-soft); }
.asr-cw-msg-avatar svg { width: 14px; height: 14px; }

.asr-cw-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.asr-cw-msg.is-bot  .asr-cw-bubble { background: var(--cw-slate-100); color: var(--cw-slate-800); border-top-left-radius: 6px; }
.asr-cw-msg.is-user .asr-cw-bubble { background: var(--cw-gold);      color: var(--cw-ink);        border-top-right-radius: 6px; font-weight: 500; }
.asr-cw-bubble strong { font-weight: 700; }

.asr-cw-typing { display: flex; gap: 10px; align-items: center; }
.asr-cw-typing .asr-cw-msg-avatar { background: var(--cw-gold); color: var(--cw-ink); }
.asr-cw-typing-bubble {
	background: var(--cw-slate-100);
	padding: 12px 16px;
	border-radius: 16px;
	border-top-left-radius: 6px;
	display: flex;
	gap: 5px;
}
.asr-cw-typing-bubble span {
	width: 6px;
	height: 6px;
	border-radius: 9999px;
	background: var(--cw-slate-500);
	animation: asrCwBounce 1.1s infinite;
}
.asr-cw-typing-bubble span:nth-child(2) { animation-delay: 0.12s; }
.asr-cw-typing-bubble span:nth-child(3) { animation-delay: 0.24s; }

@keyframes asrCwBounce {
	0%, 80%, 100% { transform: translateY(0); }
	40%           { transform: translateY(-4px); }
}

.asr-cw-error {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	padding: 10px 12px;
	background: var(--cw-red-50);
	border: 1px solid var(--cw-red-200);
	color: var(--cw-red-600);
	font-size: 12px;
	border-radius: 12px;
}
.asr-cw-error svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

.asr-cw-handoff {
	align-self: center;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	background: rgba(212,160,23,0.12);
	color: var(--cw-gold);
	border: 1px solid rgba(212,160,23,0.4);
	border-radius: 9999px;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}
.asr-cw-handoff:hover { background: var(--cw-gold); color: var(--cw-ink); }
.asr-cw-handoff svg { width: 14px; height: 14px; }

.asr-cw-input-bar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--cw-slate-100);
	background: #fff;
}
.asr-cw-input {
	flex: 1;
	resize: none;
	padding: 10px 12px;
	border-radius: 12px;
	border: 1px solid var(--cw-slate-200);
	background: #fff;
	font: inherit;
	font-size: 14px;
	color: var(--cw-slate-800);
	max-height: 110px;
	overflow-y: auto;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.asr-cw-input:focus {
	border-color: var(--cw-gold);
	box-shadow: 0 0 0 3px rgba(212,160,23,0.18);
}
.asr-cw-input:disabled { opacity: 0.6; cursor: not-allowed; }

.asr-cw-send {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: var(--cw-gold);
	color: var(--cw-ink);
	border: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease;
}
.asr-cw-send:hover:not(:disabled) { background: var(--cw-gold-soft); }
.asr-cw-send:disabled { background: var(--cw-slate-200); color: var(--cw-slate-500); cursor: not-allowed; }
.asr-cw-send svg { width: 16px; height: 16px; }

@media (max-width: 420px) {
	.asr-cw-window {
		right: 12px;
		left: 12px;
		bottom: 84px;
		width: auto;
		max-height: 74vh;
	}
	.asr-cw-trigger { bottom: 16px; right: 16px; }
}
