/* CG WhatsApp · Creacions Gràfiques */
.cgwa {
	--cgwa-color: #25D366;
	--cgwa-size: 60px;
	--cgwa-x: 20px;
	--cgwa-y: 20px;
	--cgwa-radius: 50%;
	position: fixed;
	bottom: var(--cgwa-y);
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	transition: opacity .3s ease, transform .3s ease;
}
.cgwa.cgwa-shape-round   { --cgwa-radius: 50%; }
.cgwa.cgwa-shape-rounded { --cgwa-radius: 22%; }
.cgwa.cgwa-shape-square  { --cgwa-radius: 0; }
.cgwa--right { right: var(--cgwa-x); }
.cgwa--left  { left: var(--cgwa-x); align-items: flex-start; }
.cgwa.cgwa-hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }

.cgwa *, .cgwa *::before, .cgwa *::after { box-sizing: border-box; }

/* Burbuja */
.cgwa-bubble {
	position: relative;
	width: var(--cgwa-size);
	height: var(--cgwa-size);
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	background: var(--cgwa-color);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
	transition: transform .2s ease, box-shadow .2s ease;
}
.cgwa-bubble:hover { transform: scale(1.07); box-shadow: 0 8px 26px rgba(0, 0, 0, .28); }
.cgwa-bubble:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 6px var(--cgwa-color); }
.cgwa-bubble .cgwa-icon { width: 56%; height: 56%; transition: transform .25s ease, opacity .25s ease; }
.cgwa-bubble .cgwa-x {
	position: absolute;
	font-size: calc(var(--cgwa-size) * .55);
	line-height: 1;
	opacity: 0;
	transform: rotate(-90deg);
	transition: transform .25s ease, opacity .25s ease;
}
.cgwa.cgwa-open .cgwa-bubble .cgwa-icon { opacity: 0; transform: rotate(90deg); }
.cgwa.cgwa-open .cgwa-bubble .cgwa-x { opacity: 1; transform: rotate(0); }

/* Forma: selector con ID + !important para que el tema no la pise */
#cgwa .cgwa-bubble,
#cgwa.cgwa-pulse .cgwa-bubble::before {
	border-radius: var(--cgwa-radius) !important;
	min-width: 0;
	min-height: 0;
	line-height: 1;
	text-transform: none;
	letter-spacing: 0;
}

/* Pulso */
.cgwa-pulse .cgwa-bubble::before {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--cgwa-color);
	z-index: -1;
	animation: cgwa-pulse 2.2s ease-out infinite;
}
.cgwa.cgwa-open .cgwa-bubble::before { animation: none; }
@keyframes cgwa-pulse {
	0%   { transform: scale(1);   opacity: .55; }
	80%  { transform: scale(1.6); opacity: 0; }
	100% { transform: scale(1.6); opacity: 0; }
}

/* Etiqueta */
.cgwa-tip {
	position: absolute;
	bottom: calc(var(--cgwa-size) / 2 - 17px);
	white-space: nowrap;
	background: #fff;
	color: #1f2937;
	padding: 7px 14px;
	border-radius: 20px;
	font-size: 14px;
	font-weight: 500;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
	transition: opacity .25s ease;
	pointer-events: none;
}
.cgwa--right .cgwa-tip { right: calc(var(--cgwa-size) + 12px); }
.cgwa--left  .cgwa-tip { left:  calc(var(--cgwa-size) + 12px); }
.cgwa.cgwa-open .cgwa-tip,
.cgwa.cgwa-tip-off .cgwa-tip { opacity: 0; }

/* Ventana de chat */
.cgwa-panel {
	width: 340px;
	max-width: calc(100vw - 2 * var(--cgwa-x));
	background: #efeae2;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px) scale(.97);
	transform-origin: bottom right;
	transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.cgwa--left .cgwa-panel { transform-origin: bottom left; }
.cgwa.cgwa-open .cgwa-panel { opacity: 1; visibility: visible; transform: none; }

.cgwa-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	background: var(--cgwa-color);
	color: #fff;
}
.cgwa-avatar {
	position: relative;
	flex: 0 0 46px;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	display: flex;
	align-items: center;
	justify-content: center;
}
.cgwa-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.cgwa-avatar .cgwa-icon { width: 60%; height: 60%; }
.cgwa-dot {
	position: absolute;
	right: 1px;
	bottom: 1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #4ade80;
	border: 2px solid var(--cgwa-color);
}
.cgwa-offline .cgwa-dot { background: #d1d5db; }
.cgwa-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cgwa-who strong { font-size: 16px; font-weight: 600; color: #fff; }
.cgwa-who small { font-size: 12.5px; opacity: .9; color: #fff; }
.cgwa-close {
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 6px;
	opacity: .85;
}
.cgwa-close:hover { opacity: 1; }

.cgwa-body { padding: 20px 16px 8px; min-height: 90px; }
.cgwa-msg {
	position: relative;
	display: inline-block;
	max-width: 88%;
	background: #fff;
	color: #111827;
	padding: 10px 14px;
	border-radius: 0 12px 12px 12px;
	box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
	font-size: 14.5px;
	animation: cgwa-in .35s ease both;
}
.cgwa-msg::before {
	content: "";
	position: absolute;
	top: 0;
	left: -8px;
	border-top: 8px solid #fff;
	border-left: 8px solid transparent;
}
.cgwa-msg--offline,
.cgwa-offline .cgwa-msg--online { display: none; }
.cgwa-offline .cgwa-msg--offline { display: inline-block; }
@keyframes cgwa-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cgwa-foot { padding: 12px 16px 16px; }

/* Botones (ventana + shortcode) */
.cgwa-open,
.cgwa-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 20px;
	border-radius: 999px;
	background: var(--cgwa-color, #25D366);
	color: #fff !important;
	font-weight: 600;
	font-size: 15px;
	text-decoration: none !important;
	transition: filter .2s ease, transform .2s ease;
}
.cgwa-open { width: 100%; }
.cgwa-open:hover,
.cgwa-btn:hover { filter: brightness(.93); transform: translateY(-1px); }
.cgwa-open .cgwa-icon,
.cgwa-btn .cgwa-icon { width: 20px; height: 20px; flex: 0 0 20px; }

/* Dispositivos */
@media (min-width: 768px) { .cgwa.cgwa-no-desktop { display: none !important; } }
@media (max-width: 767px) {
	.cgwa.cgwa-no-mobile { display: none !important; }
	.cgwa-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.cgwa, .cgwa *, .cgwa *::before { animation: none !important; transition: none !important; }
}
