/* ATS AI Chat widget */
#ats-chat-root {
	--ats-chat-brand: #594652;
	--ats-chat-brand-dark: #3f3139;
	--ats-chat-accent: #FFD902;
	--ats-chat-dark: #373737;
	--ats-chat-bg: #ffffff;
	--ats-chat-surface: #f6f4f5;
	--ats-chat-border: #e8e3e6;
	--ats-chat-text: #262626;
	--ats-chat-muted: #7a7077;
	--ats-chat-radius: 18px;
	--ats-chat-shadow: 0 24px 60px rgba(32, 20, 28, 0.28), 0 4px 14px rgba(32, 20, 28, 0.12);
	--ats-chat-font: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-family: var(--ats-chat-font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--ats-chat-text);
	z-index: 99999;
	position: relative;
}
#ats-chat-root *, #ats-chat-root *::before, #ats-chat-root *::after { box-sizing: border-box; }
#ats-chat-root button { font-family: inherit; cursor: pointer; }

/* Launcher */
.ats-chat-launcher {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 99999;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px 12px 14px;
	border: 0;
	border-radius: 999px;
	background: var(--ats-chat-brand);
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	letter-spacing: 0.01em;
	box-shadow: 0 12px 30px rgba(89, 70, 82, 0.4);
	transform: translateY(16px);
	opacity: 0;
	transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .35s, background .2s, box-shadow .2s;
}
.ats-chat-launcher.is-visible { transform: translateY(0); opacity: 1; }
.ats-chat-launcher:hover { background: var(--ats-chat-brand-dark); box-shadow: 0 14px 34px rgba(89, 70, 82, 0.5); }
.ats-chat-launcher:focus-visible { outline: 3px solid var(--ats-chat-accent); outline-offset: 2px; }
.ats-chat-launcher__icon {
	width: 34px; height: 34px; border-radius: 50%;
	background: var(--ats-chat-accent);
	display: grid; place-items: center; flex: 0 0 auto;
}
.ats-chat-launcher__icon svg { width: 18px; height: 18px; fill: var(--ats-chat-dark); }
.ats-chat-launcher.is-open { opacity: 0; pointer-events: none; transform: translateY(16px); }

/* Panel */
.ats-chat-panel {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 99999;
	width: 390px;
	max-width: calc(100vw - 24px);
	height: min(660px, calc(100vh - 44px));
	display: flex;
	flex-direction: column;
	background: var(--ats-chat-bg);
	border-radius: var(--ats-chat-radius);
	box-shadow: var(--ats-chat-shadow);
	overflow: hidden;
	transform-origin: bottom right;
	transform: translateY(18px) scale(.96);
	opacity: 0;
	pointer-events: none;
	transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .25s;
}
.ats-chat-panel.is-open { transform: none; opacity: 1; pointer-events: auto; }
#ats-chat-root[data-mode="inline"] .ats-chat-panel {
	position: relative; right: auto; bottom: auto;
	width: 100%; max-width: none; height: 640px;
	transform: none; opacity: 1; pointer-events: auto;
	box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
#ats-chat-root[data-mode="inline"] .ats-chat-launcher,
#ats-chat-root[data-mode="inline"] .ats-chat-header__close { display: none; }

/* Header */
.ats-chat-header {
	display: flex; align-items: center; gap: 12px;
	padding: 14px 14px 14px 18px;
	background: linear-gradient(135deg, var(--ats-chat-brand) 0%, var(--ats-chat-brand-dark) 100%);
	color: #fff;
	position: relative;
}
.ats-chat-header::after {
	content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
	background: var(--ats-chat-accent);
}
.ats-chat-header__logo {
	width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
	background: rgba(255,255,255,.12);
	display: grid; place-items: center; overflow: hidden;
}
.ats-chat-header__logo--img { width: auto; min-width: 42px; padding: 0 10px; }
.ats-chat-header__logo img { max-width: 120px; max-height: 26px; object-fit: contain; display: block; }
.ats-chat-header__logo svg { width: 22px; height: 22px; fill: var(--ats-chat-accent); }
.ats-chat-header__text { flex: 1 1 auto; min-width: 0; }
.ats-chat-header__title { font-weight: 700; font-size: 16px; line-height: 1.2; margin: 0; }
.ats-chat-header__subtitle { font-size: 12.5px; opacity: .8; margin: 3px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ats-chat-header__status {
	display: inline-block; width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80; margin-right: 6px; box-shadow: 0 0 0 3px rgba(74,222,128,.25);
	vertical-align: middle; position: relative; top: -1px;
}
.ats-chat-header__btn {
	width: 34px; height: 34px; border: 0; border-radius: 10px;
	background: rgba(255,255,255,.1); color: #fff;
	display: grid; place-items: center; flex: 0 0 auto;
	transition: background .15s;
}
.ats-chat-header__btn:hover { background: rgba(255,255,255,.22); }
.ats-chat-header__btn svg { width: 17px; height: 17px; fill: currentColor; }

/* Messages */
.ats-chat-body {
	flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
	padding: 18px 16px 8px;
	background: var(--ats-chat-surface);
	scroll-behavior: smooth;
}
.ats-chat-body::-webkit-scrollbar { width: 8px; }
.ats-chat-body::-webkit-scrollbar-thumb { background: #d9d2d6; border-radius: 8px; }
.ats-chat-msg { display: flex; flex-direction: column; margin: 0 0 12px; max-width: 88%; animation: ats-chat-in .25s ease-out; }
.ats-chat-msg--user { align-self: flex-end; margin-left: auto; align-items: flex-end; }
.ats-chat-msg--bot { align-self: flex-start; }
.ats-chat-bubble {
	padding: 11px 14px;
	border-radius: 16px;
	font-size: 14.5px;
	line-height: 1.55;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}
.ats-chat-msg--user .ats-chat-bubble { background: var(--ats-chat-brand); color: #fff; border-bottom-right-radius: 5px; }
.ats-chat-msg--bot .ats-chat-bubble { background: #fff; color: var(--ats-chat-text); border: 1px solid var(--ats-chat-border); border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.ats-chat-bubble a { color: var(--ats-chat-brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ats-chat-msg--user .ats-chat-bubble a { color: var(--ats-chat-accent); }
.ats-chat-bubble strong { font-weight: 700; }
.ats-chat-msg--error .ats-chat-bubble { background: #fff4f3; border-color: #f5c6c2; color: #8a1f17; }
.ats-chat-time { font-size: 11px; color: var(--ats-chat-muted); margin: 4px 6px 0; }
@keyframes ats-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Typing */
.ats-chat-typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.ats-chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ats-chat-brand); opacity: .35; animation: ats-chat-dot 1.2s infinite; }
.ats-chat-typing i:nth-child(2) { animation-delay: .2s; }
.ats-chat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ats-chat-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Product cards */
.ats-chat-products { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; width: 100%; }
.ats-chat-card {
	display: flex; gap: 12px; align-items: center;
	background: #fff; border: 1px solid var(--ats-chat-border); border-radius: 14px;
	padding: 10px; text-decoration: none; color: inherit;
	transition: box-shadow .15s, transform .15s, border-color .15s;
}
.ats-chat-card:hover { box-shadow: 0 8px 22px rgba(89,70,82,.14); transform: translateY(-1px); border-color: #d9cfd5; }
.ats-chat-card__img { width: 64px; height: 64px; border-radius: 10px; flex: 0 0 auto; background: var(--ats-chat-surface); object-fit: contain; display: block; }
.ats-chat-card__body { flex: 1 1 auto; min-width: 0; }
.ats-chat-card__name { font-weight: 600; font-size: 13.5px; line-height: 1.3; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ats-chat-card__meta { font-size: 12px; color: var(--ats-chat-muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.ats-chat-card__price { color: var(--ats-chat-text); font-weight: 700; font-size: 13px; }
.ats-chat-card__tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.ats-chat-card__tag--stock { background: #e8f8ee; color: #1c7c3f; }
.ats-chat-card__tag--out { background: #fdecec; color: #a32a22; }
.ats-chat-card__tag--kit { background: #fff7c2; color: #6b5a00; }
.ats-chat-card__tag--sale { background: #e8f8ee; color: #1c7c3f; }
.ats-chat-card__arrow { width: 28px; height: 28px; border-radius: 50%; background: var(--ats-chat-accent); display: grid; place-items: center; flex: 0 0 auto; }
.ats-chat-card__arrow svg { width: 14px; height: 14px; fill: var(--ats-chat-dark); }

/* CTA */
.ats-chat-cta {
	display: inline-flex; align-items: center; gap: 8px; margin-top: 8px;
	padding: 9px 16px; border-radius: 999px;
	background: var(--ats-chat-accent); color: var(--ats-chat-dark);
	font-weight: 700; font-size: 13.5px; text-decoration: none;
	transition: filter .15s, transform .15s;
}
.ats-chat-cta:hover { filter: brightness(.95); transform: translateY(-1px); }

/* Suggestions */
.ats-chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 10px; }
.ats-chat-chip {
	border: 1px solid #d9cfd5; background: #fff; color: var(--ats-chat-brand);
	border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
	transition: background .15s, border-color .15s;
}
.ats-chat-chip:hover { background: var(--ats-chat-brand); border-color: var(--ats-chat-brand); color: #fff; }

/* Composer */
.ats-chat-footer { background: #fff; border-top: 1px solid var(--ats-chat-border); padding: 10px 12px 10px; }
.ats-chat-form { display: flex; align-items: flex-end; gap: 8px; }
.ats-chat-input {
	flex: 1 1 auto; resize: none; border: 1px solid #d9cfd5; border-radius: 14px;
	padding: 10px 14px; font: inherit; font-size: 14.5px; line-height: 1.4;
	max-height: 120px; min-height: 42px; background: #fff; color: var(--ats-chat-text);
	outline: none; transition: border-color .15s, box-shadow .15s;
}
.ats-chat-input:focus { border-color: var(--ats-chat-brand); box-shadow: 0 0 0 3px rgba(89,70,82,.12); }
.ats-chat-input::placeholder { color: #a39aa0; }
.ats-chat-send {
	width: 42px; height: 42px; border: 0; border-radius: 12px; flex: 0 0 auto;
	background: var(--ats-chat-accent); color: var(--ats-chat-dark);
	display: grid; place-items: center;
	transition: filter .15s, transform .1s, opacity .15s;
}
.ats-chat-send:hover { filter: brightness(.95); }
.ats-chat-send:active { transform: scale(.96); }
.ats-chat-send:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.ats-chat-send svg { width: 18px; height: 18px; fill: currentColor; }
.ats-chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.ats-chat-note { font-size: 11px; color: var(--ats-chat-muted); margin: 8px 2px 0; line-height: 1.4; }

/* Allowance meter */
.ats-chat-allowance { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ats-chat-muted); margin: 0 2px 8px; }
.ats-chat-allowance__bar { flex: 1 1 auto; height: 5px; background: #ebe6e9; border-radius: 999px; overflow: hidden; }
.ats-chat-allowance__fill { height: 100%; background: linear-gradient(90deg, var(--ats-chat-brand), var(--ats-chat-accent)); border-radius: 999px; transition: width .3s; }
.ats-chat-allowance.is-empty { color: #a32a22; }

@media (max-width: 640px) {
	.ats-chat-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100dvh; border-radius: 0; }
	.ats-chat-launcher { right: 14px; bottom: 14px; padding: 12px 16px 12px 12px; }
	.ats-chat-msg { max-width: 94%; }
}
@media (prefers-reduced-motion: reduce) {
	#ats-chat-root * { animation: none !important; transition: none !important; }
}
