/* «دپارتمان‌ها»: departments index + department chat (change list #5). Plain CSS, dark theme, RTL-first. */
.dep-page {
    --dep-bg: #0A0A0F;
    --dep-card: #141418;
    --dep-card-2: #1C1C22;
    --dep-line: rgba(255, 255, 255, .07);
    --dep-text: #F0F0F2;
    --dep-muted: #A0A0AB;
    --dep-faint: #8A8A96;
    --dep-accent: #6E56CF;
    --dep-accent-2: #9B8DE8;
    --dep-amber: #FFC53D;
    --dep-red: #FF6369;
    background: var(--dep-bg);
    color: var(--dep-text);
    min-height: 70vh;
    padding-bottom: 48px;
}
.dep-page *, .dep-page *::before, .dep-page *::after { box-sizing: border-box; }
.dep-page h1, .dep-page h2, .dep-page h3, .dep-page p { text-align: start; }
.dep-wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.dep-hero {
    background: radial-gradient(ellipse at 80% 40%, rgba(110, 86, 207, .22) 0%, transparent 60%), radial-gradient(ellipse at 10% 0%, rgba(0, 144, 255, .12) 0%, transparent 50%), var(--dep-bg);
    padding: 40px 0 32px;
    border-bottom: 1px solid var(--dep-line);
}
.dep-hero-sm { padding: 24px 0 22px; }
.dep-badge-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
    background: rgba(110, 86, 207, .12); border: 1px solid rgba(110, 86, 207, .25); color: var(--dep-accent-2); font-size: 12px; font-weight: 600;
}
.dep-hero-title { font-size: 30px; line-height: 1.5; font-weight: 800; margin: 14px 0 8px; color: var(--dep-text); }
.dep-hero-title span { display: block; color: var(--dep-accent-2); }
.dep-hero-hint { color: var(--dep-muted); font-size: 15px; line-height: 2; max-width: 720px; margin: 0 0 20px; }
.dep-search { display: flex; gap: 8px; max-width: 620px; background: var(--dep-card); border: 1px solid var(--dep-line); border-radius: 14px; padding: 6px; }
.dep-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--dep-text); font-size: 14px; padding: 8px 10px; }
.dep-search input::placeholder { color: var(--dep-faint); }
.dep-search:focus-within { border-color: rgba(110, 86, 207, .55); }
.dep-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 18px; border-radius: 10px;
    background: var(--dep-accent); color: #fff !important; font-size: 14px; font-weight: 600; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.dep-btn:hover { background: #7C66DC; }
.dep-btn:focus-visible, .dep-page a:focus-visible, .dep-page button:focus-visible, .dep-page textarea:focus-visible { outline: 2px solid var(--dep-accent-2); outline-offset: 2px; }
.dep-btn-ghost { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); color: var(--dep-text) !important; }
.dep-btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.dep-link { color: var(--dep-accent-2); font-size: 14px; text-decoration: none; }
.dep-link:hover { text-decoration: underline; }

.dep-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 24px; max-width: 620px; }
.dep-stat { background: rgba(255, 255, 255, .04); border: 1px solid var(--dep-line); border-radius: 12px; padding: 12px; text-align: center; }
.dep-stat b { display: block; font-size: 22px; color: var(--dep-text); }
.dep-stat span { font-size: 12px; color: var(--dep-muted); }

.dep-section { padding-top: 28px; }
.dep-section-title { font-size: 20px; font-weight: 700; margin: 0 0 14px; color: var(--dep-text); }
.dep-card { background: var(--dep-card); border: 1px solid var(--dep-line); border-radius: 16px; }
.dep-empty { padding: 32px 20px; text-align: center; color: var(--dep-muted); }
.dep-empty p { margin: 0 0 14px; }

/* departments grid */
.dep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.dep-item { display: flex; flex-direction: column; padding: 18px; transition: border-color .15s; min-width: 0; }
.dep-item:hover { border-color: rgba(110, 86, 207, .45); }
.dep-item-head { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.dep-item-icon { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--dep-card-2); border: 1px solid var(--dep-line); flex-shrink: 0; }
.dep-item-title { font-size: 16px; line-height: 1.8; font-weight: 700; margin: 0; color: var(--dep-text); overflow-wrap: anywhere; }
.dep-item-title a { color: inherit; text-decoration: none; }
.dep-item-title a:hover { color: var(--dep-accent-2); }
.dep-item-desc { color: var(--dep-muted); font-size: 13px; line-height: 1.9; margin: 10px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dep-item-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--dep-line); font-size: 12px; color: var(--dep-muted); }
.dep-item-meta b { color: var(--dep-text); font-weight: 600; }
.dep-item-foot { margin-top: auto; padding-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.dep-subs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dep-subs a { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--dep-line); color: var(--dep-muted); text-decoration: none; }
.dep-subs a:hover { color: var(--dep-text); border-color: rgba(110, 86, 207, .45); }
.dep-manager { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.dep-manager img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.dep-manager a { color: var(--dep-text); text-decoration: none; font-weight: 600; }
.dep-manager a:hover { color: var(--dep-accent-2); }

/* search results */
.dep-results { list-style: none; margin: 0; padding: 0; }
.dep-results li { padding: 14px 18px; border-bottom: 1px solid var(--dep-line); }
.dep-results li:last-child { border-bottom: 0; }
.dep-results a { color: var(--dep-text); text-decoration: none; display: block; }
.dep-results a:hover .dep-result-text { color: var(--dep-accent-2); }
.dep-result-meta { font-size: 12px; color: var(--dep-muted); margin-bottom: 4px; }
.dep-result-text { font-size: 14px; line-height: 1.9; overflow-wrap: anywhere; }

/* department page */
.dep-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--dep-faint); margin-bottom: 14px; }
.dep-breadcrumb a { color: var(--dep-muted); text-decoration: none; }
.dep-breadcrumb a:hover { color: var(--dep-text); }
.dep-breadcrumb [aria-current] { color: var(--dep-text); font-weight: 600; }
.dep-head { display: flex; gap: 14px; align-items: flex-start; }
.dep-head-icon { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--dep-card-2); border: 1px solid var(--dep-line); flex-shrink: 0; }
.dep-head-body { min-width: 0; flex: 1; }
.dep-head-title { font-size: 22px; line-height: 1.7; font-weight: 800; margin: 0; color: var(--dep-text); overflow-wrap: anywhere; }
.dep-head-desc { color: var(--dep-muted); font-size: 14px; line-height: 1.9; margin: 4px 0 0; max-width: 820px; }
.dep-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; font-size: 13px; color: var(--dep-muted); }
.dep-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--dep-faint); }
.dep-closed-flag { color: var(--dep-red); }

.dep-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; padding-top: 20px; align-items: start; }
.dep-main { min-width: 0; }
.dep-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dep-side-card { padding: 16px; }
.dep-side-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; color: var(--dep-text); }
.dep-side-hint { font-size: 13px; line-height: 1.9; color: var(--dep-muted); margin: 0 0 10px; }
.dep-side-list { list-style: none; margin: 0; padding: 0; }
.dep-side-list li { padding: 8px 0; border-bottom: 1px solid var(--dep-line); }
.dep-side-list li:last-child { border-bottom: 0; }
.dep-side-list a { color: var(--dep-text); font-size: 14px; text-decoration: none; overflow-wrap: anywhere; }
.dep-side-list a:hover { color: var(--dep-accent-2); }
.dep-side-sub { display: block; font-size: 12px; color: var(--dep-faint); margin-top: 2px; }

/* chat */
.dchat { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.dchat-ico { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; display: inline-block; vertical-align: middle; }
[dir="rtl"] .dchat-ico-flip { transform: scaleX(-1); }
.sr-only-dchat { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.dchat-pinned { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--dep-line); background: rgba(255, 197, 61, .06); }
.dchat-pinned-ico { color: var(--dep-amber); display: inline-flex; }
.dchat-pinned-body { flex: 1; min-width: 0; text-align: start; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.dchat-pinned-label { display: block; font-size: 12px; color: var(--dep-amber); font-weight: 600; }
.dchat-pinned-text { display: block; font-size: 13px; color: var(--dep-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dchat-pinned-close { background: none; border: 0; color: var(--dep-muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.dchat-pinned-close:hover { color: var(--dep-text); background: rgba(255, 255, 255, .06); }

.dchat-list { height: min(66vh, 640px); min-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: auto; }
.dchat-list:focus { outline: none; }
.dchat-list:focus-visible { box-shadow: inset 0 0 0 2px rgba(155, 141, 232, .5); }
.dchat-older { text-align: center; }
.dchat-older-btn { background: rgba(255, 255, 255, .05); border: 1px solid var(--dep-line); color: var(--dep-muted); border-radius: 999px; padding: 6px 14px; font-size: 12px; cursor: pointer; }
.dchat-older-btn:hover { color: var(--dep-text); }
.dchat-empty { margin: auto; text-align: center; color: var(--dep-muted); font-size: 14px; line-height: 2; padding: 30px 10px; }

.dchat-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 88%; align-self: flex-start; scroll-margin: 70px; }
.dchat-msg.is-mine { align-self: flex-end; flex-direction: row-reverse; }
.dchat-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: var(--dep-card-2); display: block; }
.dchat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dchat-bubble { min-width: 0; background: var(--dep-card-2); border: 1px solid var(--dep-line); border-radius: 14px; border-start-start-radius: 4px; padding: 8px 12px 6px; }
.dchat-msg.is-mine .dchat-bubble { background: rgba(110, 86, 207, .16); border-color: rgba(110, 86, 207, .32); border-start-start-radius: 14px; border-start-end-radius: 4px; }
.dchat-msg.is-pinned .dchat-bubble { box-shadow: inset 0 0 0 1px rgba(255, 197, 61, .35); }
.dchat-msg.is-flash .dchat-bubble { animation: dchat-flash 1.6s ease-out; }
@keyframes dchat-flash { 0% { box-shadow: 0 0 0 3px rgba(155, 141, 232, .8); } 100% { box-shadow: 0 0 0 0 rgba(155, 141, 232, 0); } }
@media (prefers-reduced-motion: reduce) { .dchat-msg.is-flash .dchat-bubble { animation: none; box-shadow: 0 0 0 2px rgba(155, 141, 232, .8); } }

.dchat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--dep-faint); margin-bottom: 2px; }
.dchat-name { color: var(--dep-accent-2); font-weight: 700; font-size: 13px; text-decoration: none; }
.dchat-name:hover { text-decoration: underline; }
.dchat-badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; line-height: 1.8; }
.dchat-badge.is-manager { color: var(--dep-amber); background: rgba(255, 197, 61, .12); border: 1px solid rgba(255, 197, 61, .3); }
.dchat-badge.is-admin { color: var(--dep-red); background: rgba(229, 72, 77, .14); border: 1px solid rgba(229, 72, 77, .32); }
.dchat-time { color: var(--dep-faint); }
.dchat-edited { color: var(--dep-faint); font-style: italic; }
.dchat-pin-flag { color: var(--dep-amber); display: inline-flex; }

.dchat-quote { display: block; width: 100%; text-align: start; background: rgba(255, 255, 255, .04); border: 0; border-inline-start: 3px solid var(--dep-accent); border-radius: 6px; padding: 5px 9px; margin: 4px 0 6px; cursor: pointer; color: inherit; font: inherit; }
.dchat-quote:hover { background: rgba(255, 255, 255, .07); }
.dchat-quote-name { display: block; font-size: 12px; color: var(--dep-accent-2); font-weight: 600; }
.dchat-quote-text { display: block; font-size: 12px; color: var(--dep-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }

.dchat-text { font-size: 14px; line-height: 2; color: var(--dep-text); overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
.dchat-text a { color: var(--dep-accent-2); text-decoration: underline; }

.dchat-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; margin-inline-start: -6px; }
.dchat-act { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--dep-faint); font-size: 12px; padding: 4px 6px; border-radius: 6px; cursor: pointer; min-height: 28px; font-family: inherit; }
.dchat-act .dchat-ico { width: 14px; height: 14px; }
.dchat-act:hover { color: var(--dep-text); background: rgba(255, 255, 255, .06); }
.dchat-act.is-danger:hover { color: var(--dep-red); background: rgba(229, 72, 77, .1); }
.dchat-act[disabled] { opacity: .5; cursor: wait; }

.dchat-viewport { position: relative; }
.dchat-newbtn { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; background: var(--dep-accent); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); z-index: 2; font-family: inherit; }
.dchat-newbtn-count:not(:empty) { background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 0 7px; font-size: 12px; }

.dchat-composer { border-top: 1px solid var(--dep-line); padding: 10px 12px 8px; background: #111115; }
.dchat-context { display: flex; align-items: center; gap: 8px; background: rgba(110, 86, 207, .1); border-inline-start: 3px solid var(--dep-accent); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.dchat-context-body { flex: 1; min-width: 0; }
.dchat-context-title { display: block; font-size: 12px; color: var(--dep-accent-2); font-weight: 600; }
.dchat-context-text { display: block; font-size: 12px; color: var(--dep-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dchat-context-close { background: none; border: 0; color: var(--dep-muted); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; }
.dchat-context-close:hover { color: var(--dep-text); }
.dchat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.dchat-input { flex: 1; min-width: 0; resize: none; background: var(--dep-card-2); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; color: var(--dep-text); font-size: 14px; line-height: 1.9; padding: 9px 12px; max-height: 180px; min-height: 44px; font-family: inherit; }
.dchat-input::placeholder { color: var(--dep-faint); }
.dchat-input:focus { border-color: rgba(110, 86, 207, .6); outline: none; box-shadow: 0 0 0 2px rgba(110, 86, 207, .25); }
.dchat-send { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; min-width: 44px; padding: 0 16px; border-radius: 12px; background: var(--dep-accent); color: #fff; border: 0; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.dchat-send:hover { background: #7C66DC; }
.dchat-send[disabled] { opacity: .6; cursor: wait; }
.dchat-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--dep-faint); min-height: 18px; }
.dchat-status { color: var(--dep-red); flex: 1; min-width: 0; }
.dchat-status.is-ok { color: #3DD68C; }
.dchat-counter { margin-inline-start: auto; white-space: nowrap; }
.dchat-locked { border-top: 1px solid var(--dep-line); padding: 18px 16px; text-align: center; color: var(--dep-muted); font-size: 14px; line-height: 1.9; background: #111115; }
.dchat-locked strong { display: block; color: var(--dep-text); font-size: 15px; margin-bottom: 4px; }
.dchat-locked p { margin: 0 0 12px; }
.dchat-locked-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 991px) {
    .dep-layout { grid-template-columns: minmax(0, 1fr); }
    .dchat-hint { display: none; }
}
@media (max-width: 575px) {
    .dep-hero { padding: 26px 0 22px; }
    .dep-hero-title { font-size: 23px; }
    .dep-head-title { font-size: 18px; }
    .dep-head-icon { width: 44px; height: 44px; }
    .dep-grid { grid-template-columns: minmax(0, 1fr); }
    .dep-stats { gap: 8px; }
    .dep-stat b { font-size: 18px; }
    .dchat-list { height: 62vh; padding: 10px 8px 6px; }
    .dchat-msg { max-width: 96%; gap: 6px; }
    .dchat-avatar { width: 30px; height: 30px; }
    .dchat-send-label { display: none; }
    .dchat-send { padding: 0 12px; }
    .dchat-quote-text { max-width: 220px; }
}

/* panel «دپارتمان‌های من» */
.dep-page.dep-panel { background: transparent; min-height: 0; padding: 0; }
.dep-panel-title { font-size: 19px; font-weight: 700; margin: 0 0 6px; color: var(--dep-text); }
.dep-panel-hint { font-size: 13px; line-height: 1.9; color: var(--dep-muted); margin: 0 0 14px; }
.dep-panel-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--dep-line); flex-wrap: wrap; }
.dep-panel-row:last-child { border-bottom: 0; }
.dep-panel-row-body { flex: 1; min-width: 0; }
.dep-panel-row-title { color: var(--dep-text); font-weight: 600; font-size: 15px; text-decoration: none; overflow-wrap: anywhere; }
.dep-panel-row-title:hover { color: var(--dep-accent-2); }
.dep-panel-row-sub { font-size: 12px; color: var(--dep-muted); margin-top: 3px; }
.dep-unread { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(110, 86, 207, .18); color: var(--dep-accent-2); border: 1px solid rgba(110, 86, 207, .35); }
.dep-unread.is-zero { background: rgba(255, 255, 255, .04); color: var(--dep-faint); border-color: var(--dep-line); }
.dep-panel-block { margin-bottom: 28px; }

/* on a phone the site-wide AI launcher shrinks to its icon on the chat page so it covers less of the composer */
@media (max-width: 767px) {
    body:has(#dchat) .ai-launcher__label { display: none; }
}
