/* =========================================================
   AMIR CHAT — Dark Blue App Theme
   پالت: مشکی آبی‌ تیره + آبی الکتریک + فیروزه‌ای، افکت شیشه‌ای (Glassmorphism)
   فونت: Vazirmatn
   طراحی به شکل «اپلیکیشن تمام‌صفحه» (نه یک ویجت داخل سایت)
   ========================================================= */

:root {
	--ac-bg: #060911;
	--ac-bg-2: #0a0f1c;
	--ac-surface: #0e1420;
	--ac-surface-2: #131a2a;
	--ac-surface-3: #182238;
	--ac-border: #212c42;
	--ac-primary: #2f6fed;
	--ac-primary-light: #6ea8ff;
	--ac-cyan: #22d3ee;
	--ac-indigo: #7c6cf6;
	--ac-glass: rgba(255, 255, 255, 0.05);
	--ac-glass-border: rgba(255, 255, 255, 0.12);
	--ac-text: #eef3fb;
	--ac-text-dim: #8b96ad;
	--ac-danger: #f26d6d;
	--ac-online: #4ade80;
	--ac-radius: 14px;
	--ac-shadow: 0 20px 60px rgba(0,0,0,.45);
	--ac-font: 'Vazirmatn', Tahoma, sans-serif;
}

html, body { height: 100%; }
.amirchat-root, .amirchat-root * { box-sizing: border-box; }
.amirchat-root {
	font-family: var(--ac-font);
	color: var(--ac-text);
	direction: rtl;
	height: 100dvh;
	width: 100%;
	overflow: hidden;
	background: var(--ac-bg);
}
.amirchat-root button { font-family: var(--ac-font); cursor: pointer; }
.amirchat-root input, .amirchat-root textarea, .amirchat-root select { font-family: var(--ac-font); }

/* ================= صفحه ورود / ثبت‌نام (Glassmorphism + گرادیانت چرخشی) ================= */

.ac-auth-screen {
	position: relative;
	height: 100dvh;
	width: 100%;
	display: flex; align-items: center; justify-content: center;
	overflow: hidden;
	background:
		radial-gradient(circle at 15% 20%, rgba(47,111,237,.22), transparent 45%),
		radial-gradient(circle at 85% 75%, rgba(34,211,238,.14), transparent 45%),
		radial-gradient(circle at 50% 100%, rgba(124,108,246,.12), transparent 50%),
		var(--ac-bg);
	padding: 24px 16px;
}

.ac-mesh-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; opacity: .55; }

.ac-auth-card {
	position: relative; z-index: 2;
	width: 100%; max-width: 400px;
	background: var(--ac-glass);
	border: 1px solid var(--ac-glass-border);
	backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
	border-radius: 22px;
	padding: 34px 30px;
	box-shadow: var(--ac-shadow), inset 0 1px 0 rgba(255,255,255,.05);
	animation: acCardIn .6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes acCardIn { from { opacity:0; transform: translateY(18px) scale(.98);} to { opacity:1; transform: translateY(0) scale(1);} }

.ac-brand { text-align: center; margin-bottom: 20px; }
.ac-brand-logo {
	width: 60px; height: 60px; margin: 0 auto 12px;
	border-radius: 18px;
	background: linear-gradient(135deg, var(--ac-cyan), var(--ac-primary));
	color: #06101f; font-weight: 800; font-size: 27px;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 10px 26px rgba(47,111,237,.45);
}
.ac-brand h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: .3px; background: linear-gradient(90deg, var(--ac-primary-light), var(--ac-cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ac-brand-logo-img { object-fit: cover; background: var(--ac-surface-2); padding: 0; box-shadow: 0 10px 26px rgba(47,111,237,.3); }
.ac-brand p { color: var(--ac-text-dim); font-size: 13px; margin: 0; }

.ac-tabs { display: flex; background: var(--ac-surface-2); border-radius: 999px; padding: 4px; margin-bottom: 20px; border: 1px solid var(--ac-glass-border); }
.ac-tab { flex: 1; background: transparent; border: none; color: var(--ac-text-dim); padding: 9px 0; border-radius: 999px; font-size: 14px; transition: .2s; }
.ac-tab.active { background: linear-gradient(90deg, var(--ac-primary), var(--ac-cyan)); color: #051019; font-weight: 700; }

.ac-form { display: flex; flex-direction: column; gap: 12px; }

.ac-field-group { display: flex; flex-direction: column; gap: 6px; }
.ac-field-label { font-size: 12.5px; color: var(--ac-text-dim); font-weight: 600; padding: 0 2px; }

.ac-field-wrap.ac-field-invalid,
.ac-field-wrap.ac-field-invalid:focus-within {
	background: var(--ac-danger);
	animation: acShake .4s;
}
.ac-field-wrap.ac-field-invalid input { box-shadow: none; }
@keyframes acShake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-4px); }
	40%, 60% { transform: translateX(4px); }
}

.ac-field-wrap {
	/* حاشیه‌ی گرادیانت چرخشی ۶ رنگ دور کادر (دقیقا مشابه تکنیک AMIR PANEL):
	   با چرخاندن خودِ زاویه‌ی conic-gradient (نه چرخاندن کل المان)، رنگ‌ها دقیقا
	   دور قاب مستطیلی/گردشده می‌چرخند و هیچ لکه یا دایره‌ی اضافه‌ای دیده نمی‌شود. */
	--ac-angle: 0deg;
	position: relative;
	padding: 1.6px;
	border-radius: 12px;
	background: rgba(255,255,255,.14);
	transition: background .2s;
}
@property --ac-angle {
	syntax: '<angle>';
	initial-value: 0deg;
	inherits: false;
}
@keyframes acBorderSpin { to { --ac-angle: 360deg; } }
.ac-field-wrap:focus-within {
	background: conic-gradient(from var(--ac-angle),
		var(--ac-fg1, #22d3ee), var(--ac-fg2, #2f6fed), var(--ac-fg3, #7c6cf6),
		var(--ac-fg4, #a855f7), var(--ac-fg5, #ec4899), var(--ac-fg6, #38bdf8), var(--ac-fg1, #22d3ee));
	animation: acBorderSpin var(--ac-border-speed, 3.5s) linear infinite;
}
@media (prefers-reduced-motion: reduce) {
	.ac-field-wrap:focus-within { animation: none; --ac-angle: 45deg; }
}
.ac-form input, .ac-form textarea, .ac-field-wrap input {
	position: relative; z-index: 1;
	width: 100%;
	background: var(--ac-surface-2); border: none; color: var(--ac-text);
	padding: 12px 14px; border-radius: 10.5px; font-size: 14px; outline: none;
}

.ac-btn-primary {
	display: block;
	width: 100%;
	box-sizing: border-box;
	background: linear-gradient(135deg, var(--ac-cyan), var(--ac-primary));
	color: #051019; border: none; padding: 12px 0; border-radius: 12px;
	font-weight: 700; font-size: 14px; margin-top: 4px; transition: transform .15s, box-shadow .15s;
	white-space: nowrap;
}
.ac-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47,111,237,.35); }
.ac-btn-small {
	background: var(--ac-surface-3); color: var(--ac-primary-light); border: 1px solid var(--ac-glass-border);
	padding: 9px 14px; border-radius: 8px; font-size: 13px;
}
.ac-form-error { color: var(--ac-danger); font-size: 13px; min-height: 16px; line-height: 1.6; }
.ac-form-error:not(:empty) { background: rgba(242,109,109,.12); border: 1px solid rgba(242,109,109,.35); padding: 8px 12px; border-radius: 10px; margin-top: 2px; }

.ac-verify-block { margin-bottom: 14px; }
.ac-verify-block label { display: block; font-size: 13px; color: var(--ac-text-dim); margin-bottom: 6px; }
.ac-verify-row { display: flex; gap: 8px; align-items: stretch; }
.ac-verify-row .ac-field-wrap-code { flex: 1; }
.ac-verify-row .ac-field-wrap-code input { text-align: center; letter-spacing: 6px; font-size: 16px; font-weight: 700; }

.ac-btn-large {
	font-size: 16px; padding: 15px 0; border-radius: 14px; margin-top: 10px;
	box-shadow: 0 12px 30px rgba(47,111,237,.4), inset 0 1px 0 rgba(255,255,255,.15);
	letter-spacing: .3px;
}
.ac-btn-large:hover { box-shadow: 0 16px 36px rgba(47,111,237,.55); }
.ac-resend-link { background: none; border: none; color: var(--ac-primary-light); font-size: 12px; margin-top: 6px; padding: 0; text-decoration: underline; }

.ac-install-hint { position: relative; z-index: 2; margin-top: 16px; text-align: center; }
.ac-install-btn {
	display: inline-flex; align-items: center; gap: 6px; background: var(--ac-glass); border: 1px solid var(--ac-glass-border);
	color: var(--ac-primary-light); font-size: 12.5px; padding: 8px 16px; border-radius: 999px; backdrop-filter: blur(10px);
}

/* ================= اپلیکیشن اصلی (تمام‌صفحه) ================= */

.ac-app { display: flex; height: 100dvh; width: 100%; background: var(--ac-bg); }

.ac-sidebar { width: 340px; min-width: 300px; background: var(--ac-surface); border-left: 1px solid var(--ac-border); display: flex; flex-direction: column; }
.ac-sidebar-header { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--ac-border); position: relative; }
.ac-sidebar-header h2 { font-size: 16px; flex: 1; margin: 0; background: linear-gradient(90deg, var(--ac-primary-light), var(--ac-cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ac-header-actions { display: flex; gap: 4px; }
.ac-icon-btn { background: var(--ac-surface-2); border: 1px solid var(--ac-border); color: var(--ac-text); width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; transition: .15s; }
.ac-icon-btn:hover { border-color: var(--ac-primary); color: var(--ac-primary-light); }

.ac-avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--ac-surface-3); flex-shrink: 0; }

.ac-menu-dropdown {
	position: absolute; top: 58px; left: 16px; z-index: 20; display: none; flex-direction: column;
	background: var(--ac-surface-3); border: 1px solid var(--ac-border); border-radius: 12px; overflow: hidden;
	box-shadow: var(--ac-shadow); min-width: 210px;
}
.ac-menu-dropdown.open { display: flex; }
.ac-menu-dropdown button { background: transparent; border: none; color: var(--ac-text); text-align: right; padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--ac-border); }
.ac-menu-dropdown button:last-child { border-bottom: none; }
.ac-menu-dropdown button:hover { background: var(--ac-surface-2); color: var(--ac-primary-light); }

.ac-search-box { padding: 10px 14px; }
.ac-search-box input { width: 100%; background: var(--ac-surface-2); border: 1px solid var(--ac-border); color: var(--ac-text); padding: 9px 12px; border-radius: 10px; font-size: 13px; outline: none; }
.ac-search-box input:focus { border-color: var(--ac-primary); }
.ac-search-results { max-height: 160px; overflow-y: auto; padding: 0 8px; }
.ac-search-results:empty { display: none; }

.ac-conversation-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.ac-conv-item, .ac-search-result-item {
	display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; transition: background .15s;
}
.ac-conv-item:hover, .ac-search-result-item:hover { background: var(--ac-surface-2); }
.ac-conv-item.active { background: var(--ac-surface-3); box-shadow: inset 2px 0 0 var(--ac-primary); }
.ac-conv-meta { flex: 1; min-width: 0; }
.ac-conv-title-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ac-conv-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-conv-time { font-size: 11px; color: var(--ac-text-dim); flex-shrink: 0; }
.ac-conv-last { font-size: 12.5px; color: var(--ac-text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ac-conv-badge { font-size: 10px; background: var(--ac-surface-3); color: var(--ac-primary-light); padding: 1px 7px; border-radius: 20px; margin-inline-start: 4px; }

.ac-chat-window { flex: 1; display: flex; flex-direction: column; background: var(--ac-bg-2); position: relative; }
.ac-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ac-text-dim); gap: 8px; }
.ac-empty-logo { font-size: 42px; opacity: .5; }

.ac-chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ac-chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--ac-border); background: var(--ac-surface); }
.ac-chat-header-info { flex: 1; min-width: 0; }
.ac-chat-title { font-size: 14.5px; font-weight: 700; }
.ac-chat-subtitle { font-size: 12px; color: var(--ac-text-dim); }

.ac-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.ac-msg-row { display: flex; gap: 8px; max-width: 72%; }
.ac-msg-row.mine { align-self: flex-start; flex-direction: row-reverse; }
.ac-msg-row.theirs { align-self: flex-end; }
.ac-bubble { padding: 10px 14px; border-radius: var(--ac-radius); font-size: 14px; line-height: 1.7; position: relative; word-break: break-word; }
.ac-msg-row.mine .ac-bubble { background: linear-gradient(135deg, #163a72, #0f2650); border: 1px solid rgba(47,111,237,.5); border-bottom-left-radius: 4px; }
.ac-msg-row.theirs .ac-bubble { background: var(--ac-surface-2); border: 1px solid var(--ac-border); border-bottom-right-radius: 4px; }
.ac-bubble-sender { font-size: 11.5px; color: var(--ac-cyan); font-weight: 700; margin-bottom: 3px; }
.ac-bubble-time { font-size: 10px; color: var(--ac-text-dim); margin-top: 4px; text-align: left; }
.ac-bubble img.ac-msg-image { max-width: 260px; border-radius: 10px; display: block; margin-top: 4px; }
.ac-bubble video.ac-msg-video { max-width: 260px; border-radius: 10px; display: block; margin-top: 4px; }
.ac-msg-file { display: flex; align-items: center; gap: 8px; background: var(--ac-surface-3); padding: 8px 10px; border-radius: 8px; margin-top: 4px; text-decoration: none; color: var(--ac-text); }
.ac-msg-location { display: block; margin-top: 4px; color: var(--ac-primary-light); text-decoration: none; font-size: 13px; }

.ac-typing-indicator { padding: 0 20px 6px; font-size: 12px; color: var(--ac-cyan); }

.ac-send-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--ac-border); background: var(--ac-surface); }
.ac-send-form textarea { flex: 1; resize: none; max-height: 120px; background: var(--ac-surface-2); border: 1px solid var(--ac-border); color: var(--ac-text); border-radius: 12px; padding: 10px 14px; font-size: 14px; outline: none; }
.ac-send-form textarea:focus { border-color: var(--ac-primary); }
.ac-send-btn { width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0; background: linear-gradient(135deg, var(--ac-cyan), var(--ac-primary)); color: #051019; font-size: 16px; }

/* ---------------- مودال‌ها ---------------- */
.ac-modal-overlay { position: fixed; inset: 0; background: rgba(2,4,10,.65); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 999; }
.ac-modal { background: var(--ac-surface); border: 1px solid var(--ac-glass-border); border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto; box-shadow: var(--ac-shadow); }
.ac-modal h3 { margin-top: 0; background: linear-gradient(90deg, var(--ac-primary-light), var(--ac-cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ac-modal .ac-form input, .ac-modal .ac-form textarea { margin-bottom: 0; }
.ac-modal-close { float: left; background: none; border: none; color: var(--ac-text-dim); font-size: 18px; }
.ac-agent-item, .ac-bot-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.ac-agent-item:hover, .ac-bot-item:hover { background: var(--ac-surface-2); }

/* ---------------- ریسپانسیو موبایل (اپ تمام‌صفحه) ---------------- */
@media (max-width: 780px) {
	.ac-sidebar { position: absolute; inset: 0; width: 100%; z-index: 5; transition: transform .25s; }
	.ac-sidebar.hide-on-mobile { transform: translateX(-100%); }
	.ac-chat-window { width: 100%; }
	.ac-msg-row { max-width: 88%; }
	.ac-back-btn { display: inline-flex !important; }
}
.ac-back-btn { display: none; }

/* اسکرول‌بار سفارشی */
.amirchat-root ::-webkit-scrollbar { width: 8px; }
.amirchat-root ::-webkit-scrollbar-thumb { background: var(--ac-surface-3); border-radius: 10px; }
.amirchat-root ::-webkit-scrollbar-track { background: transparent; }
