/* VP Iframe Assistant
 * Estilos del frontend. Los colores y dimensiones se inyectan como
 * variables CSS (:root) desde PHP según la configuración del plugin.
 */

.cqs-widget {
	--cqs-primary: #0a7cba;
	--cqs-button-text: #ffffff;
	--cqs-header-bg: #0a7cba;
	--cqs-header-text: #ffffff;
	--cqs-panel-width: 420px;
	--cqs-panel-height: 640px;
	--cqs-radius: 16px;
	--cqs-gap: 24px;

	position: fixed;
	bottom: var(--cqs-gap);
	z-index: 99990;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}

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

.cqs-widget.cqs-pos-right {
	right: var(--cqs-gap);
}

.cqs-widget.cqs-pos-left {
	left: var(--cqs-gap);
}

/* ---------- Botón lanzador ---------- */

.cqs-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 22px;
	border: none;
	border-radius: 999px;
	background: var(--cqs-primary);
	color: var(--cqs-button-text);
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
	transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
	max-width: 90vw;
}

.cqs-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.cqs-launcher:focus-visible {
	outline: 3px solid rgba(0, 0, 0, 0.35);
	outline-offset: 2px;
}

.cqs-launcher__icon {
	display: inline-flex;
}

.cqs-launcher__label {
	white-space: nowrap;
}

/* Oculta el lanzador cuando el panel está abierto */
.cqs-widget.is-open .cqs-launcher {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.85);
}

/* ---------- Panel del visor ---------- */

.cqs-panel {
	position: absolute;
	bottom: 0;
	width: var(--cqs-panel-width);
	height: var(--cqs-panel-height);
	max-width: calc(100vw - 2 * var(--cqs-gap));
	max-height: calc(100vh - 2 * var(--cqs-gap));
	background: #ffffff;
	border-radius: var(--cqs-radius);
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.98);
	transform-origin: bottom right;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.cqs-widget.cqs-pos-left .cqs-panel {
	transform-origin: bottom left;
}

.cqs-widget.cqs-pos-right .cqs-panel {
	right: 0;
}

.cqs-widget.cqs-pos-left .cqs-panel {
	left: 0;
}

.cqs-widget.is-open .cqs-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.cqs-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	background: var(--cqs-header-bg);
	color: var(--cqs-header-text);
	flex: 0 0 auto;
}

.cqs-panel__titles {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.cqs-panel__title {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
}

.cqs-panel__subtitle {
	font-size: 12.5px;
	font-weight: 400;
	opacity: 0.85;
	line-height: 1.2;
}

.cqs-panel__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	flex: 0 0 auto;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: var(--cqs-header-text);
	cursor: pointer;
	transition: background 0.18s ease;
}

.cqs-panel__close:hover {
	background: rgba(255, 255, 255, 0.32);
}

.cqs-panel__close:focus-visible {
	outline: 2px solid var(--cqs-header-text);
	outline-offset: 2px;
}

.cqs-panel__body {
	position: relative;
	flex: 1 1 auto;
	background: #f7f8fa;
}

.cqs-panel__body iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* ---------- Pie / aviso de privacidad ---------- */

.cqs-panel__footer {
	flex: 0 0 auto;
	padding: 10px 16px;
	background: #f1f3f5;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	color: #5a6573;
	font-size: 11.5px;
	line-height: 1.4;
	text-align: center;
}

.cqs-panel__footer a {
	color: var(--cqs-primary);
	text-decoration: underline;
}

/* ---------- Loader ---------- */

.cqs-panel__loader {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f7f8fa;
	z-index: 1;
}

.cqs-panel__loader.is-hidden {
	display: none;
}

.cqs-spinner {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 4px solid rgba(0, 0, 0, 0.12);
	border-top-color: var(--cqs-primary);
	animation: cqs-spin 0.8s linear infinite;
}

@keyframes cqs-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------- Responsive / móvil ---------- */

@media (max-width: 600px) {
	.cqs-widget {
		--cqs-gap: 16px;
	}

	.cqs-panel {
		position: fixed;
		inset: 0;
		width: 100vw;
		height: 100%;
		max-width: 100vw;
		max-height: 100%;
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cqs-launcher,
	.cqs-panel {
		transition: none;
	}

	.cqs-spinner {
		animation-duration: 1.6s;
	}
}
