/*
 * Ultimate Kilimanjaro Chatbot
 * All styles scoped under #ukcb-root to avoid theme conflicts.
 */

#ukcb-root {
	/* Brand-aligned palette — UK brand blue */
	--ukcb-accent:        #333F67;
	--ukcb-accent-dark:   #252E4D;
	--ukcb-accent-soft:   #eef0f6;
	--ukcb-bg:            #ffffff;
	--ukcb-surface:       #f7f8fa;
	--ukcb-text:          #1a2530;
	--ukcb-text-muted:    #6b7785;
	--ukcb-border:        #e3e7ec;
	--ukcb-shadow:        0 18px 50px rgba(15, 25, 40, 0.18), 0 4px 12px rgba(15, 25, 40, 0.06);
	--ukcb-radius:        14px;
	--ukcb-font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	--ukcb-z:             999998;

	font-family: var(--ukcb-font);
	color: var(--ukcb-text);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

#ukcb-root *,
#ukcb-root *::before,
#ukcb-root *::after {
	box-sizing: border-box;
}

/* ---- Floating launcher button --------------------------------------- */
.ukcb-launcher {
	position: fixed;
	bottom: 96px;
	right: 22px;
	z-index: var(--ukcb-z);
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: 0;
	cursor: pointer;
	background: linear-gradient(135deg, var(--ukcb-accent) 0%, var(--ukcb-accent-dark) 100%);
	color: #fff;
	box-shadow: 0 10px 28px rgba(51, 63, 103, 0.40), 0 4px 10px rgba(15, 25, 40, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ukcb-launcher:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 14px 34px rgba(51, 63, 103, 0.50), 0 5px 12px rgba(15, 25, 40, 0.22);
}
.ukcb-launcher:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}
.ukcb-launcher svg {
	width: 28px !important;
	height: 28px !important;
	min-width: 28px !important;
	min-height: 28px !important;
	max-width: 28px !important;
	max-height: 28px !important;
	stroke: #fff !important;
	stroke-width: 2 !important;
	fill: none !important;
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
}
.ukcb-launcher svg path {
	stroke: #fff !important;
	fill: none !important;
	visibility: visible !important;
	opacity: 1 !important;
}

/* Pulse halo on first appearance */
.ukcb-launcher::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: 50%;
	border: 2px solid var(--ukcb-accent);
	opacity: 0;
	animation: ukcb-pulse 2.4s ease-out 1s 2;
}
@keyframes ukcb-pulse {
	0%   { opacity: 0.7; transform: scale(1); }
	100% { opacity: 0;   transform: scale(1.5); }
}

/* ---- Chat panel ----------------------------------------------------- */
.ukcb-panel {
	position: fixed;
	bottom: 170px;
	right: 22px;
	z-index: var(--ukcb-z);
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 200px);
	background: var(--ukcb-bg);
	border-radius: var(--ukcb-radius);
	box-shadow: var(--ukcb-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: ukcb-pop 0.22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes ukcb-pop {
	from { opacity: 0; transform: translateY(8px) scale(.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ukcb-header {
	background: linear-gradient(135deg, var(--ukcb-accent) 0%, var(--ukcb-accent-dark) 100%);
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.ukcb-header-title {
	font-weight: 600;
	font-size: 15px;
	display: flex;
	align-items: center;
	gap: 10px;
}
.ukcb-header-status {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22e1a8;
	box-shadow: 0 0 0 3px rgba(34, 225, 168, 0.3);
}
.ukcb-close {
	background: rgba(255, 255, 255, 0.15);
	border: 0;
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
	font-size: 18px;
	line-height: 1;
}
.ukcb-close:hover { background: rgba(255, 255, 255, 0.28); }
.ukcb-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---- Messages area -------------------------------------------------- */
.ukcb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	background: var(--ukcb-surface);
	scroll-behavior: smooth;
}
.ukcb-messages::-webkit-scrollbar { width: 6px; }
.ukcb-messages::-webkit-scrollbar-thumb { background: #cdd5de; border-radius: 3px; }
.ukcb-messages::-webkit-scrollbar-track { background: transparent; }

.ukcb-msg {
	display: flex;
	margin-bottom: 12px;
	animation: ukcb-msg-in 0.25s ease;
}
@keyframes ukcb-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}
.ukcb-msg.user { justify-content: flex-end; }
.ukcb-msg-bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.ukcb-msg.bot .ukcb-msg-bubble {
	background: var(--ukcb-bg);
	color: var(--ukcb-text);
	border: 1px solid var(--ukcb-border);
	border-bottom-left-radius: 4px;
}
.ukcb-msg.user .ukcb-msg-bubble {
	background: var(--ukcb-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ukcb-msg.error .ukcb-msg-bubble {
	background: #fff4f4;
	color: #b3261e;
	border: 1px solid #f5c6c6;
	border-bottom-left-radius: 4px;
}
.ukcb-msg-bubble a {
	color: inherit;
	text-decoration: underline;
	font-weight: 500;
}
.ukcb-msg.user .ukcb-msg-bubble a { color: #fff; }

/* "Talk to a human" CTA inside a bot bubble */
.ukcb-cta-row {
	display: flex;
	justify-content: flex-start;
	margin: 4px 0 16px;
}
.ukcb-cta {
	background: var(--ukcb-accent-soft);
	color: var(--ukcb-accent-dark);
	border: 1px solid #d4d8e6;
	padding: 8px 14px;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease;
}
.ukcb-cta:hover { background: #e0e3ee; }

/* Typing indicator */
.ukcb-typing {
	display: inline-flex;
	gap: 4px;
	padding: 4px 0;
}
.ukcb-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b1bac4;
	animation: ukcb-bounce 1.2s infinite ease-in-out;
}
.ukcb-typing span:nth-child(2) { animation-delay: 0.15s; }
.ukcb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ukcb-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---- Composer ------------------------------------------------------- */
.ukcb-composer {
	border-top: 1px solid var(--ukcb-border);
	background: var(--ukcb-bg);
	padding: 12px;
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.ukcb-input {
	flex: 1;
	border: 1px solid var(--ukcb-border);
	border-radius: 10px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 14.5px;
	color: var(--ukcb-text);
	background: var(--ukcb-surface);
	resize: none;
	max-height: 120px;
	min-height: 40px;
	line-height: 1.4;
	overflow-y: hidden;
	overflow-x: hidden;
	transition: border-color 0.15s ease, background 0.15s ease;
}
.ukcb-input:focus {
	outline: none;
	border-color: var(--ukcb-accent);
	background: #fff;
}
/* Defensively kill any spinner controls or number-input artifacts that
 * a host theme might be applying to descendants. The composer input is
 * a textarea, but Chrome/parent CSS sometimes injects spinner buttons
 * via ::-webkit-inner-spin-button on inputs that look like ours. */
.ukcb-input,
#ukcb-root textarea,
#ukcb-root input[type="text"] {
	-webkit-appearance: none !important;
	-moz-appearance: textfield !important;
	appearance: none !important;
}
.ukcb-input::-webkit-inner-spin-button,
.ukcb-input::-webkit-outer-spin-button,
#ukcb-root textarea::-webkit-inner-spin-button,
#ukcb-root textarea::-webkit-outer-spin-button,
#ukcb-root input::-webkit-inner-spin-button,
#ukcb-root input::-webkit-outer-spin-button {
	-webkit-appearance: none !important;
	appearance: none !important;
	display: none !important;
	margin: 0 !important;
	width: 0 !important;
	height: 0 !important;
}
.ukcb-send {
	background: var(--ukcb-accent);
	color: #fff;
	border: 0;
	border-radius: 10px;
	width: 40px;
	height: 40px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, transform 0.1s ease;
	flex-shrink: 0;
}
.ukcb-send:hover:not(:disabled) { background: var(--ukcb-accent-dark); }
.ukcb-send:active:not(:disabled) { transform: scale(0.96); }
.ukcb-send:disabled { background: #c5cdd6; cursor: not-allowed; }
.ukcb-send svg {
	width: 18px !important;
	height: 18px !important;
	min-width: 18px !important;
	min-height: 18px !important;
	max-width: 18px !important;
	max-height: 18px !important;
	fill: #fff !important;
	stroke: none !important;
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
}
.ukcb-send svg path {
	fill: #fff !important;
	stroke: none !important;
	visibility: visible !important;
	opacity: 1 !important;
}

.ukcb-footer {
	font-size: 11px;
	color: var(--ukcb-text-muted);
	text-align: center;
	padding: 6px 12px 10px;
	background: var(--ukcb-bg);
}
.ukcb-footer button {
	background: none;
	border: 0;
	color: var(--ukcb-accent-dark);
	font-size: 11px;
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

/* ---- Ticket form (overlay inside panel) ----------------------------- */
.ukcb-ticket-view {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	background: var(--ukcb-bg);
}
.ukcb-ticket-view h3 {
	margin: 0 0 6px;
	font-size: 17px;
	color: var(--ukcb-text);
	font-weight: 600;
}
.ukcb-ticket-view .ukcb-ticket-sub {
	color: var(--ukcb-text-muted);
	font-size: 13px;
	margin-bottom: 16px;
}
.ukcb-field { margin-bottom: 12px; }
.ukcb-field label {
	display: block;
	font-size: 12.5px;
	color: var(--ukcb-text-muted);
	font-weight: 500;
	margin-bottom: 4px;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}
.ukcb-field input,
.ukcb-field textarea {
	width: 100%;
	border: 1px solid var(--ukcb-border);
	border-radius: 8px;
	padding: 9px 11px;
	font-family: inherit;
	font-size: 14px;
	background: var(--ukcb-surface);
	color: var(--ukcb-text);
	transition: border-color 0.15s ease, background 0.15s ease;
}
.ukcb-field input:focus,
.ukcb-field textarea:focus {
	outline: none;
	border-color: var(--ukcb-accent);
	background: #fff;
}
.ukcb-field textarea { resize: vertical; min-height: 90px; }
.ukcb-honeypot {
	position: absolute !important;
	left: -9999px !important;
	top: -9999px !important;
}
.ukcb-ticket-actions {
	display: flex;
	gap: 8px;
	margin-top: 14px;
}
.ukcb-btn-primary {
	background: var(--ukcb-accent);
	color: #fff;
	border: 0;
	padding: 10px 18px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 500;
	font-size: 14px;
	transition: background 0.15s ease;
}
.ukcb-btn-primary:hover:not(:disabled) { background: var(--ukcb-accent-dark); }
.ukcb-btn-primary:disabled { background: #c5cdd6; cursor: not-allowed; }
.ukcb-btn-secondary {
	background: transparent;
	color: var(--ukcb-text);
	border: 1px solid var(--ukcb-border);
	padding: 10px 16px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 500;
	font-size: 14px;
	transition: background 0.15s ease;
}
.ukcb-btn-secondary:hover { background: var(--ukcb-surface); }
.ukcb-form-error {
	color: #b3261e;
	font-size: 13px;
	margin: 8px 0 0;
}
.ukcb-success {
	background: #e8f9ef;
	color: #166534;
	border: 1px solid #b9e7c8;
	border-radius: 10px;
	padding: 14px;
	font-size: 14px;
}

/* ---- Mobile --------------------------------------------------------- */
@media (max-width: 480px) {
	.ukcb-panel {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
	}
	.ukcb-launcher {
		bottom: 88px;
		right: 16px;
	}
}

/* Hide widget when panel is open (mobile aesthetic) */
.ukcb-panel-open .ukcb-launcher {
	transform: scale(0);
	pointer-events: none;
	transition: transform 0.2s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	#ukcb-root *,
	#ukcb-root *::before,
	#ukcb-root *::after {
		animation-duration: 0.001ms !important;
		transition-duration: 0.05s !important;
	}
}
