/* ITEXTRAB AI chat widget — styles scoped to #itx-ai-root.
   Dark slate theme matching itextrab.com: bg #1f272c, panel #2b373e,
   accent #2f8cff (set via --itx-accent), text #e9eef2, muted #aab7c2. */
#itx-ai-root {
	--itx-accent: #2f8cff;
	--itx-bg: #1f272c;
	--itx-panel: #2b373e;
	--itx-panel-2: #233038;
	--itx-text: #e9eef2;
	--itx-muted: #aab7c2;
	--itx-dim: #7f8e9a;
	--itx-line: rgba(255, 255, 255, .09);
	--itx-radius: 12px;
	position: fixed;
	z-index: 99990;
	bottom: 18px;
	right: 18px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
	font-size: 15px;
	color: var(--itx-text);
	direction: ltr;
}
#itx-ai-root *, #itx-ai-root *::before, #itx-ai-root *::after { box-sizing: border-box; }

/* launcher */
#itx-launcher {
	width: 58px; height: 58px;
	border: 1px solid rgba(47, 140, 255, .45);
	border-radius: 50%;
	background: linear-gradient(135deg, var(--itx-accent), #0f5aa6);
	color: #fff; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 12px 32px -8px rgba(47, 140, 255, .55);
	position: relative;
	transition: transform .18s ease;
}
#itx-launcher:hover { transform: translateY(-2px); }
#itx-launcher svg { width: 26px; height: 26px; }
#itx-launcher .itx-dot {
	position: absolute; top: 3px; right: 3px;
	width: 11px; height: 11px; border-radius: 50%;
	background: #4ade80; border: 2px solid var(--itx-bg);
}
#itx-launcher.itx-pulsing::after {
	content: "";
	position: absolute; inset: -5px;
	border-radius: 50%;
	border: 2px solid var(--itx-accent);
	animation: itx-pulse 1.8s ease-out infinite;
}
@keyframes itx-pulse {
	0% { transform: scale(.85); opacity: .9; }
	100% { transform: scale(1.35); opacity: 0; }
}

/* teaser */
#itx-teaser {
	position: absolute; bottom: 68px; right: 0;
	max-width: 240px;
	background: var(--itx-panel);
	border: 1px solid var(--itx-line);
	border-radius: var(--itx-radius);
	padding: 10px 14px;
	font-size: .86rem; line-height: 1.4;
	color: var(--itx-text);
	box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6);
	cursor: pointer;
	opacity: 0; transform: translateY(6px); pointer-events: none;
	transition: opacity .3s ease, transform .3s ease;
}
#itx-teaser.itx-show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#itx-teaser::after {
	content: "";
	position: absolute; bottom: -6px; right: 22px;
	width: 10px; height: 10px;
	background: var(--itx-panel);
	border-right: 1px solid var(--itx-line);
	border-bottom: 1px solid var(--itx-line);
	transform: rotate(45deg);
}

/* panel */
#itx-panel {
	position: absolute; bottom: 74px; right: 0;
	width: 366px; max-width: calc(100vw - 24px);
	height: 540px; max-height: calc(100vh - 110px);
	background: var(--itx-bg);
	border: 1px solid var(--itx-line);
	border-radius: 18px;
	display: flex; flex-direction: column;
	overflow: hidden;
	box-shadow: 0 24px 60px -16px rgba(0, 0, 0, .65);
	opacity: 0; transform: translateY(14px) scale(.98); pointer-events: none;
	transition: opacity .22s ease, transform .22s ease;
}
#itx-panel.itx-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* header */
.itx-head {
	display: flex; align-items: center; gap: 10px;
	padding: 14px 16px;
	background: var(--itx-panel-2);
	border-bottom: 1px solid var(--itx-line);
}
.itx-ava {
	width: 36px; height: 36px; border-radius: 50%;
	background: linear-gradient(135deg, var(--itx-accent), #0f5aa6);
	display: flex; align-items: center; justify-content: center;
	flex: 0 0 auto;
}
.itx-ava svg { width: 20px; height: 20px; }
.itx-who { flex: 1; min-width: 0; }
.itx-name { font-weight: 700; font-size: .95rem; color: #fff; }
.itx-status { font-size: .74rem; color: var(--itx-muted); }
.itx-x {
	width: 30px; height: 30px;
	background: rgba(255, 255, 255, .04);
	border: 1px solid var(--itx-line);
	border-radius: 8px;
	color: var(--itx-muted); cursor: pointer;
	font-size: .8rem; line-height: 1;
}
.itx-x:hover { color: #fff; background: rgba(255, 255, 255, .08); }

/* messages */
.itx-msgs {
	flex: 1; overflow-y: auto;
	padding: 14px 14px 6px;
	display: flex; flex-direction: column; gap: 8px;
	scrollbar-width: thin; scrollbar-color: var(--itx-panel) transparent;
}
.itx-msgs::-webkit-scrollbar { width: 5px; }
.itx-msgs::-webkit-scrollbar-thumb { background: var(--itx-panel); border-radius: 3px; }
.itx-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: .88rem; line-height: 1.55; }
.itx-msg.bot {
	align-self: flex-start;
	background: var(--itx-panel);
	border: 1px solid var(--itx-line);
	border-bottom-left-radius: 4px;
}
.itx-msg.user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--itx-accent), #0f5aa6);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.itx-msg ul { margin: 6px 0 2px; padding-inline-start: 18px; }
.itx-msg li { margin: 3px 0; }
.itx-msg b { color: #fff; }

/* typing */
.itx-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--itx-panel); border-radius: 14px; border-bottom-left-radius: 4px; }
.itx-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--itx-muted); animation: itx-blink 1.2s infinite; }
.itx-typing i:nth-child(2) { animation-delay: .2s; }
.itx-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes itx-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* chips */
.itx-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 4px; }
.itx-chip {
	background: rgba(47, 140, 255, .12);
	border: 1px solid rgba(47, 140, 255, .35);
	color: #9cc8ff;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: .78rem;
	cursor: pointer;
	transition: background .15s ease;
}
.itx-chip:hover { background: rgba(47, 140, 255, .22); }

/* input */
.itx-input { display: flex; gap: 8px; padding: 10px 14px; }
.itx-input input {
	flex: 1; min-width: 0;
	background: var(--itx-panel-2);
	border: 1px solid var(--itx-line);
	border-radius: 10px;
	padding: 11px 13px;
	color: var(--itx-text);
	font-size: .88rem;
	font-family: inherit;
	outline: none;
}
.itx-input input:focus { border-color: rgba(47, 140, 255, .55); }
.itx-input input::placeholder { color: var(--itx-dim); }
.itx-input button {
	width: 42px;
	background: linear-gradient(135deg, var(--itx-accent), #0f5aa6);
	border: none; border-radius: 10px;
	color: #fff; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.itx-input button:disabled { opacity: .55; cursor: default; }
.itx-input button svg { width: 18px; height: 18px; }

/* footer */
.itx-foot {
	padding: 8px 14px 11px;
	font-size: .68rem;
	color: var(--itx-dim);
	text-align: center;
	border-top: 1px solid var(--itx-line);
	background: var(--itx-bg);
}

/* ---------- handoff card ---------- */
.itx-msg.itx-handoff {
	max-width: 94%;
	background: var(--itx-panel-2);
	border: 1px solid rgba(47, 140, 255, .4);
	padding: 14px;
}
.itx-ho-title { font-weight: 700; font-size: .9rem; color: #fff; margin-bottom: 4px; }
.itx-ho-sub { font-size: .78rem; color: var(--itx-muted); margin-bottom: 10px; }
.itx-ho-form { display: flex; flex-direction: column; gap: 4px; }
.itx-ho-form label { font-size: .68rem; color: var(--itx-dim); text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }
.itx-ho-form input, .itx-ho-form textarea {
	background: var(--itx-bg);
	border: 1px solid var(--itx-line);
	border-radius: 8px;
	padding: 9px 11px;
	color: var(--itx-text);
	font-size: .84rem;
	font-family: inherit;
	outline: none;
	width: 100%;
}
.itx-ho-form textarea { min-height: 64px; resize: vertical; }
.itx-ho-form input:focus, .itx-ho-form textarea:focus { border-color: rgba(47, 140, 255, .55); }
.itx-ho-send {
	margin-top: 10px;
	background: linear-gradient(135deg, var(--itx-accent), #0f5aa6);
	border: none; border-radius: 9px;
	padding: 10px;
	color: #fff; font-weight: 700; font-size: .85rem;
	cursor: pointer;
}
.itx-ho-send:disabled { opacity: .6; cursor: default; }
.itx-ho-ok, .itx-ho-err { display: none; font-size: .8rem; margin-top: 8px; line-height: 1.5; }
.itx-ho-ok.itx-show, .itx-ho-err.itx-show { display: block; }
.itx-ho-err { color: #ff8a95; }

/* ---------- RTL (Arabic UI) ---------- */
#itx-ai-root.itx-rtl { direction: rtl; }
#itx-ai-root.itx-rtl #itx-panel,
#itx-ai-root.itx-rtl .itx-msg,
#itx-ai-root.itx-rtl .itx-ho-form { text-align: right; }
#itx-ai-root.itx-rtl #itx-teaser { right: auto; left: 0; }
#itx-ai-root.itx-rtl #itx-teaser::after { right: auto; left: 22px; }
#itx-ai-root.itx-rtl .itx-msg.bot { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
#itx-ai-root.itx-rtl .itx-msg.user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
#itx-ai-root.itx-rtl .itx-ho-form label { text-transform: none; letter-spacing: 0; }

/* ---------- mobile ---------- */
@media (max-width: 480px) {
	#itx-ai-root { bottom: 12px; right: 12px; left: 12px; }
	#itx-panel { width: 100%; right: 0; height: calc(100vh - 96px); max-height: none; }
	#itx-teaser { max-width: 200px; }
}
