/**
 * Premium WA Chat Manager - Frontend Styles
 * WhatsApp widget UI, responsive, customizable via CSS variables.
 */

.pwacm-wrapper {
	position: fixed;
	z-index: 999990;
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	opacity: 0;
	transition: opacity .35s ease;
}
.pwacm-wrapper.pwacm-reveal {
	opacity: 1;
}

/* ---------- Floating Trigger ---------- */
.pwacm-trigger {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: var(--pwacm-accent, #25D366);
	color: #fff;
	border: none;
	border-radius: 50px;
	padding: 12px 20px 12px 14px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
	transition: transform .2s ease, box-shadow .2s ease;
	align-self: inherit;
	max-width: 320px;
}
.pwacm-trigger:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
.pwacm-trigger-icon {
	display: inline-flex;
	width: 30px;
	height: 30px;
	background: rgba(255, 255, 255, .18);
	border-radius: 50%;
	align-items: center;
	justify-content: center;
	flex: 0 0 30px;
}
.pwacm-trigger-icon .pwacm-wa-icon {
	width: 22px;
	height: 22px;
	color: #fff;
}
.pwacm-trigger-text {
	white-space: nowrap;
	line-height: 1.1;
}

/* Animations */
.pwacm-anim-pulse {
	animation: pwacm-pulse 2.2s infinite;
}
@keyframes pwacm-pulse {
	0% { box-shadow: 0 6px 22px rgba(0,0,0,.22), 0 0 0 0 rgba(37, 211, 102, .6); }
	70% { box-shadow: 0 6px 22px rgba(0,0,0,.22), 0 0 0 16px rgba(37, 211, 102, 0); }
	100% { box-shadow: 0 6px 22px rgba(0,0,0,.22), 0 0 0 0 rgba(37, 211, 102, 0); }
}
.pwacm-anim-bounce {
	animation: pwacm-bounce 2s infinite;
}
@keyframes pwacm-bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-6px); }
}

/* ---------- Welcome Bubble ---------- */
.pwacm-welcome-bubble {
	position: relative;
	background: #fff;
	color: #222;
	padding: 12px 34px 12px 14px;
	border-radius: 14px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .16);
	max-width: 260px;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
	animation: pwacm-fadein .4s ease;
}
.pwacm-bubble-close {
	position: absolute;
	top: 4px;
	right: 8px;
	background: none;
	border: none;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	color: #999;
}

/* ---------- Chat Box ---------- */
.pwacm-box {
	width: 340px;
	max-width: calc(100vw - 30px);
	background: var(--pwacm-bubble-bg, #fff);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
	transform: translateY(20px) scale(.96);
	opacity: 0;
	pointer-events: none;
	transition: transform .25s ease, opacity .25s ease;
	max-height: 78vh;
	display: flex;
	flex-direction: column;
}
.pwacm-box.pwacm-open {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: auto;
}

.pwacm-box-header {
	background: var(--pwacm-header, #075E54);
	color: var(--pwacm-text, #fff);
	padding: 14px 14px 14px 8px;
	display: flex;
	align-items: center;
	gap: 8px;
	position: relative;
}
.pwacm-back-btn,
.pwacm-close-btn {
	background: none;
	border: none;
	color: var(--pwacm-text, #fff);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 2px;
}
.pwacm-close-btn {
	position: absolute;
	top: 10px;
	right: 12px;
	font-size: 22px;
	line-height: 1;
	opacity: .85;
}
.pwacm-close-btn:hover { opacity: 1; }
.pwacm-header-avatar img {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	border: 2px solid rgba(255, 255, 255, .5);
}
.pwacm-header-meta {
	display: flex;
	flex-direction: column;
	line-height: 1.25;
	padding-right: 24px;
}
.pwacm-header-title {
	font-weight: 700;
	font-size: 15px;
}
.pwacm-header-sub {
	font-size: 12px;
	opacity: .85;
}

/* Notice */
.pwacm-notice {
	background: rgba(0, 0, 0, .06);
	color: #333;
	font-size: 12.5px;
	line-height: 1.45;
	padding: 10px 14px;
	display: flex;
	gap: 8px;
	align-items: flex-start;
	border-bottom: 1px solid rgba(0, 0, 0, .05);
}
.pwacm-notice svg {
	flex: 0 0 16px;
	margin-top: 1px;
	color: var(--pwacm-accent, #25D366);
}

/* Agents list */
.pwacm-agents-list {
	padding: 10px;
	overflow-y: auto;
	background:
		linear-gradient(rgba(229, 221, 213, .35), rgba(229, 221, 213, .35));
	flex: 1 1 auto;
}
.pwacm-agent-item {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, .06);
	border-radius: 12px;
	padding: 10px 12px;
	margin-bottom: 10px;
	cursor: pointer;
	text-align: left;
	transition: transform .15s ease, box-shadow .15s ease;
}
.pwacm-agent-item:last-child { margin-bottom: 0; }
.pwacm-agent-item:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}
.pwacm-agent-avatar {
	position: relative;
	flex: 0 0 46px;
}
.pwacm-agent-avatar img {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	object-fit: cover;
	background: #eee;
}
.pwacm-status-dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: 2px solid #fff;
}
.pwacm-agent-avatar .pwacm-status-dot {
	display: none; /* Sembunyikan titik status pada foto avatar; titik di samping teks Online/Offline tetap tampil. */
}
.pwacm-dot-online { background: #25D366; }
.pwacm-dot-offline { background: #9aa0a6; }

.pwacm-agent-info {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.pwacm-agent-role {
	font-size: 11.5px;
	color: #667781;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .3px;
}
.pwacm-agent-name {
	font-size: 15px;
	font-weight: 600;
	color: #111b21;
}
.pwacm-agent-area {
	font-weight: 400;
	color: #667781;
	font-size: 13px;
}
.pwacm-agent-status {
	font-size: 12px;
	color: #667781;
	display: inline-flex;
	align-items: center;
	gap: 5px;
}
.pwacm-agent-go {
	flex: 0 0 34px;
	width: 34px;
	height: 34px;
	background: var(--pwacm-accent, #25D366);
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}
.pwacm-agent-go .pwacm-wa-icon {
	width: 20px;
	height: 20px;
	color: #fff;
}

/* GDPR */
.pwacm-gdpr {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	padding: 10px 14px;
	font-size: 11.5px;
	color: #555;
	background: #fafafa;
	border-top: 1px solid rgba(0, 0, 0, .05);
	cursor: pointer;
}
.pwacm-gdpr input { margin-top: 2px; }
.pwacm-gdpr-error {
	background: #fdecea;
	color: #b71c1c;
}

.pwacm-box-footer {
	text-align: center;
	font-size: 11px;
	color: #8696a0;
	padding: 8px;
	background: #f7f7f7;
}
.pwacm-box-footer strong { color: #075E54; }

/* ---------- Department Tabs ---------- */
.pwacm-dept-tabs {
	display: flex;
	gap: 6px;
	padding: 10px 10px 0;
	flex-wrap: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	background: rgba(229, 221, 213, .35);
}
.pwacm-dept-tabs::-webkit-scrollbar { height: 5px; }
.pwacm-dept-tabs::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .18); border-radius: 4px; }
.pwacm-dept-tab {
	flex: 0 0 auto;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, .1);
	border-radius: 20px;
	padding: 6px 14px;
	font-size: 12.5px;
	font-weight: 600;
	color: #667781;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease;
}
.pwacm-dept-tab.pwacm-dept-active {
	background: var(--pwacm-accent, #25D366);
	color: #fff;
	border-color: var(--pwacm-accent, #25D366);
}
.pwacm-dept-icon {
	flex: 0 0 14px;
	opacity: .85;
}
.pwacm-dept-tab.pwacm-dept-active .pwacm-dept-icon { opacity: 1; }
.pwacm-dept-panel { display: none; }
.pwacm-dept-panel.pwacm-dept-panel-active { display: block; }
.pwacm-dept-tabs + .pwacm-dept-panel,
.pwacm-dept-panel { padding-top: 10px; }

/* ---------- Inline (shortcode) ---------- */
.pwacm-inline {
	max-width: 380px;
	margin: 20px 0;
}
.pwacm-inline-box {
	background: var(--pwacm-bubble-bg, #fff);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 8px 30px rgba(0, 0, 0, .14);
	border: 1px solid rgba(0, 0, 0, .06);
}
.pwacm-inline-box .pwacm-box-header {
	background: var(--pwacm-header, #075E54);
	color: var(--pwacm-text, #fff);
	padding: 14px;
}
.pwacm-inline-box .pwacm-agents-list { max-height: 420px; }

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

/* Animasi geser halus saat kartu agen muncul / berpindah posisi (rotasi) */
@keyframes pwacm-slide-in {
	from { opacity: 0; transform: translateX(-14px); }
	to { opacity: 1; transform: translateX(0); }
}
.pwacm-agent-item.pwacm-slide-in {
	animation: pwacm-slide-in .32s cubic-bezier(.22, .61, .36, 1) both;
}
@media (prefers-reduced-motion: reduce) {
	.pwacm-agent-item.pwacm-slide-in { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
	.pwacm-box {
		width: calc(100vw - 24px);
	}
	.pwacm-trigger-text {
		font-size: 14px;
	}
	.pwacm-welcome-bubble {
		max-width: calc(100vw - 90px);
	}
}
