/* ============================================================
   دستیار راهکاران — تم «شب آئورا» (تیره)
   ------------------------------------------------------------
   هویت دوتایی:
     • کاربر  = نارنجی برند راهکاران (#FF8F00 → #ED6C02)
     • دستیار = گرادیان الکتریکی بنفش → سرخابی → فیروزه‌ای
               (#818CF8 → #C084FC → #22D3EE)
   پس‌زمینه: سرمه‌ای عمیق #0A0F1E + هاله‌های آئورای متحرک
   ============================================================ */
@font-face {
    font-family: 'IRANSansX';
    src: url('../font/IRANSansXFaNum-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    src: url('../font/IRANSansXFaNum-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    src: url('../font/IRANSansXFaNum-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    /* ── پس‌زمینه و سطوح ── */
    --bg-base: #0A0F1E;                       /* عمیق‌ترین لایه */
    --glass: rgba(255, 255, 255, 0.045);      /* کارت شیشه‌ای */
    --glass-strong: rgba(19, 26, 48, 0.86);   /* سطوح نیازمند خوانایی */
    --glass-border: rgba(148, 163, 184, 0.16);
    --bg-hover: rgba(255, 255, 255, 0.075);
    --bg-active: rgba(255, 255, 255, 0.11);

    /* ── متن ── */
    --text-primary: #E8EDFA;
    --text-secondary: #A8B2CC;
    --text-tertiary: #7B86A6;
    --text-on-color: #FFFFFF;
    --text-link: #9CC3FD;

    /* ── هویت دستیار (هوش مصنوعی) ── */
    --ai-a: #818CF8;   /* بنفش ایندیگو */
    --ai-b: #C084FC;   /* سرخابی روشن */
    --ai-c: #22D3EE;   /* فیروزه‌ای */
    --ai-gradient: linear-gradient(135deg, #818CF8 0%, #C084FC 55%, #22D3EE 120%);
    --ai-soft: rgba(129, 140, 248, 0.14);
    --ai-glow: 0 0 0 1px rgba(192, 132, 252, 0.35), 0 4px 22px -4px rgba(129, 140, 248, 0.55);

    /* ── هویت کاربر (برند راهکاران) ── */
    --primary: #FF8F00;
    --primary-hover: #FFA733;
    --user-gradient: linear-gradient(135deg, #FF8F00 0%, #ED6C02 100%);
    --user-glow: 0 4px 20px -6px rgba(255, 143, 0, 0.5);

    /* ── وضعیت ── */
    --success-main: #34D399;
    --success-text: #6EE7B7;
    --success-soft: rgba(52, 211, 153, 0.12);
    --error-main: #F87171;
    --error-text: #FCA5A5;
    --error-soft: rgba(248, 113, 113, 0.12);
    --warning-main: #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.10);

    /* ── شعاع و سایه ── */
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -12px rgba(0, 0, 0, 0.45);
    --shadow-focus: 0 0 0 3px rgba(129, 140, 248, 0.28);

    /* کد */
    --code-bg: #0B1220;
    --code-border: rgba(148, 163, 184, 0.14);
    --code-text: #CBD5E1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: 'IRANSansX', 'Segoe UI', Tahoma, sans-serif;
    font-weight: 400;
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ─────────── هاله آئورا (پس‌زمینه متحرک) ─────────── */
body::before {
    content: '';
    position: fixed;
    inset: -25%;
    z-index: -1;
    background:
        radial-gradient(42% 36% at 80% 8%,  rgba(99, 102, 241, 0.20), transparent 62%),
        radial-gradient(34% 30% at 6%  28%, rgba(192, 132, 252, 0.13), transparent 62%),
        radial-gradient(46% 38% at 55% 110%, rgba(34, 211, 238, 0.11), transparent 62%),
        radial-gradient(26% 22% at 88% 80%, rgba(255, 143, 0, 0.07), transparent 60%);
    animation: aurora 30s ease-in-out infinite alternate;
    will-change: transform;
    pointer-events: none;
}
@keyframes aurora {
    0%   { transform: translate3d(-1.5%, -1%, 0) scale(1); }
    50%  { transform: translate3d(1.5%, 1.2%, 0) scale(1.06); }
    100% { transform: translate3d(-1%, 1.8%, 0) scale(1.03); }
}

::selection { background: rgba(129, 140, 248, 0.4); color: #fff; }

/* اسکرول‌بار تیره */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.35) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.28); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }
::-webkit-scrollbar-track { background: transparent; }

/* ─────────── متن گرادیانی ─────────── */
.g-text {
    background: var(--ai-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ─────────── فیلدهای ورودی ─────────── */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: #5A6480; }
.input:focus {
    border-color: rgba(129, 140, 248, 0.65);
    box-shadow: var(--shadow-focus);
    background: rgba(255, 255, 255, 0.07);
}
select.input option { background: #141B33; color: var(--text-primary); }

/* ─────────── دکمه‌ها ─────────── */
.btn {
    height: 44px;
    padding: 0 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--user-gradient);
    color: #fff;
    box-shadow: var(--user-glow);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; filter: none; }

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-color: var(--glass-border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger-ghost { background: transparent; color: var(--error-main); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--error-soft); }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-md); }

/* ─────────── کارت ─────────── */
.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ─────────── صفحه ورود ─────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 404px;
    padding: 40px 34px 30px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}
/* خط گرادیانی بالای کارت ورود */
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--ai-gradient);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
    margin-bottom: 10px;
}
.login-title { text-align: center; font-size: 19px; font-weight: 700; margin: 0; }
.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12.5px;
    margin: 6px 0 26px;
}
.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 11.5px;
}
.login-footer b { color: var(--text-secondary); font-weight: 500; }
.login-error {
    display: none;
    background: var(--error-soft);
    color: var(--error-text);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}
.login-error.show { display: block; }
.login-tabs {
    display: flex;
    gap: 24px;
    justify-content: center;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 24px;
}
.login-tabs .tab { padding-bottom: 10px; color: var(--text-tertiary); font-size: 14px; cursor: default; }
.login-tabs .tab.active { color: var(--ai-a); font-weight: 500; border-bottom: 2px solid var(--ai-a); }

.login-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--text-secondary);
    background: var(--ai-soft);
    border: 1px solid rgba(129, 140, 248, 0.22);
    border-radius: 999px;
    padding: 5px 14px;
    margin-bottom: 22px;
    width: fit-content;
    margin-inline: auto;
}
.login-timer .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success-main);
    box-shadow: 0 0 10px var(--success-main);
    animation: pulse 1.8s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ─────────── لوگو/اورب گرادیانی دستیار ─────────── */
.logo-badge {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--ai-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 700;
    box-shadow: var(--ai-glow);
    flex-shrink: 0;
    position: relative;
}
.logo-badge::after {   /* بازتاب ظریف */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.28), transparent 42%);
    pointer-events: none;
}

/* ─────────── چیدمان اصلی چت ─────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}
.chat-header {
    height: 62px;
    background: rgba(13, 18, 36, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 22px;
    gap: 13px;
    flex-shrink: 0;
}
.chat-header .logo-badge {
    width: 36px; height: 36px;
    border-radius: 12px;
    font-size: 16px;
    box-shadow: none;
}
.chat-header h1 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: 0; }
.chat-header .sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }

/* نشان «آنلاین — هوش مصنوعی فعال» */
.status-pill {
    margin-inline-start: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 4px 13px;
    white-space: nowrap;
}
.status-pill .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success-main);
    box-shadow: 0 0 8px var(--success-main);
    animation: pulse 2s infinite;
}
.status-pill b { color: var(--success-text); font-weight: 500; }

/* ─────────── ناحیه گفتگو ─────────── */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── ردیف پیام: هر .msg یک ردیف افقی تمام‌عرض است ──
   (سوختن در RTL: ردیف افقی، main-start = راست فیزیکی)
   کاربر → راست، دستیار → چپ */
.msg { display: flex; width: 100%; gap: 10px; }

/* پیام کاربر (راست / نارنجی برند) */
.msg.user { justify-content: flex-start; }
.msg.user .bubble {
    background: var(--user-gradient);
    color: #fff;
    border-bottom-left-radius: 6px;
    box-shadow: var(--user-glow);
    max-width: 78%;
}
.msg.user .bubble a { color: #FFE9CC; }

/* پیام دستیار (چپ / اورب + ستون شیشه‌ای) */
.msg.agent { justify-content: flex-end; align-items: flex-end; }
/* اورب آخرین فرزند DOM است → در RTL سمت چپ می‌نشیند */
.ai-orb {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ai-gradient);
    flex-shrink: 0;
    position: relative;
    box-shadow: var(--ai-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.ai-orb::before {   /* برق مرکزی */
    content: '';
    width: 9px; height: 9px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
}
/* حلقه چرخان هنگام فکرکردن */
.msg.agent.thinking .ai-orb::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 2px;
    background: conic-gradient(from 0deg, #22D3EE, #818CF8, #C084FC, #22D3EE);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin 1.6s linear infinite;
}
.msg.agent.thinking .ai-orb {
    animation: orb-breathe 1.6s ease-in-out infinite;
}
@keyframes orb-breathe {
    0%, 100% { box-shadow: var(--ai-glow); }
    50% { box-shadow: 0 0 0 1px rgba(192, 132, 252, 0.5), 0 0 34px -2px rgba(129, 140, 248, 0.85); }
}

/* ستون محتوای پیام دستیار (بدون grow — اندازه طبیعی تا ۸۸٪ عرض) */
.acol {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    flex: 0 1 auto;
    max-width: 88%;
}
.msg.agent .bubble { width: fit-content; min-width: 120px; }
.msg.agent .acol > .tool-feed, .msg.agent .acol > .rdl-card { width: 100%; }
.tb-scroll { overflow-x: auto; margin: 2px 0; }
.msg.agent .bubble {
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--glass-border);
    border-bottom-right-radius: 6px;
    width: fit-content;
    max-width: 100%;
    box-shadow: 0 6px 24px -14px rgba(0, 0, 0, 0.6);
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.9;
    word-break: break-word;
    white-space: pre-wrap;
}
.bubble:empty { display: none; }   /* کارت RDL بدون حباب متن */

/* مکان‌نمای چشمک‌زن هنگام استریم */
.bubble.streaming::after {
    content: '▍';
    color: var(--ai-c);
    display: inline-block;
    animation: blink 0.9s steps(1) infinite;
    margin-inline-start: 1px;
    text-shadow: 0 0 8px var(--ai-c);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* نقطه‌چین‌های اولیه «در حال فکر کردن» */
.typing-dots { display: inline-flex; gap: 5px; padding: 5px 3px; align-items: center; }
.typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-a), var(--ai-b));
    opacity: .85;
    animation: bounce 1.3s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* ─────────── محتوای مارک‌داون داخل حباب ─────────── */
.bubble table {
    border-collapse: collapse;
    margin: 10px 0 4px;
    font-size: 12.5px;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.bubble th, .bubble td {
    border: 1px solid rgba(148, 163, 184, 0.22);
    padding: 6px 12px;
    text-align: right;
}
.bubble th {
    background: rgba(129, 140, 248, 0.16);
    color: #DDE2F5;
    font-weight: 500;
}
.bubble tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }
.bubble pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    color: var(--code-text);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.65;
}
.bubble code { font-family: 'Consolas', 'Courier New', monospace; }
.bubble :not(pre) > code {
    background: rgba(129, 140, 248, 0.18);
    border: 1px solid rgba(129, 140, 248, 0.25);
    color: #C9D6FF;
    border-radius: 6px;
    padding: 1px 7px;
    font-size: 12.5px;
    direction: ltr;
    unicode-bidi: isolate;
}
.bubble a { color: var(--text-link); }
.bubble h4 { margin: 10px 0 4px; font-size: 14.5px; color: #F1F4FD; }
.bubble strong { color: #F5F7FF; }

/* نوار اکشن پیام (کپی + ساعت) */
.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity .18s;
    min-height: 21px;
    font-size: 11px;
}
.msg.agent:hover .msg-meta,
.msg.agent .bubble.streaming ~ .msg-meta { opacity: 1; }
.msg-time { color: var(--text-tertiary); font-size: 10.5px; direction: ltr; unicode-bidi: plaintext; }
.msg-meta:empty { display: none; }
.btn-copy {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 9px;
    border-radius: 999px;
    transition: background .12s, color .12s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-copy:hover { background: var(--bg-hover); color: var(--ai-a); }
.btn-copy.ok { color: var(--success-main); }

/* ─────────── چیپ فعالیت ابزارها ─────────── */
.tool-feed {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.028);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 8px;
    width: 100%;
}
.tool-row {
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    transition: border-color .2s, background .2s;
    position: relative;
}
.tool-row.running {
    border-color: rgba(129, 140, 248, 0.4);
    background: rgba(129, 140, 248, 0.07);
}
/* نوار پیشرفت ظریف ابزار در حال اجرا */
.tool-row.running::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ai-a), var(--ai-b), var(--ai-c), var(--ai-a));
    background-size: 250% 100%;
    animation: slide 1.8s linear infinite;
}
@keyframes slide { from { background-position: 0 0; } to { background-position: 250% 0; } }

.tool-row.done { background: rgba(52, 211, 153, 0.05); border-color: rgba(52, 211, 153, 0.16); }
.tool-row.err { background: var(--error-soft); border-color: rgba(248, 113, 113, 0.4); }

.tool-details > summary { list-style: none; cursor: pointer; }
.tool-details > summary::-webkit-details-marker { display: none; }

.tool-summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    font-size: 12.5px;
    user-select: none;
}
.tool-summary .t-icon {
    width: 24px; height: 24px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    flex-shrink: 0;
}
.tool-row.running .t-icon { background: var(--ai-soft); }
.tool-row.done .t-icon { background: var(--success-soft); }
.tool-summary .t-label {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.tool-row.running .t-label { color: #C7CEF5; }
.tool-summary .t-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 15px;
}
.tool-ok {
    color: var(--success-main);
    font-weight: 700;
    animation: pop-in .3s cubic-bezier(.2, 1.6, .4, 1);
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.7);
}
.tool-no { color: var(--error-main); font-weight: 700; }
@keyframes pop-in { from { transform: scale(0); opacity: 0; } }

.tool-body { padding: 2px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.tool-sec { display: flex; flex-direction: column; gap: 4px; }
.tool-sec-h { font-size: 11px; color: var(--text-tertiary); font-weight: 500; }
.tool-input, .tool-result {
    margin: 0;
    padding: 9px 11px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
    max-height: 220px;
    overflow-y: auto;
}
.tool-input {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    color: var(--code-text);
}
.tool-result {
    background: var(--success-soft);
    border: 1px solid rgba(52, 211, 153, 0.25);
    color: var(--success-text);
}
.tool-row.err .tool-result {
    background: var(--error-soft);
    border-color: rgba(248, 113, 113, 0.35);
    color: var(--error-text);
}

.spinner {
    width: 13px; height: 13px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top-color: var(--ai-a);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── نشان پاسخ از حافظه ─────────── */
.cache-note {
    align-self: flex-start;
    font-size: 10.5px;
    color: var(--warning-main);
    background: var(--warning-soft);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 999px;
    padding: 2px 11px;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ─────────── کارت دانلود RDL ─────────── */
.rdl-card {
    align-self: flex-start;
    background: var(--success-soft);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: var(--radius-lg);
    padding: 11px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 88%;
    box-shadow: 0 0 24px -14px rgba(52, 211, 153, 0.5);
}
.rdl-card .icon { font-size: 19px; }
.rdl-card .t { color: var(--success-text); font-size: 13px; font-weight: 500; }
.rdl-card .s { color: var(--text-tertiary); font-size: 11.5px; }
.rdl-card .btn {
    background: linear-gradient(135deg, #34D399, #10B981);
    color: #052E1F;
    font-weight: 700;
    box-shadow: none;
}

/* ─────────── صفحه خوش‌آمد ─────────── */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 20px 40px;
    animation: fade-up .5s ease both;
    min-height: 100%;
}
.welcome .orb {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: var(--ai-gradient);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ai-glow);
    animation: orb-float 5s ease-in-out infinite;
}
.welcome .orb::before {
    content: '';
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 26px rgba(255, 255, 255, 0.95);
    animation: core-pulse 2.6s ease-in-out infinite;
}
/* حلقه گرادیانی دور اورب */
.welcome .orb::after {
    content: '';
    position: absolute;
    inset: -9px;
    border-radius: 50%;
    padding: 1.5px;
    background: conic-gradient(from 0deg, transparent 10%, #22D3EE 28%, #818CF8 45%, #C084FC 65%, transparent 82%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin 5s linear infinite;
}
@keyframes orb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes core-pulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }

.welcome h2 {
    font-size: 21px;
    font-weight: 700;
    margin: 18px 0 2px;
}
.welcome .w-sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 8px; text-align: center; max-width: 520px; }
.welcome .w-acc { font-size: 12px; color: var(--text-tertiary); }

/* کارت‌های توانمندی */
.wcap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 780px;
    margin-top: 22px;
}
.wcap {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 16px 18px 14px;
    cursor: pointer;
    transition: border-color .18s, background .18s, transform .18s, box-shadow .18s;
    text-align: right;
    animation: fade-up .5s ease both;
}
.wcap:hover {
    border-color: rgba(129, 140, 248, 0.5);
    background: rgba(129, 140, 248, 0.07);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px -18px rgba(129, 140, 248, 0.5);
}
.wcap .wcap-ic {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 10px;
    background: var(--ai-soft);
    border: 1px solid rgba(129, 140, 248, 0.2);
}
.wcap:nth-child(2n) .wcap-ic { background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.22); }
.wcap:nth-child(3n) .wcap-ic { background: rgba(251, 191, 36, 0.10); border-color: rgba(251, 191, 36, 0.2); }
.wcap:nth-child(4n) .wcap-ic { background: rgba(52, 211, 153, 0.10); border-color: rgba(52, 211, 153, 0.22); }
.wcap .wcap-t { font-size: 13.5px; font-weight: 500; margin: 0 0 3px; }
.wcap .wcap-d { font-size: 11.5px; color: var(--text-tertiary); margin: 0 0 10px; line-height: 1.7; }
.wcap .wcap-ex {
    display: block;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 11px;
    width: fit-content;
    margin-top: 5px;
    cursor: pointer;
    font-family: inherit;
    transition: color .12s, border-color .12s, background .12s;
}
.wcap .wcap-ex:hover {
    color: #D8DFF8;
    border-color: rgba(129, 140, 248, 0.35);
    background: rgba(129, 140, 248, 0.1);
}

/* ─────────── نوار ورودی پیام ─────────── */
.composer {
    background: rgba(13, 18, 36, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
    padding: 13px 20px 15px;
}
.composer-inner {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    gap: 9px;
    align-items: flex-end;
}
.composer textarea {
    flex: 1;
    min-height: 46px;
    max-height: 150px;
    resize: none;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    outline: none;
    background: rgba(255, 255, 255, 0.055);
    color: var(--text-primary);
    transition: border-color .15s, box-shadow .15s, background .15s;
    line-height: 1.7;
}
.composer textarea::placeholder { color: #5A6480; }
.composer textarea:focus {
    border-color: rgba(129, 140, 248, 0.6);
    box-shadow: var(--shadow-focus);
    background: rgba(255, 255, 255, 0.075);
}
.composer textarea:disabled { opacity: .65; }
.composer .btn { border-radius: 14px; height: 46px; }
.composer .btn:disabled { opacity: .5; }
.composer-hint {
    max-width: 880px;
    margin: 9px auto 0;
    font-size: 10.5px;
    color: var(--text-tertiary);
    text-align: center;
}

/* چیپ‌های سوال سریع */
.chips {
    max-width: 880px;
    margin: 0 auto 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 5px 15px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .12s, color .12s, background .12s;
}
.chip:hover {
    border-color: rgba(192, 132, 252, 0.55);
    color: #E2D6FF;
    background: rgba(192, 132, 252, 0.1);
}

/* ─────────── سایدبار ─────────── */
.sidebar {
    width: 264px;
    background: rgba(13, 18, 36, 0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-inline-start: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-profile {
    padding: 22px 18px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255, 143, 0, 0.16);
    border: 1px solid rgba(255, 143, 0, 0.35);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.sidebar-profile .name { font-weight: 500; font-size: 14px; color: var(--text-primary); }
.sidebar-profile .role { font-size: 11px; color: var(--text-tertiary); }
.sidebar-section {
    padding: 16px 18px 6px;
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, color .12s;
    border: none;
    background: transparent;
    width: 100%;
    font-family: inherit;
    text-align: right;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
    background: rgba(255, 143, 0, 0.13);
    border: 1px solid rgba(255, 143, 0, 0.22);
    color: #FFC46B;
    font-weight: 500;
}
.nav-item .ic { font-size: 15px; }
.nav-item .cnt {
    margin-inline-start: auto;
    background: rgba(255, 143, 0, 0.16);
    color: #FFC46B;
    border-radius: 999px;
    font-size: 10.5px;
    padding: 1px 8px;
}
.sidebar-bottom { padding: 10px; border-top: 1px solid var(--glass-border); }

/* گزارش‌ها در سایدبار */
.report-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .12s, color .12s;
}
.report-item:hover { background: var(--bg-hover); color: var(--primary); }
.report-item .rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-empty { color: var(--text-tertiary); font-size: 12px; padding: 8px 12px; }

/* ─────────── بلوک خطای پاسخ ─────────── */
.agent-err {
    background: var(--error-soft);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: var(--error-text);
    border-radius: var(--radius-md);
    padding: 9px 13px;
    font-size: 12.5px;
    white-space: pre-wrap;
    word-break: break-word;
    width: fit-content;
    max-width: 100%;
}

/* ─────────── چیپ‌های پیوست ─────────── */
.attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 880px;
    margin: 0 auto 8px;
}
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 3px 6px 3px 13px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 320px;
}
.attach-chip .ic { font-size: 13px; }
.attach-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; unicode-bidi: plaintext; }
.attach-chip .sz { color: var(--text-tertiary); font-size: 10.5px; direction: ltr; flex-shrink: 0; }
.attach-chip .x {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 15px;
    line-height: 1;
    padding: 0 3px;
    flex-shrink: 0;
}
.attach-chip .x:hover { color: var(--error-main); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .msg.user { max-width: 92%; }
    .msg.agent { max-width: 96%; }
    .rdl-card { max-width: 96%; }
    .wcap-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .wcap-grid { grid-template-columns: 1fr; }
    .status-pill b { display: none; }
    .messages { padding: 18px 14px 12px; }
}

/* دسترس‌پذیری: کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
    body::before, .welcome .orb, .welcome .orb::after, .welcome .orb::before,
    .ai-orb, .msg.agent.thinking .ai-orb, .msg.agent.thinking .ai-orb::after,
    .bubble.streaming::after, .tool-row.running::before { animation: none !important; }
}

/* ═══════════════ صفحات مدیریت (admin) ═══════════════ */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page-main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 26px 20px 70px;
}
.page-main .card {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(8px);
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 22px;
}
.tabs .tab {
    padding: 10px 18px;
    font-family: inherit;
    font-size: 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .12s, border-color .12s;
}
.tabs .tab:hover { color: var(--text-primary); }
.tabs .tab.active { color: var(--ai-a); font-weight: 500; border-bottom-color: var(--ai-a); }

/* جدول */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: right;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    vertical-align: middle;
}
.table tr:hover td { background: rgba(255, 255, 255, 0.035); }
.table .actions { display: flex; gap: 6px; white-space: nowrap; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}
.badge-admin { background: var(--warning-soft); color: var(--warning-main); }
.badge-user { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }
.badge-active { background: var(--success-soft); color: var(--success-text); }
.badge-inactive { background: var(--error-soft); color: var(--error-text); }

/* مودال */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 16, 0.66);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
    width: 100%;
    max-width: 420px;
    background: #141B33;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
    animation: fade-up .2s ease both;
}
.modal h3 { margin: 0 0 16px; font-size: 15px; }
.modal .field { margin-bottom: 14px; }

/* توست */
.toast-wrap {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
}
.toast {
    background: #1B2440;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 11px 17px;
    font-size: 13px;
    box-shadow: var(--shadow-card);
    animation: toast-in .2s ease;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.45); color: var(--success-text); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); color: var(--error-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* فعالیت کاربر */
.activity-toolbar { margin-bottom: 16px; }
.activity-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.msg-row {
    display: flex;
    gap: 12px;
    font-size: 13px;
}
.msg-row .who { flex-shrink: 0; width: 46px; text-align: center; }
.msg-row .who .av {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.msg-row.user .who .av { background: var(--user-gradient); color: #fff; }
.msg-row.agent .who .av { background: var(--ai-gradient); color: #fff; }
.msg-row .body {
    flex: 1;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-row .meta { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.audit-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
    font-size: 12.5px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
}
.audit-row .at { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; direction: ltr; }
.audit-row .act {
    font-weight: 500;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 1px 8px;
    white-space: nowrap;
}
.audit-row .act.fail { background: var(--error-soft); color: var(--error-text); }
.audit-row .det {
    color: var(--text-secondary);
    direction: ltr;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    unicode-bidi: plaintext;
}
.audit-row .det[title]:hover { overflow: visible; white-space: normal; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.form-grid .field { margin-bottom: 0; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
