/**
 * Strynic AI Chat — widget styles.
 * Themed for brug-yachtcharter.com (Elementor kit palette):
 *   primary #165B78 · secondary #6FD1E0 · accent #FBBF8E
 *   dark #0E394B / #314A55 · surface #F2F8F8 · font "Avenir Next"
 * The accent color (--strynic-ai-accent) is injected via
 * wp_add_inline_style() from the saved setting.
 */

:root {
	--strynic-ai-accent: #165b78;
	--strynic-ai-ink: #0e394b;        /* primary text */
	--strynic-ai-ink-soft: #606c77;   /* muted text */
	--strynic-ai-surface: #f2f8f8;    /* message area */
	--strynic-ai-card: #ffffff;       /* bubbles / window */
	--strynic-ai-line: #d9e6ea;       /* borders */
	--strynic-ai-radius-lg: 16px;
	--strynic-ai-radius-md: 12px;
	--strynic-ai-radius-sm: 8px;
	--strynic-ai-control: 44px;       /* unified control height */
	--strynic-ai-pad: 14px;           /* unified padding unit */
	--strynic-ai-font: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ------------------------------------------------------------------ *
 * Chat window (shared by inline + floating)
 * ------------------------------------------------------------------ */

.strynic-chat {
	display: flex;
	flex-direction: column;
	background: var(--strynic-ai-card);
	color: var(--strynic-ai-ink);
	border: 1px solid var(--strynic-ai-line);
	border-radius: var(--strynic-ai-radius-lg);
	box-shadow: 0 12px 40px rgba(14, 57, 75, 0.18);
	overflow: hidden;
	font-family: var(--strynic-ai-font);
	font-size: 15px;
	line-height: 1.5;
	box-sizing: border-box;
}

/* Author display:flex would otherwise beat the UA [hidden] rule. */
.strynic-chat[hidden] {
	display: none !important;
}

.strynic-chat *,
.strynic-chat *::before,
.strynic-chat *::after {
	box-sizing: inherit;
	font-family: inherit;
}

.strynic-chat--inline {
	width: 100%;
	max-width: 640px;
	height: 480px;
	margin: 0 auto;
}

/* Header */

.strynic-chat__header {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 56px;
	padding: 0 var(--strynic-ai-pad);
	background: var(--strynic-ai-accent);
	color: #ffffff;
	flex-shrink: 0;
}

.strynic-chat__title {
	flex: 1;
	font-weight: 600;
	font-size: 15px;
	letter-spacing: 0.2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/*
 * Widget buttons live inside arbitrary themes, and theme CSS loves to
 * restyle `button` (background, padding, radius, text-transform…).
 * Shape and color get !important so the widget survives everywhere.
 */
.strynic-chat .strynic-chat__iconbtn {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 32px !important;
	height: 32px !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: var(--strynic-ai-radius-sm) !important;
	background: transparent !important;
	background-image: none !important;
	color: #ffffff !important;
	box-shadow: none !important;
	text-transform: none !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	cursor: pointer;
	line-height: 0 !important;
	flex-shrink: 0;
	transition: background 0.15s ease;
}

.strynic-chat .strynic-chat__iconbtn:hover,
.strynic-chat .strynic-chat__iconbtn:focus-visible {
	background: rgba(255, 255, 255, 0.25) !important;
	color: #ffffff !important;
}

/* Message list */

.strynic-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: var(--strynic-ai-pad);
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--strynic-ai-surface);
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: rgba(14, 57, 75, 0.25) transparent;
}

.strynic-chat__messages::-webkit-scrollbar {
	width: 8px;
}

.strynic-chat__messages::-webkit-scrollbar-thumb {
	background: rgba(14, 57, 75, 0.25);
	border-radius: 4px;
}

.strynic-chat__messages::-webkit-scrollbar-track {
	background: transparent;
}

.strynic-chat__row {
	display: flex;
}

.strynic-chat__row--user {
	justify-content: flex-end;
}

.strynic-chat__row--assistant {
	justify-content: flex-start;
}

.strynic-chat__bubble {
	max-width: 82%;
	padding: 10px var(--strynic-ai-pad);
	border-radius: var(--strynic-ai-radius-md);
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	margin: 0;
}

.strynic-chat__row--user .strynic-chat__bubble {
	background: var(--strynic-ai-accent);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.strynic-chat__row--assistant .strynic-chat__bubble {
	background: var(--strynic-ai-card);
	border: 1px solid var(--strynic-ai-line);
	color: var(--strynic-ai-ink);
	border-bottom-left-radius: 4px;
}

.strynic-chat__bubble.is-error {
	background: #fef2f2;
	border-color: #fecaca;
	color: #b91c1c;
}

/* Typing indicator (three pulsing dots via pseudo-element) */

.strynic-chat__bubble.is-typing:empty::after {
	content: "•••";
	letter-spacing: 3px;
	color: var(--strynic-ai-ink-soft);
	animation: strynic-pulse 1.2s ease-in-out infinite;
}

@keyframes strynic-pulse {
	0%, 100% { opacity: 0.35; }
	50% { opacity: 1; }
}

/* Input row */

.strynic-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 12px var(--strynic-ai-pad);
	border-top: 1px solid var(--strynic-ai-line);
	background: var(--strynic-ai-card);
	flex-shrink: 0;
	margin: 0;
}

.strynic-chat .strynic-chat__input {
	flex: 1;
	resize: none !important;
	border: 1px solid var(--strynic-ai-line) !important;
	border-radius: var(--strynic-ai-radius-md) !important;
	padding: 10px var(--strynic-ai-pad) !important;
	margin: 0 !important;
	font: inherit;
	font-size: 15px !important;
	line-height: 1.4 !important;
	color: var(--strynic-ai-ink) !important;
	background: var(--strynic-ai-card) !important;
	max-height: 120px;
	min-height: var(--strynic-ai-control) !important;
	height: var(--strynic-ai-control);
	overflow-y: hidden; /* JS flips to auto only when content exceeds max-height. */
	outline: none;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
}

.strynic-chat .strynic-chat__input::placeholder {
	color: var(--strynic-ai-ink-soft);
	opacity: 1;
}

.strynic-chat .strynic-chat__input:focus {
	border-color: var(--strynic-ai-accent);
	box-shadow: 0 0 0 2px rgba(22, 91, 120, 0.2);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--strynic-ai-accent) 25%, transparent);
}

.strynic-chat .strynic-chat__input:disabled {
	opacity: 0.6;
}

.strynic-chat .strynic-chat__send {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: var(--strynic-ai-control) !important;
	height: var(--strynic-ai-control) !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: var(--strynic-ai-radius-md) !important;
	background: var(--strynic-ai-accent) !important;
	background-image: none !important;
	color: #ffffff !important;
	box-shadow: none !important;
	text-transform: none !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	cursor: pointer;
	flex-shrink: 0;
	line-height: 0 !important;
	transition: filter 0.15s ease;
}

.strynic-chat .strynic-chat__send:hover:not(:disabled),
.strynic-chat .strynic-chat__send:focus-visible {
	filter: brightness(1.12);
	color: #ffffff;
}

.strynic-chat .strynic-chat__send:disabled {
	opacity: 0.55;
	cursor: default;
}

/* ------------------------------------------------------------------ *
 * Floating mode: draggable launcher bubble + anchored window
 * ------------------------------------------------------------------ */

.strynic-chat-host {
	position: fixed;
	z-index: 99999;
}

/*
 * Launcher: perfectly round, 60px, middle-right by default.
 * !important on the shape properties defends against theme button CSS
 * (padding/border-radius overrides are what make bubbles go oval).
 */
.strynic-chat__launcher.strynic-chat__launcher {
	position: fixed;
	top: 50%;
	right: 16px;
	margin: -30px 0 0 0;
	width: 60px !important;
	height: 60px !important;
	min-width: 60px;
	min-height: 60px;
	max-width: 60px;
	max-height: 60px;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--strynic-ai-accent) !important;
	background-image: none !important;
	color: #ffffff !important;
	box-shadow: 0 6px 20px rgba(14, 57, 75, 0.3) !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	cursor: grab;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	line-height: 0 !important;
	box-sizing: border-box;
	transition: transform 0.15s ease, filter 0.15s ease;
	touch-action: none; /* Needed for pointer-based dragging on touch. */
	z-index: 100000;
	-webkit-tap-highlight-color: transparent;
}

.strynic-chat__launcher.strynic-chat__launcher:hover,
.strynic-chat__launcher.strynic-chat__launcher:focus-visible {
	transform: scale(1.06);
	filter: brightness(1.1);
	color: #ffffff;
}

.strynic-chat__launcher.strynic-chat__launcher.is-dragging {
	cursor: grabbing;
	transform: scale(1.08);
	transition: none;
}

.strynic-chat__launcher svg {
	width: 28px;
	height: 28px;
}

.strynic-chat--floating {
	position: fixed;
	top: 50%;
	right: 90px;
	width: 370px;
	height: min(560px, calc(100vh - 32px));
	margin-top: min(-280px, calc((100vh - 32px) / -2));
	z-index: 100000;
	animation: strynic-pop 0.16s ease;
}

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

/* Page-scroll lock while the mobile sheet is open (toggled by JS). */

.strynic-chat-lock,
.strynic-chat-lock body {
	overflow: hidden !important;
	overscroll-behavior: none;
}

/* Mobile: floating window becomes a full-screen sheet */

@media (max-width: 480px) {
	.strynic-chat--floating {
		top: 0;
		right: 0;
		width: 100% !important;
		height: 100% !important;
		height: 100dvh !important;
		margin: 0;
		border-radius: 0;
		border: 0;
		animation: none;
	}

	/* Respect notches / home indicators on iPhones. */
	.strynic-chat--floating .strynic-chat__header {
		padding-top: env(safe-area-inset-top, 0px);
		height: calc(56px + env(safe-area-inset-top, 0px));
	}

	.strynic-chat--floating .strynic-chat__form {
		padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	}

	/* 16px stops iOS Safari from auto-zooming the page on input focus. */
	.strynic-chat .strynic-chat__input {
		font-size: 16px !important;
	}

	.strynic-chat--inline {
		height: 420px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.strynic-chat--floating {
		animation: none;
	}

	.strynic-chat__launcher,
	.strynic-chat__iconbtn,
	.strynic-chat__send {
		transition: none;
	}

	.strynic-chat__bubble.is-typing:empty::after {
		animation: none;
	}
}
