/* Swim2u AI Chat Widget */
#swim2u-chat-root, #swim2u-chat-root * { box-sizing: border-box; }

#swim2u-chat-root {
	--s2u-primary: #6c63b3;      /* Swim2u purple */
	--s2u-primary-dark: #564ea0;
	--s2u-teal: #3eb4cb;         /* Swim2u teal */
	--s2u-gradient: linear-gradient(135deg, #6c63b3 0%, #3eb4cb 100%);
	--s2u-bg: #ffffff;
	--s2u-user: #6c63b3;
	--s2u-bot: #f1f5f9;
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Floating button */
#swim2u-chat-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var(--s2u-gradient);
	color: #fff;
	box-shadow: 0 6px 20px rgba(108, 99, 179, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#swim2u-chat-toggle:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(62, 180, 203, 0.5); }
#swim2u-chat-toggle svg { width: 30px; height: 30px; }

/* Chat window */
#swim2u-chat-window {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 120px);
	background: var(--s2u-bg);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
	display: none;
	flex-direction: column;
	overflow: hidden;
}
#swim2u-chat-root.s2u-open #swim2u-chat-window { display: flex; }

#swim2u-chat-header {
	background: var(--s2u-gradient);
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 10px;
}
#swim2u-chat-header .s2u-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
#swim2u-chat-header .s2u-sub { font-size: 12px; opacity: 0.9; }
#swim2u-chat-header .s2u-avatar {
	width: 38px; height: 38px; border-radius: 50%;
	background: rgba(255,255,255,0.2);
	display: flex; align-items: center; justify-content: center; font-size: 20px;
	overflow: hidden; flex: 0 0 auto;
}
#swim2u-chat-header .s2u-avatar.has-logo { background: #fff; }
#swim2u-chat-header .s2u-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }
#swim2u-chat-close {
	background: transparent; border: none; color: #fff;
	font-size: 22px; cursor: pointer; line-height: 1; opacity: 0.85;
}
#swim2u-chat-close:hover { opacity: 1; }

#swim2u-chat-close { margin-left: auto; }

#swim2u-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f8fafc;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.s2u-msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.s2u-msg.bot { align-self: flex-start; background: var(--s2u-bot); color: #1e293b; border-bottom-left-radius: 4px; }
.s2u-msg.user { align-self: flex-end; background: var(--s2u-user); color: #fff; border-bottom-right-radius: 4px; }

/* Quick-reply chips */
.s2u-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.s2u-chip {
	background: #fff; border: 1.5px solid var(--s2u-primary); color: var(--s2u-primary);
	border-radius: 18px; padding: 7px 14px; font-size: 13px; font-family: inherit;
	cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.s2u-chip:hover { background: var(--s2u-primary); color: #fff; }
.s2u-chip.selected { background: var(--s2u-primary); color: #fff; }
.s2u-chip.selected::before { content: "✓ "; }

/* "Go back" — clearly secondary so it never competes with a real answer */
.s2u-chip.s2u-back {
	border: 1.5px dashed #cbd5e1;
	color: #64748b;
	background: transparent;
}
.s2u-chip.s2u-back:hover { background: #f1f5f9; color: #475569; border-color: #94a3b8; }

.s2u-confirm {
	flex-basis: 100%;
	margin-top: 4px;
	background: var(--s2u-teal); border: none; color: #fff;
	border-radius: 18px; padding: 9px 16px; font-size: 13px; font-family: inherit;
	cursor: pointer; transition: opacity 0.15s ease;
}
.s2u-confirm:disabled { background: #cbd5e1; color: #64748b; cursor: not-allowed; }
.s2u-confirm:not(:disabled):hover { opacity: 0.9; }

.s2u-typing { align-self: flex-start; background: var(--s2u-bot); border-radius: 14px; padding: 12px 16px; display: inline-flex; gap: 4px; }
.s2u-typing span { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: s2u-blink 1.2s infinite both; }
.s2u-typing span:nth-child(2) { animation-delay: 0.2s; }
.s2u-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes s2u-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

#swim2u-chat-input {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #e2e8f0;
	background: #fff;
}
#swim2u-chat-input textarea {
	flex: 1; resize: none; border: 1px solid #cbd5e1; border-radius: 12px;
	padding: 10px 12px; font-size: 14px; font-family: inherit; max-height: 90px; outline: none;
}
#swim2u-chat-input textarea:focus { border-color: var(--s2u-primary); }
#swim2u-chat-send {
	background: var(--s2u-primary); border: none; color: #fff; width: 44px; border-radius: 12px;
	cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#swim2u-chat-send:hover { background: var(--s2u-primary-dark); }
#swim2u-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
#swim2u-chat-send svg { width: 20px; height: 20px; }

.s2u-footer { text-align: center; font-size: 11px; color: #94a3b8; padding: 0 0 8px; background: #fff; }

/* Left-hand placement */
#swim2u-chat-root.s2u-left { right: auto; left: 24px; }
#swim2u-chat-root.s2u-left #swim2u-chat-window { right: auto; left: 0; }

/* Mobile: full-screen chat, like Tidio */
@media (max-width: 600px) {
	#swim2u-chat-root { bottom: 16px; right: 16px; }
	#swim2u-chat-root.s2u-left { right: auto; left: 16px; }

	#swim2u-chat-root.s2u-open #swim2u-chat-window,
	#swim2u-chat-root.s2u-left.s2u-open #swim2u-chat-window {
		position: fixed;
		top: 0; left: 0; right: 0; bottom: 0;
		width: 100%;
		max-width: none;
		height: 100vh;
		height: 100dvh; /* accounts for mobile browser chrome */
		max-height: none;
		border-radius: 0;
	}

	/* The bubble would sit on top of the full-screen panel — hide it while open. */
	#swim2u-chat-root.s2u-open #swim2u-chat-toggle { display: none; }

	/* Respect notches / home indicators. */
	#swim2u-chat-header { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
	#swim2u-chat-input { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
	#swim2u-chat-close { font-size: 28px; padding: 0 4px; }
}
