/**
 * Virginia Chat — estilos del widget.
 *
 * Los colores y tamaños se inyectan como variables CSS desde el panel de
 * WordPress (Virginia_Chat_Settings::inline_css()). Los valores de aquí son
 * solo el respaldo por si el plugin se usa sin configuración.
 *
 * Todas las reglas van bajo .vc-root para no afectar al tema ni a otros plugins.
 *
 * @package Virginia_Chat
 */

.vc-root {
	--vc-brand: #f46424;
	--vc-header: #1a3447;
	--vc-header-text: #ffffff;
	--vc-bot-bg: #fafafa;
	--vc-bot-text: #3f3f3f;
	--vc-user-text: #1a1a1a;
	--vc-panel-bg: #ffffff;
	--vc-border: #dcdcdc;
	--vc-panel-w: 352px;
	--vc-panel-h: 448px;
	--vc-toggle-size: 64px;
	--vc-offset: 20px;

	position: fixed;
	right: var(--vc-offset);
	bottom: var(--vc-offset);
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	color: #3f3f3f;
	text-align: left;
	box-sizing: border-box;
}

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

/* -------------------------------------------------------------------------
 * Panel
 * ---------------------------------------------------------------------- */

.vc-panel {
	width: var(--vc-panel-w);
	height: var(--vc-panel-h);
	max-width: calc(100vw - (var(--vc-offset) * 2));
	max-height: calc(100vh - (var(--vc-offset) * 2) - 80px);
	margin: 0;
	padding: 0;
	border: 1px solid var(--vc-border);
	border-radius: 16px;
	background: var(--vc-panel-bg);
	box-shadow: 0 20px 25px -5px rgb(0 0 0 / 10%), 0 8px 10px -6px rgb(0 0 0 / 10%);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	animation: vc-fade-in 0.18s ease-out;
}

.vc-hidden {
	display: none !important;
}

@keyframes vc-fade-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* -------------------------------------------------------------------------
 * Cabecera
 * ---------------------------------------------------------------------- */

.vc-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	background: var(--vc-header);
	color: var(--vc-header-text);
}

.vc-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: rgb(255 255 255 / 20%);
}

.vc-head-copy {
	flex: 1;
	min-width: 0;
}

.vc-title {
	margin: 0;
	padding: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--vc-header-text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.vc-subtitle {
	margin: 2px 0 0;
	padding: 0;
	font-size: 12px;
	line-height: 1.3;
	color: var(--vc-header-text);
	opacity: 0.75;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.vc-icon-button {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--vc-header-text);
	opacity: 0.75;
	display: grid;
	place-items: center;
	cursor: pointer;
	flex-shrink: 0;
}

.vc-icon-button svg {
	width: 18px;
	height: 18px;
	display: block;
}

.vc-icon-button:hover,
.vc-icon-button:focus-visible {
	background: rgb(255 255 255 / 12%);
	opacity: 1;
}

/* -------------------------------------------------------------------------
 * Mensajes
 * ---------------------------------------------------------------------- */

.vc-list {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--vc-panel-bg);
}

.vc-row {
	display: flex;
}

.vc-row--user {
	justify-content: flex-end;
}

.vc-row--bot {
	justify-content: flex-start;
}

.vc-bubble {
	max-width: 82%;
	border-radius: 16px;
	padding: 8px 12px;
	font-size: 14px;
	line-height: 20px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.vc-row--user .vc-bubble {
	background: var(--vc-brand);
	color: var(--vc-user-text);
	border-bottom-right-radius: 6px;
}

.vc-row--bot .vc-bubble {
	background: var(--vc-bot-bg);
	color: var(--vc-bot-text);
	border-bottom-left-radius: 6px;
}

/* Enlaces dentro de las respuestas de Virginia. */
.vc-link {
	color: var(--vc-brand);
	text-decoration: underline;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}

.vc-link:hover,
.vc-link:focus-visible {
	text-decoration-thickness: 2px;
}

.vc-row--user .vc-link {
	color: inherit;
}

.vc-typing {
	display: flex;
	gap: 4px;
	padding: 10px 12px;
	background: var(--vc-bot-bg);
	border-radius: 16px;
}

.vc-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--vc-bot-text);
	opacity: 0.5;
	animation: vc-bounce 1s infinite;
}

.vc-typing span:nth-child(2) {
	animation-delay: 120ms;
}

.vc-typing span:nth-child(3) {
	animation-delay: 240ms;
}

@keyframes vc-bounce {
	50% {
		transform: translateY(-3px);
	}
}

.vc-error {
	margin: 0;
	padding: 8px 12px;
	border-radius: 8px;
	background: #fff1ef;
	color: #b42318;
	font-size: 12px;
	line-height: 1.5;
}

.vc-footer {
	margin: 0;
	padding: 8px 16px 12px;
	font-size: 11px;
	line-height: 1.4;
	text-align: center;
	color: var(--vc-bot-text);
	opacity: 0.6;
}

/* -------------------------------------------------------------------------
 * Formulario
 * ---------------------------------------------------------------------- */

.vc-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--vc-border);
	background: var(--vc-panel-bg);
}

.vc-input {
	flex: 1;
	min-height: 40px;
	max-height: 112px;
	margin: 0;
	padding: 8px 12px;
	border: 1px solid var(--vc-border);
	border-radius: 12px;
	background: var(--vc-panel-bg);
	color: inherit;
	font-family: inherit;
	font-size: 14px;
	line-height: 20px;
	resize: none;
	overflow-y: auto;
	box-shadow: none;
}

.vc-input:focus {
	border-color: var(--vc-brand);
	outline: none;
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--vc-brand) 25%, transparent);
}

.vc-send {
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--vc-brand);
	color: var(--vc-user-text);
	display: grid;
	place-items: center;
	cursor: pointer;
	flex-shrink: 0;
}

.vc-send svg {
	width: 18px;
	height: 18px;
	display: block;
}

.vc-send:disabled {
	opacity: 0.5;
	cursor: default;
}

.vc-send:not(:disabled):hover {
	filter: brightness(0.94);
}

/* -------------------------------------------------------------------------
 * Burbuja flotante
 * ---------------------------------------------------------------------- */

.vc-toggle {
	width: var(--vc-toggle-size);
	height: var(--vc-toggle-size);
	padding: 0;
	border: 1px solid var(--vc-border);
	border-radius: 50%;
	background: var(--vc-panel-bg);
	box-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%);
	overflow: hidden;
	cursor: pointer;
	transition: transform 0.15s ease;
	flex-shrink: 0;
}

.vc-toggle:hover,
.vc-toggle:focus-visible {
	transform: scale(1.05);
}

.vc-toggle img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

/* -------------------------------------------------------------------------
 * Accesibilidad y móvil
 * ---------------------------------------------------------------------- */

@media (max-width: 480px) {
	.vc-panel {
		width: calc(100vw - (var(--vc-offset) * 2));
		height: calc(100vh - (var(--vc-offset) * 2) - 80px);
		max-height: none;
	}

	.vc-bubble {
		max-width: 88%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vc-panel {
		animation: none;
	}

	.vc-typing span {
		animation: none;
	}

	.vc-toggle {
		transition: none;
	}

	.vc-toggle:hover,
	.vc-toggle:focus-visible {
		transform: none;
	}
}

@media print {
	.vc-root {
		display: none !important;
	}
}
