/* Tokify — Asistente web (v0.12.0). Estilos propios: no dependen del tema. */

.tk-asst {
	--tka-bg: #111018;
	--tka-raised: #1c1a26;
	--tka-line: #2f2b3d;
	--tka-text: #f4f2f8;
	--tka-muted: #a9a4b8;
	--tka-brand-1: #388cff;
	--tka-brand-2: #a05aff;
	--tka-gold: #f5b041;
	--tka-on-gold: #1b1206;
	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--tka-text);
}
.tk-asst-right { right: 20px; }
.tk-asst-left { left: 20px; }
.tk-asst *, .tk-asst *::before, .tk-asst *::after { box-sizing: border-box; }
.tk-asst [hidden] { display: none !important; }

/* Botón flotante */
.tk-asst-fab {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--tka-brand-1), var(--tka-brand-2));
	color: #fff;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(40, 20, 90, .45);
	transition: transform .15s ease;
}
.tk-asst-left .tk-asst-fab { margin-right: auto; }
.tk-asst-right .tk-asst-fab { margin-left: auto; }
.tk-asst-fab:hover { transform: scale(1.06); }
.tk-asst-fab:focus-visible, .tk-asst button:focus-visible, .tk-asst textarea:focus-visible, .tk-asst input:focus-visible, .tk-asst a:focus-visible {
	outline: 3px solid var(--tka-gold);
	outline-offset: 2px;
}

/* Panel */
.tk-asst-panel {
	display: flex;
	flex-direction: column;
	width: 370px;
	height: min(560px, calc(100vh - 120px));
	margin-bottom: 14px;
	overflow: hidden;
	border: 1px solid var(--tka-line);
	border-radius: 18px;
	background: var(--tka-bg);
	box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.tk-asst-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 12px 12px 14px;
	background: linear-gradient(135deg, rgba(56, 140, 255, .25), rgba(160, 90, 255, .25));
	border-bottom: 1px solid var(--tka-line);
}
.tk-asst-avatar {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--tka-brand-1), var(--tka-brand-2));
	font-weight: 800;
}
.tk-asst-titles { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.tk-asst-titles strong { font-size: 15px; }
.tk-asst-badge {
	display: inline-block;
	padding: 0 6px;
	border-radius: 6px;
	background: var(--tka-gold);
	color: var(--tka-on-gold);
	font-size: 11px;
	font-weight: 800;
	vertical-align: 2px;
}
.tk-asst-note { color: var(--tka-muted); font-size: 12px; }
.tk-asst-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--tka-text);
	cursor: pointer;
}
.tk-asst-close:hover { background: rgba(255, 255, 255, .1); }

/* Mensajes */
.tk-asst-log { display: flex; flex: 1; flex-direction: column; gap: 10px; padding: 14px; overflow-y: auto; overscroll-behavior: contain; }
.tk-asst-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; overflow-wrap: anywhere; }
.tk-asst-assistant { align-self: flex-start; background: var(--tka-raised); border-bottom-left-radius: 4px; }
.tk-asst-user { align-self: flex-end; background: linear-gradient(135deg, var(--tka-brand-1), var(--tka-brand-2)); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.tk-asst-msg.is-error { border: 1px solid rgba(245, 176, 65, .5); }
.tk-asst-msg a { color: #9cc5ff; text-decoration: underline; }
.tk-asst-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-asst-chip, .tk-asst-cta {
	padding: 7px 12px;
	border: 1px solid var(--tka-line);
	border-radius: 999px;
	background: transparent;
	color: var(--tka-text);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.tk-asst-chip:hover, .tk-asst-cta:hover { border-color: var(--tka-gold); }
.tk-asst-cta { align-self: flex-start; border-color: var(--tka-gold); color: var(--tka-gold); font-weight: 600; }
.tk-asst-typing { display: flex; gap: 4px; }
.tk-asst-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--tka-muted); animation: tk-asst-dot 1s infinite ease-in-out; }
.tk-asst-typing span:nth-child(2) { animation-delay: .15s; }
.tk-asst-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tk-asst-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Entrada */
.tk-asst-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--tka-line); }
.tk-asst-input textarea {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	padding: 9px 12px;
	border: 1px solid var(--tka-line);
	border-radius: 12px;
	background: var(--tka-raised);
	color: var(--tka-text);
	font: inherit;
	resize: none;
}
.tk-asst-send {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 12px;
	background: var(--tka-gold);
	color: var(--tka-on-gold);
	cursor: pointer;
}
.tk-asst-send:disabled { opacity: .5; cursor: wait; }
.tk-asst-foot { padding: 0 12px 10px; text-align: center; }
.tk-asst-link {
	padding: 4px;
	border: 0;
	background: none;
	color: var(--tka-muted);
	font: inherit;
	font-size: 13px;
	text-decoration: underline;
	cursor: pointer;
}
.tk-asst-link:hover { color: var(--tka-text); }

/* Formulario */
.tk-asst-form { display: flex; flex: 1; flex-direction: column; gap: 10px; padding: 16px; overflow-y: auto; }
.tk-asst-form-title { font-size: 16px; }
.tk-asst-form-intro { margin: 0; color: var(--tka-muted); font-size: 13px; }
.tk-asst-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.tk-asst-field input, .tk-asst-field textarea {
	padding: 9px 11px;
	border: 1px solid var(--tka-line);
	border-radius: 10px;
	background: var(--tka-raised);
	color: var(--tka-text);
	font: inherit;
	font-weight: 400;
}
.tk-asst-field textarea { resize: vertical; }
.tk-asst-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--tka-muted); }
.tk-asst-check input { margin-top: 3px; accent-color: var(--tka-gold); }
.tk-asst-check a { color: #9cc5ff; }
.tk-asst-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.tk-asst-form-err { margin: 0; color: #ffb4a6; font-size: 13px; }
.tk-asst-form-ok { margin: 0; padding: 12px; border-radius: 12px; background: rgba(120, 200, 140, .14); color: #b8ecc4; }
.tk-asst-form-acts { display: flex; gap: 12px; align-items: center; }
.tk-asst-btn {
	padding: 10px 16px;
	border: 0;
	border-radius: 12px;
	background: var(--tka-gold);
	color: var(--tka-on-gold);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}
.tk-asst-btn:disabled { opacity: .6; cursor: wait; }

/* Móvil: el panel ocupa casi toda la pantalla */
@media (max-width: 480px) {
	.tk-asst { bottom: 14px; }
	.tk-asst-right { right: 14px; }
	.tk-asst-left { left: 14px; }
	.tk-asst.is-open { left: 8px; right: 8px; }
	.tk-asst-panel { width: 100%; height: calc(100vh - 100px); height: calc(100dvh - 100px); }
	.tk-asst-fab { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
	.tk-asst-fab { transition: none; }
	.tk-asst-typing span { animation: none; }
}
