/* Napki AI Chat - estilos del widget */

.napki-chat {
	--napki-chat-color: #8d1d2c;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}

.napki-chat--right { right: 20px; }
.napki-chat--left { left: 20px; }

/* Botón flotante */
.napki-chat__launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	background: var(--napki-chat-color);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease;
	padding: 0;
}

.napki-chat__launcher:hover { transform: scale(1.07); }

/* Panel */
.napki-chat__panel {
	position: absolute;
	bottom: 74px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

.napki-chat--right .napki-chat__panel { right: 0; }
.napki-chat--left .napki-chat__panel { left: 0; }

/* El display:flex de arriba anularía el atributo hidden: forzar el cierre real del panel */
.napki-chat__panel[hidden] { display: none !important; }

/* Cabecera */
.napki-chat__header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	background: var(--napki-chat-color);
	color: #fff;
}

.napki-chat__status {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #6ee86e;
	flex: 0 0 auto;
}

.napki-chat__title {
	flex: 1 1 auto;
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.napki-chat__close,
.napki-chat__reset {
	flex: 0 0 auto;
	background: none;
	border: none;
	color: #fff;
	opacity: 0.85;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 2px 4px;
}

.napki-chat__close { font-size: 24px; }
.napki-chat__close:hover,
.napki-chat__reset:hover { opacity: 1; }

/* Mensajes */
.napki-chat__messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px;
	background: #f5f5f7;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.napki-chat__msg {
	max-width: 84%;
	padding: 9px 13px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: normal;
}

.napki-chat__msg--bot {
	align-self: flex-start;
	background: #fff;
	color: #222;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.napki-chat__msg--user {
	align-self: flex-end;
	background: var(--napki-chat-color);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.napki-chat__msg a { color: inherit; text-decoration: underline; }

/* Indicador de escritura */
.napki-chat__msg--typing {
	display: flex;
	gap: 4px;
	padding: 12px 14px;
}

.napki-chat__msg--typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b5b5bd;
	animation: napki-chat-blink 1.2s infinite both;
}

.napki-chat__msg--typing span:nth-child(2) { animation-delay: 0.2s; }
.napki-chat__msg--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes napki-chat-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

/* Formulario */
.napki-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	background: #fff;
	border-top: 1px solid #e6e6ea;
	margin: 0;
}

.napki-chat__input {
	flex: 1 1 auto;
	resize: none;
	border: 1px solid #d5d5db;
	border-radius: 10px;
	padding: 9px 12px;
	font: inherit;
	color: #222;
	background: #fff;
	max-height: 110px;
	outline: none;
}

.napki-chat__input:focus { border-color: var(--napki-chat-color); }

.napki-chat__send {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: var(--napki-chat-color);
	color: #fff;
	cursor: pointer;
	padding: 0;
}

.napki-chat__send:hover { filter: brightness(1.1); }

/* Móvil: panel a pantalla (casi) completa */
@media (max-width: 480px) {
	.napki-chat--right,
	.napki-chat--left { right: 12px; left: auto; bottom: 12px; }

	.napki-chat__panel {
		position: fixed;
		inset: auto 8px 80px 8px;
		width: auto;
		height: 70vh;
		max-height: none;
	}
}

/* Formulario de contacto dentro del chat */
.napki-chat__lead-btn {
	display: block;
	width: 100%;
	padding: 8px 12px;
	border: 0;
	border-top: 1px solid #e5e7eb;
	background: #fff;
	color: var(--napki-chat-color);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.napki-chat__lead-btn[hidden] { display: none; }
.napki-chat__lead {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	background: #fff;
	color: #1f2937;
	font-size: 14px;
}
.napki-chat__lead p { margin: 0; }
.napki-chat__lead-campo { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 13px; }
.napki-chat__lead-campo input {
	padding: 8px 10px;
	min-height: 40px;
	box-sizing: border-box;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	color: #1f2937;
	font: inherit;
	font-size: 16px;
	font-weight: 400;
}
.napki-chat__lead-gdpr { font-size: 12px; line-height: 1.4; }
.napki-chat__lead-gdpr a { color: var(--napki-chat-color); text-decoration: underline; }
.napki-chat__lead-trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.napki-chat__lead-fallo { color: #b91c1c; font-size: 13px; }
.napki-chat__lead-fallo:empty { display: none; }
.napki-chat__lead-acciones { display: flex; gap: 8px; }
.napki-chat__lead-acciones button {
	flex: 1;
	min-height: 40px;
	border: 0;
	border-radius: 8px;
	background: var(--napki-chat-color);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.napki-chat__lead-acciones button:disabled { opacity: .6; cursor: wait; }
.napki-chat__lead-acciones .napki-chat__lead-cancelar { background: #f1f5f9; color: #1f2937; }
.napki-chat__lead :focus-visible, .napki-chat__lead-btn:focus-visible { outline: 2px solid var(--napki-chat-color); outline-offset: 1px; }
