/**
 * WC AI Chatbot — Widget Styles
 * Premium redesign: inspired by Claude.ai, Intercom Fin, Linear.
 *
 * Design principles:
 * – Dark confident header (not brand-colored) for trust & professionalism
 * – Asymmetric bubbles: AI = full-width content card, User = compact colored
 * – 4-layer shadow system for genuine spatial depth
 * – Spring-eased micro-animations on every interaction
 * – 15px / 1.65 line-height for maximum readability
 *
 * @package WCAIC
 * @since   1.2.0
 */

/* =========================================================================
   CSS Custom Properties
   ========================================================================= */

:root {
	/* Brand accent — overridden by JS from plugin settings */
	--wcaic-primary:       #7C3AED;
	--wcaic-primary-hover: #6D28D9;

	/* Surface colors */
	--wcaic-bg:            #ffffff;
	--wcaic-bg-subtle:     #f8f8fc;
	--wcaic-bg-input:      #f4f4f8;

	/* Text */
	--wcaic-text:          #0f0f18;
	--wcaic-text-light:    #6b7280;
	--wcaic-text-muted:    #9ca3af;

	/* Borders */
	--wcaic-border:        rgba(0, 0, 0, 0.08);
	--wcaic-border-input:  rgba(0, 0, 0, 0.12);

	/* Bubble colors */
	--wcaic-user-bg:       var(--wcaic-primary);
	--wcaic-user-text:     #ffffff;
	--wcaic-bot-bg:        var(--wcaic-bg-subtle);
	--wcaic-bot-text:      var(--wcaic-text);

	/* Status */
	--wcaic-green:         #22c55e;
	--wcaic-red:           #ef4444;
	--wcaic-amber:         #f59e0b;

	/* Header — always dark, regardless of brand color */
	--wcaic-header-bg:     #0f0f13;

	/* Sizing */
	--wcaic-radius:        20px;
	--wcaic-radius-msg:    16px;
	--wcaic-z-index:       9999;

	/* Font — improve rendering with font-smoothing in each component */
	--wcaic-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

	/* Shadows */
	--wcaic-shadow-toggle:
		0 4px 14px rgba(124, 58, 237, 0.38),
		0 2px 6px  rgba(0, 0, 0, 0.14);

	--wcaic-shadow-panel:
		0 0 0 1px rgba(0, 0, 0, 0.04),
		0 4px 6px -1px rgba(0, 0, 0, 0.06),
		0 12px 28px -4px rgba(0, 0, 0, 0.13),
		0 36px 64px -8px rgba(0, 0, 0, 0.16);

	--wcaic-shadow-card:
		0 1px 3px rgba(0, 0, 0, 0.06),
		0 4px 12px rgba(0, 0, 0, 0.08);

	--wcaic-shadow-card-hover:
		0 4px 10px rgba(0, 0, 0, 0.08),
		0 12px 28px rgba(0, 0, 0, 0.14);
}

/* =========================================================================
   Reset & Container
   ========================================================================= */

.wcaic,
.wcaic *,
.wcaic *::before,
.wcaic *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.wcaic {
	font-family: var(--wcaic-font);
	font-size: 15px;
	line-height: 1.65;
	color: var(--wcaic-text);
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: var(--wcaic-z-index);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* =========================================================================
   Toggle Button (Floating Launcher)
   ========================================================================= */

.wcaic-toggle {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	background: var(--wcaic-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--wcaic-shadow-toggle);
	transition:
		transform  0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
		box-shadow 0.2s  ease,
		background 0.15s ease;
	position: relative;
	outline: none;
	/* GPU layer for smooth compositing */
	will-change: transform;
	transform: translateZ(0);
}

.wcaic-toggle:hover {
	background: var(--wcaic-primary-hover);
	transform: scale(1.09) translateZ(0);
	box-shadow:
		0 6px 22px rgba(124, 58, 237, 0.50),
		0 3px 9px  rgba(0, 0, 0, 0.16);
}

.wcaic-toggle:active {
	transform: scale(0.96) translateZ(0);
}

.wcaic-toggle:focus-visible {
	outline: 3px solid var(--wcaic-primary);
	outline-offset: 3px;
}

/* Icon swap */
.wcaic-toggle__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.wcaic-toggle__icon--close {
	display: none;
}

.wcaic--open .wcaic-toggle__icon--chat {
	display: none;
}

.wcaic--open .wcaic-toggle__icon--close {
	display: flex;
}

/* Unread badge */
.wcaic-toggle__badge {
	position: absolute;
	top: -1px;
	right: -1px;
	min-width: 18px;
	height: 18px;
	background: var(--wcaic-red);
	border-radius: 9px;
	border: 2.5px solid #fff;
	font-size: 10px;
	font-weight: 700;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 3px;
	animation: wcaic-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wcaic-badge-pop {
	from { transform: scale(0); opacity: 0; }
	to   { transform: scale(1); opacity: 1; }
}

/* Pulse while waiting for first interaction */
@keyframes wcaic-pulse {
	0%, 100% {
		box-shadow:
			0 4px 14px rgba(124, 58, 237, 0.38),
			0 2px 6px  rgba(0, 0, 0, 0.14);
	}
	50% {
		box-shadow:
			0 4px 24px rgba(124, 58, 237, 0.60),
			0 2px 8px  rgba(0, 0, 0, 0.18);
	}
}

.wcaic-toggle--pulse {
	animation: wcaic-pulse 2.2s ease-in-out infinite;
}

/* =========================================================================
   Panel (Chat Window)
   ========================================================================= */

.wcaic-panel {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 60vw;
	min-width: 380px;
	max-width: 860px;
	height: 72vh;
	min-height: 520px;
	max-height: 820px;

	/* Glassmorphism */
	background: rgba(255, 255, 255, 0.93);
	backdrop-filter: blur(24px) saturate(180%);
	-webkit-backdrop-filter: blur(24px) saturate(180%);

	border-radius: var(--wcaic-radius);
	box-shadow: var(--wcaic-shadow-panel);
	border: 1px solid rgba(255, 255, 255, 0.55);

	display: none;
	flex-direction: column;
	overflow: hidden;
	will-change: transform, opacity;
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
	.wcaic-panel {
		background: rgba(255, 255, 255, 0.98);
	}
}

.wcaic--open .wcaic-panel {
	display: flex;
}

/* Desktop: scale in from bottom-right */
@keyframes wcaic-panel-in {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.93);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.wcaic--open .wcaic-panel {
	transform-origin: bottom right;
	animation: wcaic-panel-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================================
   Header
   ========================================================================= */

.wcaic-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--wcaic-header-bg);
	color: #fff;
	flex-shrink: 0;
	position: relative;
	overflow: hidden;
}

/* Subtle gradient overlay on header */
.wcaic-panel__header::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		135deg,
		rgba(124, 58, 237, 0.20) 0%,
		rgba(99, 102, 241, 0.10) 50%,
		transparent 100%
	);
	pointer-events: none;
}

.wcaic-panel__header-info {
	display: flex;
	align-items: center;
	gap: 11px;
	position: relative;
	z-index: 1;
}

/* Avatar container with animated glow ring */
.wcaic-panel__avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: linear-gradient(
		135deg,
		var(--wcaic-primary) 0%,
		#a78bfa 100%
	);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	position: relative;
}

.wcaic-panel__avatar::before {
	content: '';
	position: absolute;
	inset: -3px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--wcaic-primary), #a78bfa, transparent);
	opacity: 0.45;
	animation: wcaic-avatar-ring 3s ease-in-out infinite;
}

@keyframes wcaic-avatar-ring {
	0%  { transform: scale(1);    opacity: 0.45; }
	50% { transform: scale(1.12); opacity: 0.20; }
	100%{ transform: scale(1);    opacity: 0.45; }
}

.wcaic-panel__avatar svg {
	position: relative;
	z-index: 1;
}

/* Title + status */
.wcaic-panel__title {
	display: block;
	font-weight: 600;
	font-size: 15px;
	line-height: 1.2;
	color: #ffffff;
}

.wcaic-panel__status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.62);
	line-height: 1.4;
	margin-top: 1px;
}

/* Green status dot */
.wcaic-panel__status::before {
	content: '';
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--wcaic-green);
	box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
	animation: wcaic-status-blink 2.4s ease-in-out infinite;
	flex-shrink: 0;
}

@keyframes wcaic-status-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0.55; }
}

/* Header action buttons */
.wcaic-panel__header-actions {
	display: flex;
	gap: 4px;
	position: relative;
	z-index: 1;
}

.wcaic-panel__btn {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	border: none;
	background: rgba(255, 255, 255, 0.10);
	color: rgba(255, 255, 255, 0.75);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}

.wcaic-panel__btn:hover {
	background: rgba(255, 255, 255, 0.20);
	color: #ffffff;
}

.wcaic-panel__btn:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.6);
	outline-offset: 1px;
}

/* =========================================================================
   Messages Area
   ========================================================================= */

.wcaic-panel__messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px 16px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

/* Thin premium scrollbar */
.wcaic-panel__messages::-webkit-scrollbar {
	width: 4px;
}

.wcaic-panel__messages::-webkit-scrollbar-track {
	background: transparent;
}

.wcaic-panel__messages::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.12);
	border-radius: 4px;
}

.wcaic-panel__messages::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.22);
}

.wcaic-panel__messages {
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

/* =========================================================================
   Message Bubbles — Asymmetric Design
   ========================================================================= */

.wcaic-msg {
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: pre-wrap;
	animation: wcaic-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes wcaic-msg-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Skip animation when restoring session */
.wcaic-no-anim .wcaic-msg {
	animation: none;
}

/* ── AI (bot) message: full-width content card ── */
.wcaic-msg--bot {
	align-self: flex-start;
	max-width: 92%;
	padding: 12px 16px;
	background: var(--wcaic-bg-subtle);
	color: var(--wcaic-bot-text);
	border: 1px solid var(--wcaic-border);
	border-radius: 3px var(--wcaic-radius-msg) var(--wcaic-radius-msg) var(--wcaic-radius-msg);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
	font-size: 15px;
	line-height: 1.65;
}

/* ── User message: compact right-aligned bubble ── */
.wcaic-msg--user {
	align-self: flex-end;
	max-width: 78%;
	padding: 11px 15px;
	background: var(--wcaic-primary);
	color: var(--wcaic-user-text);
	border-radius: var(--wcaic-radius-msg) 3px var(--wcaic-radius-msg) var(--wcaic-radius-msg);
	box-shadow:
		0 2px 8px rgba(124, 58, 237, 0.28),
		0 1px 3px rgba(0, 0, 0, 0.10);
	font-size: 15px;
	line-height: 1.55;
	animation: wcaic-msg-user-in 0.22s ease-out both;
}

@keyframes wcaic-msg-user-in {
	from { opacity: 0; transform: translateX(12px); }
	to   { opacity: 1; transform: translateX(0); }
}

.wcaic-no-anim .wcaic-msg--user {
	animation: none;
}

/* ── System / error message ── */
.wcaic-msg--system {
	align-self: center;
	max-width: 88%;
	padding: 9px 14px;
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid rgba(239, 68, 68, 0.20);
	font-size: 13px;
	text-align: center;
	border-radius: 10px;
}

/* ── Streaming cursor (CSS-only, added via wcaic-msg--streaming class) ── */
.wcaic-msg--streaming::after {
	content: '';
	display: inline-block;
	width: 2px;
	height: 0.95em;
	background: var(--wcaic-primary);
	margin-left: 3px;
	vertical-align: text-bottom;
	border-radius: 1px;
	animation: wcaic-cursor-blink 0.65s step-end infinite;
}

@keyframes wcaic-cursor-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0; }
}

/* =========================================================================
   Product Cards
   ========================================================================= */

/* List layout (1–2 products) */
.wcaic-products {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-self: flex-start;
	max-width: 92%;
	animation: wcaic-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.wcaic-no-anim .wcaic-products {
	animation: none;
}

.wcaic-product {
	background: var(--wcaic-bg);
	border: 1px solid var(--wcaic-border);
	border-radius: 14px;
	overflow: hidden;
	display: flex;
	gap: 12px;
	padding: 12px;
	box-shadow: var(--wcaic-shadow-card);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wcaic-product:hover {
	transform: translateY(-2px);
	box-shadow: var(--wcaic-shadow-card-hover);
}

.wcaic-product__img-wrap {
	position: relative;
	flex-shrink: 0;
}

.wcaic-product__img {
	width: 76px;
	height: 76px;
	border-radius: 10px;
	object-fit: cover;
	display: block;
	background: var(--wcaic-bg-subtle);
}

.wcaic-product__sale-badge {
	position: absolute;
	top: 5px;
	left: 5px;
	background: var(--wcaic-red);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 5px;
	letter-spacing: 0.02em;
	line-height: 1.3;
}

.wcaic-product__info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.wcaic-product__brand {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--wcaic-primary);
	letter-spacing: 0.6px;
}

.wcaic-product__name {
	font-weight: 600;
	font-size: 13px;
	line-height: 1.35;
	color: var(--wcaic-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.wcaic-product__price {
	font-size: 15px;
	font-weight: 700;
	color: var(--wcaic-primary);
	margin-top: 1px;
}

.wcaic-product__price del {
	color: var(--wcaic-text-muted);
	font-weight: 400;
	font-size: 12px;
	margin-right: 4px;
}

/* Star rating */
.wcaic-product__rating {
	display: inline-flex;
	align-items: center;
	gap: 1px;
	font-size: 12px;
	line-height: 1;
}

.wcaic-star {
	font-size: 12px;
	line-height: 1;
}

.wcaic-star--full  { color: var(--wcaic-amber); }
.wcaic-star--half  { color: var(--wcaic-amber); opacity: 0.6; }
.wcaic-star--empty { color: #d1d5db; }

.wcaic-product__reviews {
	font-size: 11px;
	color: var(--wcaic-text-light);
	margin-left: 3px;
}

/* Stock status */
.wcaic-product__stock {
	font-size: 11px;
	font-weight: 600;
}

.wcaic-product__stock--out      { color: var(--wcaic-red); }
.wcaic-product__stock--backorder { color: #f97316; }

.wcaic-product__desc {
	font-size: 12px;
	color: var(--wcaic-text-light);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Action buttons row */
.wcaic-product__actions {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
}

.wcaic-product__btn {
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	font-family: var(--wcaic-font);
	color: #fff;
	background: var(--wcaic-primary);
	border: none;
	border-radius: 7px;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}

.wcaic-product__btn:hover:not(:disabled) {
	background: var(--wcaic-primary-hover);
	transform: translateY(-1px);
}

.wcaic-product__btn:active:not(:disabled) {
	transform: translateY(0);
}

.wcaic-product__btn:disabled,
.wcaic-product__btn--out {
	background: var(--wcaic-text-muted);
	cursor: not-allowed;
	opacity: 0.7;
}

.wcaic-product__link {
	font-size: 12px;
	font-weight: 500;
	color: var(--wcaic-text-light);
	text-decoration: none;
	border: 1px solid var(--wcaic-border-input);
	padding: 4px 10px;
	border-radius: 7px;
	transition: color 0.15s ease, border-color 0.15s ease;
	white-space: nowrap;
}

.wcaic-product__link:hover {
	color: var(--wcaic-primary);
	border-color: var(--wcaic-primary);
}

/* =========================================================================
   Carousel Layout (3+ products)
   ========================================================================= */

.wcaic-products__carousel-wrap {
	position: relative;
	align-self: flex-start;
	max-width: 96%;
}

.wcaic-products--carousel {
	flex-direction: row;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	max-width: 100%;
	padding-bottom: 6px;
	gap: 10px;
}

.wcaic-products--carousel::-webkit-scrollbar {
	display: none;
}

/* Vertical card layout in carousel */
.wcaic-products--carousel .wcaic-product {
	min-width: 200px;
	max-width: 200px;
	flex-shrink: 0;
	scroll-snap-align: start;
	flex-direction: column;
	padding: 0;
	gap: 0;
}

.wcaic-products--carousel .wcaic-product__img-wrap {
	width: 100%;
}

.wcaic-products--carousel .wcaic-product__img {
	width: 100%;
	height: 130px;
	border-radius: 13px 13px 0 0;
}

.wcaic-products--carousel .wcaic-product__info {
	padding: 10px 12px 12px;
	gap: 4px;
}

.wcaic-products--carousel .wcaic-product__actions {
	flex-direction: column;
	gap: 6px;
}

.wcaic-products--carousel .wcaic-product__btn {
	width: 100%;
	text-align: center;
	padding: 7px;
	border-radius: 8px;
}

.wcaic-products--carousel .wcaic-product__link {
	width: 100%;
	text-align: center;
	padding: 5px;
}

/* Carousel nav arrows */
.wcaic-products__nav {
	position: absolute;
	top: calc(65px);
	transform: translateY(-50%);
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 1px solid var(--wcaic-border);
	background: var(--wcaic-bg);
	color: var(--wcaic-text);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
	transition: background 0.15s ease, box-shadow 0.15s ease;
}

.wcaic-products__nav:hover {
	background: var(--wcaic-bg-subtle);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

.wcaic-products__nav--prev { left: -15px; }
.wcaic-products__nav--next { right: -15px; }

/* =========================================================================
   Quick Reply Chips
   ========================================================================= */

.wcaic-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	align-self: flex-start;
	max-width: 96%;
	padding-top: 2px;
}

.wcaic-quick-reply {
	display: inline-block;
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 500;
	font-family: var(--wcaic-font);
	color: var(--wcaic-primary);
	background: transparent;
	border: 1.5px solid var(--wcaic-primary);
	border-radius: 100px;
	cursor: pointer;
	transition:
		background  0.15s ease,
		color       0.15s ease,
		transform   0.15s ease,
		box-shadow  0.15s ease;
	text-decoration: none;
	line-height: 1.3;
	white-space: nowrap;

	/* Staggered appear animations (overridden per nth-child below) */
	animation: wcaic-chip-in 0.22s ease-out both;
}

.wcaic-quick-reply:nth-child(1) { animation-delay: 0.00s; }
.wcaic-quick-reply:nth-child(2) { animation-delay: 0.06s; }
.wcaic-quick-reply:nth-child(3) { animation-delay: 0.12s; }
.wcaic-quick-reply:nth-child(4) { animation-delay: 0.18s; }

@keyframes wcaic-chip-in {
	from { opacity: 0; transform: scale(0.88) translateY(4px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}

.wcaic-no-anim .wcaic-quick-reply {
	animation: none;
}

.wcaic-quick-reply:hover {
	background: var(--wcaic-primary);
	color: #fff;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.wcaic-quick-reply:active {
	transform: translateY(0);
}

.wcaic-quick-reply--link {
	background: var(--wcaic-primary);
	color: #fff;
	box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}

.wcaic-quick-reply--link:hover {
	background: var(--wcaic-primary-hover);
	color: #fff;
}

/* =========================================================================
   Welcome Buttons
   ========================================================================= */

.wcaic-welcome-buttons {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-self: flex-start;
	max-width: 96%;
	padding-top: 4px;
	animation: wcaic-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.wcaic-no-anim .wcaic-welcome-buttons {
	animation: none;
}

.wcaic-welcome-buttons__label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--wcaic-text-muted);
}

.wcaic-welcome-buttons__group {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* =========================================================================
   Cart Summary Card
   ========================================================================= */

.wcaic-cart {
	align-self: flex-start;
	max-width: 92%;
	background: var(--wcaic-bg);
	border: 1px solid var(--wcaic-border);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: var(--wcaic-shadow-card);
	animation: wcaic-msg-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.wcaic-no-anim .wcaic-cart {
	animation: none;
}

.wcaic-cart__title {
	font-weight: 600;
	font-size: 14px;
	padding: 12px 14px 10px;
	border-bottom: 1px solid var(--wcaic-border);
	display: flex;
	align-items: center;
	gap: 7px;
	color: var(--wcaic-text);
}

.wcaic-cart__items {
	list-style: none;
	padding: 0;
	margin: 0;
	font-size: 13px;
}

.wcaic-cart__items li {
	display: flex;
	justify-content: space-between;
	padding: 8px 14px;
	border-bottom: 1px solid var(--wcaic-border);
	color: var(--wcaic-text);
	gap: 8px;
}

.wcaic-cart__items li:last-child {
	border-bottom: none;
}

.wcaic-cart__total {
	font-weight: 700;
	font-size: 15px;
	display: flex;
	justify-content: space-between;
	padding: 10px 14px;
	border-top: 2px solid var(--wcaic-border);
	color: var(--wcaic-text);
}

.wcaic-cart__checkout {
	display: block;
	margin: 0;
	padding: 12px 16px;
	font-size: 14px;
	font-weight: 600;
	font-family: var(--wcaic-font);
	text-align: center;
	color: #fff;
	background: var(--wcaic-primary);
	border: none;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.15s ease;
	border-top: 1px solid rgba(0,0,0,0.06);
}

.wcaic-cart__checkout:hover {
	background: var(--wcaic-primary-hover);
	color: #fff;
}

/* =========================================================================
   Thinking Indicator — appears as a bot chat bubble between messages & input
   ========================================================================= */

.wcaic-typing {
	/* Outer container: sits between scrollable messages and the input bar */
	display: none; /* toggled to flex by JS */
	padding: 4px 16px 10px;
	flex-shrink: 0;
}

/* Inner bubble — looks like a bot message */
.wcaic-typing__bubble {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 13px 18px;
	background: var(--wcaic-bg-subtle);
	border: 1px solid var(--wcaic-border);
	border-radius: 3px var(--wcaic-radius-msg) var(--wcaic-radius-msg) var(--wcaic-radius-msg);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
	position: relative;
	overflow: hidden;

	/* Slide-in from left on appear (mirrors bot message animation) */
	animation: wcaic-thinking-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes wcaic-thinking-in {
	from {
		opacity: 0;
		transform: translateX(-8px) scale(0.95);
	}
	to {
		opacity: 1;
		transform: translateX(0) scale(1);
	}
}

/* Shimmer sweep — light gloss moving across the bubble */
.wcaic-typing__bubble::after {
	content: '';
	position: absolute;
	top: 0;
	left: -120%;
	width: 70%;
	height: 100%;
	background: linear-gradient(
		100deg,
		transparent 0%,
		rgba(124, 58, 237, 0.07) 45%,
		rgba(255, 255, 255, 0.18) 55%,
		transparent 100%
	);
	animation: wcaic-shimmer-sweep 2.2s ease-in-out infinite;
}

@keyframes wcaic-shimmer-sweep {
	0%   { left: -120%; }
	100% { left: 200%;  }
}

/* Three animated dots */
.wcaic-typing__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--wcaic-primary);
	opacity: 0.35;
	flex-shrink: 0;
	animation: wcaic-dot-wave 1.4s ease-in-out infinite;
}

.wcaic-typing__dot:nth-child(1) { animation-delay: 0.00s; }
.wcaic-typing__dot:nth-child(2) { animation-delay: 0.22s; }
.wcaic-typing__dot:nth-child(3) { animation-delay: 0.44s; }

@keyframes wcaic-dot-wave {
	0%, 55%, 100% {
		transform: translateY(0)    scale(1);
		opacity: 0.35;
	}
	27% {
		transform: translateY(-8px) scale(1.15);
		opacity: 1;
	}
}

/* =========================================================================
   Input Area
   ========================================================================= */

.wcaic-panel__input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--wcaic-border);
	background: rgba(255, 255, 255, 0.96);
	flex-shrink: 0;
	position: relative;
}

/* Subtle top fade from messages */
.wcaic-panel__input::before {
	content: '';
	position: absolute;
	top: -20px;
	left: 0;
	right: 0;
	height: 20px;
	background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.6));
	pointer-events: none;
}

.wcaic-panel__textarea {
	flex: 1;
	resize: none;
	border: 1.5px solid var(--wcaic-border-input);
	border-radius: 12px;
	padding: 10px 14px;
	font-family: var(--wcaic-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--wcaic-text);
	background: var(--wcaic-bg-input);
	outline: none;
	max-height: 100px;
	overflow-y: auto;
	transition:
		border-color 0.18s ease,
		box-shadow   0.18s ease,
		background   0.15s ease;
	-webkit-font-smoothing: antialiased;
}

.wcaic-panel__textarea:focus {
	border-color: var(--wcaic-primary);
	background: var(--wcaic-bg);
	box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.wcaic-panel__textarea::placeholder {
	color: var(--wcaic-text-muted);
}

/* Send button — ghost when empty, glowing when has content */
.wcaic-panel__send {
	width: 40px;
	height: 40px;
	border-radius: 11px;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition:
		background   0.18s ease,
		box-shadow   0.18s ease,
		transform    0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
		opacity      0.15s ease,
		color        0.15s ease;
}

/* Disabled / empty state */
.wcaic-panel__send:disabled {
	background: transparent;
	color: var(--wcaic-text-muted);
	opacity: 0.5;
	cursor: default;
}

/* Has content — lit up */
.wcaic-panel__send:not(:disabled) {
	background: var(--wcaic-primary);
	color: #ffffff;
	box-shadow: 0 3px 10px rgba(124, 58, 237, 0.35);
}

.wcaic-panel__send:not(:disabled):hover {
	background: var(--wcaic-primary-hover);
	box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
	transform: translateY(-1px);
}

.wcaic-panel__send:not(:disabled):active {
	transform: scale(0.93);
}

.wcaic-panel__send:focus-visible {
	outline: 2px solid var(--wcaic-primary);
	outline-offset: 2px;
}

/* =========================================================================
   Footer
   ========================================================================= */

.wcaic-panel__footer {
	text-align: center;
	padding: 6px 12px;
	font-size: 11px;
	color: var(--wcaic-text-muted);
	background: rgba(255, 255, 255, 0.95);
	flex-shrink: 0;
	letter-spacing: 0.01em;
}

/* =========================================================================
   Screen Reader Utilities
   ========================================================================= */

.screen-reader-text {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* =========================================================================
   Mobile Responsive (≤480px)
   ========================================================================= */

@media (max-width: 480px) {
	.wcaic {
		bottom: 16px;
		right: 16px;
	}

	/* Full-screen panel on mobile */
	.wcaic-panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		height: 100dvh; /* iOS dynamic viewport */
		border-radius: 0;
		border: none;

		/* Mobile: slide up */
		animation: wcaic-panel-slide-up 0.32s cubic-bezier(0.32, 0.72, 0, 1) !important;
		transform-origin: center bottom !important;
	}

	@keyframes wcaic-panel-slide-up {
		from { transform: translateY(100%); opacity: 0.5; }
		to   { transform: translateY(0);    opacity: 1; }
	}

	/* Hide launcher when panel open (it's behind full-screen overlay) */
	.wcaic--open .wcaic-toggle {
		display: none;
	}

	/* Safe area insets */
	.wcaic-panel__header {
		padding-top: max(14px, env(safe-area-inset-top));
	}

	.wcaic-panel__input {
		padding-bottom: max(12px, env(safe-area-inset-bottom));
	}

	/* Smaller carousel cards */
	.wcaic-products--carousel .wcaic-product {
		min-width: 176px;
		max-width: 176px;
	}

	/* Hide carousel nav on mobile (swipe instead) */
	.wcaic-products__nav {
		display: none;
	}

	/* Larger tap targets */
	.wcaic-quick-reply {
		font-size: 13px;
		padding: 9px 17px;
	}

	/* Wider messages */
	.wcaic-msg--bot {
		max-width: 96%;
	}

	.wcaic-msg--user {
		max-width: 84%;
	}
}

/* =========================================================================
   Reduced Motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
	.wcaic-toggle,
	.wcaic-panel,
	.wcaic-msg,
	.wcaic-msg--user,
	.wcaic-typing__dot,
	.wcaic-typing__bubble,
	.wcaic-typing__bubble::after,
	.wcaic-quick-reply,
	.wcaic-products,
	.wcaic-cart,
	.wcaic-welcome-buttons,
	.wcaic-panel__header::before,
	.wcaic-panel__avatar::before {
		animation: none !important;
		transition: none !important;
	}

	.wcaic-panel__status::before {
		animation: none !important;
	}

	.wcaic-msg--streaming::after {
		animation: none !important;
		opacity: 1;
	}

	.wcaic-typing__dot {
		opacity: 0.6 !important;
	}
}
