/* Agency Pro Live Support — Frontend */

.apls-widget {
	position: fixed;
	bottom: var(--apls-bottom, 24px);
	z-index: var(--apls-z, 99999);
	font-family: var(--apls-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: var(--apls-font-size, 14px);
	line-height: 1.5;
	pointer-events: auto;
	isolation: isolate;
}

.apls-widget--right {
	right: var(--apls-side, 24px);
	left: auto;
}

.apls-widget--left {
	left: var(--apls-side, 24px);
	right: auto;
}

.apls-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	box-shadow: none;
	position: relative;
	z-index: 2;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
}

.apls-launcher__status {
	position: absolute;
	right: -2px;
	bottom: -2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 2px solid #fff;
	background: #86efac;
	box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
	z-index: 3;
}

.apls-widget.is-offline .apls-launcher__status {
	background: #fca5a5;
}

.apls-launcher--pill .apls-launcher__status {
	right: 4px;
	bottom: 4px;
}

.apls-launcher__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: var(--apls-launcher-size, 60px);
	height: var(--apls-launcher-size, 60px);
	min-width: var(--apls-launcher-size, 60px);
	min-height: var(--apls-launcher-size, 60px);
	border-radius: 50%;
	background: linear-gradient(135deg, var(--apls-launcher-bg, var(--apls-primary, #2563eb)), var(--apls-accent, #1d4ed8));
	color: var(--apls-launcher-text, #fff);
	box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.apls-launcher__icon svg {
	display: block;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	fill: currentColor;
}

.apls-launcher--square .apls-launcher__icon {
	border-radius: calc(var(--apls-radius, 16px) * 0.75);
}

.apls-launcher__pill {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	padding: 14px 20px;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--apls-launcher-bg, var(--apls-primary, #2563eb)), var(--apls-accent, #1d4ed8));
	color: var(--apls-launcher-text, #fff);
	font-weight: 700;
	font-size: 14px;
	box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.apls-launcher__emoji {
	font-size: 28px;
	line-height: 1;
}

.apls-launcher__custom-icon {
	width: 32px;
	height: 32px;
	object-fit: contain;
}

.apls-launcher:hover .apls-launcher__icon {
	transform: scale(1.05);
	box-shadow: 0 12px 32px rgba(37, 99, 235, 0.5);
}

.apls-launcher__bubble {
	flex-shrink: 1;
	max-width: 200px;
	padding: 10px 14px;
	border-radius: 12px;
	background: #fff;
	color: #0f172a;
	box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
	font-weight: 600;
	font-size: 13px;
	animation: apls-bounce 2s ease infinite;
	pointer-events: none;
}

@keyframes apls-bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-4px); }
}

.apls-panel {
	position: absolute;
	bottom: calc(var(--apls-launcher-size, 60px) + 16px);
	width: var(--apls-width, 380px);
	max-width: calc(100vw - 32px);
	max-height: var(--apls-height, 520px);
	background: var(--apls-panel-bg, #fff);
	border-radius: var(--apls-radius, 16px);
	border: var(--apls-border-width, 0) solid var(--apls-border-color, #e2e8f0);
	font-size: var(--apls-font-size, 14px);
	box-shadow: var(--apls-panel-shadow, 0 20px 60px rgba(15, 23, 42, 0.2));
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.96);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
	pointer-events: none;
}

.apls-widget.is-open .apls-panel {
	pointer-events: auto;
}

.apls-anim--fade .apls-panel {
	transform: translateY(0) scale(1);
}

.apls-anim--fade.apls-widget.is-open .apls-panel {
	opacity: 1;
	visibility: visible;
}

.apls-anim--scale .apls-panel {
	transform: scale(0.85);
}

.apls-anim--scale.apls-widget.is-open .apls-panel {
	transform: scale(1);
}

.apls-widget--right .apls-panel {
	right: 0;
	left: auto;
}

.apls-widget--left .apls-panel {
	left: 0;
	right: auto;
}

.apls-widget.is-open .apls-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.apls-panel__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 16px 52px 16px 18px;
	background: linear-gradient(135deg, var(--apls-primary, #2563eb), var(--apls-accent, #1d4ed8));
	color: var(--apls-header-text, #fff);
	background-size: cover;
	background-position: center;
	position: relative;
}

.apls-panel__header-info {
	flex: 1;
	min-width: 0;
}

.apls-panel__header--image::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, var(--apls-header-overlay, 0));
	pointer-events: none;
}

.apls-panel__header--image > * {
	position: relative;
	z-index: 1;
}

.apls-panel__header-info strong {
	display: block;
	font-size: 16px;
}

.apls-panel__subtitle {
	display: block;
	font-size: 12px;
	opacity: 0.9;
	margin-top: 2px;
}

.apls-panel__status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	white-space: nowrap;
	flex-shrink: 0;
}

.apls-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #86efac;
	box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.35);
}

.apls-panel__status.is-offline .apls-status-dot {
	background: #fca5a5;
	box-shadow: 0 0 0 3px rgba(252, 165, 165, 0.35);
}

.apls-panel__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 5;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	background: rgba(255, 255, 255, 0.2);
	border: 0;
	color: var(--apls-header-text, #fff);
	width: 36px;
	height: 36px;
	border-radius: 10px;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.15s ease, transform 0.15s ease;
}

.apls-panel__close:hover,
.apls-panel__close:focus {
	background: rgba(255, 255, 255, 0.32);
	outline: none;
}

.apls-panel__close:active {
	transform: scale(0.96);
}

.apls-theme--minimal .apls-panel__close {
	background: #f1f5f9;
	color: #0f172a;
}

.apls-theme--minimal .apls-panel__close:hover,
.apls-theme--minimal .apls-panel__close:focus {
	background: #e2e8f0;
}

.apls-panel__body {
	min-height: 320px;
	max-height: 420px;
	display: flex;
	flex-direction: column;
}

.apls-start {
	padding: 20px;
}

.apls-welcome {
	margin: 0 0 16px;
	color: #334155;
}

.apls-form label {
	display: block;
	margin-bottom: 12px;
}

.apls-form label span {
	display: block;
	margin-bottom: 4px;
	font-weight: 600;
	font-size: 12px;
	color: #64748b;
}

.apls-form input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	font-size: 14px;
}

.apls-btn {
	border: 0;
	border-radius: 10px;
	cursor: pointer;
	font-weight: 600;
}

.apls-btn--primary {
	width: 100%;
	padding: 12px;
	background: var(--apls-primary, #2563eb);
	color: #fff;
	margin-top: 4px;
}

.apls-gdpr {
	margin: 12px 0 0;
	font-size: 11px;
	color: #94a3b8;
}

.apls-chat {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 320px;
}

.apls-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--apls-chat-bg, #f8fafc);
	min-height: 240px;
	max-height: calc(var(--apls-height, 520px) - 180px);
}

.apls-msg {
	max-width: 85%;
	margin-bottom: 10px;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	word-break: break-word;
}

.apls-msg--visitor {
	margin-left: auto;
	background: var(--apls-visitor-bg, var(--apls-primary, #2563eb));
	color: var(--apls-visitor-text, #fff);
	border-bottom-right-radius: 4px;
}

.apls-msg--agent,
.apls-msg--system {
	margin-right: auto;
	background: var(--apls-agent-bg, #fff);
	color: var(--apls-agent-text, #0f172a);
	border: 1px solid var(--apls-border-color, #e2e8f0);
	border-bottom-left-radius: 4px;
}

.apls-msg__meta {
	font-size: 10px;
	opacity: 0.75;
	margin-bottom: 4px;
}

.apls-msg__body {
	white-space: pre-wrap;
	word-break: break-word;
}

.apls-message-form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #e2e8f0;
	background: #fff;
}

.apls-message-form input {
	flex: 1;
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
}

.apls-btn--send {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	background: var(--apls-primary, #2563eb);
	color: #fff;
	border-radius: 10px;
}

@media (max-width: 480px) {
	.apls-panel {
		width: calc(100vw - 24px);
		bottom: 70px;
	}
	.apls-launcher__bubble {
		display: none;
	}
}

/* Themes */
.apls-theme--glass .apls-panel {
	background: rgba(255,255,255,0.85);
	backdrop-filter: blur(12px);
	box-shadow: 0 20px 60px rgba(15,23,42,0.15);
}
.apls-theme--dark .apls-panel { background: #0f172a; color: #e2e8f0; }
.apls-theme--dark .apls-messages { background: #1e293b; }
.apls-theme--dark .apls-msg--agent, .apls-theme--dark .apls-msg--system { background: #334155; color: #f1f5f9; border-color: #475569; }
.apls-theme--minimal .apls-launcher__icon { box-shadow: none; border: 2px solid var(--apls-primary); background: #fff; color: var(--apls-primary); }
.apls-theme--minimal .apls-panel__header { background: #fff; color: #0f172a; border-bottom: 1px solid #e2e8f0; }

.apls-has-pulse .apls-launcher__icon { animation: apls-pulse 2s infinite; }
@keyframes apls-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(37,99,235,.5)} 50%{box-shadow:0 0 0 12px rgba(37,99,235,0)} }

.apls-launcher__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: #dc2626;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
}
.apls-launcher { position: relative; }

.apls-proactive {
	position: absolute;
	bottom: 76px;
	max-width: 280px;
	padding: 14px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.apls-widget--right .apls-proactive { right: 0; }
.apls-widget--left .apls-proactive { left: 0; }
.apls-proactive__close { float: right; border: 0; background: none; font-size: 18px; cursor: pointer; }
.apls-btn--sm { padding: 8px 12px; font-size: 12px; margin-top: 8px; }

.apls-panel__avatar, .apls-launcher__avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.apls-msg__avatar { width: 20px; height: 20px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

.apls-typing { display: flex; align-items: center; gap: 6px; padding: 0 16px 8px; font-size: 12px; color: #64748b; }
.apls-typing[hidden],
.apls-typing.is-apls-hidden {
	display: none !important;
}

.apls-ai-commands {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 12px 10px;
}

.apls-ai-command {
	border: 1px solid var(--apls-border, #e2e8f0);
	background: #f8fafc;
	color: #334155;
	font-size: 12px;
	line-height: 1.3;
	padding: 6px 10px;
	border-radius: 999px;
	cursor: pointer;
	transition: background .15s, border-color .15s;
}

.apls-ai-command:hover {
	background: #eff6ff;
	border-color: #93c5fd;
	color: #1d4ed8;
}

.apls-ai-commands.is-apls-hidden {
	display: none !important;
}
.apls-typing span { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; animation: apls-typing 1.2s infinite; }
.apls-typing span:nth-child(2) { animation-delay: .2s; }
.apls-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes apls-typing { 0%,100%{opacity:.3} 50%{opacity:1} }

.apls-rating { padding: 20px; text-align: center; }
.apls-rating__stars button { border: 0; background: none; font-size: 28px; color: #cbd5e1; cursor: pointer; }
.apls-rating__stars button:hover { color: #fbbf24; }
.apls-rating__thanks { color: #16a34a; font-weight: 600; }

.apls-start-notice {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: 10px;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1e40af;
	font-size: 13px;
	line-height: 1.45;
}

.apls-rating__skip {
	margin: 12px 0 0;
	font-size: 13px;
}

.apls-link-btn {
	border: 0;
	background: none;
	padding: 0;
	color: #2563eb;
	cursor: pointer;
	text-decoration: underline;
	font-size: inherit;
}

.apls-link-btn:hover {
	color: #1d4ed8;
}

.apls-new-chat-wrap {
	padding: 20px;
	text-align: center;
	border-top: 1px solid var(--apls-border-color, #e2e8f0);
}

.apls-closed-text {
	margin: 0 0 12px;
	color: #64748b;
	font-size: 13px;
}

.apls-btn--block {
	display: block;
	width: 100%;
}

.apls-form textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--apls-border-color, #e2e8f0);
	border-radius: 10px;
	font-size: 14px;
	resize: vertical;
}

.apls-form select { width: 100%; padding: 10px 12px; border: 1px solid var(--apls-border-color, #e2e8f0); border-radius: 10px; }

.apls-panel__brand {
	padding: 8px 16px;
	text-align: center;
	font-size: 11px;
	color: #94a3b8;
	border-top: 1px solid var(--apls-border-color, #e2e8f0);
	background: var(--apls-panel-bg, #fff);
}

.apls-offline-banner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	margin-bottom: 14px;
	border-radius: 10px;
	background: #fef3c7;
	border: 1px solid #fde68a;
	color: #92400e;
	font-size: 13px;
	line-height: 1.45;
}

.apls-offline-banner[hidden],
.apls-offline-banner.is-apls-hidden {
	display: none !important;
}

.apls-offline-banner--compact {
	margin: 12px 12px 0;
}

.apls-offline-banner__dot {
	flex-shrink: 0;
	width: 10px;
	height: 10px;
	margin-top: 4px;
	border-radius: 50%;
	background: #f59e0b;
	box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.apls-theme--dark .apls-offline-banner {
	background: #422006;
	border-color: #78350f;
	color: #fde68a;
}
