/*
 * Claude Chatbot widget.
 *
 * Every rule is scoped under #ccb-root. The ID selector is deliberate: page builders and
 * themes (Elementor kits, for example) restyle every <button>, <textarea>, <h2> and <a>
 * with class-based selectors, and an ID outranks all of them.
 * Override the CSS variables on #ccb-root to restyle.
 */

#ccb-root {
	--ccb-radius: 16px;
	--ccb-bg: #ffffff;
	--ccb-text: #1f2328;
	--ccb-muted: #6b7280;
	--ccb-border: #e5e7eb;
	--ccb-bot-bg: #f1f2f4;
	--ccb-error-bg: #fef2f2;
	--ccb-error-text: #991b1b;

	position: fixed;
	bottom: 20px;
	z-index: 99999;
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Hebrew", Arial, sans-serif;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.5;
	letter-spacing: normal;
	text-transform: none;
	color: var(--ccb-text);
}

#ccb-root[data-pos="left"] { left: 20px; }
#ccb-root[data-pos="right"] { right: 20px; }

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

/* Buttons and the textarea start from a clean slate; :where() adds no specificity. */
#ccb-root :where(button, textarea) {
	margin: 0;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	color: inherit;
}

/* Launcher ------------------------------------------------------------- */

#ccb-root .ccb-launcher,
#ccb-root .ccb-launcher:hover,
#ccb-root .ccb-launcher:focus,
#ccb-root .ccb-launcher:active {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ccb-color, #4f46e5);
	color: var(--ccb-on-color, #fff);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	cursor: pointer;
}

#ccb-root .ccb-launcher {
	transition: transform 0.15s ease;
}

#ccb-root .ccb-launcher:hover { transform: scale(1.06); }

#ccb-root .ccb-launcher svg,
#ccb-root .ccb-close svg,
#ccb-root .ccb-send svg {
	display: block;
	width: 24px;
	height: 24px;
	fill: currentColor;
	pointer-events: none;
}

/* Bubble next to the launcher ------------------------------------------ */

#ccb-root .ccb-bubble,
#ccb-root .ccb-bubble:hover,
#ccb-root .ccb-bubble:focus,
#ccb-root .ccb-bubble:active {
	position: absolute;
	top: 50%;
	display: block;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	padding: 8px 14px;
	border: 1px solid var(--ccb-border);
	border-radius: 999px;
	background: var(--ccb-bg);
	color: var(--ccb-text);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
}

/* The bubble sits on the side facing the page, with its tail pointing at the launcher. */
#ccb-root[data-pos="left"] .ccb-bubble { --ccb-shift: -8px; left: calc(100% + 12px); }
#ccb-root[data-pos="right"] .ccb-bubble { --ccb-shift: 8px; right: calc(100% + 12px); }

#ccb-root .ccb-bubble {
	transform: translateY(-50%);
	animation: ccb-bubble-in 0.4s ease-out 0.6s both;
}

#ccb-root .ccb-bubble::before {
	content: "";
	position: absolute;
	top: 50%;
	width: 10px;
	height: 10px;
	margin-top: -5px;
	background: var(--ccb-bg);
	transform: rotate(45deg);
}

#ccb-root[data-pos="left"] .ccb-bubble::before {
	left: -6px;
	border-left: 1px solid var(--ccb-border);
	border-bottom: 1px solid var(--ccb-border);
}

#ccb-root[data-pos="right"] .ccb-bubble::before {
	right: -6px;
	border-top: 1px solid var(--ccb-border);
	border-right: 1px solid var(--ccb-border);
}

/* Must come after the launcher and bubble rules above: their :hover/:focus states set
   `display` at the same specificity, and a focused bubble would otherwise stay visible. */
#ccb-root.is-open .ccb-launcher,
#ccb-root.is-open .ccb-bubble { display: none; }

/* Panel ---------------------------------------------------------------- */

#ccb-root .ccb-panel {
	display: none;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 24px);
	height: 560px;
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
	margin: 0;
	padding: 0;
	background: var(--ccb-bg);
	border: 1px solid var(--ccb-border);
	border-radius: var(--ccb-radius);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden;
}

#ccb-root.is-open .ccb-panel {
	display: flex;
	animation: ccb-pop 0.18s ease-out;
}

#ccb-root .ccb-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 16px;
	background: var(--ccb-color, #4f46e5);
	color: var(--ccb-on-color, #fff);
}

#ccb-root .ccb-title {
	margin: 0;
	padding: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
	color: inherit;
}

#ccb-root .ccb-close,
#ccb-root .ccb-close:hover,
#ccb-root .ccb-close:focus,
#ccb-root .ccb-close:active {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	box-shadow: none;
	cursor: pointer;
}

#ccb-root .ccb-close:hover { background: rgba(255, 255, 255, 0.2); }
#ccb-root .ccb-close svg { width: 20px; height: 20px; }

/* Messages ------------------------------------------------------------- */

#ccb-root .ccb-messages {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Own messages sit on the right, the bot's on the left, in both text directions. */
#ccb-root .ccb-msg {
	max-width: 85%;
	margin: 0;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.5;
	overflow-wrap: anywhere;
	word-break: break-word;
}

#ccb-root .ccb-msg--bot,
#ccb-root .ccb-msg--error {
	margin-right: auto;
	background: var(--ccb-bot-bg);
	color: var(--ccb-text);
	border-bottom-left-radius: 4px;
}

#ccb-root .ccb-msg--user {
	margin-left: auto;
	background: var(--ccb-color, #4f46e5);
	color: var(--ccb-on-color, #fff);
	white-space: pre-wrap;
	border-bottom-right-radius: 4px;
}

#ccb-root .ccb-msg--error {
	background: var(--ccb-error-bg);
	color: var(--ccb-error-text);
}

#ccb-root .ccb-msg p {
	margin: 0;
	padding: 0;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

#ccb-root .ccb-msg p + p,
#ccb-root .ccb-msg p + ul,
#ccb-root .ccb-msg p + ol,
#ccb-root .ccb-msg ul + p,
#ccb-root .ccb-msg ol + p { margin-top: 8px; }

#ccb-root .ccb-msg ul,
#ccb-root .ccb-msg ol {
	margin: 0;
	padding: 0;
	padding-inline-start: 20px;
	list-style-position: outside;
}

#ccb-root .ccb-msg ul { list-style-type: disc; }
#ccb-root .ccb-msg ol { list-style-type: decimal; }

#ccb-root .ccb-msg li {
	margin: 0;
	padding: 0;
	color: inherit;
}

#ccb-root .ccb-msg a,
#ccb-root .ccb-msg a:hover,
#ccb-root .ccb-msg a:visited {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	background: none;
}

#ccb-root .ccb-retry,
#ccb-root .ccb-retry:hover,
#ccb-root .ccb-retry:focus,
#ccb-root .ccb-retry:active {
	display: block;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	margin-top: 8px;
	padding: 4px 12px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	box-shadow: none;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
}

#ccb-root .ccb-retry:hover { background: rgba(153, 27, 27, 0.08); }

/* Thumbs up/down under a reply ------------------------------------------ */

#ccb-root .ccb-rate {
	display: flex;
	gap: 4px;
	margin: 6px 0 0;
	padding: 0;
}

#ccb-root .ccb-rate-btn,
#ccb-root .ccb-rate-btn:hover,
#ccb-root .ccb-rate-btn:focus,
#ccb-root .ccb-rate-btn:active {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ccb-muted);
	box-shadow: none;
	cursor: pointer;
	opacity: 0.8;
}

#ccb-root .ccb-rate-btn:hover { background: rgba(0, 0, 0, 0.07); opacity: 1; }

/* After the hover rule on purpose: a chosen rating keeps its look while hovered. */
#ccb-root .ccb-rate-btn[aria-pressed="true"] {
	background: rgba(0, 0, 0, 0.09);
	color: var(--ccb-color, #4f46e5);
	opacity: 1;
}

#ccb-root .ccb-rate-btn svg {
	display: block;
	width: 16px;
	height: 16px;
	fill: currentColor;
	pointer-events: none;
}

#ccb-root .ccb-rate-down svg { transform: rotate(180deg); }

#ccb-root .ccb-rate-btn:focus-visible {
	outline: 2px solid var(--ccb-color, #4f46e5);
	outline-offset: 1px;
}

/* Typing indicator ----------------------------------------------------- */

#ccb-root .ccb-typing {
	display: flex;
	gap: 5px;
	align-items: center;
	padding: 13px 14px;
}

#ccb-root .ccb-typing i {
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--ccb-muted);
	animation: ccb-bounce 1.2s infinite ease-in-out;
}

#ccb-root .ccb-typing i:nth-child(2) { animation-delay: 0.15s; }
#ccb-root .ccb-typing i:nth-child(3) { animation-delay: 0.3s; }

/* Composer ------------------------------------------------------------- */

#ccb-root .ccb-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 10px 12px 6px;
	border: 0;
	border-top: 1px solid var(--ccb-border);
}

#ccb-root .ccb-input,
#ccb-root .ccb-input:hover,
#ccb-root .ccb-input:focus {
	flex: 1;
	width: auto;
	min-width: 0;
	/* An explicit height, so a theme's textarea height cannot apply; the script grows it inline. */
	height: 40px;
	min-height: 40px;
	max-height: 120px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid var(--ccb-border);
	border-radius: 20px;
	background: var(--ccb-bg);
	color: var(--ccb-text);
	box-shadow: none;
	resize: none;
	outline: none;
	/* 16px stops iOS Safari from zooming the page on focus. */
	font-size: 16px;
	line-height: 1.4;
}

#ccb-root .ccb-input:focus { border-color: var(--ccb-color, #4f46e5); }

#ccb-root .ccb-send,
#ccb-root .ccb-send:hover,
#ccb-root .ccb-send:focus,
#ccb-root .ccb-send:active {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 40px;
	height: 40px;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ccb-color, #4f46e5);
	color: var(--ccb-on-color, #fff);
	box-shadow: none;
	cursor: pointer;
}

#ccb-root .ccb-send svg { width: 20px; }
#ccb-root[dir="rtl"] .ccb-send svg { transform: scaleX(-1); }
#ccb-root .ccb-send:disabled { opacity: 0.5; cursor: not-allowed; }

#ccb-root .ccb-note {
	margin: 0;
	padding: 0 12px 10px;
	font-size: 11px;
	line-height: 1.4;
	text-align: center;
	color: var(--ccb-muted);
}

#ccb-root .ccb-launcher:focus-visible,
#ccb-root .ccb-close:focus-visible,
#ccb-root .ccb-send:focus-visible,
#ccb-root .ccb-retry:focus-visible {
	outline: 2px solid var(--ccb-color, #4f46e5);
	outline-offset: 2px;
}

#ccb-root .ccb-header .ccb-close:focus-visible { outline-color: currentColor; }

#ccb-root .ccb-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Mobile: the panel takes over the whole screen ------------------------ */

@media (max-width: 480px) {
	#ccb-root.is-open {
		inset: 0;
	}

	#ccb-root.is-open .ccb-panel {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	html.ccb-lock,
	html.ccb-lock body {
		overflow: hidden;
	}
}

@keyframes ccb-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to { opacity: 1; transform: none; }
}

@keyframes ccb-bubble-in {
	from { opacity: 0; transform: translateY(-50%) translateX(var(--ccb-shift, 0)); }
	to { opacity: 1; transform: translateY(-50%); }
}

@keyframes ccb-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	#ccb-root .ccb-launcher,
	#ccb-root .ccb-bubble,
	#ccb-root.is-open .ccb-panel { animation: none; transition: none; }
	#ccb-root .ccb-typing i { animation: none; opacity: 0.7; }
}
