/* EAFF Chatbot widget styles. Scoped under #eaff-cb to avoid leaking into the host theme. */

#eaff-cb {
	--eaff-primary: #0F2A3D;
	--eaff-primary-2: #16394F;
	--eaff-accent: #C9A227;
	--eaff-bg: #FBFAF7;
	--eaff-panel: #FFFFFF;
	--eaff-text: #1B2430;
	--eaff-muted: #667080;
	--eaff-border: #E4E1D8;
	--eaff-radius: 16px;
	--eaff-shadow: 0 18px 45px -12px rgba(15, 42, 61, 0.35), 0 4px 14px rgba(15, 42, 61, 0.12);
	position: fixed;
	z-index: 2147483000;
	bottom: 22px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--eaff-text);
}
#eaff-cb.eaff-pos-right { right: 22px; }
#eaff-cb.eaff-pos-left  { left: 22px; }
#eaff-cb * { box-sizing: border-box; }

/* ---- launcher ---- */
#eaff-cb .eaff-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	border: none;
	cursor: pointer;
	background: var(--eaff-primary);
	color: #fff;
	padding: 14px 20px 14px 16px;
	border-radius: 999px;
	box-shadow: var(--eaff-shadow);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#eaff-cb .eaff-launcher:hover { transform: translateY(-1px); }
#eaff-cb .eaff-launcher:focus-visible { outline: 2px solid var(--eaff-accent); outline-offset: 3px; }
#eaff-cb .eaff-launcher-icon {
	width: 30px; height: 30px; border-radius: 50%;
	background: var(--eaff-accent);
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
}
#eaff-cb .eaff-launcher-icon svg { width: 16px; height: 16px; }
#eaff-cb .eaff-launcher-icon.eaff-icon-custom,
#eaff-cb .eaff-header-avatar.eaff-icon-custom {
	overflow: hidden;
	background: var(--eaff-bg);
}
#eaff-cb .eaff-launcher-icon.eaff-icon-custom img,
#eaff-cb .eaff-header-avatar.eaff-icon-custom img {
	width: 100%; height: 100%;
	object-fit: cover;
	display: block;
}
#eaff-cb .eaff-dot {
	position: absolute; top: -3px; right: -3px;
	width: 11px; height: 11px; border-radius: 50%;
	background: var(--eaff-accent);
	border: 2px solid var(--eaff-bg);
}
#eaff-cb .eaff-launcher-wrap { position: relative; display: inline-block; }

/* ---- panel ---- */
#eaff-cb .eaff-panel {
	position: absolute;
	bottom: 70px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 600px;
	max-height: min(600px, calc(100vh - 120px));   /* fallback for older browsers */
	max-height: min(600px, calc(100dvh - 120px));  /* accounts for mobile address bar */
	background: var(--eaff-bg);
	border-radius: var(--eaff-radius);
	box-shadow: var(--eaff-shadow);
	border: 1px solid var(--eaff-border);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}
#eaff-cb.eaff-pos-right .eaff-panel { right: 0; }
#eaff-cb.eaff-pos-left  .eaff-panel { left: 0; }
#eaff-cb.eaff-open .eaff-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Hide the launcher entirely while the panel is open, so it can never sit
   on top of the input bar. It reappears the moment the panel closes
   (the header's own X button, or Esc, toggles the same "eaff-open" class). */
#eaff-cb.eaff-open .eaff-launcher-wrap {
	display: none;
}

#eaff-cb .eaff-header {
	background: linear-gradient(135deg, var(--eaff-primary), var(--eaff-primary-2));
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
#eaff-cb .eaff-header-avatar {
	width: 36px; height: 36px; border-radius: 50%;
	background: var(--eaff-accent);
	display: flex; align-items: center; justify-content: center;
	font-family: Georgia, "Times New Roman", serif;
	font-weight: 700;
	color: var(--eaff-primary);
	flex-shrink: 0;
}
#eaff-cb .eaff-header-text { flex: 1; min-width: 0; }
#eaff-cb .eaff-header-name {
	font-family: Georgia, "Times New Roman", serif;
	font-size: 16px;
	font-weight: 700;
	margin: 0;
}
#eaff-cb .eaff-header-status {
	font-size: 12.5px;
	color: rgba(255,255,255,0.75);
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 2px;
}
#eaff-cb .eaff-header-status::before {
	content: "";
	width: 7px; height: 7px; border-radius: 50%;
	background: #4ADE80;
	display: inline-block;
}
#eaff-cb .eaff-close,
#eaff-cb .eaff-reset {
	background: rgba(255,255,255,0.12);
	border: none;
	color: #fff;
	width: 30px; height: 30px;
	border-radius: 50%;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
}
#eaff-cb .eaff-close:hover,
#eaff-cb .eaff-reset:hover { background: rgba(255,255,255,0.22); }
#eaff-cb .eaff-close:focus-visible,
#eaff-cb .eaff-reset:focus-visible { outline: 2px solid var(--eaff-accent); outline-offset: 2px; }
#eaff-cb .eaff-reset svg { width: 16px; height: 16px; }

#eaff-cb .eaff-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background:
		radial-gradient(circle at 100% 0%, rgba(201,162,39,0.06), transparent 40%),
		var(--eaff-bg);
}
#eaff-cb .eaff-row { display: flex; gap: 8px; max-width: 92%; }
#eaff-cb .eaff-row.eaff-bot { align-self: flex-start; }
#eaff-cb .eaff-row.eaff-user { align-self: flex-end; flex-direction: row-reverse; }

#eaff-cb .eaff-bubble {
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
#eaff-cb .eaff-row.eaff-bot .eaff-bubble {
	background: var(--eaff-panel);
	border: 1px solid var(--eaff-border);
	border-top-left-radius: 4px;
	color: var(--eaff-text);
}
#eaff-cb .eaff-row.eaff-user .eaff-bubble {
	background: var(--eaff-primary);
	color: #fff;
	border-top-right-radius: 4px;
}
#eaff-cb .eaff-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#eaff-cb .eaff-row.eaff-bot .eaff-bubble a { color: var(--eaff-primary-2); font-weight: 600; }
#eaff-cb .eaff-bubble ul { margin: 6px 0 0; padding-left: 18px; }
#eaff-cb .eaff-bubble li { margin: 2px 0; }
#eaff-cb .eaff-bubble strong { font-weight: 700; }

#eaff-cb .eaff-link-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 9px;
	padding: 7px 12px;
	background: var(--eaff-accent);
	color: var(--eaff-primary);
	border-radius: 999px;
	font-weight: 700;
	font-size: 13.5px;
	text-decoration: none !important;
}
#eaff-cb .eaff-link-chip:hover { filter: brightness(0.95); }

#eaff-cb .eaff-suggestions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 4px;
	align-self: flex-start;
	max-width: 92%;
}
#eaff-cb .eaff-suggestion-btn {
	text-align: left;
	background: var(--eaff-panel);
	border: 1px solid var(--eaff-border);
	color: var(--eaff-primary-2);
	padding: 8px 12px;
	border-radius: 10px;
	cursor: pointer;
	font-size: 13.5px;
	font-weight: 600;
}
#eaff-cb .eaff-suggestion-btn:hover { border-color: var(--eaff-accent); background: #FFFDF5; }

#eaff-cb .eaff-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--eaff-panel);
	border: 1px solid var(--eaff-border);
	border-radius: 14px;
	border-top-left-radius: 4px;
}
#eaff-cb .eaff-typing span {
	width: 6px; height: 6px; border-radius: 50%;
	background: var(--eaff-muted);
	animation: eaff-bounce 1.2s infinite ease-in-out;
}
#eaff-cb .eaff-typing span:nth-child(2) { animation-delay: 0.15s; }
#eaff-cb .eaff-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes eaff-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

#eaff-cb .eaff-langbar {
	display: flex;
	justify-content: flex-end;
	gap: 5px;
	padding: 8px 14px 0;
	flex-shrink: 0;
}
#eaff-cb .eaff-lang-btn {
	background: transparent;
	border: 1px solid var(--eaff-border);
	color: var(--eaff-muted);
	border-radius: 999px;
	padding: 3px 10px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
	cursor: pointer;
}
#eaff-cb .eaff-lang-btn:hover { border-color: var(--eaff-accent); color: var(--eaff-primary-2); }
#eaff-cb .eaff-lang-btn.eaff-lang-active {
	background: var(--eaff-primary);
	border-color: var(--eaff-primary);
	color: #fff;
}

#eaff-cb .eaff-quickbar {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	padding: 0 14px 10px;
	flex-shrink: 0;
	max-height: 220px;
	opacity: 1;
	overflow: hidden;
	transition: max-height 0.25s ease, opacity 0.2s ease, padding-bottom 0.25s ease;
}
/* Added once a question has been asked (quick link or typed) - collapses the
   row away entirely so it stops eating into the message area's reading
   space, rather than just hiding the buttons and leaving a gap behind. */
#eaff-cb .eaff-quickbar.eaff-quickbar-hidden {
	max-height: 0;
	opacity: 0;
	padding-bottom: 0;
	pointer-events: none;
}
#eaff-cb .eaff-quick-btn {
	background: var(--eaff-panel);
	border: 1px solid var(--eaff-border);
	color: var(--eaff-primary-2);
	padding: 6px 11px;
	border-radius: 999px;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
}
#eaff-cb .eaff-quick-btn:hover { border-color: var(--eaff-accent); }

/* Used once there are enough quick links (>4) that the default size would
   take up too much of the panel - smaller text/padding and tighter gaps let
   more of them sit on each row without the list running too tall. */
#eaff-cb .eaff-quickbar-compact { gap: 5px; }
#eaff-cb .eaff-quickbar-compact .eaff-quick-btn {
	padding: 4px 9px;
	font-size: 11.5px;
}

#eaff-cb .eaff-inputbar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--eaff-border);
	background: var(--eaff-panel);
	flex-shrink: 0;
}
#eaff-cb .eaff-input {
	flex: 1;
	resize: none;
	border: 1px solid var(--eaff-border);
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	color: var(--eaff-text);
	max-height: 90px;
	background: var(--eaff-bg);
}
#eaff-cb .eaff-input:focus { outline: none; border-color: var(--eaff-accent); }
#eaff-cb .eaff-send {
	width: 40px; height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--eaff-primary);
	color: #fff;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
	transition: transform 0.1s ease;
}
#eaff-cb .eaff-send:hover:not(:disabled) { transform: scale(1.05); }
#eaff-cb .eaff-send:disabled { opacity: 0.4; cursor: default; }
#eaff-cb .eaff-send svg { width: 17px; height: 17px; }

#eaff-cb .eaff-footer-note {
	text-align: center;
	font-size: 11px;
	color: var(--eaff-muted);
	padding: 6px 10px 10px;
	flex-shrink: 0;
}

/* "Start a new chat?" confirmation - an absolutely-positioned layer confined
   to the panel itself (which is already position: absolute, so inset: 0
   here stays within the chat box, never the full page). Hidden by default
   and faded/scaled in via the .eaff-open modifier, matching the same pattern
   used for the launcher <-> panel toggle elsewhere in this file. */
#eaff-cb .eaff-confirm-overlay {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(15, 20, 28, 0.45);
	border-radius: var(--eaff-radius);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease;
}
#eaff-cb .eaff-confirm-overlay.eaff-open {
	opacity: 1;
	visibility: visible;
}
#eaff-cb .eaff-confirm-box {
	background: var(--eaff-panel);
	border-radius: 12px;
	box-shadow: var(--eaff-shadow);
	padding: 18px;
	width: 100%;
	max-width: 280px;
	transform: translateY(6px);
	transition: transform 0.15s ease;
}
#eaff-cb .eaff-confirm-overlay.eaff-open .eaff-confirm-box { transform: translateY(0); }
#eaff-cb .eaff-confirm-text {
	margin: 0 0 14px;
	font-size: 13.5px;
	line-height: 1.45;
	color: var(--eaff-text);
}
#eaff-cb .eaff-confirm-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}
#eaff-cb .eaff-confirm-cancel,
#eaff-cb .eaff-confirm-ok {
	border: none;
	border-radius: 8px;
	padding: 7px 14px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
#eaff-cb .eaff-confirm-cancel {
	background: transparent;
	color: var(--eaff-muted);
}
#eaff-cb .eaff-confirm-cancel:hover { background: rgba(0,0,0,0.06); }
#eaff-cb .eaff-confirm-ok {
	background: var(--eaff-accent);
	color: #fff;
}
#eaff-cb .eaff-confirm-ok:hover { filter: brightness(1.06); }

/* Tablet / small laptop: panel scales with the viewport instead of staying
   a fixed 380x600, so it never crowds a narrower screen. */
@media (max-width: 700px) and (min-width: 481px) {
	#eaff-cb .eaff-panel {
		width: min(380px, calc(100vw - 32px));
		height: min(600px, calc(100vh - 100px));
		height: min(600px, calc(100dvh - 100px));
	}
}

/* Phones: full-screen sheet. 100dvh (not vh) so it sizes to the visible
   area even while the mobile browser's address bar is showing/hiding. */
@media (max-width: 480px) {
	#eaff-cb { bottom: 14px; }
	#eaff-cb.eaff-pos-right { right: 14px; }
	#eaff-cb.eaff-pos-left  { left: 14px; }
	#eaff-cb .eaff-panel {
		position: fixed;
		top: max(12px, env(safe-area-inset-top, 0px));
		left: 12px;
		right: 12px;
		bottom: max(12px, env(safe-area-inset-bottom, 0px));
		width: auto;
		height: auto;
		max-height: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	#eaff-cb .eaff-panel, #eaff-cb .eaff-launcher, #eaff-cb .eaff-typing span { transition: none; animation: none; }
}
