/* Easy Chat Support - Capripio — front-end widget
 * Matches the admin dashboard's glass design language: frosted panels,
 * SF-style type, iMessage-style bubbles, pill controls. The widget's
 * chosen accent color (--cpecs-color) drives the header/launcher/
 * outgoing bubbles; everything else is neutral glass.
 */

.cpecs-widget-root {
	--cpecs-color: #5b3df5;
	--cpecs-ink: #1d1d1f;
	--cpecs-ink-soft: #6e6e73;
	--cpecs-red: #ff3b30;
	--cpecs-radius: 22px;
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--cpecs-ink);
	color-scheme: light;
}

.cpecs-pos-right { right: 24px; }
.cpecs-pos-left { left: 24px; }

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

.cpecs-launcher {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--cpecs-color);
	background: linear-gradient(135deg, var(--cpecs-color), color-mix(in srgb, var(--cpecs-color) 70%, #1d1d1f));
	border: none;
	box-shadow: 0 10px 26px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.35);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform .18s cubic-bezier(.34,1.56,.64,1), opacity .15s ease;
}
.cpecs-launcher:hover { transform: scale(1.06); }
.cpecs-launcher.cpecs-hide { opacity: 0; pointer-events: none; transform: scale(.7); }

.cpecs-launcher-ring {
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid var(--cpecs-color);
	opacity: 0;
	animation: cpecs-pulse 2.6s ease-out infinite;
}
@keyframes cpecs-pulse {
	0% { opacity: .45; transform: scale(.85); }
	80% { opacity: 0; transform: scale(1.25); }
	100% { opacity: 0; transform: scale(1.25); }
}
.cpecs-launcher-icon { display: flex; align-items: center; justify-content: center; color: #fff; line-height: 0; }
.cpecs-launcher-icon svg { display: block; }

/* ---------------- Panel (glass) ---------------- */

.cpecs-panel {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 356px;
	max-width: calc(100vw - 32px);
	height: 500px;
	max-height: calc(100vh - 140px);
	background: rgba(255,255,255,0.68);
	-webkit-backdrop-filter: blur(26px) saturate(180%);
	backdrop-filter: blur(26px) saturate(180%);
	border: 1px solid rgba(255,255,255,0.7);
	border-radius: var(--cpecs-radius);
	box-shadow: 0 20px 60px rgba(20,20,30,0.22), inset 0 1px 0 rgba(255,255,255,0.5);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(.96);
	pointer-events: none;
	transform-origin: bottom right;
	transition: opacity .2s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}
.cpecs-pos-left .cpecs-panel { right: auto; left: 0; transform-origin: bottom left; }
.cpecs-panel.cpecs-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

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

.cpecs-header {
	background: var(--cpecs-color);
	background: linear-gradient(160deg, var(--cpecs-color), color-mix(in srgb, var(--cpecs-color) 78%, #1d1d1f));
	padding: 16px 16px;
	flex-shrink: 0;
}
.cpecs-header-row { display: flex; align-items: center; gap: 12px; }
.cpecs-avatar {
	width: 36px; height: 36px;
	border-radius: 50%;
	background: rgba(255,255,255,0.22);
	display: flex; align-items: center; justify-content: center;
	flex: 0 0 36px;
}
.cpecs-header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cpecs-header-title {
	color: #fff;
	font-weight: 700;
	font-size: 14.5px;
	letter-spacing: -0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.cpecs-header-sub { display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.68); font-size: 11.5px; }
.cpecs-online-dot { width: 6px; height: 6px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 3px rgba(52,199,89,0.3); flex: 0 0 6px; }
.cpecs-close {
	margin-left: auto;
	background: rgba(255,255,255,0.16);
	border: none;
	width: 26px; height: 26px;
	border-radius: 50%;
	color: #fff;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	flex: 0 0 26px;
	display: flex; align-items: center; justify-content: center;
	transition: background .12s ease;
}
.cpecs-close:hover { background: rgba(255,255,255,0.26); }

/* ---------------- Pre-chat form ---------------- */

.cpecs-prechat {
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.cpecs-field-group { display: flex; flex-direction: column; gap: 4px; }

.cpecs-input {
	border: 1px solid rgba(120,120,128,0.22);
	background-color: rgba(255,255,255,0.6);
	color: var(--cpecs-ink);
	border-radius: 12px;
	padding: 11px 13px;
	font-size: 14px;
	outline: none;
	transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
	width: 100%;
	box-sizing: border-box;
}
.cpecs-input:focus {
	border-color: var(--cpecs-color);
	background-color: rgba(255,255,255,0.85);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--cpecs-color) 16%, transparent);
}
.cpecs-input.cpecs-input-error { border-color: var(--cpecs-red); }
.cpecs-input.cpecs-input-error:focus { box-shadow: 0 0 0 4px rgba(255,59,48,0.14); }

.cpecs-field-error {
	font-size: 11.5px;
	color: var(--cpecs-red);
	display: none;
	padding-left: 2px;
}
.cpecs-field-error.cpecs-show { display: block; }

.cpecs-start-btn {
	background: var(--cpecs-color);
	background: linear-gradient(135deg, var(--cpecs-color), color-mix(in srgb, var(--cpecs-color) 75%, #0071e3));
	color: #fff;
	border: none;
	border-radius: 12px;
	padding: 11px 12px;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	margin-top: 2px;
	box-shadow: 0 6px 16px color-mix(in srgb, var(--cpecs-color) 35%, transparent);
	transition: filter .12s ease, transform .1s ease;
}
.cpecs-start-btn:hover { filter: brightness(1.06); }
.cpecs-start-btn:active { transform: scale(.98); }

/* ---------------- Messages (iMessage-style bubbles) ---------------- */

.cpecs-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.cpecs-bubble {
	max-width: 78%;
	padding: 10px 13px;
	border-radius: 18px;
	font-size: 13.5px;
	line-height: 1.45;
	word-wrap: break-word;
	display: flex;
	flex-direction: column;
	gap: 3px;
	animation: cpecs-pop .16s ease-out;
}
@keyframes cpecs-pop {
	from { opacity: 0; transform: scale(.94) translateY(4px); }
	to { opacity: 1; transform: scale(1) translateY(0); }
}

.cpecs-bubble-time { font-size: 10px; opacity: .6; }

.cpecs-in {
	align-self: flex-start;
	background: rgba(120,120,128,0.14);
	color: var(--cpecs-ink);
}
.cpecs-out {
	align-self: flex-end;
	background: var(--cpecs-color);
	background: linear-gradient(135deg, var(--cpecs-color), color-mix(in srgb, var(--cpecs-color) 75%, #0071e3));
	color: #fff;
}
.cpecs-out .cpecs-bubble-time { color: rgba(255,255,255,0.75); }

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

.cpecs-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid rgba(120,120,128,0.14);
	flex-shrink: 0;
}
.cpecs-msg-input {
	flex: 1;
	border: none;
	background-color: rgba(120,120,128,0.12);
	color: var(--cpecs-ink);
	border-radius: 999px;
	padding: 11px 16px;
	font-size: 13.5px;
	outline: none;
	transition: background-color .12s ease;
}
.cpecs-msg-input:focus { background-color: rgba(120,120,128,0.2); }
.cpecs-msg-input::placeholder { color: var(--cpecs-ink-soft); opacity: 1; }

.cpecs-send-btn {
	background: var(--cpecs-color);
	background: linear-gradient(135deg, var(--cpecs-color), color-mix(in srgb, var(--cpecs-color) 75%, #0071e3));
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	padding: 0;
	line-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: filter .12s ease, transform .12s ease;
}
.cpecs-send-btn:hover { filter: brightness(1.08); transform: scale(1.04); }
.cpecs-send-btn span {
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
}
.cpecs-send-btn svg { display: block; }

/* ---------------- Branding footer ---------------- */

.cpecs-branding {
	text-align: center;
	padding: 7px 0 10px;
	flex-shrink: 0;
}
.cpecs-branding-link {
	font-size: 11px;
	color: var(--cpecs-ink-soft);
	text-decoration: none;
	letter-spacing: .01em;
}
.cpecs-branding-link:hover { color: var(--cpecs-color); text-decoration: underline; }

@media (max-width: 420px) {
	.cpecs-panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 120px);
	}
}
