/* AAA Super Assistant — floating booking widget.
 * 5.4.3: professional redesign — labelled fields, tabbed channel switch,
 * trust strip, success state, phone bottom sheet with sticky send button.
 * Uses the --aaaos-* brand variables printed by includes/branding.php, so it
 * matches whichever of the four AAAOS brand sites it runs on. */

#aaaos-assistant {
	--sa-ink: var(--aaaos-ink, #221a10);
	--sa-ink-soft: var(--aaaos-ink-soft, #4a3c2c);
	--sa-muted: #7a6a55;
	--sa-paper: #ffffff;
	--sa-cream: var(--aaaos-stone, #fdf3e2);
	--sa-line: #eadfca;
	--sa-line-strong: #d9c7a4;
	--sa-gold: #e0a526;
	--sa-accent: var(--aaaos-laterite, #c14a26);
	--sa-wa: #1fa855;
	--sa-wa-dark: #178a45;
	--sa-radius: 18px;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: var(--aaaos-font-body, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif);
	color: var(--sa-ink);
	-webkit-font-smoothing: antialiased;
}

#aaaos-assistant *,
#aaaos-assistant *::before,
#aaaos-assistant *::after { box-sizing: border-box; }

/* 5.4.2: form controls don't inherit font by default. */
#aaaos-assistant button,
#aaaos-assistant input,
#aaaos-assistant textarea,
#aaaos-assistant select { font-family: inherit; }

#aaaos-assistant [hidden] { display: none !important; }

/* ---------- Launcher bubble ---------- */
#aaaos-assistant-bubble {
	position: relative;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--sa-ink);
	border: 2px solid var(--sa-gold);
	box-shadow: 0 10px 28px rgba(34, 26, 16, .32), 0 2px 6px rgba(0, 0, 0, .18);
	cursor: pointer;
	padding: 0;
	overflow: hidden;
	display: grid;
	place-items: center;
	transition: transform .2s ease, box-shadow .2s ease;
}
#aaaos-assistant-bubble:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(34, 26, 16, .38); }
#aaaos-assistant-bubble:focus-visible { outline: 3px solid var(--sa-gold); outline-offset: 3px; }
#aaaos-assistant-bubble img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s, transform .2s; }
.aaaos-sa-bubble-x {
	position: absolute; inset: 0; display: grid; place-items: center;
	color: #fff; opacity: 0; transform: rotate(-90deg); transition: opacity .2s, transform .2s;
}
#aaaos-assistant.open #aaaos-assistant-bubble img { opacity: 0; transform: scale(.7); }
#aaaos-assistant.open .aaaos-sa-bubble-x { opacity: 1; transform: none; }

/* ---------- Panel ---------- */
#aaaos-assistant-panel {
	position: absolute;
	right: 0;
	bottom: 78px;
	width: 380px;
	max-height: min(680px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	background: var(--sa-paper);
	border: 1px solid var(--sa-line);
	border-radius: var(--sa-radius);
	box-shadow: 0 24px 60px rgba(34, 26, 16, .28), 0 4px 14px rgba(34, 26, 16, .12);
	overflow: hidden;
	transform-origin: bottom right;
	animation: aaaos-sa-in .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes aaaos-sa-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* Header */
#aaaos-assistant-head {
	flex: none;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 18px 16px 18px 20px;
	background:
		radial-gradient(120% 140% at 0% 0%, rgba(224, 165, 38, .18), transparent 55%),
		linear-gradient(135deg, #2b2014 0%, #1a130b 100%);
	color: #fff;
	border-bottom: 2px solid var(--sa-gold);
}
.aaaos-sa-avatar { position: relative; flex: none; }
#aaaos-assistant-head-icon {
	display: block;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	box-shadow: 0 0 0 2px var(--sa-gold), 0 4px 12px rgba(0, 0, 0, .35);
}
.aaaos-sa-online {
	position: absolute; right: 0; bottom: 1px;
	width: 13px; height: 13px; border-radius: 50%;
	background: #2ecc71; border: 2px solid #1f170d;
}
#aaaos-assistant-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aaaos-sa-eyebrow {
	font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--sa-gold);
}
#aaaos-assistant-head-text strong {
	font-family: var(--aaaos-font-display, "Fraunces", Georgia, serif);
	font-size: 19px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; color: #fff;
}
.aaaos-sa-status { font-size: 12px; line-height: 1.35; color: rgba(255, 244, 222, .72); }
.aaaos-sa-close {
	flex: none; align-self: flex-start;
	width: 34px; height: 34px; border-radius: 50%;
	display: grid; place-items: center;
	border: 1px solid rgba(255, 255, 255, .16);
	background: rgba(255, 255, 255, .06);
	color: #fff; cursor: pointer; padding: 0;
	transition: background .15s;
}
.aaaos-sa-close:hover { background: rgba(255, 255, 255, .16); }
.aaaos-sa-close:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 2px; }

/* Body */
#aaaos-assistant-body {
	flex: 1 1 auto;
	position: relative;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 20px 0;
	scrollbar-width: thin;
}
#aaaos-assistant-greeting { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--sa-ink-soft); }

/* Tabs (segmented control) */
.aaaos-sa-tabs {
	display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
	padding: 4px; margin-bottom: 18px;
	background: var(--sa-cream);
	border: 1px solid var(--sa-line);
	border-radius: 12px;
}
.aaaos-sa-tab {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	min-height: 40px; padding: 8px 10px;
	border: 0; border-radius: 9px; background: transparent;
	font-size: 13.5px; font-weight: 600; color: var(--sa-ink-soft);
	cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.aaaos-sa-tab:hover { color: var(--sa-ink); }
.aaaos-sa-tab[aria-selected="true"] { background: #fff; color: var(--sa-ink); box-shadow: 0 1px 3px rgba(34, 26, 16, .14), 0 0 0 1px var(--sa-line); }
.aaaos-sa-tab[data-tab="wa"][aria-selected="true"] svg { color: var(--sa-wa); }
.aaaos-sa-tab[data-tab="mail"][aria-selected="true"] svg { color: var(--sa-accent); }
.aaaos-sa-tab:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 1px; }

/* Fields */
.aaaos-sa-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.aaaos-sa-field { margin-bottom: 14px; min-width: 0; }
.aaaos-sa-field label {
	display: block; margin-bottom: 6px;
	font-size: 12.5px; font-weight: 600; letter-spacing: .01em; color: var(--sa-ink);
}
.aaaos-sa-field abbr { text-decoration: none; color: var(--sa-accent); }
.aaaos-sa-opt { font-weight: 400; color: var(--sa-muted); }
.aaaos-sa-row { display: grid; grid-template-columns: 1fr 132px; gap: 12px; }

#aaaos-assistant-form input:not([type=hidden]):not(.aaaos-sa-hp),
#aaaos-assistant-form textarea {
	display: block; width: 100%;
	min-height: 44px; padding: 10px 13px; margin: 0;
	font-size: 15px; line-height: 1.4; color: var(--sa-ink);
	background: #fff;
	border: 1px solid var(--sa-line-strong);
	border-radius: 10px;
	box-shadow: inset 0 1px 2px rgba(34, 26, 16, .04);
	transition: border-color .15s, box-shadow .15s;
	-webkit-appearance: none; appearance: none;
}
#aaaos-assistant-form textarea { min-height: 84px; resize: vertical; }
#aaaos-assistant-form input::placeholder,
#aaaos-assistant-form textarea::placeholder { color: #a8998a; opacity: 1; }
#aaaos-assistant-form input:focus,
#aaaos-assistant-form textarea:focus {
	outline: none; border-color: var(--sa-gold);
	box-shadow: 0 0 0 3px rgba(224, 165, 38, .22);
}
#aaaos-assistant-form [aria-invalid="true"] { border-color: #c0392b !important; box-shadow: 0 0 0 3px rgba(192, 57, 43, .14) !important; }
.aaaos-sa-err { display: block; margin-top: 5px; font-size: 12px; color: #b03a2e; }
.aaaos-sa-err:empty { display: none; }

/* Travellers stepper */
.aaaos-sa-stepper {
	display: grid; grid-template-columns: 36px 1fr 36px; align-items: center;
	height: 44px; border: 1px solid var(--sa-line-strong); border-radius: 10px; background: #fff; overflow: hidden;
}
.aaaos-sa-stepper:focus-within { border-color: var(--sa-gold); box-shadow: 0 0 0 3px rgba(224, 165, 38, .22); }
.aaaos-sa-stepper button {
	height: 100%; border: 0; background: var(--sa-cream); color: var(--sa-ink);
	font-size: 18px; font-weight: 600; cursor: pointer; padding: 0;
}
.aaaos-sa-stepper button:hover { background: #f5e6c8; }
#aaaos-assistant-form .aaaos-sa-stepper input {
	min-height: 0 !important; height: 100%; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
	text-align: center; padding: 0 !important; font-weight: 600; -moz-appearance: textfield;
}
.aaaos-sa-stepper input::-webkit-outer-spin-button,
.aaaos-sa-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Channel-specific visibility */
#aaaos-assistant[data-tab="wa"] .aaaos-sa-mail-only { display: none !important; }
#aaaos-assistant[data-tab="mail"] .aaaos-sa-wa-only { display: none !important; }

/* Actions */
.aaaos-sa-actions {
	position: sticky; bottom: 0; z-index: 1;
	margin: 0 -20px; padding: 12px 20px 12px;
	background: linear-gradient(to bottom, rgba(255, 255, 255, .88), #fff 28%);
}
.aaaos-sa-submit {
	width: 100%; min-height: 50px;
	display: flex; align-items: center; justify-content: center;
	border: 0; border-radius: 12px; cursor: pointer;
	font-size: 15.5px; font-weight: 700; letter-spacing: .01em; color: #fff;
	background: var(--sa-wa);
	box-shadow: 0 6px 16px rgba(31, 168, 85, .28);
	transition: background .15s, transform .15s, box-shadow .15s;
}
.aaaos-sa-submit > span { display: inline-flex; align-items: center; gap: 9px; }
.aaaos-sa-submit:hover { background: var(--sa-wa-dark); transform: translateY(-1px); }
.aaaos-sa-submit:focus-visible { outline: 3px solid var(--sa-gold); outline-offset: 2px; }
.aaaos-sa-submit:disabled { opacity: .7; cursor: progress; transform: none; }
#aaaos-assistant[data-tab="mail"] .aaaos-sa-submit { background: var(--sa-ink); box-shadow: 0 6px 16px rgba(34, 26, 16, .25); }
#aaaos-assistant[data-tab="mail"] .aaaos-sa-submit:hover { background: #3a2c1b; }
.aaaos-sa-hint { margin: 9px 0 0; text-align: center; font-size: 12px; line-height: 1.45; color: var(--sa-muted); }
#aaaos-assistant-status { margin-top: 8px; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--sa-ink-soft); }
#aaaos-assistant-status:empty { display: none; }

/* Success state */
.aaaos-sa-success { text-align: center; padding: 22px 6px 26px; }
.aaaos-sa-success__icon {
	display: inline-grid; place-items: center; width: 58px; height: 58px; margin-bottom: 12px;
	border-radius: 50%; background: #e7f6ec; color: var(--sa-wa);
}
.aaaos-sa-success strong { display: block; font-family: var(--aaaos-font-display, "Fraunces", Georgia, serif); font-size: 20px; margin-bottom: 6px; }
.aaaos-sa-success p { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--sa-ink-soft); }
.aaaos-sa-link { border: 0; background: none; padding: 4px; font-size: 13.5px; font-weight: 600; color: var(--sa-accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Trust footer */
.aaaos-sa-foot {
	flex: none;
	display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
	padding: 11px 20px;
	background: #fbf6ec;
	border-top: 1px solid var(--sa-line);
	font-size: 11.5px; color: var(--sa-muted);
}
.aaaos-sa-foot > span { display: inline-flex; align-items: center; gap: 5px; }
.aaaos-sa-foot svg { color: var(--sa-gold); }
.aaaos-sa-foot a { margin-left: auto; font-weight: 700; color: var(--sa-accent); text-decoration: none; white-space: nowrap; }
.aaaos-sa-foot a:hover { text-decoration: underline; }

/* ---------- Hook popup ---------- */
#aaaos-assistant-hook {
	display: none;
	position: absolute;
	right: 74px;
	bottom: 12px;
	width: max-content;
	max-width: min(250px, calc(100vw - 100px));
	align-items: center;
	background: #fff;
	border: 1px solid var(--sa-line);
	border-radius: 14px;
	box-shadow: 0 10px 28px rgba(34, 26, 16, .2);
	opacity: 0;
	transform: translateY(6px) scale(.96);
	transition: opacity .25s ease, transform .25s ease;
}
#aaaos-assistant-hook.show { display: flex; opacity: 1; transform: none; }
#aaaos-assistant-hook::after {
	content: ""; position: absolute; right: -7px; bottom: 22px; width: 14px; height: 14px;
	background: #fff; border-right: 1px solid var(--sa-line); border-bottom: 1px solid var(--sa-line);
	transform: rotate(-45deg);
}
#aaaos-assistant-hook-open {
	display: flex; align-items: center; gap: 10px; flex: 1;
	padding: 11px 26px 11px 11px; border: none; background: none; text-align: left; cursor: pointer;
}
#aaaos-assistant-hook-icon { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; box-shadow: 0 0 0 1.5px var(--sa-gold); }
#aaaos-assistant-hook span { font-size: 13px; line-height: 1.35; color: var(--sa-ink); font-weight: 600; }
#aaaos-assistant-hook-close {
	position: absolute; top: 5px; right: 7px; width: 20px; height: 20px;
	border: none; background: none; color: var(--sa-muted); font-size: 17px; line-height: 1; cursor: pointer; padding: 0;
}
#aaaos-assistant.open #aaaos-assistant-hook { display: none; }

@media (prefers-reduced-motion: reduce) {
	#aaaos-assistant-panel { animation: none; }
	#aaaos-assistant *, #aaaos-assistant-hook { transition: none !important; }
}

/* ---------- Phones: full-height bottom sheet ---------- */
html.aaaos-sa-lock, html.aaaos-sa-lock body { overflow: hidden; }

@media (max-width: 480px) {
	#aaaos-assistant { right: 14px; bottom: 14px; }
	#aaaos-assistant-bubble { width: 56px; height: 56px; }

	#aaaos-assistant.open #aaaos-assistant-bubble { display: none; }

	#aaaos-assistant-panel {
		position: fixed;
		left: 0; right: 0; bottom: 0; top: auto;
		width: 100%;
		max-height: none;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
		border: 0;
		animation-name: aaaos-sa-up;
	}
	@keyframes aaaos-sa-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

	#aaaos-assistant-head { padding: 14px 14px 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); gap: 12px; }
	#aaaos-assistant-head-icon { width: 46px; height: 46px; }
	#aaaos-assistant-head-text strong { font-size: 18px; }
	.aaaos-sa-close { width: 38px; height: 38px; }

	#aaaos-assistant-body { padding: 16px 16px 0; }
	#aaaos-assistant-form input:not([type=hidden]):not(.aaaos-sa-hp),
	#aaaos-assistant-form textarea { font-size: 16px; } /* prevents iOS zoom */
	.aaaos-sa-row { grid-template-columns: 1fr 124px; gap: 10px; }

	.aaaos-sa-actions {
		position: sticky; bottom: 0;
		margin: 0 -16px; padding: 12px 16px 14px;
	}
	.aaaos-sa-foot { padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }

	#aaaos-assistant-hook { right: 64px; max-width: min(230px, calc(100vw - 90px)); }
	#aaaos-assistant-hook-icon { width: 28px; height: 28px; }
	#aaaos-assistant-hook span { font-size: 12.5px; }
}
