/**
 * Iffects WhatsApp Chat — Frontend Styles
 *
 * Mobile-first, modern, animated.
 *
 * @package IffectsWhatsAppChat
 * @since   1.0.0
 */

/* ===========================
   CSS Custom Properties
   =========================== */
:root {
	--iwac-primary: #4DC95B;
	--iwac-pos: right;
	--iwac-radius: 16px;
	--iwac-shadow: 0 8px 32px rgba(0, 0, 0, .15);
	--iwac-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ===========================
   Widget Wrapper
   =========================== */
.iwac-widget {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: var(--iwac-font);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.iwac--right {
	right: 24px;
}

.iwac--left {
	left: 24px;
}

/* ===========================
   Bubble Button (closed)
   =========================== */
.iwac-bubble {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 24px;
	background: var(--iwac-primary);
	color: #fff;
	border: none;
	border-radius: 50px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 600;
	font-family: var(--iwac-font);
	box-shadow: 0 4px 18px rgba(37, 211, 102, .4);
	transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s, opacity .3s;
	white-space: nowrap;
}

.iwac-bubble:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 24px rgba(37, 211, 102, .55);
}

.iwac-bubble:active {
	transform: scale(.97);
}

.iwac-bubble-icon {
	flex-shrink: 0;
}

/* Pulse animation */
.iwac-bubble::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50px;
	animation: iwac-pulse 2.5s infinite;
	pointer-events: none;
}

@keyframes iwac-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, .5); }
	70%  { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); }
	100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* Hide bubble when panel open */
.iwac-widget.iwac--open .iwac-bubble {
	opacity: 0;
	pointer-events: none;
	transform: scale(.5) translateY(20px);
}

/* ===========================
   Panel (open state)
   =========================== */
.iwac-panel {
	position: absolute;
	bottom: 0;
	width: 360px;
	max-height: 520px;
	background: #fff;
	border-radius: var(--iwac-radius);
	box-shadow: var(--iwac-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transform: scale(.85) translateY(30px);
	opacity: 0;
	transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), opacity .25s ease;
	pointer-events: none;
}

.iwac--right .iwac-panel {
	right: 0;
}

.iwac--left .iwac-panel {
	left: 0;
}

.iwac-widget.iwac--open .iwac-panel {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: auto;
}

/* Remove hidden attribute when JS opens */
.iwac-panel[hidden] {
	display: flex !important; /* still flex but invisible via opacity/pointer */
}

/* ===========================
   Panel Header
   =========================== */
.iwac-panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 20px;
	background: var(--iwac-primary);
	color: #fff;
}

.iwac-panel-title {
	font-size: 15px;
	font-weight: 400;
}

.iwac-panel-title strong {
	font-weight: 700;
	font-size: 17px;
}

.iwac-panel-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 26px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	transition: transform .2s;
}

.iwac-panel-close:hover {
	transform: scale(1.2);
}

/* ===========================
   Agent List
   =========================== */
.iwac-agent-list {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	flex: 1;
}

.iwac-agent {
	border-bottom: 1px solid #f0f0f0;
	transition: background .2s;
}

.iwac-agent:last-child {
	border-bottom: none;
}

.iwac-agent:hover {
	background: #f8fdf8;
}

.iwac-agent-link {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px 20px;
	text-decoration: none;
	color: inherit;
}

/* Avatar + status dot */
.iwac-agent-avatar-wrap {
	position: relative;
	flex-shrink: 0;
}

.iwac-agent-avatar {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid #eee;
}

.iwac-status-dot {
	position: absolute;
	bottom: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 2px solid #fff;
}

.iwac-status-dot--online {
	background: #25D366;
	box-shadow: 0 0 6px rgba(37, 211, 102, .6);
}

.iwac-status-dot--offline {
	background: #e74c3c;
}

/* Agent info text */
.iwac-agent-info {
	flex: 1;
	min-width: 0;
}

.iwac-agent-role {
	display: block;
	font-size: 12px;
	color: #888;
	text-transform: uppercase;
	letter-spacing: .5px;
}

.iwac-agent-name {
	display: block;
	font-size: 16px;
	font-weight: 700;
	color: #222;
	margin: 2px 0;
}

.iwac-agent-sched {
	display: block;
	font-size: 12px;
	color: var(--iwac-primary);
	font-weight: 500;
}

.iwac-agent--offline .iwac-agent-sched {
	color: #bbb;
}

/* WhatsApp icon on the right */
.iwac-agent-wa-icon {
	flex-shrink: 0;
	opacity: .7;
	transition: opacity .2s, transform .2s;
}

.iwac-agent:hover .iwac-agent-wa-icon {
	opacity: 1;
	transform: scale(1.15);
}

/* No agents message */
.iwac-no-agents {
	padding: 30px 20px;
	text-align: center;
	color: #999;
}

/* ===========================
   Panel Footer / Copyright
   =========================== */
.iwac-panel-footer {
	padding: 12px 20px;
	text-align: center;
	font-size: 11px;
	color: #aaa;
	border-top: 1px solid #f0f0f0;
	background: #fafafa;
}

.iwac-panel-footer a {
	color: var(--iwac-primary);
	text-decoration: none;
	font-weight: 600;
}

.iwac-panel-footer a:hover {
	text-decoration: underline;
}

/* ===========================
   Staggered entrance animation
   =========================== */
.iwac-widget.iwac--open .iwac-agent {
	animation: iwac-slide-in .35s ease both;
}

.iwac-widget.iwac--open .iwac-agent:nth-child(1) { animation-delay: .05s; }
.iwac-widget.iwac--open .iwac-agent:nth-child(2) { animation-delay: .1s; }
.iwac-widget.iwac--open .iwac-agent:nth-child(3) { animation-delay: .15s; }
.iwac-widget.iwac--open .iwac-agent:nth-child(4) { animation-delay: .2s; }
.iwac-widget.iwac--open .iwac-agent:nth-child(5) { animation-delay: .25s; }

@keyframes iwac-slide-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ===========================
   Shortcode Grid
   =========================== */
.iwac-shortcode-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 16px;
}

.iwac-sc-card {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 12px;
	box-shadow: 0 2px 8px rgba(0,0,0,.06);
	transition: box-shadow .2s, transform .2s;
}

.iwac-sc-card:hover {
	box-shadow: 0 4px 16px rgba(0,0,0,.1);
	transform: translateY(-2px);
}

.iwac-sc-avatar {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
}

.iwac-sc-info {
	flex: 1;
}

.iwac-sc-role {
	font-size: 12px;
	color: #888;
	text-transform: uppercase;
}

.iwac-sc-name {
	font-size: 16px;
	display: block;
}

.iwac-sc-schedule {
	font-size: 12px;
	color: var(--iwac-primary);
}

.iwac-sc-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--iwac-primary);
	flex-shrink: 0;
	transition: transform .2s;
}

.iwac-sc-btn:hover {
	transform: scale(1.1);
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 480px) {
	.iwac-panel {
		width: calc(100vw - 32px);
		max-height: 70vh;
	}

	.iwac-widget {
		bottom: 16px;
	}

	.iwac--right {
		right: 16px;
	}

	.iwac--left {
		left: 16px;
	}

	.iwac-bubble {
		padding: 10px 18px;
		font-size: 14px;
	}
}

/* ===========================
   Accessibility — prefers-reduced-motion
   =========================== */
@media (prefers-reduced-motion: reduce) {
	.iwac-bubble,
	.iwac-panel,
	.iwac-agent,
	.iwac-agent-wa-icon,
	.iwac-panel-close,
	.iwac-sc-card,
	.iwac-sc-btn {
		transition: none !important;
		animation: none !important;
	}

	.iwac-bubble::before {
		animation: none !important;
	}
}
