/* Digi AI — front-end chat widget (light theme, RTL). */

.digi-ai-root {
	--dgai-accent: #1d3557;
	--dgai-accent-2: #2b4d7e;
	--dgai-highlight: #e63946;
	--dgai-launcher: #e63946;
	--dgai-send: #51CCC3;
	--dgai-ink: #1f2b3a;
	--dgai-ink-soft: #64748b;
	--dgai-line: #e7ecf3;
	--dgai-surface: #ffffff;
	--dgai-canvas: #f6f8fc;
	--dgai-radius: 20px;
	--dgai-font: 'Vazirmatn', 'IRANSansX', 'IRANSans', 'Yekan Bakh', 'Segoe UI', Tahoma, sans-serif;

	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99998;
	font-family: var(--dgai-font);
	direction: rtl;
}

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

.digi-ai-root .dgai-svg-fill {
	fill: currentColor;
	stroke: none;
}

/* ---------------------------------------------------------------- launcher */

.dgai-launcher {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 51px;
	height: 51px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--dgai-launcher);
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: transform .18s ease;
	position: relative;
}

.dgai-launcher:hover {
	transform: translateY(-2px);
}

.dgai-launcher:active {
	transform: translateY(0);
}

.dgai-launcher-icon {
	display: grid;
	place-items: center;
	color: #fff;
	flex: none;
}

.dgai-launcher-icon svg {
	width: 24px;
	height: 24px;
}

.dgai-launcher-badge {
	position: absolute;
	top: -4px;
	left: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--dgai-accent);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 0 0 3px #fff;
}

.digi-ai-root[data-open="1"] .dgai-launcher {
	transform: scale(.9);
	opacity: 0;
	pointer-events: none;
}

/* ------------------------------------------------------------------- panel */

.dgai-panel {
	position: absolute;
	bottom: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	width: 404px;
	max-width: calc(100vw - 32px);
	height: min(560px, calc(100vh - 180px));
	min-height: 420px;
	background: var(--dgai-surface);
	border: 1px solid var(--dgai-line);
	border-radius: var(--dgai-radius);
	box-shadow: 0 30px 70px rgba(16, 24, 40, .18), 0 4px 12px rgba(16, 24, 40, .06);
	overflow: hidden;
	opacity: 0;
	transform: translateY(10px) scale(.99);
	transform-origin: bottom left;
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}

.digi-ai-root[data-open="1"] .dgai-panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

/* ------------------------------------------------------------------ header */

.dgai-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--dgai-surface);
	border-bottom: 1px solid var(--dgai-line);
	flex: none;
}

.dgai-avatar {
	position: relative;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--dgai-launcher);
	color: #fff;
	flex: none;
}

.dgai-avatar svg {
	width: 23px;
	height: 23px;
}

.dgai-avatar::after {
	content: "";
	position: absolute;
	bottom: 1px;
	left: 1px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 2.5px #fff;
}

.dgai-titles {
	flex: 1;
	min-width: 0;
}

.dgai-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: var(--dgai-ink);
	line-height: 1.5;
}

.dgai-subtitle {
	margin: 2px 0 0;
	font-size: 12px;
	color: var(--dgai-ink-soft);
	line-height: 1.5;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dgai-head-actions {
	display: flex;
	gap: 4px;
	flex: none;
}

.dgai-icon-btn {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--dgai-ink-soft);
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}

.dgai-icon-btn:hover {
	background: #f1f5f9;
	color: var(--dgai-ink);
}

.dgai-icon-btn svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ------------------------------------------------------------------ ribbon */

.dgai-ribbon {
	display: none;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 9px 14px 9px 18px;
	font-size: 12.5px;
	font-weight: 600;
	border-bottom: 1px solid transparent;
	flex: none;
}

.digi-ai-root[data-status="pending"] .dgai-ribbon,
.digi-ai-root[data-status="active"] .dgai-ribbon {
	display: flex;
}

.digi-ai-root[data-status="pending"] .dgai-ribbon {
	background: #fff8ec;
	color: #b45309;
	border-bottom-color: #fdebd0;
}

.digi-ai-root[data-status="active"] .dgai-ribbon {
	background: #eefbf3;
	color: #15803d;
	border-bottom-color: #d9f2e3;
}

.dgai-ribbon-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
	flex: none;
	animation: dgai-pulse 1.6s ease-in-out infinite;
}

.dgai-ribbon-cancel {
	margin-inline-start: auto;
	padding: 5px 12px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: rgba(255, 255, 255, .7);
	color: inherit;
	font-family: inherit;
	font-size: 11.5px;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s ease, color .15s ease;
}

.dgai-ribbon-cancel:hover {
	background: currentColor;
}

.dgai-ribbon-cancel:hover span {
	color: #fff;
}

@keyframes dgai-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50%      { opacity: .35; transform: scale(.8); }
}

/* ---------------------------------------------------------------- messages */

.dgai-messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 8px;
	background: var(--dgai-canvas);
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
	/* LTR only so the scrollbar sits on the right; children stay RTL. */
	direction: ltr;
	scrollbar-width: thin;
	scrollbar-color: #d7dfea transparent;
}

.dgai-messages > * {
	direction: rtl;
}

.dgai-messages::-webkit-scrollbar {
	width: 8px;
}

.dgai-messages::-webkit-scrollbar-thumb {
	background: #d7dfea;
	border-radius: 999px;
}

.dgai-messages::-webkit-scrollbar-track,
.dgai-messages::-webkit-scrollbar-button {
	background: transparent;
	display: none;
}

.dgai-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
}

/* Visitor on the right, assistant and support agent on the left.
   (The list itself is LTR for the scrollbar, so these read physically.) */
.dgai-row.is-user {
	align-self: flex-end;
	flex-direction: row;
}

.dgai-row.is-bot,
.dgai-row.is-agent {
	align-self: flex-start;
	flex-direction: row-reverse;
}

.dgai-mini-avatar {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--dgai-accent-2), var(--dgai-accent));
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	flex: none;
	margin-bottom: 16px;
}

.dgai-row.is-agent .dgai-mini-avatar {
	background: var(--dgai-highlight);
}

.dgai-mini-avatar svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: #fff;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.dgai-bubble-wrap {
	min-width: 0;
	max-width: 300px;
}

.dgai-bubble {
	padding: 11px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.95;
	color: var(--dgai-ink);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.dgai-row.is-bot .dgai-bubble,
.dgai-row.is-agent .dgai-bubble {
	background: #fff;
	border: 1px solid var(--dgai-line);
	border-top-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.dgai-row.is-agent .dgai-bubble {
	border-color: #fadadd;
	background: #fffdfd;
}

.dgai-row.is-user .dgai-bubble {
	background: linear-gradient(135deg, var(--dgai-accent-2), var(--dgai-accent));
	color: #fff;
	border-top-right-radius: 4px;
	box-shadow: 0 6px 16px rgba(29, 53, 87, .18);
}

.dgai-bubble a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.dgai-row.is-bot .dgai-bubble a,
.dgai-row.is-agent .dgai-bubble a {
	color: var(--dgai-accent-2);
	font-weight: 600;
}

.dgai-bubble p {
	margin: 0 0 8px;
}

.dgai-bubble p:last-child {
	margin-bottom: 0;
}

.dgai-bubble ul,
.dgai-bubble ol {
	margin: 6px 0;
	padding-inline-start: 20px;
}

.dgai-bubble li {
	margin-bottom: 4px;
}

.dgai-bubble code {
	padding: 1px 5px;
	border-radius: 6px;
	background: rgba(29, 53, 87, .08);
	font-family: 'SF Mono', Consolas, monospace;
	font-size: 12.5px;
	direction: ltr;
	display: inline-block;
}

.dgai-row.is-user .dgai-bubble code {
	background: rgba(255, 255, 255, .18);
}

.dgai-time {
	margin-top: 5px;
	font-size: 10.5px;
	color: #9aa7b8;
}

.dgai-row.is-bot .dgai-time,
.dgai-row.is-agent .dgai-time {
	text-align: left;
}

.dgai-system {
	align-self: center;
	max-width: 92%;
	padding: 8px 14px;
	border-radius: 12px;
	background: #eaeff6;
	color: #566579;
	font-size: 12px;
	line-height: 1.8;
	text-align: center;
}

/* ------------------------------------------------- handoff hint (discreet) */

.dgai-hint {
	align-self: flex-start;
	margin-top: -4px;
	padding-left: 38px;
}

.dgai-hint-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border: 1px dashed #f0c2c7;
	border-radius: 999px;
	background: #fffafa;
	color: var(--dgai-highlight);
	font-family: inherit;
	font-size: 11.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.dgai-hint-btn:hover {
	background: var(--dgai-highlight);
	border-color: var(--dgai-highlight);
	color: #fff;
}

.dgai-hint-btn svg {
	width: 14px;
	height: 14px;
}

/* typing */

.dgai-typing {
	display: flex;
	gap: 4px;
	padding: 14px 16px;
}

.dgai-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b9c4d4;
	animation: dgai-bounce 1.2s infinite ease-in-out;
}

.dgai-typing i:nth-child(2) { animation-delay: .15s; }
.dgai-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes dgai-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30%           { transform: translateY(-5px); opacity: 1; }
}

/* ----------------------------------------------------- guest introduction */

.dgai-gate {
	margin: auto 0;
	padding: 22px 20px;
	border: 1px solid var(--dgai-line);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 2px 10px rgba(16, 24, 40, .04);
	text-align: center;
}

.dgai-gate-icon {
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	margin: 0 auto 12px;
	border-radius: 50%;
	background: var(--dgai-launcher);
	color: #fff;
}

.dgai-gate-icon svg {
	width: 24px;
	height: 24px;
}

.dgai-gate-title {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 700;
	color: var(--dgai-ink);
}

.dgai-gate-text {
	margin: 0 0 16px;
	font-size: 12.5px;
	line-height: 1.9;
	color: var(--dgai-ink-soft);
}

.dgai-gate-input {
	width: 100%;
	margin-bottom: 9px;
	padding: 11px 14px;
	border: 1px solid #dfe6f0;
	border-radius: 12px;
	background: #f8fafc;
	color: var(--dgai-ink);
	font-family: inherit;
	font-size: 13.5px;
	outline: none;
	transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
	direction: rtl;
}

.dgai-gate-input[type="email"] {
	direction: ltr;
	text-align: right;
}

.dgai-gate-input:focus {
	border-color: #b9cbe4;
	background: #fff;
	box-shadow: 0 0 0 3px rgba(43, 77, 126, .08);
}

.dgai-gate-error {
	margin: 0 0 8px;
	color: var(--dgai-highlight);
	font-size: 11.5px;
}

.dgai-gate-submit {
	width: 100%;
	padding: 11px 16px;
	border: 0;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--dgai-accent-2), var(--dgai-accent));
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: transform .12s ease, opacity .15s ease;
}

.dgai-gate-submit:hover {
	transform: translateY(-1px);
}

/* ------------------------------------------------------------------ footer */

.dgai-suggest {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 16px 12px;
	background: var(--dgai-canvas);
}

.digi-ai-root[data-gate="1"] .dgai-suggest,
.digi-ai-root[data-gate="1"] .dgai-composer {
	display: none;
}

.dgai-chip {
	padding: 5px 11px;
	border: 1px solid #dbe4ef;
	border-radius: 999px;
	background: #fff;
	color: var(--dgai-accent-2);
	font-family: inherit;
	font-size: 11.5px;
	font-weight: 600;
	line-height: 1.8;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease, transform .12s ease;
}

.dgai-chip:hover {
	background: #eef3fb;
	border-color: #c6d5ea;
	transform: translateY(-1px);
}

.dgai-composer {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 12px 14px;
	background: #fff;
	border-top: 1px solid var(--dgai-line);
	flex: none;
}

.dgai-input {
	flex: 1;
	/* Same height as the send button so the two line up when empty. */
	min-height: 48px;
	max-height: 150px;
	/* Grows with the text instead of showing a scrollbar. */
	overflow-y: hidden;
	padding: 11px 14px;
	border: 1px solid #dfe6f0;
	border-radius: 14px;
	background: #f8fafc;
	color: var(--dgai-ink);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.7;
	resize: none;
	outline: none;
	transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.dgai-input:focus {
	border-color: #b9cbe4;
	background: #fff;
	box-shadow: 0 0 0 3px rgba(43, 77, 126, .08);
}

.dgai-input::placeholder {
	color: #9aa7b8;
}

.dgai-send {
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 14px;
	background: var(--dgai-send);
	color: #fff;
	cursor: pointer;
	flex: none;
	transition: opacity .15s ease, transform .12s ease, box-shadow .15s ease;
	box-shadow: 0 6px 16px rgba(81, 204, 195, .3);
}

.dgai-send:hover:not(:disabled) {
	transform: translateY(-1px);
}

.dgai-send:disabled {
	opacity: .45;
	box-shadow: none;
	cursor: default;
}

.dgai-send svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.dgai-error {
	align-self: center;
	max-width: 92%;
	padding: 9px 14px;
	border: 1px solid #f7d4d8;
	border-radius: 12px;
	background: #fff5f6;
	color: #b3232f;
	font-size: 12px;
	line-height: 1.8;
	text-align: center;
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 560px) {
	.digi-ai-root {
		bottom: 16px;
		right: 16px;
	}

	.dgai-launcher {
		width: 49px;
		height: 49px;
	}

	.dgai-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		height: 100dvh;
		border: 0;
		border-radius: 0;
	}

	.dgai-bubble-wrap {
		max-width: calc(100vw - 100px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.digi-ai-root * {
		animation: none !important;
		transition: none !important;
	}
}

/* Inline [digi_ai] button */

.dgai-inline-open {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 18px;
	border: 0;
	border-radius: 999px;
	background: #e63946;
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}
