/* Connected Chat — front-end widget
   Themeable via CSS variables set inline by JS from admin settings. */

#cc-root {
	--cc-primary: #0F766E;
	--cc-accent: #134E4A;
	--cc-radius: 18px;
	--cc-shadow: 0 12px 40px rgba(15, 23, 42, .18);
	--cc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Launcher ---------- */
.cc-launcher {
	position: fixed;
	bottom: 24px;
	z-index: 999998;
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	border: 0;
	padding: 0;
	background: none;
	font-family: var(--cc-font);
	animation: cc-pop .5s cubic-bezier(.18, .89, .32, 1.28) both;
}
.cc-launcher.right { right: 24px; flex-direction: row-reverse; }
.cc-launcher.left  { left: 24px; }

.cc-launcher-btn {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(145deg, var(--cc-primary), var(--cc-accent));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--cc-shadow);
	transition: transform .25s cubic-bezier(.18, .89, .32, 1.28), box-shadow .25s;
	position: relative;
}
.cc-launcher-btn svg { width: 28px; height: 28px; transition: transform .35s; }
.cc-launcher:hover .cc-launcher-btn { transform: scale(1.08) translateY(-2px); }
.cc-launcher:active .cc-launcher-btn { transform: scale(.96); }

.cc-launcher-btn::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	box-shadow: 0 0 0 0 var(--cc-primary);
	animation: cc-ping 2.4s ease-out infinite;
}

.cc-launcher-label {
	background: #fff;
	color: #0f172a;
	padding: 9px 14px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	box-shadow: var(--cc-shadow);
	white-space: nowrap;
	animation: cc-fade-in .6s .3s both;
}

/* ---------- Panel ---------- */
.cc-panel-win {
	position: fixed;
	bottom: 100px;
	z-index: 999999;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 130px);
	background: #fff;
	border-radius: var(--cc-radius);
	box-shadow: var(--cc-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	font-family: var(--cc-font);
	transform-origin: bottom right;
	opacity: 0;
	transform: translateY(20px) scale(.94);
	pointer-events: none;
	transition: opacity .28s ease, transform .32s cubic-bezier(.18, .89, .32, 1.28);
}
.cc-panel-win.right { right: 24px; transform-origin: bottom right; }
.cc-panel-win.left  { left: 24px; transform-origin: bottom left; }
.cc-panel-win.open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.cc-header {
	background: linear-gradient(140deg, var(--cc-primary), var(--cc-accent));
	color: #fff;
	padding: 18px 18px 20px;
	display: flex;
	align-items: center;
	gap: 12px;
	position: relative;
}
.cc-header-logo {
	width: 42px; height: 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .18);
	display: flex; align-items: center; justify-content: center;
	font-size: 20px; overflow: hidden; flex: 0 0 auto;
}
.cc-header-logo img { width: 100%; height: 100%; object-fit: cover; }
.cc-header-text { line-height: 1.3; }
.cc-header-title { font-weight: 700; font-size: 16px; }
.cc-header-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.cc-header-sub::before {
	content: "";
	display: inline-block;
	width: 7px; height: 7px;
	border-radius: 50%;
	background: #4ade80;
	margin-right: 6px;
	box-shadow: 0 0 0 rgba(74, 222, 128, .6);
	animation: cc-live 2s infinite;
}
.cc-close {
	position: absolute; top: 14px; right: 14px;
	background: rgba(255, 255, 255, .15);
	border: 0; color: #fff; cursor: pointer;
	width: 28px; height: 28px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	transition: background .2s, transform .2s;
}
.cc-close:hover { background: rgba(255, 255, 255, .28); transform: rotate(90deg); }

/* ---------- Messages ---------- */
.cc-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	background: #f6f7f9;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}
.cc-msg {
	max-width: 82%;
	padding: 11px 14px;
	font-size: 14px;
	line-height: 1.5;
	border-radius: 16px;
	animation: cc-msg-in .34s cubic-bezier(.18, .89, .32, 1.28) both;
	word-wrap: break-word;
}
.cc-msg.bot {
	background: #fff;
	color: #1f2937;
	align-self: flex-start;
	border-bottom-left-radius: 5px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.cc-msg.user {
	background: linear-gradient(145deg, var(--cc-primary), var(--cc-accent));
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 5px;
}
.cc-msg a { color: inherit; text-decoration: underline; }

.cc-typing {
	align-self: flex-start;
	background: #fff;
	padding: 13px 16px;
	border-radius: 16px;
	border-bottom-left-radius: 5px;
	display: flex; gap: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.cc-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: #cbd5e1;
	animation: cc-bounce 1.2s infinite;
}
.cc-typing span:nth-child(2) { animation-delay: .18s; }
.cc-typing span:nth-child(3) { animation-delay: .36s; }

/* buttons in chat */
.cc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; animation: cc-fade-in .4s both; }
.cc-action-btn {
	background: #fff;
	border: 1.5px solid var(--cc-primary);
	color: var(--cc-primary);
	padding: 8px 13px;
	border-radius: 999px;
	font-size: 13px; font-weight: 600;
	cursor: pointer;
	transition: background .2s, color .2s, transform .15s;
}
.cc-action-btn:hover { background: var(--cc-primary); color: #fff; transform: translateY(-1px); }

/* lead form */
.cc-lead {
	background: #fff;
	border-radius: 14px;
	padding: 14px;
	align-self: stretch;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
	animation: cc-msg-in .34s both;
}
.cc-lead p { margin: 0 0 10px; font-size: 13px; color: #475569; }
.cc-lead input, .cc-lead textarea {
	width: 100%;
	border: 1px solid #e2e8f0;
	border-radius: 9px;
	padding: 9px 11px;
	font-size: 13px;
	margin-bottom: 8px;
	box-sizing: border-box;
	font-family: inherit;
	transition: border-color .2s, box-shadow .2s;
}
.cc-lead input:focus, .cc-lead textarea:focus {
	outline: 0;
	border-color: var(--cc-primary);
	box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}
.cc-lead button {
	width: 100%;
	background: linear-gradient(145deg, var(--cc-primary), var(--cc-accent));
	color: #fff; border: 0;
	padding: 10px; border-radius: 9px;
	font-size: 14px; font-weight: 600; cursor: pointer;
	transition: transform .15s, filter .2s;
}
.cc-lead button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.cc-consent { font-size: 11px; color: #94a3b8; margin-top: 6px; }

/* ---------- Composer ---------- */
.cc-composer {
	display: flex;
	gap: 8px;
	padding: 12px;
	background: #fff;
	border-top: 1px solid #eef0f3;
}
.cc-composer input {
	flex: 1;
	border: 1px solid #e2e8f0;
	border-radius: 999px;
	padding: 11px 16px;
	font-size: 14px;
	font-family: inherit;
	transition: border-color .2s, box-shadow .2s;
}
.cc-composer input:focus {
	outline: 0;
	border-color: var(--cc-primary);
	box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}
.cc-send {
	width: 44px; height: 44px;
	border-radius: 50%;
	border: 0;
	background: linear-gradient(145deg, var(--cc-primary), var(--cc-accent));
	color: #fff; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	flex: 0 0 auto;
	transition: transform .15s, filter .2s;
}
.cc-send:hover { filter: brightness(1.08); transform: scale(1.05); }
.cc-send:active { transform: scale(.92); }
.cc-send svg { width: 20px; height: 20px; }

.cc-footer {
	text-align: center;
	font-size: 11px;
	color: #94a3b8;
	padding: 6px;
	background: #fff;
}
.cc-footer a { color: #94a3b8; text-decoration: none; }

/* ---------- Keyframes ---------- */
@keyframes cc-pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes cc-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cc-msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes cc-ping { 0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, .5); } 70%, 100% { box-shadow: 0 0 0 16px rgba(15, 118, 110, 0); } }
@keyframes cc-live { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); } 70%, 100% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); } }

@media (max-width: 480px) {
	.cc-panel-win { width: calc(100vw - 20px); height: calc(100vh - 110px); bottom: 90px; }
	.cc-panel-win.right { right: 10px; }
	.cc-panel-win.left { left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
	.cc-launcher, .cc-launcher-btn::after, .cc-msg, .cc-header-sub::before, .cc-lead, .cc-actions, .cc-panel-win { animation: none !important; transition: opacity .2s ease !important; }
}
