/* ══════════════════════════════════════════════════════════════
   صفحه‌ی چت‌بات پشتیبانی IT بیمکس — پورت از تمپلیت Django
   (bimax-src/.../chat/templates/chat/chat.html) به PHP
   تفاوت‌ها: مودال ایمیل سازمانی حذف شده (چت مهمان/ناشناس)،
   بنر اختلال با دکمه‌ی بستن (JS آن را نشون می‌ده)، آدرس فونت‌ها
   به /assets-bimax/fonts تغییر کرده.
   ══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   رنگ‌ها و اندازه‌ها — همه‌ی ظاهر از همین متغیرها میاد
   ══════════════════════════════════════════════════════════════ */
:root {
    --bg:            #0b0d0f;
    --panel:         #111417;
    --surface:       #161a1e;
    --surface-2:     #1c2126;
    --surface-3:     #232930;
    --border:        #22282e;
    --border-strong: #2e363e;
    --text:          #e6eaee;
    --text-2:        #aab3bc;
    --muted:         #7d8791;
    --faint:         #58616b;
    --accent:        #00d47c;
    --accent-strong: #00e68a;
    --accent-soft:   rgba(0, 212, 124, .10);
    --accent-line:   rgba(0, 212, 124, .35);
    --warn:          #f0b33a;
    --warn-soft:     rgba(240, 179, 58, .10);
    --danger:        #ef6461;
    --radius:        14px;
    --radius-sm:     10px;
    --content-w:     760px;
    --ease:          cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Vazirmatn, Tahoma, sans-serif !important;
}

html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
svg.ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* ══════════════ چیدمان کلی ══════════════ */
.layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

/* ══════════════ ستون کناری: موضوعات ══════════════ */
.side-panel {
    order: 2;
    width: 300px;
    flex-shrink: 0;
    background: var(--panel);
    border-inline-start: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.panel-head {
    padding: 20px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.panel-head h2 { font-size: 14px; font-weight: 700; color: var(--text); }
.panel-hint { font-size: 12px; color: var(--muted); line-height: 1.8; }

.sc-search-wrap {
    margin: 0 14px 10px;
    position: relative;
    display: flex;
    align-items: center;
}
.sc-search-wrap svg.ic {
    position: absolute;
    right: 11px;
    width: 16px; height: 16px;
    color: var(--faint);
    pointer-events: none;
}
.sc-search {
    width: 100%;
    padding: 9px 36px 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .2s, background .2s;
}
.sc-search:focus { border-color: var(--accent-line); background: var(--surface-2); }
.sc-search::placeholder { color: var(--faint); }

.sc-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    text-align: right;
    transition: background .15s, color .15s, border-color .15s;
}
.sc-item:hover { background: var(--surface); color: var(--text); }
.sc-item.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.sc-item:disabled { opacity: .5; cursor: wait; }

.sc-icon {
    width: 34px; height: 34px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
    color: var(--muted);
    transition: color .15s, border-color .15s, background .15s;
}
.sc-item:hover .sc-icon { color: var(--text-2); border-color: var(--border-strong); }
.sc-item.active .sc-icon { color: var(--accent); border-color: var(--accent-line); background: transparent; }

.sc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sc-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-sub {
    font-size: 11px;
    color: var(--faint);
    direction: ltr;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-empty { font-size: 12px; color: var(--faint); text-align: center; padding: 28px 0; line-height: 1.8; }

/* ══════════════ ستون اصلی: چت ══════════════ */
.chat-wrap {
    order: 1;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-head {
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.brand-mark {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text h1 { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.online-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dot-sm { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.head-spacer { flex: 1; }
.head-actions { display: flex; align-items: center; gap: 6px; }

.head-btn {
    height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.head-btn svg.ic { width: 16px; height: 16px; }
.head-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.head-btn.topics-btn { display: none; }

/* ── اطلاعیه‌ی اختلال (قابل بستن) ── */
.incident-banner {
    display: none;
    margin: 12px auto 0;
    width: min(var(--content-w), calc(100% - 32px));
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--warn-soft);
    border: 1px solid rgba(240, 179, 58, .35);
    color: #f3d9a4;
    font-size: 13px;
    line-height: 1.8;
}
.incident-banner.active { display: flex; }
.incident-banner .icon { color: var(--warn); margin-top: 3px; }
.incident-banner strong { color: var(--warn); font-weight: 700; }
.incident-banner .body { flex: 1; min-width: 0; }
.incident-close {
    flex-shrink: 0;
    width: 26px; height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--warn);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: .7;
    transition: opacity .15s, background .15s;
}
.incident-close:hover { opacity: 1; background: rgba(240, 179, 58, .12); }

/* ══════════════ بدنه‌ی چت: حالت خالی (وسط) و حالت گفتگو ══════════════ */
.chat-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.hero {
    display: none;
    text-align: center;
    padding: 0 16px 26px;
}
.hero-mark {
    width: 52px; height: 52px;
    margin: 0 auto 18px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
}
.hero-mark svg.ic { width: 26px; height: 26px; stroke-width: 1.5; }
.hero h2 { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.hero p { margin-top: 10px; font-size: 14px; color: var(--muted); line-height: 1.9; }

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px max(16px, calc((100% - var(--content-w)) / 2)) 16px;
    scroll-behavior: smooth;
}

.composer-wrap {
    flex-shrink: 0;
    width: min(var(--content-w), calc(100% - 32px));
    margin: 0 auto;
    padding: 8px 0 14px;
}
.composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 7px 7px 7px;
    padding-inline-start: 18px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 26px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 10px 30px rgba(0, 0, 0, .25), 0 0 0 3px var(--accent-soft); }
.composer input {
    flex: 1;
    min-width: 0;
    height: 40px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14.5px;
}
.composer input::placeholder { color: var(--faint); }
.composer input:disabled { cursor: not-allowed; }
.composer input:disabled::placeholder { color: var(--faint); opacity: .7; }

.send-btn {
    width: 40px; height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #04150d;
    cursor: pointer;
    transition: background .15s, transform .15s, opacity .15s;
}
.send-btn svg.ic { width: 18px; height: 18px; stroke-width: 2.2; }
.send-btn:hover { background: var(--accent-strong); }
.send-btn:active { transform: scale(.94); }

.composer-note {
    margin-top: 8px;
    text-align: center;
    font-size: 11px;
    color: var(--faint);
}

.chips {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.chip svg.ic { width: 16px; height: 16px; color: var(--muted); }
.chip:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.chip:hover svg.ic { color: var(--accent); }

/* حالت خالی: عنوان و کادر نوشتن وسط صفحه */
.chat-body.is-empty { justify-content: center; padding-bottom: 8vh; }
.chat-body.is-empty .hero { display: block; animation: fadeUp .5s var(--ease) both; }
.chat-body.is-empty .messages { display: none; }
.chat-body.is-empty .chips { display: flex; }
.chat-body.is-empty .composer-note { display: none; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* ══════════════ پیام‌ها ══════════════ */
.msg {
    max-width: 85%;
    font-size: 14px;
    line-height: 1.9;
    word-break: break-word;
    animation: fadeUp .25s var(--ease) both;
}
.msg.user {
    align-self: flex-end;
    background: var(--surface-2);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    white-space: pre-wrap;
}
.msg.bot {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 6px;
}
.msg.bot.notice {
    background: transparent;
    border: 1px dashed var(--accent-line);
    color: var(--text-2);
    font-size: 13px;
    padding: 9px 14px;
    white-space: pre-line;
    unicode-bidi: plaintext;
}
.msg p { margin-bottom: 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { padding-right: 22px; margin: 8px 0; }
.msg li { margin-bottom: 4px; }
.msg strong { color: var(--text); font-weight: 700; }
.msg a { color: var(--accent); text-underline-offset: 3px; }
.msg code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; direction: ltr; unicode-bidi: embed; }

.dots-wrap { display: flex; gap: 5px; padding: 6px 2px; }
.dots-wrap span {
    width: 6px; height: 6px;
    background: var(--muted);
    border-radius: 50%;
    animation: bop 1.2s infinite;
}
.dots-wrap span:nth-child(2) { animation-delay: .15s; }
.dots-wrap span:nth-child(3) { animation-delay: .3s; }
@keyframes bop {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

/* ── گزینه‌ها ── */
.opts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: flex-start;
    max-width: 92%;
    animation: fadeUp .25s var(--ease) both;
}
.opt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    text-align: right;
    transition: background .15s, border-color .15s, color .15s;
}
.opt-btn svg.ic { width: 16px; height: 16px; color: var(--muted); }
.opt-btn:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.opt-btn:hover svg.ic { color: var(--accent); }
.opt-btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; border-color: var(--border); color: var(--muted); }
.opt-btn.back-btn { color: var(--muted); border-style: dashed; }
.opt-btn.back-btn:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.opt-btn.ticket-btn { border-color: rgba(240, 179, 58, .45); color: var(--warn); }
.opt-btn.ticket-btn:hover { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

/* ── تصویر و ویدیو ── */
.chat-image-wrap, .chat-video-wrap {
    align-self: flex-start;
    max-width: min(85%, 440px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeUp .25s var(--ease) both;
}
.chat-image-wrap img, .chat-video-wrap video {
    width: 100%;
    display: block;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #000;
}
.chat-image-wrap img { cursor: zoom-in; transition: opacity .2s; }
.chat-image-wrap img:hover { opacity: .9; }
.chat-image-caption, .chat-video-caption { font-size: 11.5px; color: var(--muted); padding-right: 4px; }

.img-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.img-lightbox.active { display: flex; }
.img-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: var(--radius); }

/* ══════════════ پنجره‌ی فرم اطلاعات تکمیلی ══════════════ */
.data-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 9, .72);
    backdrop-filter: blur(6px);
    padding: 16px;
}
.data-modal-overlay.active { display: flex; }

.data-modal-box {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    padding: 30px 26px 26px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    animation: fadeUp .3s var(--ease) both;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.submit-data-btn {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #04150d;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.submit-data-btn:hover { background: var(--accent-strong); }
.submit-data-btn:active { transform: scale(.98); }

.data-modal-title { font-size: 15px; font-weight: 700; line-height: 1.8; margin-bottom: 18px; color: var(--text); }
.form-group { margin-bottom: 14px; text-align: right; }
.form-group label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }

/* ══════════════ موبایل ══════════════ */
@media (max-width: 860px) {
    .side-panel { display: none; }
    .head-btn.topics-btn { display: inline-flex; }
    .head-btn .btn-label { display: none; }
    .head-btn { padding: 0 9px; }
    .chat-head { padding: 0 12px; }
    .hero h2 { font-size: 21px; }
    .msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
