/**
 * Ripe Innovation AI Assistant — widget styles.
 *
 * Palette and shapes follow the site: brand orange #F69421, 8px inputs,
 * pill buttons, white cards with a layered shadow. Everything is scoped
 * under .rai- so it cannot leak into Elementor's styles.
 */

.rai-root {
	--rai-brand: #f69421;
	--rai-brand-dark: #e07e0c;
	--rai-ink: #1f2124;
	--rai-ink-soft: #5a6069;
	--rai-muted: #98a2ae;
	--rai-line: #e1e6ec;
	--rai-line-soft: #eceff3;
	--rai-fill: #f7f9fb;
	--rai-surface: #ffffff;
	--rai-live: #22c55e;

	/* Launcher colour. Set by a class on .rai-root from the settings page,
	   so it can change without touching this file. */
	--rai-cta:        #f69421;
	--rai-cta-hover:  #e07e0c;
	--rai-cta-text:   #ffffff;
	--rai-cta-glow:   rgba(246, 148, 33, .38);
	--rai-cta-glow-2: rgba(246, 148, 33, .48);
	--rai-cta-ring:   #b4632a;
	--rai-shadow: 0 4px 6px rgba(16, 24, 40, .04), 0 12px 32px rgba(16, 24, 40, .12);

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.55;
	color: var(--rai-ink);
}

.rai-root *,
.rai-root *::before,
.rai-root *::after {
	box-sizing: border-box;
}

/**
 * The theme sets `display` on bare button/span selectors, which beats the
 * user-agent rule behind the [hidden] attribute. Without this, elements the
 * script hides — the lane badge, the Switch link, the composer — stay visible.
 */
.rai-root [hidden] {
	display: none !important;
}

/**
 * Themes frequently ship blanket `svg { width: … }` / `max-width` rules that
 * collapse an inline icon to zero width. Icons are sized explicitly below;
 * this stops anything outside the widget from resizing them.
 */
.rai-root svg {
	max-width: none;
	min-width: 0;
	vertical-align: middle;
}

/* ---------- Launcher ---------- */

/* Same brand orange, dark label — the readable pairing (7.05:1 vs 2.29:1). */
.rai-root.acc-orangedark {
	--rai-cta-text:   #1f2124;
	--rai-cta-ring:   #1f2124;
}

.rai-root.acc-green {
	--rai-cta:        #15803d;
	--rai-cta-hover:  #166534;
	--rai-cta-text:   #ffffff;
	--rai-cta-glow:   rgba(21, 128, 61, .34);
	--rai-cta-glow-2: rgba(21, 128, 61, .46);
	--rai-cta-ring:   #86efac;
}

.rai-root.acc-dark {
	--rai-cta:        #1f2124;
	--rai-cta-hover:  #33373c;
	--rai-cta-text:   #ffffff;
	--rai-cta-glow:   rgba(31, 33, 36, .34);
	--rai-cta-glow-2: rgba(31, 33, 36, .46);
	--rai-cta-ring:   #9aa3ad;
}

.rai-root .rai-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 0 22px;
	border: 0;
	border-radius: 30px;
	background: var(--rai-cta);
	color: var(--rai-cta-text);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .2px;
	cursor: pointer;
	box-shadow: 0 4px 14px var(--rai-cta-glow);
	transition: background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.rai-root .rai-launcher:hover {
	background: var(--rai-cta-hover);
	box-shadow: 0 8px 22px var(--rai-cta-glow-2);
	transform: translateY(-1px);
}

.rai-root .rai-launcher:focus-visible {
	outline: 3px solid var(--rai-cta-ring);
	outline-offset: 2px;
}

.rai-root .rai-launcher svg {
	width: 20px !important;
	height: 20px !important;
	flex: 0 0 auto;
}

.rai-root.is-open .rai-launcher {
	display: none;
}

/* ---------- Panel ---------- */

.rai-root .rai-panel {
	display: none;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 40px);
	background: var(--rai-surface);
	border: 1px solid var(--rai-line-soft);
	border-radius: 16px;
	box-shadow: var(--rai-shadow);
	overflow: hidden;
}

.rai-root.is-open .rai-panel {
	display: flex;
	animation: rai-in .22s ease;
}

@keyframes rai-in {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.rai-root.is-open .rai-panel { animation: none; }
	.rai-root .rai-launcher { transition: none; }
}

/* ---------- Header ---------- */

.rai-root .rai-head {
	flex: none;
	padding: 13px 14px 12px 16px;
	background: var(--rai-ink);
	color: #fff;
}

.rai-root .rai-head-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* Live indicator — a green dot with a soft breathing glow. */
.rai-root .rai-status {
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--rai-live);
	box-shadow: 0 0 0 0 rgba(34, 197, 94, .55);
	animation: rai-pulse 2.4s ease-out infinite;
}

@keyframes rai-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
	70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
	100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.rai-root .rai-status {
		animation: none;
		box-shadow: 0 0 8px rgba(34, 197, 94, .8);
	}
}

.rai-root .rai-head-title {
	flex: 1;
	min-width: 0;
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Outlined chip, matching the reference widget's badge treatment. */
.rai-root .rai-badge {
	flex: 0 0 auto;
	padding: 3px 7px;
	border: 1px solid rgba(255, 255, 255, .28);
	border-radius: 5px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 9.5px;
	font-weight: 500;
	letter-spacing: .08em;
	line-height: 1;
	text-transform: uppercase;
	color: rgba(255, 255, 255, .72);
	white-space: nowrap;
}

/* Second row: which lane is active, plus the way back. */
.rai-root .rai-head-lane {
	display: flex;
	align-items: center;
	gap: 7px;
	margin: 7px 0 0 18px;
}

.rai-root .rai-lane {
	padding: 2px 8px;
	border-radius: 20px;
	background: rgba(255, 255, 255, .16);
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: .4px;
	text-transform: uppercase;
	white-space: nowrap;
}

.rai-root .rai-lane.is-support {
	background: var(--rai-brand);
	color: #fff;
}

.rai-root .rai-sep {
	color: rgba(255, 255, 255, .35);
	font-size: 11px;
}

.rai-root .rai-switch {
	background: none;
	border: 0;
	padding: 0;
	color: rgba(255, 255, 255, .7);
	font-size: 11px;
	text-decoration: underline;
	cursor: pointer;
}

.rai-root .rai-switch:hover { color: #fff; }

.rai-root .rai-close {
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	cursor: pointer;
}

.rai-root .rai-close:hover { background: rgba(255, 255, 255, .2); }

.rai-root .rai-close svg { width: 15px !important; height: 15px !important; flex: 0 0 auto; }

/* ---------- Body ---------- */

.rai-root .rai-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--rai-fill);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* ---------- Mode chooser ---------- */

.rai-root .rai-modes {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 4px;
}

.rai-root .rai-mode {
	display: block;
	width: 100%;
	text-align: left;
	padding: 14px 16px;
	border: 1.5px solid var(--rai-line);
	border-radius: 12px;
	background: var(--rai-surface);
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.rai-root .rai-mode:hover {
	border-color: var(--rai-brand);
	box-shadow: 0 4px 14px rgba(16, 24, 40, .08);
	transform: translateY(-1px);
}

.rai-root .rai-mode:focus-visible {
	outline: 3px solid rgba(246, 148, 33, .4);
	outline-offset: 2px;
}

.rai-root .rai-mode-title {
	display: block;
	font-weight: 600;
	font-size: 15px;
	color: var(--rai-ink);
}

.rai-root .rai-mode-sub {
	display: block;
	margin-top: 2px;
	font-size: 13px;
	color: var(--rai-ink-soft);
}

/* ---------- Messages ---------- */

.rai-root .rai-msg {
	max-width: 88%;
	padding: 11px 14px;
	border-radius: 14px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.rai-root .rai-msg.is-bot {
	align-self: flex-start;
	background: var(--rai-surface);
	border: 1px solid var(--rai-line-soft);
	border-bottom-left-radius: 5px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.rai-root .rai-msg.is-user {
	align-self: flex-end;
	background: var(--rai-brand);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.rai-root .rai-msg a {
	color: inherit;
	text-decoration: underline;
}

.rai-root .rai-msg.is-bot a { color: var(--rai-brand-dark); }

.rai-root .rai-note {
	align-self: center;
	max-width: 100%;
	padding: 6px 12px;
	border-radius: 20px;
	background: rgba(31, 33, 36, .06);
	color: var(--rai-ink-soft);
	font-size: 12px;
	text-align: center;
}

.rai-root .rai-note.is-good {
	background: rgba(29, 111, 66, .1);
	color: #1d6f42;
}

/* Typing indicator */

.rai-root .rai-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
}

.rai-root .rai-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--rai-muted);
	animation: rai-blink 1.2s infinite ease-in-out;
}

.rai-root .rai-typing span:nth-child(2) { animation-delay: .18s; }
.rai-root .rai-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes rai-blink {
	0%, 80%, 100% { opacity: .3; }
	40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.rai-root .rai-typing span { animation: none; opacity: .6; }
}

/* ---------- Sources ---------- */

.rai-root .rai-sources {
	align-self: flex-start;
	max-width: 88%;
	padding: 10px 12px;
	border: 1px dashed var(--rai-line);
	border-radius: 10px;
	background: var(--rai-surface);
	font-size: 12.5px;
}

.rai-root .rai-sources-label {
	display: block;
	font-weight: 600;
	color: var(--rai-ink-soft);
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: .4px;
	font-size: 11px;
}

.rai-root .rai-sources a {
	display: block;
	color: var(--rai-brand-dark);
	text-decoration: none;
	margin-top: 3px;
	overflow-wrap: anywhere;
}

.rai-root .rai-sources a:hover { text-decoration: underline; }

/* ---------- Composer ---------- */

.rai-root .rai-foot {
	flex: none;
	border-top: 1px solid var(--rai-line-soft);
	background: var(--rai-surface);
	padding: 10px 12px 12px;
}

.rai-root .rai-compose {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}

.rai-root .rai-input {
	flex: 1;
	min-height: 44px;
	max-height: 120px;
	padding: 11px 14px;
	border: 1.5px solid var(--rai-line);
	border-radius: 8px;
	background: var(--rai-fill);
	color: var(--rai-ink);
	font: inherit;
	line-height: 1.4;
	resize: none;
	transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.rai-root .rai-input::placeholder { color: var(--rai-muted); }

.rai-root .rai-input:hover { border-color: #cbd3dc; }

.rai-root .rai-input:focus {
	background: var(--rai-surface);
	border-color: var(--rai-brand);
	box-shadow: 0 0 0 3px rgba(246, 148, 33, .2);
	outline: none;
}

.rai-root .rai-send {
	flex: none;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 30px;
	background: var(--rai-brand);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 3px 10px rgba(246, 148, 33, .32);
	transition: background-color .15s ease, box-shadow .15s ease;
}

.rai-root .rai-send:hover:not(:disabled) {
	background: var(--rai-brand-dark);
	box-shadow: 0 6px 16px rgba(246, 148, 33, .42);
}

.rai-root .rai-send:disabled {
	background: #e4e7eb;
	color: #98a2ae;
	cursor: default;
	box-shadow: none;
}

.rai-root .rai-send svg { width: 18px !important; height: 18px !important; flex: 0 0 auto; }

.rai-root .rai-consent {
	margin: 9px 2px 0;
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--rai-muted);
}

.rai-root .rai-human {
	display: inline-block;
	margin-top: 7px;
	background: none;
	border: 0;
	padding: 0;
	font-size: 12px;
	color: var(--rai-ink-soft);
	text-decoration: underline;
	cursor: pointer;
}

.rai-root .rai-human:hover { color: var(--rai-brand-dark); }

/* ---------- Fallback form ---------- */

.rai-root .rai-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 14px;
	border: 1px solid var(--rai-line-soft);
	border-radius: 12px;
	background: var(--rai-surface);
}

.rai-root .rai-form-title {
	margin: 0 0 2px;
	font-size: 14px;
	font-weight: 600;
}

.rai-root .rai-form input,
.rai-root .rai-form textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1.5px solid var(--rai-line);
	border-radius: 8px;
	background: var(--rai-fill);
	color: var(--rai-ink);
	font: inherit;
	font-size: 14px;
	transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.rai-root .rai-form textarea { min-height: 76px; resize: vertical; }

.rai-root .rai-form input::placeholder,
.rai-root .rai-form textarea::placeholder { color: var(--rai-muted); }

.rai-root .rai-form input:focus,
.rai-root .rai-form textarea:focus {
	background: var(--rai-surface);
	border-color: var(--rai-brand);
	box-shadow: 0 0 0 3px rgba(246, 148, 33, .2);
	outline: none;
}

.rai-root .rai-form-submit {
	min-height: 44px;
	margin-top: 2px;
	border: 0;
	border-radius: 30px;
	background: var(--rai-brand);
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	letter-spacing: .2px;
	cursor: pointer;
	box-shadow: 0 3px 10px rgba(246, 148, 33, .32);
	transition: background-color .15s ease, box-shadow .15s ease;
}

.rai-root .rai-form-submit:hover:not(:disabled) {
	background: var(--rai-brand-dark);
	box-shadow: 0 6px 16px rgba(246, 148, 33, .42);
}

.rai-root .rai-form-submit:disabled { opacity: .5; cursor: default; }

.rai-root .rai-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
}

.rai-root .rai-error {
	color: #b42318;
	font-size: 12.5px;
	margin: 0;
}

/* ---------- Preview ribbon (admins only) ---------- */

.rai-root .rai-preview {
	flex: none;
	padding: 6px 12px;
	background: #fff4e5;
	border-bottom: 1px solid #f6d9ac;
	color: #8a5a12;
	font-size: 11.5px;
	text-align: center;
}

/* ---------- Small screens ---------- */

@media only screen and (max-width: 600px) {
	.rai-root {
		right: 14px;
		bottom: 14px;
		left: 14px;
	}

	.rai-root .rai-launcher {
		width: 100%;
		justify-content: center;
	}

	.rai-root .rai-panel {
		width: 100%;
		max-width: none;
		height: calc(100vh - 28px);
		height: calc(100dvh - 28px);
		border-radius: 14px;
	}

	.rai-root .rai-msg { max-width: 92%; }
	.rai-root .rai-sources { max-width: 92%; }
}

/* ---------- Customer verification ---------- */

.rai-root .rai-form-intro {
	margin: 0 0 4px;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--rai-ink-soft);
}

.rai-root .rai-form-help {
	margin: 2px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--rai-muted);
}

/* The invoice is the field that actually gates access — give it weight. */
.rai-root .rai-invoice,
.rai-root .rai-keyfield {
	letter-spacing: normal;
	border-color: var(--rai-brand) !important;
	background: #fffaf3 !important;
}

.rai-root .rai-invoice::placeholder,
.rai-root .rai-keyfield::placeholder {
	text-transform: none;
	letter-spacing: normal;
	font-family: inherit;
}

/* =====================================================================
 * Interaction-state hardening
 *
 * The theme styles bare `button:hover` / `:focus` / `:active` with its own
 * palette (a magenta-pink). Anywhere this widget changed only the border on
 * hover, that pink filled the background in and took the label with it —
 * visible on the lane chooser.
 *
 * Every interactive element below pins its own background and text colour
 * across all four states, so nothing outside the widget can recolour it.
 * The intended hover effects (border, shadow, lift) are untouched.
 * ================================================================== */

.rai-root .rai-mode:hover,
.rai-root .rai-mode:focus,
.rai-root .rai-mode:focus-visible,
.rai-root .rai-mode:active {
	background: var(--rai-surface);
	color: var(--rai-ink);
}

/* The label sits in child spans, so their colour has to be pinned too. */
.rai-root .rai-mode:hover .rai-mode-title,
.rai-root .rai-mode:focus .rai-mode-title,
.rai-root .rai-mode:active .rai-mode-title {
	color: var(--rai-ink);
}

.rai-root .rai-mode:hover .rai-mode-sub,
.rai-root .rai-mode:focus .rai-mode-sub,
.rai-root .rai-mode:active .rai-mode-sub {
	color: var(--rai-ink-soft);
}

.rai-root .rai-launcher:hover,
.rai-root .rai-launcher:focus,
.rai-root .rai-launcher:focus-visible,
.rai-root .rai-launcher:active {
	background: var(--rai-cta-hover);
	color: var(--rai-cta-text);
}

.rai-root .rai-close:hover,
.rai-root .rai-close:focus,
.rai-root .rai-close:active {
	background: rgba(255, 255, 255, .2);
	color: #fff;
}

.rai-root .rai-send:hover:not(:disabled),
.rai-root .rai-send:focus:not(:disabled),
.rai-root .rai-send:active:not(:disabled) {
	background: var(--rai-brand-dark);
	color: #fff;
}

.rai-root .rai-form-submit:hover:not(:disabled),
.rai-root .rai-form-submit:focus:not(:disabled),
.rai-root .rai-form-submit:active:not(:disabled) {
	background: var(--rai-brand-dark);
	color: #fff;
}

/* Text-style buttons must stay text — no theme fill on any state. */
.rai-root .rai-switch:hover,
.rai-root .rai-switch:focus,
.rai-root .rai-switch:active {
	background: none;
	color: #fff;
}

.rai-root .rai-human:hover,
.rai-root .rai-human:focus,
.rai-root .rai-human:active {
	background: none;
	color: var(--rai-brand-dark);
}

/* Inputs keep their own fill on every state as well. */
.rai-root .rai-input:hover,
.rai-root .rai-form input:hover,
.rai-root .rai-form textarea:hover {
	background-color: var(--rai-fill);
}

.rai-root .rai-input:focus,
.rai-root .rai-form input:focus,
.rai-root .rai-form textarea:focus {
	background-color: var(--rai-surface);
}

.rai-root .rai-invoice:hover,
.rai-root .rai-keyfield:hover,
.rai-root .rai-invoice:focus,
.rai-root .rai-keyfield:focus {
	background: #fffaf3 !important;
}

/* ---------------------------------------------------------------------
 * Chooser buttons: defensive belt-and-braces.
 *
 * A pink fill was reported on these buttons on the live site. It could not be
 * reproduced, and no hover, focus or ::selection rule anywhere on the site
 * accounts for it — so rather than guess at one cause, this closes off all of
 * them: the background is pinned with !important against any outside rule, the
 * label cannot be text-selected (there is nothing useful to select on a
 * button), and selection colours are given readable values inside the widget.
 * ------------------------------------------------------------------ */

.rai-root .rai-mode {
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.rai-root .rai-mode,
.rai-root .rai-mode:hover,
.rai-root .rai-mode:focus,
.rai-root .rai-mode:focus-visible,
.rai-root .rai-mode:active,
.rai-root .rai-mode:focus-within {
	background: var(--rai-surface) !important;
	background-image: none !important;
}

.rai-root .rai-mode .rai-mode-title,
.rai-root .rai-mode:hover .rai-mode-title,
.rai-root .rai-mode:focus .rai-mode-title,
.rai-root .rai-mode:active .rai-mode-title {
	color: var(--rai-ink) !important;
	background: transparent !important;
}

.rai-root .rai-mode .rai-mode-sub,
.rai-root .rai-mode:hover .rai-mode-sub,
.rai-root .rai-mode:focus .rai-mode-sub,
.rai-root .rai-mode:active .rai-mode-sub {
	color: var(--rai-ink-soft) !important;
	background: transparent !important;
}

/* Readable selection inside the widget, whatever the page or an extension sets. */
.rai-root ::selection {
	background: rgba(246, 148, 33, .28);
	color: var(--rai-ink);
}

.rai-root ::-moz-selection {
	background: rgba(246, 148, 33, .28);
	color: var(--rai-ink);
}
