/* =========================================================
   Session End Modal — matches .alfa-session-end-modal* markup
   ========================================================= */

.alfa-session-end-modal[hidden] {
	display: none !important;
}

.alfa-session-end-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	font-family: inherit;
	direction: rtl;
}

.alfa-session-end-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(2px);
}

.alfa-session-end-modal__panel {
	position: relative;
	z-index: 1;
	width: min(420px, 100%);
	max-height: min(90vh, 640px);
	overflow: auto;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	padding: 28px 24px 20px;
	text-align: center;
}

/* دکمه بستن — بزرگ‌تر و واضح‌تر تا فریزِ ناشی از ندیدن close تکرار نشود */
.alfa-session-end-modal__close {
	position: absolute;
	top: 8px;
	left: 10px;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 999px;
	background: #f1f5f9;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	color: #334155;
}

.alfa-session-end-modal__close:hover,
.alfa-session-end-modal__close:focus-visible {
	background: #e2e8f0;
	color: #0f172a;
	outline: none;
}

.alfa-session-end-modal__identities {
	display: grid;
	gap: 8px;
	margin: 4px 0 14px;
	text-align: right;
}

.alfa-session-end-modal__identity[hidden] {
	display: none !important;
}

.alfa-session-end-modal__identity {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border: 1px solid #dbeafe;
	border-radius: 14px;
	background: #f8fbff;
}

.alfa-session-end-modal__identity--quest {
	border-color: #fef3c7;
	background: #fffbeb;
}

.alfa-session-end-modal__identity-icon {
	width: 75px;
	height: 75px;
	flex: 0 0 75px;
	object-fit: contain;
	display: block;
	border-radius: 12px;
	background: #f8fafc;
	padding: 4px;
}

.alfa-session-end-modal__identity-label,
.alfa-session-end-modal__identity-name {
	display: block;
}

.alfa-session-end-modal__identity-label {
	margin-bottom: 3px;
	color: #64748b;
	font-size: 0.82rem;
	font-weight: 700;
}

.alfa-session-end-modal__identity-name {
	color: #1e3a8a;
	font-size: 1rem;
	line-height: 1.55;
}

.alfa-session-end-modal__title {
	margin: 8px 0 10px;
	font-size: 1.4rem;
	font-weight: 700;
	color: #0f172a;
	line-height: 1.4;
}

/* حالت موفقیت / تلاش دوباره */
.alfa-session-end-modal.is-success .alfa-session-end-modal__title {
	color: #15803d;
}

.alfa-session-end-modal.is-fail .alfa-session-end-modal__title {
	color: #b45309;
}

/* امتیاز کودک‌پسند — دو خط: بج شرکت + کیفیت (بدون «آستانه») */
.alfa-session-end-modal__score {
	margin: 0 0 12px;
	font-size: 1.05rem;
	font-weight: 700;
	color: #1d4ed8;
	line-height: 1.7;
	white-space: pre-line; /* پشتیبانی از \n بین بج و کیفیت */
}

/* خط اول = بج شرکت — حس جایزه */
.alfa-session-end-modal__score::first-line {
	color: #b45309;
}

.alfa-session-end-modal__score[hidden] {
	display: none !important;
}


.alfa-session-end-modal__body {
	margin: 0 0 20px;
	color: #334155;
	line-height: 1.75;
	font-size: 1rem;
	white-space: pre-wrap;
}

.alfa-session-end-modal__feedback {
	margin: -4px 0 20px;
	border: 1px solid #bfdbfe;
	border-radius: 12px;
	background: #eff6ff;
	color: #1e3a8a;
	text-align: right;
}

.alfa-session-end-modal__feedback[hidden] {
	display: none !important;
}

.alfa-session-end-modal__feedback summary {
	padding: 12px 14px;
	cursor: pointer;
	font-weight: 700;
}

.alfa-session-end-modal__feedback-list {
	margin: 0;
	padding: 0 32px 14px 14px;
	color: #334155;
	line-height: 1.8;
}

.alfa-session-end-modal__feedback-list li + li {
	margin-top: 6px;
}

.alfa-writer-share {
	margin: 0 0 18px;
	padding: 15px;
	border: 1px solid #fde68a;
	border-radius: 16px;
	background: linear-gradient(145deg, #fffbeb, #fff7d6);
	text-align: right;
}

.alfa-writer-share h3 {
	margin: 0 0 10px;
	color: #92400e;
	font-size: 1.05rem;
}

.alfa-writer-share__text {
	max-height: 220px;
	overflow: auto;
	padding: 12px;
	border-radius: 12px;
	background: #fff;
	color: #334155;
	line-height: 1.85;
	white-space: pre-wrap;
}

.alfa-writer-share__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 12px;
}

.alfa-writer-share__actions button {
	border: 0;
	border-radius: 999px;
	padding: 9px 14px;
	background: #f59e0b;
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.alfa-writer-share__actions button:hover,
.alfa-writer-share__actions button:focus-visible {
	background: #d97706;
}

.alfa-session-end-modal__ok {
	border: 0;
	border-radius: 12px;
	padding: 12px 28px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	background: #2563eb;
	color: #fff;
	min-width: 120px;
}

.alfa-session-end-modal__ok:hover,
.alfa-session-end-modal__ok:focus-visible {
	background: #1d4ed8;
	outline: none;
}

/* قفل اسکرول صفحه وقتی مودال باز است */
body.alfa-modal-open {
	overflow: hidden;
}

/* موبایل */
@media (max-width: 480px) {
	.alfa-session-end-modal {
		padding: 12px;
	}

	.alfa-session-end-modal__panel {
		padding: 24px 16px 16px;
		border-radius: 14px;
	}

	.alfa-session-end-modal__title {
		font-size: 1.2rem;
	}

}

/* ═══════════════════════════════════════════
   Quest CTA Card — rendered after Fantasy step 4
   ═══════════════════════════════════════════ */

.alfa-quest-cta-card {
	margin: 14px 0 0;
	animation: alfa-quest-card-in 0.4s ease-out both;
}

@keyframes alfa-quest-card-in {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

.alfa-quest-cta-card__inner {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
	background: linear-gradient(
		135deg,
		#fdf4ff 0%,
		#fef9ff 50%,
		#fffbeb 100%
	);
	border: 1.5px solid #f0abfc;
	border-radius: 14px;
	box-shadow:
		0 4px 14px rgba(168, 85, 247, 0.12),
		0 2px 6px rgba(251, 191, 36, 0.08);
}

.alfa-quest-cta-card__header {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
}

.alfa-quest-cta-card__tag {
	display: inline-flex;
	align-items: center;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 700;
	color: #7c3aed;
	background: #f3e8ff;
	border-radius: 20px;
	white-space: nowrap;
}

.alfa-quest-cta-card__badge {
	width: 42px;
	height: 42px;
	object-fit: cover;
	border-radius: 10px;
	border: 1.5px solid #f0abfc;
	box-shadow: 0 2px 6px rgba(168, 85, 247, 0.15);
}

.alfa-quest-cta-card__title {
	font-size: 17px;
	font-weight: 800;
	color: #5b21b6;
	margin: 2px 0 0;
	line-height: 1.4;
}

.alfa-quest-cta-card__subtitle {
	font-size: 13px;
	color: #6d28d9;
	opacity: 0.85;
	margin: 0;
	line-height: 1.5;
}

.alfa-quest-cta-card__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 700;
	color: #ffffff;
	background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
	border: none;
	border-radius: 10px;
	text-decoration: none;
	cursor: pointer;
	box-shadow:
		0 3px 10px rgba(124, 58, 237, 0.35),
		inset 0 1px 0 rgba(255, 255, 255, 0.15);
	transition: all 0.2s ease;
	white-space: nowrap;
}

.alfa-quest-cta-card__btn:hover {
	background: linear-gradient(135deg, #b86bfc 0%, #8b5cf6 100%);
	box-shadow:
		0 4px 14px rgba(124, 58, 237, 0.45),
		inset 0 1px 0 rgba(255, 255, 255, 0.2);
	transform: translateY(-1px);
}

.alfa-quest-cta-card__btn:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

/* =========================================
   مورد ۱ و ۲: تغییر رنگ دکمه‌های گشت‌گذار و داستان
   ========================================= */
.alfa-cta-btn.alfa-tour-btn,
.alfa-cta-btn.alfa-cta-quest,
.alfa-cta-btn.alfa-fantasy-btn {
    background-color: #E7B50E !important; /* رنگ سازمانی شما */
    color: #000 !important; /* رنگ تیره برای خوانایی بهتر روی زرد */
    border: none;
    border-radius: 8px; /* نرم کردن گوشه دکمه‌ها */
    transition: all 0.3s ease;
}

.alfa-cta-btn.alfa-tour-btn:hover,
.alfa-cta-btn.alfa-cta-quest:hover,
.alfa-cta-btn.alfa-fantasy-btn:hover {
    background-color: #cda10d !important; /* رنگ کمی تیره‌تر برای هاور */
}
.alfa-cta-btn.alfa-cta-quest {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    max-width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.alfa-cta-btn.alfa-cta-quest:hover,
.alfa-cta-btn.alfa-cta-quest:focus {
    text-decoration: none;
}


/* =========================================
   مورد ۳: استایل باکس متنی (Textarea) چت
   ========================================= */
.alfa-chat-input {
    resize: none; /* جلوگیری از تغییر اندازه دستی توسط کاربر */
    border-radius: 8px;
    padding: 10px 15px;
    font-family: inherit;
    line-height: 1.5;
}

/* =========================================
   مورد ۴: استایل پیام‌های کاربر و مدل (شبیه تلگرام/واتس‌اپ)
   ========================================= */
/* تنظیم کانتینر اصلی پیام‌ها روی حالت فلکس باکس */
.alfa-chat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    box-sizing: border-box;
    width: 100%;
    height: clamp(360px, 58vh, 620px);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(117, 82, 199, .45) rgba(117, 82, 199, .08);
    scrollbar-gutter: stable;
}

.alfa-chat-box::-webkit-scrollbar {
    width: 9px;
}

.alfa-chat-box::-webkit-scrollbar-track {
    background: rgba(117, 82, 199, .08);
    border-radius: 999px;
}

.alfa-chat-box::-webkit-scrollbar-thumb {
    background: rgba(117, 82, 199, .42);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.alfa-chat-box > :last-child {
    scroll-margin-bottom: 12px;
}

@media (max-width: 640px) {
    .alfa-chat-box {
        height: clamp(300px, 54vh, 520px);
        padding: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .alfa-chat-box {
        scroll-behavior: auto;
    }
}

/* استایل مشترک حباب‌های پیام */
.msg-child, .msg-alpha {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 14px;
}

/* پیام کاربر (کودک) - سمت راست */
.msg-child {
    background-color: #E7B50E; /* رنگ پس‌زمینه سازمانی */
    color: #000; /* رنگ متن */
    align-self: flex-start; /* چسبیدن به سمت راست در چینش RTL */
    border-bottom-right-radius: 4px; /* گوشه تیز پیام‌رسان */
}

/* پیام آلفا (مدل/هوش مصنوعی) - سمت چپ */
.msg-alpha {
    background-color: #f0f2f5; /* خاکستری روشن */
    color: #1c1e21; /* متن تیره */
    align-self: flex-end; /* چسبیدن به سمت چپ در چینش RTL */
    border-bottom-left-radius: 4px; /* گوشه تیز پیام‌رسان */
}

/* استایل مدیا داخل حباب چت */
.alfa-chat-media {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 8px; /* فاصله بین مدیا و متن زیرش */
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15); /* یک سایه ملایم برای زیبایی */
}

/* برای اینکه چیدمان عکس و متن داخل حباب مرتب باشد */
.msg-alpha {
    display: flex;
    flex-direction: column;
}

.msg-text {
    line-height: 1.6;
    white-space: pre-line;
}

.quest-cta-wrapper {
    text-align: center;
    margin-top: 15px;
}

.quest-cta-button {
    display: inline-block;
    background: #ff9800; /* نارنجی جذاب */
    color: #fff !important;
    padding: 12px 25px;
    border-radius: 30px;
    text-decoration: none !important;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    transition: transform 0.2s;
}

.quest-cta-button:hover {
    transform: scale(1.05);
    background: #f57c00;
}

/* پایان کودک‌پسند گردشگری؛ فقط برای کارت پایان Adventure */
.adventure-end-card {
    margin: 18px auto 10px;
    padding: 18px 16px 20px;
    max-width: 360px;
    text-align: center;
    direction: rtl;
    background: linear-gradient(145deg, #fff8e8, #fff1cf);
    border: 1px solid rgba(245, 158, 11, .28);
    border-radius: 22px;
    box-shadow: 0 8px 22px rgba(120, 75, 15, .12);
}

.adventure-end-emoji {
    font-size: 30px;
    line-height: 1;
    margin-bottom: 7px;
}

.adventure-end-title {
    color: #75451b;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}

.adventure-end-message {
    color: #6b5a48;
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 13px;
}

.adventure-end-button {
    display: inline-block;
    padding: 11px 18px;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 800;
    box-shadow: 0 5px 13px rgba(245, 158, 11, .28);
    transition: transform .2s ease, background .2s ease;
}

.adventure-end-button:hover,
.adventure-end-button:focus-visible {
    background: #d97706;
    color: #fff !important;
    transform: translateY(-2px);
}

.alfa-chat-media-main {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
    display: block;
}

.alfa-media-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 5px;
}

.alfa-media-icon {
    cursor: pointer;
    font-size: 1.2rem;
    background: #f0f0f0;
    padding: 5px 8px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.alfa-media-icon:hover {
    transform: scale(1.1);
    background: #e0e0e0;
}

/* =========================================================
   Media Player Modal — Layer 100001 (Above Session Modal)
   ========================================================= */
.alfa-media-player-modal[hidden] {
    display: none !important;
}

.alfa-media-player-modal {
    position: fixed;
    inset: 0;
    z-index: 100001; /* یک پله بالاتر از مودال پایان جلسه */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
}

.alfa-media-player-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
}

.alfa-media-player-modal__panel {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 32px 24px 20px;
}

.alfa-media-player-modal__close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alfa-media-player-modal__title {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
}

.alfa-media-player-modal__body {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    align-items: center;
}

.alfa-media-player-modal__body video,
.alfa-media-player-modal__body audio {
    width: 100%;
    display: block;
}

/* موبایل */
@media (max-width: 480px) {
    .alfa-media-player-modal__panel {
        padding: 28px 16px 16px;
    }
}
.alfa-chat-new-session{display:block;margin:10px auto 0;padding:9px 15px;border:1px solid #7552c7;border-radius:12px;background:#fff;color:#5f3fb0;font:inherit;font-weight:800;cursor:pointer}.alfa-chat-new-session:hover{background:#7552c7;color:#fff}.alfa-chat-new-session[hidden]{display:none}
