/**
 * CorewpBuilders Assistant — widget styles.
 * The accent colour is injected as --cwa-accent by widget.js.
 */

.cwa-root {
	--cwa-accent: #ff8300;
	--cwa-bg: #0c0c0c;
	--cwa-panel: #131313;
	--cwa-bubble: #1e1e1e;
	--cwa-line: #262626;
	--cwa-text: #ededed;
	--cwa-muted: #8c8c8c;
	--cwa-radius: 18px;
	font-family: "Ppneuemontreal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.cwa-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 999998;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 58px;
	padding: 0 22px 0 18px;
	border: none;
	border-radius: 999px;
	background: var(--cwa-accent);
	color: #101010;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
	cursor: pointer;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
	transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.25s ease;
}

.cwa-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}

.cwa-launcher:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

.cwa-launcher svg {
	width: 22px;
	height: 22px;
	flex-shrink: 0;
}

.cwa-launcher.is-open .cwa-launcher-label,
.cwa-launcher.is-open .cwa-icon-chat {
	display: none;
}

.cwa-launcher:not(.is-open) .cwa-icon-close {
	display: none;
}

.cwa-launcher.is-open {
	width: 58px;
	padding: 0;
	justify-content: center;
}

.cwa-dot {
	position: absolute;
	top: 4px;
	right: 6px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #e33;
	border: 2px solid var(--cwa-accent);
	display: none;
}

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

.cwa-panel {
	position: fixed;
	right: 24px;
	bottom: 96px;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 140px);
	background: var(--cwa-bg);
	border: 1px solid var(--cwa-line);
	border-radius: var(--cwa-radius);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
	overflow: hidden;
	opacity: 0;
	transform: translateY(14px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.cwa-panel.is-open {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

/* ---------- Header ---------- */

.cwa-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 15px;
	border-bottom: 1px solid var(--cwa-line);
	background: var(--cwa-panel);
}

.cwa-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--cwa-accent);
	color: #101010;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	flex-shrink: 0;
	overflow: hidden;
}

.cwa-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cwa-header-text {
	flex: 1;
	min-width: 0;
}

.cwa-header-text strong {
	display: block;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.cwa-header-text span {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--cwa-muted);
	font-size: 12px;
	margin-top: 2px;
}

.cwa-header-text span::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #3ddc5d;
	flex-shrink: 0;
}

.cwa-close {
	background: none;
	border: none;
	color: var(--cwa-muted);
	font-size: 26px;
	line-height: 1;
	padding: 2px 6px;
	cursor: pointer;
	border-radius: 6px;
	transition: color 0.15s ease;
}

.cwa-close:hover {
	color: #fff;
}

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

.cwa-messages {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scrollbar-width: thin;
	scrollbar-color: #333 transparent;
}

.cwa-messages::-webkit-scrollbar {
	width: 6px;
}

.cwa-messages::-webkit-scrollbar-thumb {
	background: #303030;
	border-radius: 3px;
}

.cwa-row {
	display: flex;
	gap: 9px;
	align-items: flex-end;
	animation: cwa-in 0.26s ease both;
}

.cwa-row.is-user {
	justify-content: flex-end;
}

@keyframes cwa-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.cwa-row-avatar {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--cwa-accent);
	color: #101010;
	font-size: 10px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	overflow: hidden;
}

.cwa-row-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cwa-msg {
	max-width: 80%;
	padding: 11px 15px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.55;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.cwa-msg.is-bot {
	background: var(--cwa-bubble);
	color: var(--cwa-text);
	border-bottom-left-radius: 4px;
}

.cwa-msg.is-user {
	background: var(--cwa-accent);
	color: #141005;
	font-weight: 500;
	border-bottom-right-radius: 4px;
}

.cwa-msg p {
	margin: 0 0 9px;
}

.cwa-msg p:last-child {
	margin-bottom: 0;
}

.cwa-msg ul {
	margin: 0 0 9px;
	padding-left: 18px;
}

.cwa-msg li {
	margin-bottom: 4px;
}

.cwa-msg a {
	color: var(--cwa-accent);
	text-decoration: underline;
}

.cwa-msg.is-user a {
	color: #141005;
}

.cwa-msg code {
	background: rgba(255, 255, 255, 0.09);
	padding: 1px 5px;
	border-radius: 4px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.9em;
}

.cwa-msg.is-user code {
	background: rgba(0, 0, 0, 0.14);
}

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

.cwa-typing {
	display: flex;
	gap: 4px;
	padding: 14px 16px;
}

.cwa-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--cwa-muted);
	animation: cwa-bounce 1.3s infinite ease-in-out;
}

.cwa-typing i:nth-child(2) {
	animation-delay: 0.16s;
}

.cwa-typing i:nth-child(3) {
	animation-delay: 0.32s;
}

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

/* ---------- Chips ---------- */

.cwa-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 16px 12px;
}

.cwa-chip {
	background: transparent;
	border: 1px solid #333;
	color: var(--cwa-text);
	padding: 8px 14px;
	border-radius: 999px;
	font: inherit;
	font-size: 13px;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.cwa-chip:hover {
	border-color: var(--cwa-accent);
	color: var(--cwa-accent);
}

.cwa-chip:focus-visible {
	outline: 2px solid var(--cwa-accent);
	outline-offset: 2px;
}

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

.cwa-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--cwa-line);
	background: var(--cwa-panel);
}

.cwa-input {
	flex: 1;
	background: #1a1a1a;
	border: 1px solid #303030;
	border-radius: 14px;
	color: #fff;
	font: inherit;
	font-size: 14px;
	padding: 11px 14px;
	resize: none;
	max-height: 110px;
	line-height: 1.4;
	outline: none;
	transition: border-color 0.15s ease;
}

.cwa-input::placeholder {
	color: #666;
}

.cwa-input:focus {
	border-color: var(--cwa-accent);
}

.cwa-send {
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	border: none;
	border-radius: 12px;
	background: var(--cwa-accent);
	color: #101010;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.cwa-send:disabled {
	opacity: 0.35;
	cursor: default;
}

.cwa-send svg {
	width: 17px;
	height: 17px;
}

.cwa-foot {
	padding: 0 12px 10px;
	text-align: center;
	font-size: 11px;
	color: #4a4a4a;
	background: var(--cwa-panel);
}

.cwa-foot a {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
	.cwa-panel {
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-width: none;
		height: 88dvh;
		max-height: none;
		border-radius: var(--cwa-radius) var(--cwa-radius) 0 0;
		border-bottom: none;
	}

	.cwa-launcher {
		right: 16px;
		bottom: 16px;
		height: 54px;
	}

	.cwa-msg {
		max-width: 85%;
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.cwa-panel,
	.cwa-launcher,
	.cwa-row {
		transition: none;
		animation: none;
	}

	.cwa-typing i {
		animation: none;
		opacity: 0.6;
	}
}
