/* =========================================================
   AI ChatBot – Frontend Widget
   Default palette: #003481 · #FF9200 · #262626
   ========================================================= */

:root {
	--cb-primary:     #003481;
	--cb-primary-mid: #004cbb;
	--cb-accent:      #FF9200;
	--cb-accent-dark: #e08200;
	--cb-dark:        #262626;
	--cb-white:       #ffffff;
	--cb-light:       #F4F7FB;
	--cb-border:      #E2E8F0;
	--cb-shadow:      rgba(0, 52, 129, 0.18);
	--cb-radius:      18px;
	--cb-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#aichat-root,
#aichat-root *,
#aichat-root *::before,
#aichat-root *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: var(--cb-font);
	-webkit-font-smoothing: antialiased;
}

/* =============================================================
   TRIGGER BUTTON
============================================================= */
#aichat-trigger {
	position: fixed;
	bottom: 28px;
	right: 28px;
	width: 62px;
	height: 62px;
	background: var(--cb-accent);
	color: var(--cb-white);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(255, 146, 0, 0.45), 0 2px 8px rgba(0,0,0,0.14);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	transition: transform 0.22s ease, box-shadow 0.22s ease;
	animation: cb-pulse 3s ease-in-out infinite;
}

#aichat-trigger:hover {
	transform: scale(1.12);
	box-shadow: 0 8px 30px rgba(255, 146, 0, 0.58);
	animation: none;
}

#aichat-trigger:focus-visible {
	outline: 3px solid var(--cb-primary);
	outline-offset: 3px;
}

#aichat-trigger svg {
	width: 28px;
	height: 28px;
}

.cb-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	background: var(--cb-primary);
	color: #fff;
	font-size: 9px;
	font-weight: 800;
	letter-spacing: 0.4px;
	border-radius: 10px;
	padding: 2px 5px;
	border: 2px solid #fff;
	min-width: 18px;
	text-align: center;
}

@keyframes cb-pulse {
	0%, 100% {
		box-shadow: 0 6px 24px rgba(255, 146, 0, 0.45), 0 2px 8px rgba(0,0,0,0.14);
	}
	50% {
		box-shadow: 0 6px 24px rgba(255, 146, 0, 0.45), 0 0 0 14px rgba(255, 146, 0, 0.12), 0 2px 8px rgba(0,0,0,0.14);
	}
}

/* =============================================================
   CHAT WINDOW
============================================================= */
#aichat-window {
	position: fixed;
	bottom: 106px;
	right: 28px;
	width: 385px;
	height: 575px;
	background: var(--cb-white);
	border-radius: var(--cb-radius);
	box-shadow:
		0 22px 70px rgba(0, 0, 0, 0.18),
		0 4px 18px rgba(0, 52, 129, 0.12);
	display: flex;
	flex-direction: column;
	z-index: 99998;
	overflow: hidden;
	transform: translateY(18px) scale(0.96);
	opacity: 0;
	pointer-events: none;
	transition:
		transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
		opacity   0.24s ease;
}

#aichat-window.cb-open {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: all;
}

/* =============================================================
   HEADER
============================================================= */
#aichat-header {
	background: var(--cb-primary);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.cb-avatar {
	width: 44px;
	height: 44px;
	background: var(--cb-accent);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-weight: 800;
	font-size: 13px;
	color: #fff;
	letter-spacing: 0.6px;
	border: 2px solid rgba(255,255,255,0.22);
}

.cb-header-info { flex: 1; min-width: 0; }

.cb-header-info h3 {
	color: #fff;
	font-size: 14.5px;
	font-weight: 700;
	line-height: 1.25;
}

.cb-header-info p {
	color: rgba(255,255,255,0.72);
	font-size: 11.5px;
	margin-top: 3px;
	display: flex;
	align-items: center;
	gap: 5px;
}

.cb-status-dot {
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
	animation: cb-blink 2.2s ease-in-out infinite;
}

@keyframes cb-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0.35; }
}

.cb-close {
	background: rgba(255,255,255,0.12);
	border: none;
	color: rgba(255,255,255,0.9);
	width: 32px;
	height: 32px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.18s;
	flex-shrink: 0;
}

.cb-close:hover { background: rgba(255,255,255,0.22); }

/* =============================================================
   MESSAGES AREA
============================================================= */
#aichat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
	background: var(--cb-light);
}

#aichat-messages::-webkit-scrollbar { width: 4px; }
#aichat-messages::-webkit-scrollbar-track { background: transparent; }
#aichat-messages::-webkit-scrollbar-thumb { background: #d0d7e4; border-radius: 2px; }

/* Welcome banner */
.cb-welcome {
	background: var(--cb-white);
	border: 1px solid var(--cb-border);
	border-left: 3px solid var(--cb-accent);
	border-radius: 12px;
	padding: 13px 15px;
	margin-bottom: 4px;
}

.cb-welcome strong {
	display: block;
	color: var(--cb-primary);
	font-size: 13px;
	font-weight: 700;
	margin-bottom: 4px;
}

.cb-welcome p {
	color: #5a6475;
	font-size: 12.5px;
	line-height: 1.55;
}

/* Message row */
.cb-msg {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	animation: cb-fadein 0.28s ease;
}

.cb-msg.user { flex-direction: row-reverse; }

@keyframes cb-fadein {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.cb-msg-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: 800;
	flex-shrink: 0;
	color: #fff;
}

.cb-msg.bot  .cb-msg-avatar { background: var(--cb-primary); }
.cb-msg.user .cb-msg-avatar { background: var(--cb-accent); }

.cb-bubble {
	max-width: 80%;
	padding: 10px 14px;
	font-size: 13.5px;
	line-height: 1.58;
	word-wrap: break-word;
	border-radius: 18px;
}

.cb-msg.bot .cb-bubble {
	background: var(--cb-white);
	color: var(--cb-dark);
	border: 1px solid var(--cb-border);
	border-bottom-left-radius: 4px;
}

.cb-msg.user .cb-bubble {
	background: var(--cb-primary);
	color: var(--cb-white);
	border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cb-typing .cb-bubble {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 13px 16px;
}

.cb-dot {
	width: 7px;
	height: 7px;
	background: #b0bbc8;
	border-radius: 50%;
	animation: cb-bounce 1.2s ease-in-out infinite;
}

.cb-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes cb-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30%            { transform: translateY(-7px); }
}

/* Contact-offer banner */
.cb-contact-banner {
	background: linear-gradient(135deg, #fff8ed, #fff3df);
	border: 1px solid rgba(255, 146, 0, 0.3);
	border-radius: 12px;
	padding: 13px 15px;
	text-align: center;
	animation: cb-fadein 0.36s ease;
}

.cb-contact-banner p {
	color: var(--cb-dark);
	font-size: 12.5px;
	line-height: 1.5;
	margin-bottom: 9px;
}

.cb-contact-btn {
	background: var(--cb-accent);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 7px 20px;
	font-size: 12.5px;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.18s, transform 0.15s;
}

.cb-contact-btn:hover {
	background: var(--cb-accent-dark);
	transform: translateY(-1px);
}

/* =============================================================
   LEAD FORM
============================================================= */
#aichat-lead-form {
	border-top: 2px solid var(--cb-accent);
	background: var(--cb-white);
	padding: 15px 16px 13px;
	flex-shrink: 0;
	animation: cb-fadein 0.3s ease;
}

#aichat-lead-form h4 {
	color: var(--cb-primary);
	font-size: 13.5px;
	font-weight: 700;
	margin-bottom: 12px;
}

.cb-field { margin-bottom: 9px; }

.cb-field input {
	width: 100%;
	border: 1.5px solid var(--cb-border);
	border-radius: 8px;
	padding: 9px 12px;
	font-size: 13px;
	color: var(--cb-dark);
	outline: none;
	background: var(--cb-white);
	transition: border-color 0.18s, box-shadow 0.18s;
}

.cb-field input::placeholder { color: #a0aab8; }

.cb-field input:focus {
	border-color: var(--cb-primary);
	box-shadow: 0 0 0 3px rgba(0, 52, 129, 0.1);
}

.cb-lead-submit {
	width: 100%;
	background: var(--cb-accent);
	color: #fff;
	border: none;
	border-radius: 9px;
	padding: 10px;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	margin-top: 4px;
	transition: background 0.18s, transform 0.15s;
}

.cb-lead-submit:hover    { background: var(--cb-accent-dark); transform: translateY(-1px); }
.cb-lead-submit:active   { transform: translateY(0); }
.cb-lead-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.cb-lead-error { color: #dc2626; font-size: 11.5px; margin-top: 6px; }

.cb-lead-success {
	text-align: center;
	padding: 10px 8px 6px;
}

.cb-success-icon {
	width: 48px;
	height: 48px;
	background: #dcfce7;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 10px;
	font-size: 22px;
	color: #16a34a;
}

.cb-lead-success h4 { color: var(--cb-primary); font-size: 13.5px; font-weight: 700; margin-bottom: 5px; }
.cb-lead-success p  { color: #5a6475; font-size: 12px; line-height: 1.5; }

/* =============================================================
   INPUT AREA
============================================================= */
#aichat-input-area {
	padding: 10px 12px;
	background: var(--cb-white);
	border-top: 1px solid var(--cb-border);
	display: flex;
	gap: 8px;
	align-items: flex-end;
	flex-shrink: 0;
}

#aichat-input {
	flex: 1;
	border: 1.5px solid var(--cb-border);
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 13.5px;
	color: var(--cb-dark);
	outline: none;
	resize: none;
	max-height: 92px;
	line-height: 1.45;
	background: var(--cb-light);
	transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

#aichat-input:focus {
	border-color: var(--cb-primary);
	background: var(--cb-white);
	box-shadow: 0 0 0 3px rgba(0, 52, 129, 0.08);
}

#aichat-input::placeholder { color: #a0aab8; }
#aichat-input:disabled     { opacity: 0.6; }

#aichat-send {
	width: 40px;
	height: 40px;
	background: var(--cb-accent);
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.18s, transform 0.15s;
}

#aichat-send:hover    { background: var(--cb-accent-dark); transform: scale(1.08); }
#aichat-send:active   { transform: scale(0.96); }
#aichat-send:disabled { background: #c8d0db; cursor: not-allowed; transform: none; }

/* =============================================================
   FOOTER
============================================================= */
#aichat-footer {
	padding: 5px 12px 7px;
	background: var(--cb-white);
	border-top: 1px solid var(--cb-border);
	text-align: center;
	flex-shrink: 0;
}

#aichat-footer a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 10px;
	color: #a0aab8;
	text-decoration: none;
	font-weight: 500;
	letter-spacing: 0.2px;
	transition: color 0.18s;
}

#aichat-footer a:hover { color: var(--cb-primary); }

/* =============================================================
   MOBILE
============================================================= */
@media (max-width: 460px) {
	#aichat-window {
		width: 100vw;
		height: 100dvh;
		bottom: 0;
		right: 0;
		border-radius: 0;
	}

	#aichat-trigger {
		bottom: 18px;
		right: 18px;
	}
}
