/* Cloud Digital Assistant — inherits the site's font so it feels native. */
#cda-root {
	--cda-accent: #1d4ed8;
	--cda-accent-text: #fff;
	/* Darker shade of the accent for text on white, so it stays readable (WCAG AA). */
	--cda-accent-ink: color-mix(in srgb, var(--cda-accent) 78%, #000);
	--cda-bg: #ffffff;
	--cda-surface: #f4f5f7;
	--cda-text: #14161a;
	--cda-muted: #5b616b;
	--cda-border: #e3e5e9;
	--cda-radius: 18px;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--cda-text);
}
#cda-root *, #cda-root *::before, #cda-root *::after { box-sizing: border-box; }
#cda-root.cda-pos-right { right: 20px; }
#cda-root.cda-pos-left { left: 20px; }

/* Launcher */
#cda-root .cda-launcher {
	width: 58px; height: 58px; border-radius: 50%;
	border: 0; padding: 15px; margin: 0;
	background: var(--cda-accent); color: var(--cda-accent-text);
	box-shadow: 0 8px 24px rgba(0,0,0,.18);
	cursor: pointer; display: grid; place-items: center;
	transition: transform .2s ease, box-shadow .2s ease;
	float: right;
}
#cda-root.cda-pos-left .cda-launcher { float: left; }
#cda-root .cda-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.22); }
#cda-root .cda-launcher svg { width: 26px; height: 26px; display: block; }
#cda-root button:focus-visible, #cda-root a:focus-visible, #cda-root textarea:focus-visible {
	outline: 3px solid var(--cda-accent); outline-offset: 2px;
}

/* Panel */
#cda-root .cda-panel {
	position: absolute; bottom: 72px;
	width: 380px; max-width: calc(100vw - 32px);
	height: 600px; max-height: calc(100vh - 120px);
	background: var(--cda-bg);
	border-radius: var(--cda-radius);
	box-shadow: 0 20px 60px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.06);
	display: flex; flex-direction: column; overflow: hidden;
	animation: cda-in .22s ease-out;
}
#cda-root .cda-panel[hidden] { display: none; }
#cda-root.cda-pos-right .cda-panel { right: 0; }
#cda-root.cda-pos-left .cda-panel { left: 0; }
@keyframes cda-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

#cda-root .cda-header {
	display: flex; align-items: center; gap: 10px;
	padding: 12px 12px 12px 14px;
	background: var(--cda-accent); color: var(--cda-accent-text);
}
#cda-root .cda-avatar {
	width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; overflow: hidden;
	background: #fff; color: var(--cda-accent); display: grid; place-items: center;
	font-weight: 700; font-size: 14px; box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}
#cda-root .cda-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 5px; display: block; }
#cda-root .cda-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#cda-root .cda-title strong { font-size: 16px; font-weight: 600; color: inherit; }
#cda-root .cda-title span { font-size: 12px; opacity: .85; line-height: 1.3; }
#cda-root .cda-icon-btn {
	width: 34px; height: 34px; border-radius: 50%; border: 0; margin: 0; padding: 8px;
	background: transparent; color: inherit; cursor: pointer; font-size: 18px; line-height: 1;
	display: grid; place-items: center;
}
#cda-root .cda-icon-btn:hover { background: rgba(255,255,255,.16); }
#cda-root .cda-icon-btn svg { width: 18px; height: 18px; }

/* Messages */
#cda-root .cda-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
#cda-root .cda-msg { display: flex; flex-direction: column; gap: 8px; max-width: 88%; }
#cda-root .cda-bot { align-self: flex-start; }
#cda-root .cda-user { align-self: flex-end; align-items: flex-end; }
#cda-root .cda-bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
#cda-root .cda-bot .cda-bubble { background: var(--cda-surface); border-bottom-left-radius: 4px; }
#cda-root .cda-user .cda-bubble { background: var(--cda-accent); color: var(--cda-accent-text); border-bottom-right-radius: 4px; }
#cda-root .cda-typing .cda-bubble { letter-spacing: 3px; color: var(--cda-muted); animation: cda-pulse 1s infinite; }
@keyframes cda-pulse { 50% { opacity: .4; } }

#cda-root .cda-links { display: flex; flex-direction: column; gap: 6px; }
#cda-root .cda-link {
	display: block; padding: 10px 12px; border: 1px solid var(--cda-border); border-radius: 12px;
	text-decoration: none; color: var(--cda-text); background: var(--cda-bg);
	transition: border-color .15s, transform .15s;
}
#cda-root .cda-link:hover { border-color: var(--cda-accent); transform: translateX(2px); }
#cda-root .cda-link strong { display: block; font-size: 14px; font-weight: 600; color: var(--cda-accent-ink); }
#cda-root .cda-link strong::after { content: ' →'; }
#cda-root .cda-link span { display: block; font-size: 13px; color: var(--cda-muted); margin-top: 2px; }

#cda-root .cda-summary {
	margin: 0; padding: 10px 12px; border: 1px solid var(--cda-border); border-radius: 12px;
	display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px;
}
#cda-root .cda-summary dt { color: var(--cda-muted); margin: 0; }
#cda-root .cda-summary dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* Chips */
#cda-root .cda-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; max-height: 40%; overflow-y: auto; }
#cda-root .cda-chips[hidden] { display: none; }
#cda-root .cda-chip {
	border: 1px solid var(--cda-accent); color: var(--cda-accent-ink); background: var(--cda-bg);
	border-radius: 999px; padding: 7px 13px; margin: 0; font: inherit; font-size: 13.5px; line-height: 1.2;
	cursor: pointer; text-decoration: none; display: inline-block; text-align: left;
}
#cda-root .cda-chip:hover { background: var(--cda-surface); }
#cda-root .cda-chip-primary { background: var(--cda-accent); color: var(--cda-accent-text); font-weight: 600; }
#cda-root .cda-chip-primary:hover { background: var(--cda-accent); filter: brightness(1.08); }

/* Composer */
#cda-root .cda-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--cda-border); margin: 0; }
#cda-root .cda-input {
	flex: 1; resize: none; border: 1px solid var(--cda-border); border-radius: 14px;
	padding: 10px 12px; margin: 0; font: inherit; font-size: 16px; /* 16px stops iOS zoom */
	color: var(--cda-text); background: var(--cda-bg); max-height: 140px; min-height: 42px; line-height: 1.35;
}
#cda-root .cda-input:focus { border-color: var(--cda-accent); outline: none; }
#cda-root .cda-send {
	width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; border: 0; padding: 10px; margin: 0;
	background: var(--cda-accent); color: var(--cda-accent-text); cursor: pointer; display: grid; place-items: center;
}
#cda-root .cda-send svg { width: 20px; height: 20px; }
#cda-root .cda-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

#cda-root .cda-foot { padding: 0 12px 10px; font-size: 12px; color: var(--cda-muted); text-align: center; }
#cda-root .cda-foot:empty { display: none; }
#cda-root .cda-foot a { color: var(--cda-muted); }

/* Mobile: full-screen sheet */
@media (max-width: 520px) {
	#cda-root { bottom: 16px; }
	#cda-root.cda-pos-right { right: 16px; }
	#cda-root.cda-pos-left { left: 16px; }
	#cda-root .cda-panel {
		position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0;
		height: 100dvh;
	}
	#cda-root.cda-open .cda-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	#cda-root .cda-panel, #cda-root .cda-typing .cda-bubble { animation: none; }
	#cda-root .cda-launcher, #cda-root .cda-link { transition: none; }
}
@media print { #cda-root { display: none !important; } }

/* Services showcase */
#cda-root .cda-msg:has(.cda-services) { max-width: 100%; }
#cda-root .cda-services { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#cda-root .cda-service {
	display: flex; flex-direction: column; gap: 3px; text-align: left; margin: 0;
	padding: 10px 11px; border: 1px solid var(--cda-border); border-radius: 12px;
	background: var(--cda-bg); color: var(--cda-text); font: inherit; cursor: pointer;
	transition: border-color .15s, background .15s;
}
#cda-root .cda-service:hover { border-color: var(--cda-accent); background: var(--cda-surface); }
#cda-root .cda-service strong { font-size: 13.5px; font-weight: 600; color: var(--cda-accent-ink); line-height: 1.25; }
#cda-root .cda-service span { font-size: 12.5px; color: var(--cda-muted); line-height: 1.35; }
@media (max-width: 360px) { #cda-root .cda-services { grid-template-columns: 1fr; } }
