/* ==========================================================================
   Shop with AI – Public Widget CSS
   ========================================================================== */

/* CSS Custom Properties */
:root {
	--swa-primary: #6c5ce7;
	--swa-secondary: #a29bfe;
	--swa-radius: 16px;
	--swa-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--swa-white: #ffffff;
	--swa-shadow: 0 20px 60px rgba(0,0,0,.18);
	--swa-shadow-sm: 0 4px 16px rgba(0,0,0,.10);
	--swa-bg: rgba(255,255,255,0.92);
	--swa-bg-msg-bot: rgba(108,92,231,0.08);
	--swa-bg-msg-user: var(--swa-primary);
	--swa-text: #2d3436;
	--swa-text-light: #636e72;
	--swa-border: rgba(0,0,0,.08);
	--swa-input-bg: rgba(245,246,250,0.9);
	--swa-card-bg: #ffffff;
	--swa-chip-bg: rgba(108,92,231,0.1);
	--swa-chip-color: var(--swa-primary);
	--swa-product-bg: #ffffff;
	--swa-transition: all .25s cubic-bezier(.4,0,.2,1);

	/* Floating button design variables — overridden inline per-site by
	   templates/swa-widget.php from the admin Settings > Appearance values.
	   Defaults here keep the button looking correct even before the inline
	   overrides load (avoids a flash of unstyled button). */
	--swa-btn-bg: var(--swa-primary);
	--swa-btn-icon-color: #ffffff;
	--swa-btn-text-color: #ffffff;
	--swa-btn-hover: var(--swa-secondary);
	--swa-btn-radius: 50px;
	--swa-btn-border-width: 0px;
	--swa-btn-border-color: #ffffff;
	--swa-btn-icon-size: 22px;
	--swa-btn-shadow: 0 8px 32px rgba(108,92,231,.45);
	--swa-edge-gap: 24px;
}

/* Dark mode */
.swa-dark {
	--swa-bg: rgba(24,24,35,0.97);
	--swa-bg-msg-bot: rgba(108,92,231,0.15);
	--swa-text: #f0f0f0;
	--swa-text-light: #a0a0b0;
	--swa-border: rgba(255,255,255,.08);
	--swa-input-bg: rgba(40,40,60,0.9);
	--swa-card-bg: rgba(30,30,45,0.98);
	--swa-chip-bg: rgba(108,92,231,0.2);
	--swa-product-bg: rgba(35,35,52,1);
}

/* Base reset for widget */
.swa-widget, .swa-widget * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: var(--swa-font);
}

/* ==========================================================================
   Toggle Button (Requirement #1 & #2 — position + full design customization)
   ========================================================================== */

/*
 * FIX: The #swa-widget wrapper is output by wp_footer at the end of
 * <body>. Without explicit positioning on the wrapper it sits in normal
 * document flow at the page bottom. We turn it into a zero-size fixed
 * overlay (width/height 0, pointer-events none on the wrapper itself so
 * it never blocks theme content) and let each child element opt-in to
 * pointer-events individually. This is the standard pattern for floating
 * widget containers in WordPress and is compatible with all themes.
 */
#swa-widget {
	position: fixed !important;
	top: 0;
	left: 0;
	width: 0;
	height: 0;
	z-index: 999990;
	pointer-events: none;
	overflow: visible;
}

/* All interactive children of the widget re-enable pointer events. */
#swa-widget .swa-toggle,
#swa-widget .swa-chat-window,
#swa-widget .swa-toast-container {
	pointer-events: auto;
}

/*
 * Base button: position:fixed places it relative to the viewport
 * (independently of its parent because the parent is also fixed with
 * zero dimensions, which is fine — fixed children are still viewport-
 * relative). Fallback coordinates (top-right) are set here directly so
 * the button is always visible even if a .swa-pos-* class fails to apply
 * (e.g. fresh install before settings are written, or a CSS conflict that
 * strips the class). The .swa-pos-* selectors below override these with
 * the admin's chosen corner.
 *
 * z-index 999998 safely clears:
 *   - WP admin bar            → 99999
 *   - Most theme headers      → 100–9999
 *   - WooCommerce notices     → 9999
 *   - Common plugin overlays  → up to 99998
 */
.swa-toggle {
	position: fixed;
	/* Fallback position: top-right. Overridden by .swa-pos-* below. */
	top: var(--swa-edge-gap);
	right: var(--swa-edge-gap);
	bottom: auto;
	left: auto;
	z-index: 999998;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 22px;
	background: var(--swa-btn-bg, linear-gradient(135deg, var(--swa-primary), var(--swa-secondary)));
	color: var(--swa-btn-text-color, #fff);
	border: var(--swa-btn-border-width, 0px) solid var(--swa-btn-border-color, transparent);
	border-radius: var(--swa-btn-radius, 50px);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--swa-btn-shadow, 0 8px 32px rgba(108,92,231,.45));
	transition: var(--swa-transition);
	white-space: nowrap;
	user-select: none;
	/* Prevent themes from forcing display:block or other overrides */
	line-height: normal;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	/* Ensure the button is never accidentally clipped */
	overflow: visible;
}
.swa-toggle:hover {
	background: var(--swa-btn-hover, var(--swa-secondary));
	transform: translateY(-3px) scale(1.03);
	box-shadow: 0 14px 40px rgba(108,92,231,.55);
}
.swa-toggle:active { transform: translateY(-1px); }
.swa-toggle:focus-visible {
	outline: 2px solid var(--swa-btn-bg);
	outline-offset: 3px;
}

/* Icon / label coloring inside the toggle */
.swa-toggle-emoji { font-size: var(--swa-btn-icon-size, 22px); line-height: 1; }
.swa-toggle-icon svg { color: var(--swa-btn-icon-color, #fff); }
.swa-toggle-label { color: var(--swa-btn-text-color, #fff); }

.swa-toggle-icon { display: flex; align-items: center; gap: 8px; }
.swa-toggle-close { display: none; }
.swa-toggle.swa-open .swa-toggle-open { display: none; }
.swa-toggle.swa-open .swa-toggle-close { display: flex; }

/* Optional fixed width/height (when admin sets specific px values instead
   of "auto") */
.swa-toggle { width: var(--swa-btn-width, auto); height: var(--swa-btn-height, auto); }

/* Size presets (Requirement #2: Button Size) */
.swa-btn-size-small  { padding: 10px 16px; font-size: 13px; }
.swa-btn-size-medium { padding: 14px 22px; font-size: 15px; }
.swa-btn-size-large  { padding: 18px 28px; font-size: 17px; }

/* ---- Position presets (Requirement #1) ----
   Each corner gets symmetric edge spacing using --swa-edge-gap.
   All four sides are explicitly set in every rule to guarantee clean
   overrides of the base rule's fallback top/right coordinates.
   !important is used only on the coordinate values — it is needed here
   because some aggressive themes apply `top/right/bottom/left` rules to
   all `position:fixed` elements (e.g. mobile menu overlays, cookie
   banners) using high-specificity or !important themselves. */
.swa-pos-top-right    .swa-toggle {
	top: var(--swa-edge-gap)  !important;
	right: var(--swa-edge-gap) !important;
	bottom: auto !important;
	left: auto !important;
}
.swa-pos-right-bottom .swa-toggle {
	top: auto !important;
	right: var(--swa-edge-gap) !important;
	bottom: var(--swa-edge-gap) !important;
	left: auto !important;
}
.swa-pos-left-bottom  .swa-toggle {
	top: auto !important;
	right: auto !important;
	bottom: var(--swa-edge-gap) !important;
	left: var(--swa-edge-gap)  !important;
}
.swa-pos-bottom-center .swa-toggle {
	top: auto !important;
	right: auto !important;
	bottom: var(--swa-edge-gap) !important;
	left: 50% !important;
	transform: translateX(-50%);
}
.swa-pos-bottom-center .swa-toggle:hover { transform: translateX(-50%) translateY(-3px) scale(1.03); }
.swa-pos-bottom-center .swa-toggle:active { transform: translateX(-50%) translateY(-1px); }
.swa-pos-top-left     .swa-toggle {
	top: var(--swa-edge-gap)  !important;
	right: auto !important;
	bottom: auto !important;
	left: var(--swa-edge-gap)  !important;
}

/* Chat window anchors to the same corner as its toggle button. */
.swa-pos-top-right    .swa-chat-window {
	top: 90px !important; right: var(--swa-edge-gap) !important;
	bottom: auto !important; left: auto !important;
	transform-origin: top right;
}
.swa-pos-right-bottom .swa-chat-window {
	top: auto !important; right: var(--swa-edge-gap) !important;
	bottom: 90px !important; left: auto !important;
	transform-origin: bottom right;
}
.swa-pos-left-bottom  .swa-chat-window {
	top: auto !important; right: auto !important;
	bottom: 90px !important; left: var(--swa-edge-gap) !important;
	transform-origin: bottom left;
}
.swa-pos-bottom-center .swa-chat-window {
	top: auto !important; right: auto !important;
	bottom: 90px !important; left: 50% !important;
	transform: translateX(-50%);
	transform-origin: bottom center;
}
.swa-pos-top-left     .swa-chat-window {
	top: 90px !important; right: auto !important;
	bottom: auto !important; left: var(--swa-edge-gap) !important;
	transform-origin: top left;
}

/* Button entrance/idle animation presets (Requirement #2: Button Animation) */
@keyframes swaBtnPulseRing {
	0%   { box-shadow: 0 8px 32px rgba(108,92,231,.45), 0 0 0 0 rgba(108,92,231,.5); }
	70%  { box-shadow: 0 8px 32px rgba(108,92,231,.45), 0 0 0 14px rgba(108,92,231,0); }
	100% { box-shadow: 0 8px 32px rgba(108,92,231,.45), 0 0 0 0 rgba(108,92,231,0); }
}
@keyframes swaBtnBounce {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-8px); }
}
@keyframes swaBtnShake {
	0%, 100% { transform: rotate(0); }
	20%      { transform: rotate(-8deg); }
	40%      { transform: rotate(8deg); }
	60%      { transform: rotate(-5deg); }
	80%      { transform: rotate(5deg); }
}
.swa-btn-anim-pulse  { animation: swaBtnPulseRing 2.4s ease-out infinite; }
.swa-btn-anim-bounce { animation: swaBtnBounce 1.8s ease-in-out infinite; }
.swa-btn-anim-shake  { animation: swaBtnShake 3.2s ease-in-out infinite; }
.swa-btn-anim-none   { animation: none; }
/* Pause idle animation while chat is open or on hover, so it doesn't fight
   the open/close transform. */
.swa-toggle.swa-open, .swa-toggle:hover { animation: none; }

.swa-notification-dot {
	position: absolute;
	top: -4px;
	right: -4px;
	width: 12px;
	height: 12px;
	background: #ff7675;
	border-radius: 50%;
	border: 2px solid #fff;
	animation: swa-pulse 2s infinite;
	display: none;
}
.swa-notification-dot.visible { display: block; }

@keyframes swa-pulse {
	0%,100% { transform: scale(1); opacity: 1; }
	50% { transform: scale(1.25); opacity: .7; }
}

/* ==========================================================================
   Chat Window
   ========================================================================== */
.swa-chat-window {
	position: fixed !important;
	/* Fallback coordinates match the default top-right button position.
	   Overridden per-corner by .swa-pos-* selectors above. */
	top: 90px;
	right: 24px;
	bottom: auto;
	left: auto;
	z-index: 999997;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: var(--swa-bg);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
	border-radius: var(--swa-radius);
	box-shadow: var(--swa-shadow);
	border: 1px solid var(--swa-border);
	overflow: hidden;
	transform-origin: top right;
}
.swa-chat-window[hidden] {
	display: none;
}
.swa-chat-window.swa-animating-in {
	animation: swaSlideIn .3s cubic-bezier(.34,1.56,.64,1) forwards;
}
.swa-chat-window.swa-animating-out {
	animation: swaSlideOut .2s ease-in forwards;
}
@keyframes swaSlideIn {
	from { opacity:0; transform:scale(.85) translateY(20px); }
	to   { opacity:1; transform:scale(1) translateY(0); }
}
@keyframes swaSlideOut {
	from { opacity:1; transform:scale(1); }
	to   { opacity:0; transform:scale(.9) translateY(10px); }
}

/* ==========================================================================
   Header
   ========================================================================== */
.swa-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	background: linear-gradient(135deg, var(--swa-primary), var(--swa-secondary));
	color: #fff;
	flex-shrink: 0;
}
.swa-header-left { display: flex; align-items: center; gap: 12px; }
.swa-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	overflow: hidden;
	flex-shrink: 0;
}
.swa-avatar img { width:100%; height:100%; object-fit:cover; }
.swa-header-name { font-weight: 700; font-size: 15px; }
.swa-online-indicator {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	opacity: .85;
	margin-top: 2px;
}
.swa-dot {
	width: 7px;
	height: 7px;
	background: #55efc4;
	border-radius: 50%;
	animation: swa-pulse 2s infinite;
}
.swa-header-actions { display: flex; gap: 8px; }
.swa-icon-btn {
	background: rgba(255,255,255,.15);
	border: none;
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 14px;
	transition: background .2s;
}
.swa-icon-btn:hover { background: rgba(255,255,255,.25); }

/* ==========================================================================
   Messages
   ========================================================================== */
.swa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
}
.swa-messages::-webkit-scrollbar { width: 4px; }
.swa-messages::-webkit-scrollbar-track { background: transparent; }
.swa-messages::-webkit-scrollbar-thumb { background: var(--swa-secondary); border-radius: 4px; }

/* Message rows */
.swa-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	animation: swaMsgIn .25s ease-out;
}
@keyframes swaMsgIn {
	from { opacity:0; transform:translateY(10px); }
	to   { opacity:1; transform:translateY(0); }
}
.swa-msg--user { flex-direction: row-reverse; }

.swa-msg-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--swa-chip-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	flex-shrink: 0;
	overflow: hidden;
}
.swa-msg-avatar img { width:100%; height:100%; object-fit:cover; }

.swa-msg-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 18px;
	line-height: 1.55;
	font-size: 14px;
	color: var(--swa-text);
	background: var(--swa-bg-msg-bot);
	border-bottom-left-radius: 4px;
	word-break: break-word;
}
.swa-msg--user .swa-msg-bubble {
	background: var(--swa-bg-msg-user);
	color: #fff;
	border-bottom-right-radius: 4px;
	border-bottom-left-radius: 18px;
}
.swa-msg-bubble a { color: var(--swa-primary); text-decoration: underline; }
.swa-msg--user .swa-msg-bubble a { color: rgba(255,255,255,.85); }
.swa-msg-bubble p { margin: 0 0 6px; }
.swa-msg-bubble p:last-child { margin: 0; }
.swa-msg-bubble strong { font-weight: 600; }

/* Requirement #7: category intro replies use \n\n for paragraph breaks
   instead of HTML <p> tags (they're escaped server-side for safety), so
   we render those as real visual paragraph breaks here. */
.swa-reply-text { white-space: pre-line; }
.swa-reply-text:empty { display: none; }

/* Category chips in welcome */
.swa-category-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 10px;
}
.swa-category-chip {
	display: inline-block;
	padding: 6px 12px;
	background: var(--swa-chip-bg);
	color: var(--swa-chip-color);
	border: 1px solid rgba(108,92,231,.2);
	border-radius: 50px;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: var(--swa-transition);
}
.swa-category-chip:hover {
	background: var(--swa-primary);
	color: #fff;
	border-color: var(--swa-primary);
	transform: translateY(-1px);
}

/* ==========================================================================
   Product Carousel
   ========================================================================== */
.swa-products-carousel {
	display: flex;
	overflow-x: auto;
	gap: 10px;
	padding: 4px 2px 6px;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
}
.swa-products-carousel::-webkit-scrollbar { height: 3px; }
.swa-products-carousel::-webkit-scrollbar-thumb { background: var(--swa-secondary); border-radius: 3px; }

.swa-product-card {
	flex: 0 0 180px;
	background: var(--swa-product-bg);
	border-radius: 14px;
	overflow: hidden;
	scroll-snap-align: start;
	box-shadow: var(--swa-shadow-sm);
	transition: transform .2s, box-shadow .2s;
	border: 1px solid var(--swa-border);
	display: flex;
	flex-direction: column;
}
.swa-product-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,.12); }

.swa-product-img {
	width: 100%;
	height: 130px;
	object-fit: cover;
	background: var(--swa-chip-bg);
	display: block;
}
.swa-product-img-placeholder {
	width: 100%;
	height: 130px;
	background: var(--swa-chip-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 36px;
}
.swa-product-badge {
	position: absolute;
	top: 8px;
	left: 8px;
	background: #e17055;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 7px;
	border-radius: 50px;
}
.swa-product-img-wrap { position: relative; }

.swa-product-body { padding: 10px 10px 0; flex: 1; }
.swa-product-name {
	font-size: 12px;
	font-weight: 600;
	color: var(--swa-text);
	line-height: 1.4;
	margin-bottom: 5px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.swa-product-desc {
	font-size: 11px;
	color: var(--swa-text-light);
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 5px;
}
.swa-product-pricing { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }
.swa-product-price {
	font-size: 14px;
	font-weight: 700;
	color: var(--swa-primary);
}
.swa-product-mrp {
	font-size: 11px;
	color: var(--swa-text-light);
	text-decoration: line-through;
}
.swa-product-discount {
	font-size: 10px;
	font-weight: 700;
	color: #00b894;
	background: rgba(0,184,148,.1);
	padding: 1px 5px;
	border-radius: 50px;
}
.swa-product-rating {
	display: flex;
	align-items: center;
	gap: 3px;
	font-size: 11px;
	color: var(--swa-text-light);
	margin-bottom: 5px;
}
.swa-product-rating .swa-stars { color: #f39c12; }
.swa-product-stock {
	font-size: 10px;
	font-weight: 600;
	margin-bottom: 8px;
}
.swa-product-stock.in-stock { color: #00b894; }
.swa-product-stock.out-of-stock { color: #d63031; }

/* ==========================================================================
   Product Action Buttons (Requirement #4 — modern icon buttons)
   ========================================================================== */
.swa-product-actions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 4px 10px 12px;
}

.swa-btn {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 10px;
	border-radius: 10px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: var(--swa-transition);
	text-decoration: none;
	border: none;
	white-space: nowrap;
	overflow: hidden;
}
.swa-btn-icon { font-size: 13px; line-height: 1; flex-shrink: 0; }
.swa-btn-label { line-height: 1; }

/* Add to Cart — primary action, full brand color */
.swa-btn--primary {
	background: linear-gradient(135deg, var(--swa-primary), var(--swa-secondary));
	color: #fff;
	box-shadow: 0 2px 8px rgba(108,92,231,.25);
}
.swa-btn--primary:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(108,92,231,.4);
}
.swa-btn--primary:active { transform: translateY(0); }

/* Buy Now — energetic accent, stands apart from Add to Cart */
.swa-btn--buynow {
	background: linear-gradient(135deg, #fd7e14, #f97316);
	color: #fff;
	box-shadow: 0 2px 8px rgba(249,115,22,.25);
}
.swa-btn--buynow:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(249,115,22,.4);
}
.swa-btn--buynow:active { transform: translateY(0); }

/* View Product — quiet, outline style */
.swa-btn--outline {
	background: transparent;
	color: var(--swa-primary);
	border: 1.5px solid var(--swa-chip-bg);
}
.swa-btn--outline:hover {
	background: var(--swa-chip-bg);
	border-color: var(--swa-primary);
}

.swa-btn--ghost {
	background: var(--swa-chip-bg);
	color: var(--swa-text-light);
	font-size: 14px;
}
.swa-btn--ghost:hover { background: var(--swa-border); }

/* Disabled (out of stock) */
.swa-btn:disabled,
.swa-btn.swa-atc-disabled {
	background: var(--swa-chip-bg);
	color: var(--swa-text-light);
	cursor: not-allowed;
	box-shadow: none;
	transform: none !important;
}

/* Loading state — spinner replaces icon, label dims */
.swa-btn.loading {
	pointer-events: none;
	color: transparent !important;
}
.swa-btn.loading .swa-btn-icon,
.swa-btn.loading .swa-btn-label { visibility: hidden; }
.swa-btn.loading::after {
	content: '';
	position: absolute;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255,255,255,.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: swaSpin .6s linear infinite;
}
.swa-btn--outline.loading::after { border-color: rgba(108,92,231,.3); border-top-color: var(--swa-primary); }
@keyframes swaSpin { to { transform: rotate(360deg); } }

/* Success flash after a successful Add to Cart */
.swa-btn.success {
	background: linear-gradient(135deg, #00b894, #00d2a8) !important;
	box-shadow: 0 2px 8px rgba(0,184,148,.35) !important;
}
.swa-btn.success .swa-btn-icon::before { content: '✓ '; }

/* ==========================================================================
   Typing Indicator
   ========================================================================== */
.swa-typing {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 14px 0;
}
.swa-typing[hidden] { display: none; }
.swa-typing-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	background: var(--swa-bg-msg-bot);
	padding: 10px 14px;
	border-radius: 18px;
	border-bottom-left-radius: 4px;
}
.swa-typing-dots span {
	width: 7px;
	height: 7px;
	background: var(--swa-secondary);
	border-radius: 50%;
	animation: swaBounce 1.2s infinite;
}
.swa-typing-dots span:nth-child(2) { animation-delay: .2s; }
.swa-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes swaBounce {
	0%,60%,100% { transform: translateY(0); }
	30% { transform: translateY(-6px); }
}

/* ==========================================================================
   Quick Replies
   ========================================================================== */
.swa-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 8px 14px 6px;
	flex-shrink: 0;
	min-height: 0;
}
.swa-quick-reply {
	padding: 7px 14px;
	background: var(--swa-chip-bg);
	color: var(--swa-chip-color);
	border: 1px solid rgba(108,92,231,.25);
	border-radius: 50px;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: var(--swa-transition);
	white-space: nowrap;
}
.swa-quick-reply:hover {
	background: var(--swa-primary);
	color: #fff;
	border-color: var(--swa-primary);
	transform: translateY(-1px);
}

/* ==========================================================================
   Input Area
   ========================================================================== */
.swa-input-area {
	padding: 10px 14px 12px;
	border-top: 1px solid var(--swa-border);
	background: var(--swa-bg);
	flex-shrink: 0;
}
.swa-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
}
.swa-input {
	flex: 1;
	padding: 11px 16px;
	background: var(--swa-input-bg);
	border: 1.5px solid var(--swa-border);
	border-radius: 50px;
	font-size: 14px;
	color: var(--swa-text);
	outline: none;
	transition: border-color .2s;
}
.swa-input:focus { border-color: var(--swa-primary); }
.swa-input::placeholder { color: var(--swa-text-light); }

.swa-send-btn {
	position: relative;
	width: 42px;
	height: 42px;
	min-width: 42px;
	background: linear-gradient(135deg, var(--swa-primary), var(--swa-secondary));
	color: #fff;
	border: none;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: var(--swa-transition);
	flex-shrink: 0;
	padding: 0;
	box-shadow: 0 3px 10px rgba(108,92,231,.35);
	-webkit-appearance: none;
	appearance: none;
}
.swa-send-icon, .swa-send-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: opacity .15s, transform .15s;
}
/* Nudge the paper-plane icon slightly to optically center it */
.swa-send-icon { transform: translate(-46%, -50%); }
.swa-send-spinner { opacity: 0; }

.swa-send-btn:hover:not(:disabled) {
	transform: scale(1.08);
	box-shadow: 0 6px 18px rgba(108,92,231,.5);
}
.swa-send-btn:active:not(:disabled) { transform: scale(.94); }
.swa-send-btn:focus-visible {
	outline: 2px solid var(--swa-primary);
	outline-offset: 2px;
}

/* Disabled state — empty input, nothing to send yet */
.swa-send-btn:disabled {
	background: var(--swa-chip-bg);
	color: var(--swa-text-light);
	box-shadow: none;
	cursor: not-allowed;
	opacity: .7;
}

/* Loading state — message is in flight */
.swa-send-btn.swa-loading { pointer-events: none; }
.swa-send-btn.swa-loading .swa-send-icon { opacity: 0; transform: translate(-46%,-50%) scale(.6); }
.swa-send-btn.swa-loading .swa-send-spinner {
	opacity: 1;
	animation: swaSpin .7s linear infinite;
}

.swa-powered-by {
	text-align: center;
	font-size: 10px;
	color: var(--swa-text-light);
	margin-top: 6px;
	opacity: .6;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.swa-toast-container {
	position: fixed !important;
	/* Default top-right position — will be near the button. */
	top: 90px;
	right: 24px;
	bottom: auto;
	left: auto;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.swa-toast {
	background: #2d3436;
	color: #fff;
	padding: 12px 18px;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 500;
	box-shadow: 0 6px 20px rgba(0,0,0,.2);
	animation: swaToastIn .25s ease-out;
	max-width: 280px;
}
.swa-toast.success { background: #00b894; }
.swa-toast.error { background: #d63031; }
@keyframes swaToastIn {
	from { opacity:0; transform:translateX(20px); }
	to   { opacity:1; transform:translateX(0); }
}
@keyframes swaToastOut {
	from { opacity:1; transform:translateX(0); }
	to   { opacity:0; transform:translateX(20px); }
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
@media (max-width: 480px) {
	.swa-chat-window {
		position: fixed !important;
		top: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		left: 0 !important;
		width: 100vw;
		max-width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		border: none;
		transform: none !important;
	}
	/* Tighten edge gap on small screens. Each position preset still
	   governs which corner the button sits in — we only reduce the gap. */
	.swa-toggle { --swa-edge-gap: 16px; }
	/* bottom-center needs its transform preserved on mobile */
	.swa-pos-bottom-center .swa-toggle { transform: translateX(-50%) !important; }
	.swa-toast-container {
		top: auto !important;
		bottom: 80px !important;
		right: 8px !important;
		left: auto !important;
	}
}

@media (min-width: 481px) and (max-width: 768px) {
	/* Tablet: slightly smaller chat window */
	.swa-chat-window {
		width: 340px;
		height: 520px;
	}
}

/* ==========================================================================
   "You may also like" — Upsell panel after Add to Cart (Requirement #8)
   ========================================================================== */
.swa-upsell-block {
	margin-top: 4px;
}
.swa-upsell-heading {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 700;
	color: var(--swa-text);
	margin-bottom: 8px;
	padding-top: 8px;
	border-top: 1px dashed var(--swa-border);
}
.swa-upsell-heading .swa-upsell-icon { font-size: 14px; }

/* ==========================================================================
   RTL Support
   ========================================================================== */
[dir="rtl"] .swa-msg--user { flex-direction: row; }
[dir="rtl"] .swa-msg--bot { flex-direction: row-reverse; }
[dir="rtl"] .swa-msg-bubble { border-bottom-left-radius: 18px; border-bottom-right-radius: 4px; }
[dir="rtl"] .swa-msg--user .swa-msg-bubble { border-bottom-right-radius: 18px; border-bottom-left-radius: 4px; }
[dir="rtl"] .swa-product-badge { left: auto; right: 8px; }

/* In RTL: mirror the default top-right fallback to top-left, and swap
   right-bottom / left-bottom so the position presets read naturally in
   RTL locales (right-bottom = visually right in LTR = visually left in RTL). */
[dir="rtl"] .swa-toggle {
	right: auto !important;
	left: var(--swa-edge-gap) !important;
}
[dir="rtl"] .swa-pos-top-right .swa-toggle,
[dir="rtl"] .swa-pos-right-bottom .swa-toggle {
	right: auto !important;
	left: var(--swa-edge-gap) !important;
}
[dir="rtl"] .swa-pos-top-left .swa-toggle,
[dir="rtl"] .swa-pos-left-bottom .swa-toggle {
	left: auto !important;
	right: var(--swa-edge-gap) !important;
}
[dir="rtl"] .swa-chat-window {
	right: auto !important;
	left: var(--swa-edge-gap) !important;
	transform-origin: bottom left;
}
[dir="rtl"] .swa-toast-container {
	right: auto !important;
	left: 24px !important;
}
