/*
 * Bobby – front-end chat widget styles.
 * Scoped under #bobby-root to avoid theme conflicts.
 */

#bobby-root {
	--bobby-primary: #2563eb;
	--bobby-accent: #22c55e;
	--bobby-mascot-light: #dbeafe;
	--bobby-mascot-dark: #93c5fd;
	--bobby-radius: 16px;
	--bobby-panel-w: 380px;
	--bobby-panel-h: 600px;
	--bobby-bg: #ffffff;
	--bobby-bg-soft: #f4f6fb;
	--bobby-text: #0f172a;
	--bobby-muted: #64748b;
	--bobby-border: rgba(15, 23, 42, 0.1);
	--bobby-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
	--bobby-bot-bg: #f1f5f9;
	--bobby-user-bg: var(--bobby-primary);
	--bobby-user-text: #ffffff;

	position: fixed;
	z-index: 2147483000;
	bottom: 22px;
	right: 22px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--bobby-text);
}

/* Position variants */
#bobby-root.bobby-pos-bottom-left { right: auto; left: 22px; }
#bobby-root.bobby-pos-bottom-right { right: 22px; left: auto; }

/* Dark mode */
#bobby-root.bobby-theme-dark {
	--bobby-bg: #0f172a;
	--bobby-bg-soft: #172033;
	--bobby-text: #e2e8f0;
	--bobby-muted: #94a3b8;
	--bobby-border: rgba(226, 232, 240, 0.14);
	--bobby-bot-bg: #1e293b;
}

#bobby-root *,
#bobby-root *::before,
#bobby-root *::after { box-sizing: border-box; }

#bobby-root button { font: inherit; cursor: pointer; }

/* ------------------------------------------------------------------ Launcher */
.bobby-launcher {
	position: relative;
	width: 64px;
	height: 64px;
	border: none;
	border-radius: 50%;
	background: var(--bobby-primary);
	box-shadow: var(--bobby-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease;
	color: #fff;
}
.bobby-launcher:hover { transform: translateY(-2px) scale(1.04); }
.bobby-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--bobby-primary) 50%, white); outline-offset: 3px; }
#bobby-root.bobby-size-small .bobby-launcher { width: 52px; height: 52px; }
#bobby-root.bobby-size-large .bobby-launcher { width: 76px; height: 76px; }

.bobby-launcher__mascot { width: 100%; height: 100%; display: flex; }
.bobby-launcher .bobby-mascot { width: 46px; height: 46px; margin: auto; }
#bobby-root.bobby-size-large .bobby-launcher .bobby-mascot { width: 56px; height: 56px; }

.bobby-launcher__close { display: none; }
.bobby-launcher[aria-expanded="true"] .bobby-launcher__mascot { display: none; }
.bobby-launcher[aria-expanded="true"] .bobby-launcher__close { display: flex; }

.bobby-launcher__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #ef4444;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ------------------------------------------------------------------ Mascot anim */
.bobby-mascot .bobby-eye { transform-origin: center; animation: bobby-blink 5.5s infinite; }
.bobby-mascot .bobby-antenna-ball { animation: bobby-pulse 2.6s ease-in-out infinite; }
.bobby-mascot .bobby-head { animation: bobby-float 4.5s ease-in-out infinite; }
.bobby-mascot .bobby-smile { transform-origin: center; }
#bobby-root.bobby-thinking .bobby-mascot .bobby-eye { animation: bobby-blink 1s infinite; }
#bobby-root.bobby-greeting .bobby-mascot .bobby-head { animation: bobby-wave .9s ease 2; }

@keyframes bobby-blink {
	0%, 92%, 100% { transform: scaleY(1); }
	95% { transform: scaleY(0.1); }
}
@keyframes bobby-pulse {
	0%, 100% { opacity: 1; r: 5; }
	50% { opacity: .55; }
}
@keyframes bobby-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-2.5px); }
}
@keyframes bobby-wave {
	0% { transform: rotate(0); }
	25% { transform: rotate(-6deg); }
	75% { transform: rotate(6deg); }
	100% { transform: rotate(0); }
}

/* ------------------------------------------------------------------ Hint bubble */
.bobby-hint {
	position: absolute;
	bottom: 78px;
	right: 0;
	max-width: 280px;
	background: var(--bobby-bg);
	color: var(--bobby-text);
	border: 1px solid var(--bobby-border);
	border-radius: 14px;
	box-shadow: var(--bobby-shadow);
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 12px 14px;
	animation: bobby-pop .3s cubic-bezier(.2,.9,.3,1.2);
}
#bobby-root.bobby-pos-bottom-left .bobby-hint { right: auto; left: 0; }
.bobby-hint__text { background: none; border: none; padding: 0; text-align: left; color: inherit; font-size: 14px; }
.bobby-hint__close { background: none; border: none; color: var(--bobby-muted); font-size: 18px; line-height: 1; padding: 0 2px; }
@keyframes bobby-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; } }

/* ------------------------------------------------------------------ Panel */
.bobby-panel {
	position: absolute;
	bottom: 78px;
	right: 0;
	width: var(--bobby-panel-w);
	height: min(var(--bobby-panel-h), calc(100vh - 120px));
	background: var(--bobby-bg);
	border: 1px solid var(--bobby-border);
	border-radius: var(--bobby-radius);
	box-shadow: var(--bobby-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: bobby-rise .28s cubic-bezier(.2,.9,.3,1.1);
}
#bobby-root.bobby-pos-bottom-left .bobby-panel { right: auto; left: 0; }
.bobby-panel[hidden] { display: none; }
@keyframes bobby-rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

.bobby-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--bobby-primary), color-mix(in srgb, var(--bobby-primary) 60%, #0b1220));
	color: #fff;
}
.bobby-header__identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bobby-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.bobby-avatar .bobby-mascot { width: 32px; height: 32px; }
.bobby-header__meta { display: flex; flex-direction: column; min-width: 0; }
.bobby-header__name { font-size: 15px; font-weight: 700; }
.bobby-header__status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.bobby-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bobby-accent); box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
.bobby-header__actions { display: flex; align-items: center; gap: 4px; }
.bobby-iconbtn { background: rgba(255,255,255,.14); border: none; color: #fff; width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.bobby-iconbtn:hover { background: rgba(255,255,255,.28); }
.bobby-lang { background: rgba(255,255,255,.16); color: #fff; border: none; border-radius: 9px; height: 32px; padding: 0 8px; font-size: 13px; }
.bobby-lang option { color: #0f172a; }

/* ------------------------------------------------------------------ Messages */
.bobby-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--bobby-bg-soft);
	scroll-behavior: smooth;
}
.bobby-msg { display: flex; gap: 8px; max-width: 100%; animation: bobby-msg-in .28s ease; }
@keyframes bobby-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.bobby-msg--user { flex-direction: row-reverse; }
.bobby-msg__avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bobby-primary); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.bobby-msg__avatar .bobby-mascot { width: 22px; height: 22px; }
.bobby-msg--user .bobby-msg__avatar { background: #475569; color: #fff; font-size: 12px; font-weight: 700; }
.bobby-msg__bubble {
	background: var(--bobby-bot-bg);
	color: var(--bobby-text);
	padding: 10px 13px;
	border-radius: 14px 14px 14px 4px;
	max-width: 78%;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.bobby-msg--user .bobby-msg__bubble {
	background: var(--bobby-user-bg);
	color: var(--bobby-user-text);
	border-radius: 14px 14px 4px 14px;
}
.bobby-msg__bubble a { color: inherit; text-decoration: underline; }
.bobby-msg__time { font-size: 11px; color: var(--bobby-muted); margin-top: 4px; }

/* Markdown-ish */
.bobby-msg__bubble strong { font-weight: 700; }
.bobby-msg__bubble ul { margin: 6px 0; padding-left: 18px; }
.bobby-msg__bubble code { background: rgba(100,116,139,.18); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

/* Thinking indicator */
.bobby-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.bobby-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--bobby-muted); animation: bobby-bounce 1.2s infinite; }
.bobby-typing span:nth-child(2) { animation-delay: .15s; }
.bobby-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bobby-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ------------------------------------------------------------------ Cards */
.bobby-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; width: 100%; }
.bobby-card {
	display: flex;
	gap: 12px;
	background: var(--bobby-bg);
	border: 1px solid var(--bobby-border);
	border-radius: 14px;
	padding: 10px;
	align-items: stretch;
}
.bobby-card__img { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: var(--bobby-bg-soft); flex: 0 0 auto; }
.bobby-card__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.bobby-card__name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.bobby-card__price { font-weight: 700; color: var(--bobby-primary); }
.bobby-card__price del { color: var(--bobby-muted); font-weight: 400; margin-right: 6px; }
.bobby-card__stock { font-size: 12px; color: var(--bobby-accent); }
.bobby-card__stock.is-out { color: #ef4444; }
.bobby-card__desc { font-size: 12.5px; color: var(--bobby-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bobby-card__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.bobby-btn {
	border: 1px solid var(--bobby-primary);
	background: var(--bobby-primary);
	color: #fff;
	border-radius: 9px;
	padding: 6px 11px;
	font-size: 12.5px;
	font-weight: 600;
	text-decoration: none;
	transition: transform .15s ease, opacity .15s ease;
}
.bobby-btn:hover { transform: translateY(-1px); }
.bobby-btn--ghost { background: transparent; color: var(--bobby-primary); }
.bobby-btn[disabled] { opacity: .5; cursor: not-allowed; }
.bobby-badge-sale { align-self: flex-start; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }

/* Offers table / compare */
.bobby-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--bobby-bg); border-radius: 10px; overflow: hidden; }
.bobby-table th, .bobby-table td { border: 1px solid var(--bobby-border); padding: 6px 8px; text-align: left; vertical-align: top; }
.bobby-table th { background: var(--bobby-bg-soft); font-weight: 700; }

/* Categories chips */
.bobby-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bobby-chip { background: var(--bobby-bg); border: 1px solid var(--bobby-border); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; text-decoration: none; color: var(--bobby-text); }
.bobby-chip:hover { border-color: var(--bobby-primary); color: var(--bobby-primary); }

/* Orders list */
.bobby-order { background: var(--bobby-bg); border: 1px solid var(--bobby-border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.bobby-order__head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.bobby-order__status { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; background: var(--bobby-bg-soft); border-radius: 999px; padding: 2px 8px; }

/* Contact card */
.bobby-contact { background: var(--bobby-bg); border: 1px solid var(--bobby-border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.bobby-contact input, .bobby-contact textarea { width: 100%; border: 1px solid var(--bobby-border); border-radius: 9px; padding: 8px 10px; font: inherit; background: var(--bobby-bg); color: var(--bobby-text); }
.bobby-contact textarea { resize: vertical; min-height: 70px; }

/* ------------------------------------------------------------------ Suggestions */
.bobby-suggestions { padding: 0 16px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.bobby-suggestions[hidden] { display: none; }
.bobby-suggestion { background: var(--bobby-bg); border: 1px solid var(--bobby-border); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--bobby-text); }
.bobby-suggestion:hover { border-color: var(--bobby-primary); color: var(--bobby-primary); }

/* ------------------------------------------------------------------ Composer */
.bobby-composer { border-top: 1px solid var(--bobby-border); padding: 10px 12px 8px; background: var(--bobby-bg); }
.bobby-form { display: flex; align-items: flex-end; gap: 8px; background: var(--bobby-bg-soft); border: 1px solid var(--bobby-border); border-radius: 14px; padding: 6px 6px 6px 12px; }
.bobby-input { flex: 1 1 auto; border: none; background: transparent; resize: none; font: inherit; color: var(--bobby-text); max-height: 120px; padding: 6px 0; outline: none; }
.bobby-send { background: var(--bobby-primary); color: #fff; border: none; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.bobby-send[disabled] { opacity: .5; }
.bobby-footer-note { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11px; color: var(--bobby-muted); }
.bobby-link { background: none; border: none; color: var(--bobby-muted); text-decoration: underline; padding: 0; font-size: 11px; }
.bobby-link:hover { color: var(--bobby-primary); }

/* Ghost banner */
#bobby-root.bobby-mode-ghost .bobby-header::after {
	content: "GHOSTMODE";
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .08em;
	background: rgba(255,255,255,.22);
	padding: 3px 7px;
	border-radius: 999px;
	margin-left: auto;
}

/* Screen-reader only */
#bobby-root .screen-reader-text {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ Mobile */
@media (max-width: 520px) {
	#bobby-root { bottom: 14px; right: 14px; left: 14px; }
	#bobby-root.bobby-pos-bottom-left { left: 14px; right: 14px; }
	.bobby-panel {
		position: fixed;
		inset: 0;
		width: auto;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
		bottom: 0;
	}
	.bobby-launcher { position: fixed; bottom: 14px; right: 14px; left: auto; }
	#bobby-root.bobby-pos-bottom-left .bobby-launcher { left: 14px; right: auto; }
	.bobby-msg__bubble { max-width: 84%; }
	.bobby-card__img { width: 64px; height: 64px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	#bobby-root *, #bobby-root *::before, #bobby-root *::after {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
	}
	.bobby-messages { scroll-behavior: auto; }
}

/* When animations disabled by admin */
#bobby-root.bobby-no-anim *, #bobby-root.bobby-no-anim *::before, #bobby-root.bobby-no-anim *::after {
	animation: none !important;
	transition: none !important;
}
