/* =====================================================================
   PANEL.CSS — سیستم طراحی مشترک پنل (تیکتینگ)
   این فایل جایگزین استایل‌های تکراری inline در تک‌تک صفحات می‌شود.
   ساختار و کلاس‌ها دقیقاً همان چیزی است که در dashboard.php استفاده
   می‌شد تا هیچ مارک‌آپ یا رفتار جاوااسکریپتی‌ای نشکند.
   ===================================================================== */

:root {
    --topbar-h: 64px;
    --sidebar-w: 300px;
    --tone-1: #06b6d4;
    --tone-2: #f59e0b;
    --tone-3: #ef4444;
    --tone-4: #22c55e;
    --bg: #f6f9fc;
    --surface: #fff;
    --surface-2: #fbfdff;
    --txt: #0f172a;
    --muted: #5a6b79;
    --line: #e6edf4;
    --line-strong: #d7e2ee;
    --r-xl: 16px;
    --r-md: 12px;
    --r-sm: 10px;
    --shadow-sm: 0 8px 18px rgba(2, 12, 22, .06);
    --shadow-md: 0 14px 28px rgba(2, 12, 22, .1);
    --fa-font: 'IRANSans', 'Vazir', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #0c1215;
    --surface: #0f1519;
    --surface-2: #0d1418;
    --txt: #e6f3f6;
    --muted: #9fb0ba;
    --line: #21303a;
    --line-strong: #2b3b46;
    --shadow-sm: 0 8px 20px rgba(0, 0, 0, .32);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, .36);
}

/* ===== Reset ===== */
* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

html[dir="rtl"] {
    direction: rtl
}

body {
    margin: 0;
    color: var(--txt);
    font-family: var(--fa-font);
    font-size: 15.5px;
    line-height: 1.75;
    background: var(--bg);
    padding-top: var(--topbar-h);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit
}

button,
input,
select,
textarea {
    font-family: var(--fa-font)
}

/* ===== Inline SVG icon system ===== */
.ri {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
    flex: 0 0 auto
}

.nav-items .ri {
    color: var(--tone-1)
}

.kpi .icon .ri {
    width: 26px;
    height: 26px
}

.shortcut .ri {
    color: var(--tone-1)
}

.hamburger .ri {
    width: 18px;
    height: 18px
}

.btn .ri {
    width: 18px;
    height: 18px
}

/* ===== Topbar ===== */
.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    z-index: 1200
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px
}

.logo img {
    height: 38px
}

.top-actions {
    display: flex;
    gap: 8px
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-weight: 800;
    font-size: 14.5px;
    cursor: pointer
}

.btn:hover {
    border-color: var(--line-strong)
}

.btn-primary {
    background: var(--tone-1);
    border-color: var(--tone-1);
    color: #fff
}

.btn-primary:hover {
    filter: brightness(.94)
}

.btn-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b
}

.btn-success {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534
}

.hamburger {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    padding: 8px 10px
}

/* ===== Layout: sidebar + main ===== */
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    box-shadow: var(--shadow-md);
    padding: 6px 10px 12px;
    overflow: auto;
    z-index: 1150
}

.main {
    margin-right: var(--sidebar-w);
    padding: 16px
}

@media(max-width:992px) {
    .hamburger {
        display: inline-flex
    }

    .sidebar {
        transform: translateX(100%);
        transition: .22s
    }

    .sidebar.open {
        transform: translateX(0)
    }

    .backdrop {
        position: fixed;
        inset: var(--topbar-h) 0 0 0;
        background: rgba(0, 0, 0, .35);
        display: none;
        z-index: 1100
    }

    .backdrop.show {
        display: block
    }

    .main {
        margin-right: 0;
        padding: 14px
    }
}

/* ===== Sidebar nav ===== */
.nav-group {
    border-bottom: 1px dashed var(--line-strong);
    padding: 8px 0
}

.nav-group:last-child {
    border: 0
}

.nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 14.5px;
    cursor: pointer
}

.nav-items {
    display: grid;
    gap: 8px;
    padding: 8px 6px 12px
}

.nav-items a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 14.5px
}

.nav-items a:hover {
    border-color: var(--tone-1)
}

/* ===== KPI cards ===== */
.kpis {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    margin-top: 6px
}

@media(max-width:1200px) {
    .kpis {
        grid-template-columns: repeat(2, 1fr)
    }
}

@media(max-width:560px) {
    .kpis {
        grid-template-columns: 1fr
    }
}

.kpi {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    min-height: 100px
}

.kpi .icon {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 58px;
    height: 58px;
    border-radius: 14px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 18px rgba(0, 0, 0, .12)
}

.kpi .row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    margin-right: 74px
}

.kpi .title {
    font-weight: 800;
    font-size: 14.5px
}

.kpi .val {
    font-size: 26px;
    font-weight: 900
}

.kpi.t1 .icon {
    background: var(--tone-1)
}

.kpi.t1 .val {
    color: var(--tone-1)
}

.kpi.t2 .icon {
    background: var(--tone-2)
}

.kpi.t2 .val {
    color: var(--tone-2)
}

.kpi.t3 .icon {
    background: var(--tone-3)
}

.kpi.t3 .val {
    color: var(--tone-3)
}

.kpi.t4 .icon {
    background: var(--tone-4)
}

.kpi.t4 .val {
    color: var(--tone-4)
}

.kpi:hover {
    box-shadow: var(--shadow-md)
}

.kpi.link {
    transition: transform .1s
}

.kpi.link:hover {
    transform: translateY(-2px)
}

/* ===== Shortcuts ===== */
.shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 12px 2px 0 0
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-weight: 800;
    font-size: 14.5px;
    justify-content: center
}

/* ===== Panels & list ===== */
.panel {
    margin-top: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-md)
}

.panel-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 900;
    font-size: 15.5px
}

.panel-b {
    padding: 12px 16px
}

.list {
    display: grid;
    gap: 9px
}

.item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--surface-2);
    padding: 12px;
    border-radius: 12px
}

.item .text {
    min-width: 0
}

.item .title {
    font-weight: 800;
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.item .meta {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px
}

.badge-st {
    font-size: 12.5px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: #111;
    justify-self: end;
    font-weight: 700
}

.st-open {
    background: #ecfeff;
    border-color: #99f6e4
}

.st-pending {
    background: #fff7ed;
    border-color: #fed7aa
}

.st-onhold {
    background: #eef2ff;
    border-color: #c7d2fe
}

.st-resolved {
    background: #ecfdf5;
    border-color: #a7f3d0
}

.st-closed {
    background: #fee2e2;
    border-color: #fecaca
}

/* ===== Chart ===== */
.chart {
    width: 100%;
    display: block
}

.chart .grid {
    stroke: rgba(128, 145, 160, .22);
    stroke-dasharray: 3 3;
    stroke-width: 1
}

.chart .bar {
    fill: var(--tone-1);
    rx: 7
}

.chart .line {
    fill: none;
    stroke: #0ea5a9;
    stroke-width: 2.4
}

.chart .dot {
    fill: #0ea5a9;
    r: 3.4
}

.chart .label {
    font-size: 12px;
    fill: var(--muted)
}

/* ===== Generic form controls ===== */
.form-group {
    margin-bottom: 14px
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 14px;
    color: var(--muted)
}

input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=search],
input[type=tel],
textarea,
select,
.input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: 14.5px;
    background: var(--surface);
    color: var(--txt)
}

input:focus,
textarea:focus,
select:focus,
.input:focus {
    outline: none;
    border-color: var(--tone-1);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone-1) 18%, transparent)
}

textarea {
    min-height: 110px;
    resize: vertical
}

/* ===== Tables ===== */
.table-wrap {
    overflow: auto;
    border-radius: var(--r-md)
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    background: var(--surface)
}

table.styled,
.table {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm)
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    font-size: 14.5px
}

thead th {
    background: var(--surface-2);
    font-weight: 900;
    color: var(--txt);
    font-size: 14px
}

tbody tr:hover {
    background: var(--surface-2)
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .85rem;
    border: 1px solid var(--line);
    background: var(--surface)
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin: 10px 0;
    font-size: 13.5px;
    border: 1px solid var(--line)
}

.alert-danger {
    background: #ffe4e6;
    border-color: #fecdd3;
    color: #9f1239
}

.alert-success {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534
}

.alert-warning {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #92400e
}

/* ===== Mobile list ===== */
@media(max-width:560px) {
    .item {
        grid-template-columns: 1fr auto
    }

    .item .title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden
    }
}

/* ===== small utilities ===== */
.mt-1 {
    margin-top: 6px
}

.mt-2 {
    margin-top: 12px
}

.mt-3 {
    margin-top: 18px
}

.card {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    padding: 20px;
    margin-bottom: 20px
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px
}

/* =====================================================================
   PRESENCE / STAFF-CHAT WIDGET — منتقل‌شده از استایل inline فهرست تیکت‌ها
   ===================================================================== */


.team-presence-card {
    overflow: hidden
}

.team-presence-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    overflow: visible !important;
    max-width: 100%
}

.presence-row,
.team-chip {
    cursor: pointer;
    position: relative;
    transform: none !important;
    text-decoration: none !important;
    transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease
}

.presence-row::before,
.presence-row::after,
.team-chip::before,
.team-chip::after {
    display: none !important;
    content: none !important
}

.presence-row:hover,
.team-chip:hover {
    transform: none !important;
    text-decoration: none !important;
    border-color: rgba(20, 184, 166, .24) !important;
    box-shadow: 0 5px 15px rgba(13, 148, 136, .08) !important;
    background: rgba(20, 184, 166, .055) !important
}

.presence-row:hover *,
.team-chip:hover * {
    text-decoration: none !important
}

.team-chip {
    box-sizing: border-box;
    min-width: 0 !important;
    max-width: 100%;
    flex: 1 1 190px;
    padding: 10px 12px;
    border: 1px solid rgba(15, 118, 110, .11);
    border-radius: 15px;
    background: var(--card, #fff);
    overflow: hidden
}

.presence-row {
    box-sizing: border-box;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 13px;
    margin: 2px 0;
    overflow: hidden
}

.presence-row .presence-avatar,
.team-chip .presence-avatar {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #fff;
    box-shadow: 0 5px 13px rgba(13, 148, 136, .16)
}

.presence-info {
    min-width: 0
}

.presence-info strong {
    font-weight: 900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.presence-state {
    white-space: nowrap
}

.chat-preview {
    max-width: 100% !important
}

.chat-unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(239, 68, 68, .3)
}

.chat-preview {
    display: block;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px
}

.staff-chat-shell {
    position: fixed;
    inset: auto 24px 24px auto;
    z-index: 1200;
    display: none;
    direction: rtl
}

.staff-chat-shell.open {
    display: block;
    animation: staffChatIn .2s ease-out
}

@keyframes staffChatIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.985)
    }

    to {
        opacity: 1;
        transform: none
    }
}

.staff-chat-box {
    width: min(420px, calc(100vw - 24px));
    height: min(640px, calc(100vh - 92px));
    background: var(--card, #fff);
    border: 1px solid rgba(15, 118, 110, .18);
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .28), 0 8px 24px rgba(15, 118, 110, .12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    isolation: isolate
}

.staff-chat-head {
    min-height: 78px;
    padding: 13px 15px;
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 56%, #14b8a6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden
}

.staff-chat-head:after {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    left: -42px;
    top: -76px;
    pointer-events: none
}

.staff-chat-person {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    position: relative;
    z-index: 1
}

.staff-chat-person .presence-avatar {
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    border: 2px solid rgba(255, 255, 255, .75);
    background: rgba(255, 255, 255, .18);
    color: #fff;
    box-shadow: 0 7px 18px rgba(0, 0, 0, .13)
}

.staff-chat-person>span:last-child {
    min-width: 0
}

.staff-chat-person strong {
    display: block;
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.staff-chat-person small {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: .94;
    font-size: 11px;
    margin-top: 4px
}

.staff-chat-person small:before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5eead4;
    box-shadow: 0 0 0 3px rgba(94, 234, 212, .20)
}

.staff-chat-close {
    position: relative;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: .18s ease
}

.staff-chat-close:hover {
    background: rgba(255, 255, 255, .23);
    transform: rotate(4deg)
}

.staff-chat-messages {
    flex: 1;
    overflow: auto;
    padding: 18px 14px 14px;
    background-color: var(--bg, #f8fafc);
    background-image: radial-gradient(rgba(15, 118, 110, .055) 1px, transparent 1px);
    background-size: 18px 18px;
    scroll-behavior: smooth;
    overscroll-behavior: contain
}

.staff-chat-messages::-webkit-scrollbar {
    width: 7px
}

.staff-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(15, 118, 110, .22);
    border-radius: 20px
}

.chat-empty {
    margin: 28px auto;
    text-align: center;
    color: var(--muted);
    padding: 24px 18px;
    max-width: 260px;
    border: 1px dashed rgba(15, 118, 110, .22);
    border-radius: 18px;
    background: rgba(255, 255, 255, .72);
    font-size: 12px;
    line-height: 1.9
}

.chat-row {
    display: flex;
    margin: 7px 0;
    align-items: flex-end
}

.chat-row.mine {
    justify-content: flex-start
}

.chat-row.theirs {
    justify-content: flex-end
}

.chat-bubble {
    position: relative;
    max-width: 82%;
    padding: 9px 12px 7px;
    border-radius: 16px;
    line-height: 1.8;
    font-size: 13px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 11px rgba(15, 23, 42, .07)
}

.chat-row.mine .chat-bubble {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: #fff;
    border-bottom-left-radius: 5px
}

.chat-row.theirs .chat-bubble {
    background: var(--card, #fff);
    color: var(--text, #0f172a);
    border: 1px solid rgba(15, 23, 42, .075);
    border-bottom-right-radius: 5px
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    direction: rtl;
    font-size: 9.5px;
    opacity: .72;
    margin-top: 3px;
    line-height: 1.3
}

.chat-row.mine .chat-meta {
    justify-content: flex-end
}

.staff-chat-compose {
    display: flex;
    flex-direction: row;
    direction: rtl;
    align-items: flex-end;
    gap: 9px;
    padding: 11px 12px 13px;
    border-top: 1px solid rgba(15, 23, 42, .08);
    background: var(--card, #fff);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .035)
}

.staff-chat-compose textarea {
    order: 1;
    flex: 1;
    resize: none;
    min-height: 45px;
    max-height: 120px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 15px;
    padding: 11px 13px;
    font: inherit;
    font-size: 13px;
    line-height: 1.7;
    background: var(--bg, #f8fafc);
    color: var(--text, #111827);
    outline: none;
    transition: .18s ease
}

.staff-chat-compose textarea::placeholder {
    color: #94a3b8
}

.staff-chat-compose textarea:focus {
    border-color: #14b8a6;
    background: var(--card, #fff);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, .1)
}

.staff-chat-compose button {
    order: 2;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 9px 20px rgba(20, 184, 166, .28);
    transition: .18s ease
}

.staff-chat-compose button:hover {
    transform: translateY(-1px);
    box-shadow: 0 11px 24px rgba(20, 184, 166, .34)
}

.staff-chat-compose button:active {
    transform: translateY(0) scale(.97)
}

.staff-chat-compose button:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none
}

.staff-chat-compose button .ico {
    width: 21px;
    height: 21px;
    transform: scaleX(-1)
}

html[data-theme="dark"] .chat-empty {
    background: rgba(15, 23, 42, .7)
}

html[data-theme="dark"] .staff-chat-box {
    border-color: rgba(45, 212, 191, .18)
}

html[data-theme="dark"] .chat-row.theirs .chat-bubble {
    border-color: rgba(255, 255, 255, .07)
}

@media(max-width:640px) {
    .staff-chat-shell {
        inset: auto 7px 7px 7px
    }

    .staff-chat-box {
        width: 100%;
        height: min(78vh, 660px);
        border-radius: 21px
    }

    .staff-chat-head {
        min-height: 72px
    }

    .staff-chat-messages {
        padding: 14px 10px
    }

    .chat-bubble {
        max-width: 88%
    }
}


.chat-attachment-preview {
    display: none;
    align-items: center;
    gap: 10px;
    margin: 0 12px 8px;
    padding: 9px 11px;
    border: 1px solid rgba(20, 184, 166, .22);
    border-radius: 14px;
    background: rgba(20, 184, 166, .06)
}

.chat-attachment-preview.show {
    display: flex
}

.chat-attachment-preview img {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    object-fit: cover
}

.chat-attachment-preview .meta {
    min-width: 0;
    flex: 1
}

.chat-attachment-preview strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px
}

.chat-attachment-preview small {
    color: var(--muted);
    font-size: 10px
}

.chat-attachment-remove {
    border: 0;
    background: transparent;
    color: #ef4444;
    font-size: 20px;
    cursor: pointer
}

.chat-file-btn {
    order: 3;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(20, 184, 166, .2) !important;
    background: rgba(20, 184, 166, .08) !important;
    color: #0f766e !important;
    box-shadow: none !important;
    border-radius: 13px !important
}

.chat-file-btn:hover {
    background: rgba(20, 184, 166, .15) !important;
    transform: none !important
}

.chat-file-btn .ico {
    transform: none !important;
    width: 20px !important;
    height: 20px !important
}

.chat-file-input {
    display: none
}

.chat-attachment {
    margin-top: 7px
}

.chat-attachment img {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: 12px;
    cursor: zoom-in
}

.chat-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none !important;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12)
}

.chat-row.theirs .chat-file-link {
    background: rgba(15, 118, 110, .07);
    color: #0f766e
}

.chat-file-size {
    font-size: 10px;
    opacity: .72
}



.staff-chat-compose textarea {
    min-height: 44px !important;
    height: 44px;
    max-height: 96px;
    padding-top: 10px !important;
    padding-bottom: 10px !important
}

.chat-status-ticks {
    font-weight: 900;
    letter-spacing: -2px;
    font-size: 12px;
    display: inline-block;
    min-width: 16px;
    text-align: left
}

.chat-status-ticks.read {
    color: #99f6e4
}

.chat-message-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease
}

.chat-row:hover .chat-message-actions,
.chat-row:focus-within .chat-message-actions {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.chat-action-btn {
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: inherit;
    border-radius: 7px;
    padding: 2px 7px;
    font: inherit;
    font-size: 9px;
    cursor: pointer;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    display: inline-flex !important
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, .24) !important;
    transform: none !important
}

.chat-row.theirs .chat-action-btn {
    background: rgba(15, 118, 110, .08)
}

.chat-edited {
    font-size: 9px;
    opacity: .72
}

.chat-deleted {
    font-style: italic;
    opacity: .72
}

.chat-editing .chat-bubble {
    outline: 2px solid rgba(153, 246, 228, .5)
}

@media(max-width:640px) {
    .chat-message-actions {
        opacity: 1
    }
}



.chat-head-tools {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 2
}

.chat-head-tool {
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-radius: 10px;
    height: 34px;
    padding: 0 9px;
    cursor: pointer;
    font: inherit;
    font-size: 11px
}

.chat-typing {
    min-height: 20px;
    padding: 2px 15px 4px;
    font-size: 11px;
    color: #0f766e;
    background: var(--card, #fff)
}

.chat-reply-preview {
    border-right: 3px solid #5eead4;
    padding: 5px 8px;
    margin-bottom: 6px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .13);
    font-size: 10px;
    opacity: .9
}

.chat-row.theirs .chat-reply-preview {
    background: rgba(15, 118, 110, .07)
}

.chat-reply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 0 12px 8px;
    padding: 7px 10px;
    border-radius: 12px;
    background: rgba(20, 184, 166, .08);
    border: 1px solid rgba(20, 184, 166, .18);
    font-size: 11px
}

.chat-reply-bar.show {
    display: flex
}

.chat-reply-bar span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.chat-reply-bar button {
    border: 0;
    background: transparent;
    color: #ef4444;
    cursor: pointer
}

.chat-multi-panel,
.chat-search-panel {
    display: none;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    background: var(--card, #fff)
}

.chat-multi-panel.show,
.chat-search-panel.show {
    display: block
}

.chat-multi-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    max-height: 100px;
    overflow: auto
}

.chat-multi-item {
    font-size: 10px;
    border: 1px solid rgba(20, 184, 166, .2);
    padding: 5px 8px;
    border-radius: 9px
}

.chat-search-row {
    display: flex;
    gap: 7px
}

.chat-search-row input {
    flex: 1;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 10px;
    padding: 8px;
    font: inherit
}

.chat-search-results {
    max-height: 180px;
    overflow: auto;
    margin-top: 8px
}

.chat-search-result {
    display: block;
    padding: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
    font-size: 11px;
    cursor: pointer
}

.chat-search-result:hover {
    background: rgba(20, 184, 166, .06)
}


.support-group-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 100%;
    padding: 11px 13px;
    border: 1px solid rgba(20, 184, 166, .25);
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(20, 184, 166, .12), rgba(13, 148, 136, .06));
    cursor: pointer
}

.support-group-chip strong {
    display: block
}

.support-group-chip small {
    display: block;
    color: var(--muted);
    margin-top: 2px
}

.support-group-chip .presence-avatar {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #fff
}

.support-group-chip .chat-unread-badge {
    margin-inline-start: auto
}

.chat-sender-name {
    display: block;
    font-size: 10px;
    font-weight: 900;
    opacity: .78;
    margin-bottom: 3px
}

.chat-row.mine .chat-sender-name {
    display: none
}


/* بازطراحی کنترل‌شده کارت‌های پشتیبان؛ بدون تغییر ساختار یا ایجاد اسکرول اضافه */
.team-presence-card {
    position: relative;
    padding: 0;
    border: 1px solid rgba(15, 118, 110, .11);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .96));
    box-shadow: 0 12px 34px rgba(15, 23, 42, .055);
    overflow: hidden !important;
}

.team-presence-card:before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, #14b8a6, #0d9488, #22d3ee);
    pointer-events: none;
}

.team-presence-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(15, 118, 110, .08);
    background: linear-gradient(180deg, rgba(240, 253, 250, .65), rgba(255, 255, 255, 0));
}

.team-presence-head strong {
    font-size: 14px;
    font-weight: 950;
    color: var(--text, #0f172a)
}

.team-presence-head .presence-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(20, 184, 166, .09);
    color: #0f766e;
    border: 1px solid rgba(20, 184, 166, .14);
    font-size: 11px;
    font-weight: 900;
}

.team-presence-inline {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 11px !important;
    padding: 14px 16px 16px;
    overflow: visible !important;
    max-width: 100%;
}

.team-chip {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
    display: flex !important;
    align-items: center;
    gap: 11px;
    padding: 12px 13px !important;
    border: 1px solid rgba(15, 118, 110, .105) !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, var(--card, #fff), rgba(248, 250, 252, .92)) !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .035) !important;
    overflow: hidden !important;
    isolation: isolate;
}

.team-chip:before {
    display: block !important;
    content: "" !important;
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, #2dd4bf, #0d9488);
    opacity: .8;
}

.team-chip:hover {
    background: linear-gradient(180deg, #f0fdfa, #ffffff) !important;
    border-color: rgba(20, 184, 166, .26) !important;
    box-shadow: 0 10px 26px rgba(13, 148, 136, .10) !important;
}

.team-chip .presence-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px !important;
    font-size: 14px;
    font-weight: 950;
    border: 1px solid rgba(255, 255, 255, .7);
    box-shadow: 0 8px 18px rgba(13, 148, 136, .18) !important;
}

.team-chip .presence-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0
}

.team-chip .presence-info strong {
    font-size: 13px;
    font-weight: 950;
    color: var(--text, #0f172a);
    line-height: 1.5
}

.team-chip .presence-state {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 850;
    line-height: 1.5;
}

.team-chip .presence-state:before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent)
}

.team-chip .presence-state.available {
    background: rgba(20, 184, 166, .10);
    color: #0f766e
}

.team-chip .presence-state.away {
    background: rgba(245, 158, 11, .11);
    color: #b45309
}

.team-chip .presence-state.offline {
    background: rgba(148, 163, 184, .13);
    color: #64748b
}

.team-chip .chat-preview {
    margin-top: 2px !important;
    font-size: 10.5px !important;
    line-height: 1.55;
    color: var(--muted, #64748b)
}

.team-chip .chat-unread-badge {
    position: absolute;
    top: 9px;
    left: 9px;
    z-index: 2
}

.presence-list .presence-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(15, 118, 110, .08) !important;
    background: linear-gradient(180deg, var(--card, #fff), rgba(248, 250, 252, .92));
    box-shadow: 0 3px 10px rgba(15, 23, 42, .03);
}

.presence-list .presence-row:hover {
    background: #f0fdfa !important
}

.presence-list .presence-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px !important
}

html[data-theme="dark"] .team-presence-card {
    background: linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(17, 24, 39, .96));
    border-color: rgba(45, 212, 191, .14)
}

html[data-theme="dark"] .team-presence-head {
    background: linear-gradient(180deg, rgba(13, 148, 136, .10), transparent);
    border-bottom-color: rgba(255, 255, 255, .06)
}

html[data-theme="dark"] .team-chip,
html[data-theme="dark"] .presence-list .presence-row {
    background: linear-gradient(180deg, rgba(30, 41, 59, .96), rgba(15, 23, 42, .96)) !important;
    border-color: rgba(45, 212, 191, .12) !important
}

html[data-theme="dark"] .team-chip:hover,
html[data-theme="dark"] .presence-list .presence-row:hover {
    background: rgba(13, 148, 136, .12) !important
}

@media(max-width:640px) {
    .team-presence-head {
        padding: 14px 13px 10px
    }

    .team-presence-inline {
        grid-template-columns: 1fr !important;
        padding: 11px 12px 13px;
        gap: 9px !important
    }

    .team-chip {
        padding: 11px 12px !important
    }
}



/* هماهنگ‌سازی رنگ چت و کارت‌های پشتیبان با رنگ اصلی خود سامانه */
:root {
    --staff-accent: var(--primary, #06b6d4);
    --staff-accent-dark: color-mix(in srgb, var(--staff-accent) 78%, #0f172a);
    --staff-accent-soft: color-mix(in srgb, var(--staff-accent) 10%, transparent);
    --staff-accent-border: color-mix(in srgb, var(--staff-accent) 24%, transparent);
    --staff-accent-shadow: color-mix(in srgb, var(--staff-accent) 18%, transparent);
}


/* باکس اصلی حضور تیم */
.team-presence-card {
    border-color: var(--staff-accent-border) !important;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .055), 0 0 0 1px color-mix(in srgb, var(--staff-accent) 4%, transparent) !important;
}

.team-presence-card:before {
    background: var(--staff-accent) !important;
}

.team-presence-head {
    border-bottom-color: color-mix(in srgb, var(--staff-accent) 14%, transparent) !important;
    background: linear-gradient(180deg, color-mix(in srgb, var(--staff-accent) 8%, #fff), rgba(255, 255, 255, 0)) !important;
}

.team-presence-head .presence-count {
    background: var(--staff-accent-soft) !important;
    color: var(--staff-accent-dark) !important;
    border-color: var(--staff-accent-border) !important;
}


/* کارت‌های پشتیبان */
.team-chip {
    border-color: color-mix(in srgb, var(--staff-accent) 18%, transparent) !important;
}

.team-chip:before {
    background: var(--staff-accent) !important;
}

.team-chip:hover {
    background: linear-gradient(180deg, color-mix(in srgb, var(--staff-accent) 7%, #fff), #fff) !important;
    border-color: color-mix(in srgb, var(--staff-accent) 38%, transparent) !important;
    box-shadow: 0 10px 26px var(--staff-accent-shadow) !important;
}

.team-chip .presence-avatar,
.presence-row .presence-avatar {
    background: var(--staff-accent) !important;
    box-shadow: 0 8px 18px var(--staff-accent-shadow) !important;
}

.team-chip .presence-state.available {
    background: var(--staff-accent-soft) !important;
    color: var(--staff-accent-dark) !important;
}

.presence-list .presence-row {
    border-color: color-mix(in srgb, var(--staff-accent) 14%, transparent) !important;
}

.presence-list .presence-row:hover,
.presence-row:hover,
.team-chip:hover {
    background-color: var(--staff-accent-soft) !important;
}


/* پنجره گفتگو */
.staff-chat-box {
    border-color: var(--staff-accent-border) !important;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .28), 0 8px 24px var(--staff-accent-shadow) !important;
}

.staff-chat-head {
    background: linear-gradient(135deg, var(--staff-accent-dark) 0%, var(--staff-accent) 100%) !important;
}

.staff-chat-person small:before {
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .20) !important;
}

.staff-chat-messages {
    background-image: radial-gradient(color-mix(in srgb, var(--staff-accent) 10%, transparent) 1px, transparent 1px) !important;
}

.staff-chat-messages::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--staff-accent) 28%, transparent) !important;
}

.chat-empty {
    border-color: var(--staff-accent-border) !important;
}

.chat-row.mine .chat-bubble {
    background: linear-gradient(135deg, var(--staff-accent-dark), var(--staff-accent)) !important;
}

.staff-chat-compose textarea:focus {
    border-color: var(--staff-accent) !important;
    box-shadow: 0 0 0 4px var(--staff-accent-soft) !important;
}

.staff-chat-compose .chat-send-btn {
    background: var(--staff-accent) !important;
    box-shadow: 0 9px 20px var(--staff-accent-shadow) !important;
}

.staff-chat-compose .chat-send-btn:hover {
    box-shadow: 0 11px 24px color-mix(in srgb, var(--staff-accent) 28%, transparent) !important;
}

.chat-file-btn {
    border-color: var(--staff-accent-border) !important;
    background: var(--staff-accent-soft) !important;
    color: var(--staff-accent-dark) !important;
}

.chat-file-btn:hover {
    background: color-mix(in srgb, var(--staff-accent) 16%, transparent) !important;
}

.chat-attachment-preview,
.chat-reply-bar {
    border-color: var(--staff-accent-border) !important;
    background: var(--staff-accent-soft) !important;
}

.chat-reply-preview {
    border-right-color: var(--staff-accent) !important;
}

.chat-row.theirs .chat-reply-preview,
.chat-row.theirs .chat-file-link,
.chat-row.theirs .chat-action-btn {
    background: var(--staff-accent-soft) !important;
    color: var(--staff-accent-dark) !important;
}

.chat-typing {
    color: var(--staff-accent-dark) !important;
}

.chat-search-result:hover {
    background: var(--staff-accent-soft) !important;
}

.chat-status-ticks.read {
    color: color-mix(in srgb, var(--staff-accent) 35%, #fff) !important;
}


html[data-theme="dark"] .team-presence-card {
    border-color: var(--staff-accent-border) !important;
}

html[data-theme="dark"] .team-presence-head {
    background: linear-gradient(180deg, color-mix(in srgb, var(--staff-accent) 12%, transparent), transparent) !important;
}

html[data-theme="dark"] .team-chip,
html[data-theme="dark"] .presence-list .presence-row {
    border-color: color-mix(in srgb, var(--staff-accent) 22%, transparent) !important;
}

html[data-theme="dark"] .team-chip:hover,
html[data-theme="dark"] .presence-list .presence-row:hover {
    background: color-mix(in srgb, var(--staff-accent) 14%, transparent) !important;
}

html[data-theme="dark"] .staff-chat-box {
    border-color: var(--staff-accent-border) !important;
}



.chat-row.theirs .chat-message-actions {
    justify-content: flex-start
}

.chat-row.theirs .chat-action-btn {
    background: var(--staff-accent-soft) !important;
    color: var(--staff-accent-dark) !important;
    border: 1px solid var(--staff-accent-border) !important;
}

.chat-row.theirs .chat-action-btn:hover {
    background: color-mix(in srgb, var(--staff-accent) 18%, transparent) !important;
}

@media(max-width:640px) {
    .chat-message-actions {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important
    }
}



/* ===== نسخه جمع‌وجور تیم پشتیبانی و چت ===== */
.team-presence-compact {
    display: block;
    width: 100%;
    margin: 0 0 14px;
    padding: 9px 0;
    border: 0;
    border-radius: 15px;
    background: transparent;
    overflow: hidden;
}

.team-presence-summary {
    flex: 0 0 auto;
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 13px;
    border: 1px solid color-mix(in srgb, var(--primary, #06b6d4) 22%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--primary, #06b6d4) 7%, #fff);
    color: color-mix(in srgb, var(--primary, #06b6d4) 72%, #0f172a);
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.team-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .12)
}

.team-presence-compact .team-presence-inline {
    flex: 1 1 auto;
    min-width: 0;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    gap: 8px !important;
    padding: 0 !important;
    overflow: hidden !important;
    scrollbar-width: none;
}

.team-presence-compact .team-presence-inline::-webkit-scrollbar {
    display: none
}

.team-presence-compact .team-chip {
    position: relative;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 68px;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 9px !important;
    padding: 8px 10px !important;
    border: 1px solid rgba(148, 163, 184, .22) !important;
    border-radius: 14px !important;
    background: var(--card, #fff) !important;
    box-shadow: 0 4px 13px rgba(15, 23, 42, .045) !important;
    overflow: hidden !important;
    cursor: pointer;
}

.team-presence-compact .team-chip:before {
    display: none !important
}

.team-presence-compact .team-chip:hover {
    transform: none !important;
    border-color: color-mix(in srgb, var(--primary, #06b6d4) 35%, transparent) !important;
    background: color-mix(in srgb, var(--primary, #06b6d4) 4%, #fff) !important;
    box-shadow: 0 7px 18px color-mix(in srgb, var(--primary, #06b6d4) 10%, transparent) !important;
}

.team-presence-compact .presence-avatar {
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary, #06b6d4) 80%, #0f172a), var(--primary, #06b6d4)) !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    box-shadow: none !important;
}

.team-presence-compact .status-offline .presence-avatar {
    background: #94a3b8 !important;
    filter: grayscale(.3)
}

.team-presence-compact .presence-info {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important
}

.team-presence-compact .presence-info strong {
    display: block;
    font-size: 12px !important;
    line-height: 1.35 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.team-chip-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0
}

.team-presence-compact .presence-state {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px !important;
    border-radius: 999px;
    font-size: 9px !important;
    font-weight: 800 !important;
    white-space: nowrap
}

.team-presence-compact .presence-state:before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor
}

.team-presence-compact .presence-state.available {
    background: rgba(34, 197, 94, .09) !important;
    color: #15803d !important
}

.team-presence-compact .presence-state.away {
    background: rgba(245, 158, 11, .10) !important;
    color: #b45309 !important
}

.team-presence-compact .presence-state.offline {
    background: rgba(148, 163, 184, .13) !important;
    color: #64748b !important
}

.team-presence-compact .team-chip-role {
    font-size: 9px;
    color: var(--muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.team-chip-chat {
    flex: 0 0 auto;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 45px;
    padding-right: 8px;
    border-right: 1px solid rgba(148, 163, 184, .18);
    color: color-mix(in srgb, var(--primary, #06b6d4) 75%, #0f172a);
    font-size: 8.5px;
    font-weight: 900;
    white-space: nowrap;
}

.team-chip-chat .ico {
    width: 17px;
    height: 17px;
    fill: currentColor
}

.team-presence-compact .chat-unread-badge {
    position: absolute !important;
    top: 4px !important;
    left: 4px !important;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 9px;
    box-shadow: none
}

.team-presence-compact .chat-preview {
    display: none !important
}


/* پنجره چت؛ ساده‌تر و هماهنگ */
.staff-chat-box {
    width: min(390px, calc(100vw - 24px)) !important;
    height: min(590px, calc(100vh - 88px)) !important;
    border-radius: 18px !important;
    border: 1px solid rgba(148, 163, 184, .25) !important;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .22) !important
}

.staff-chat-head {
    min-height: 64px !important;
    padding: 10px 12px !important;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary, #06b6d4) 76%, #0f172a), var(--primary, #06b6d4)) !important
}

.staff-chat-head:before,
.staff-chat-head:after {
    display: none !important
}

.staff-chat-person .presence-avatar {
    width: 38px !important;
    height: 38px !important;
    flex-basis: 38px !important;
    border-radius: 12px !important
}

.staff-chat-person strong {
    font-size: 13px !important
}

.staff-chat-person small {
    font-size: 10px !important;
    margin-top: 2px !important
}

.chat-head-tool {
    height: 30px !important;
    padding: 0 7px !important;
    font-size: 10px !important
}

.staff-chat-close {
    width: 31px !important;
    height: 31px !important;
    border-radius: 9px !important;
    font-size: 20px !important
}

.staff-chat-messages {
    padding: 13px 11px !important;
    background: #f7fafc !important;
    background-image: none !important
}

.chat-bubble {
    font-size: 12px !important;
    padding: 8px 10px 6px !important;
    border-radius: 13px !important;
    box-shadow: none !important
}

.chat-row.mine .chat-bubble {
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary, #06b6d4) 78%, #0f172a), var(--primary, #06b6d4)) !important
}

.chat-row.theirs .chat-bubble {
    background: #fff !important;
    border: 1px solid rgba(148, 163, 184, .22) !important
}

.staff-chat-compose {
    gap: 7px !important;
    padding: 9px 10px 10px !important;
    box-shadow: none !important
}

.staff-chat-compose textarea {
    height: 41px !important;
    min-height: 41px !important;
    border-radius: 12px !important;
    font-size: 12px !important
}

.staff-chat-compose button {
    width: 41px !important;
    height: 41px !important;
    flex-basis: 41px !important;
    border-radius: 12px !important
}

html[data-theme="dark"] .team-presence-summary {
    background: rgba(15, 23, 42, .72);
    border-color: rgba(45, 212, 191, .18);
    color: #a5f3fc
}

html[data-theme="dark"] .team-presence-compact .team-chip {
    background: #162132 !important;
    border-color: #2b394b !important
}

html[data-theme="dark"] .team-presence-compact .team-chip:hover {
    background: #19283a !important
}

html[data-theme="dark"] .staff-chat-messages {
    background: #0f1724 !important
}

@media(max-width:640px) {
    .team-presence-compact {
        padding: 7px 0
    }

    .team-presence-compact .team-presence-inline {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--primary, #06b6d4) 25%, transparent) transparent;
        padding-bottom: 5px !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar {
        display: block;
        height: 4px
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar-thumb {
        background: color-mix(in srgb, var(--primary, #06b6d4) 25%, transparent);
        border-radius: 20px
    }

    .team-presence-compact .team-chip {
        flex: 0 0 190px !important;
        min-width: 190px !important;
        height: 64px;
        scroll-snap-align: start;
    }

    .staff-chat-box {
        height: min(76vh, 590px) !important
    }
}



/* ===== اسکرول افقی واکنش‌گرا برای رزولوشن‌های پایین‌تر ===== */
@media (max-width: 1180px) {
    .team-presence-compact {
        position: relative;
        overflow: visible !important;
        padding-bottom: 2px;
    }

    .team-presence-compact::before,
    .team-presence-compact::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 10px;
        width: 20px;
        z-index: 3;
        pointer-events: none;
    }

    .team-presence-compact::before {
        right: 0;
        background: linear-gradient(90deg, transparent, var(--bg, #f8fafc));
    }

    .team-presence-compact::after {
        left: 0;
        background: linear-gradient(270deg, transparent, var(--bg, #f8fafc));
    }

    .team-presence-compact .team-presence-inline {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 0 2px 9px !important;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--primary, #06b6d4) 42%, #94a3b8) color-mix(in srgb, var(--primary, #06b6d4) 7%, transparent);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scroll-padding-inline: 8px;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar {
        display: block !important;
        height: 7px;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar-track {
        background: color-mix(in srgb, var(--primary, #06b6d4) 7%, transparent);
        border-radius: 999px;
        margin-inline: 8px;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar-thumb {
        min-width: 52px;
        background: linear-gradient(90deg,
                color-mix(in srgb, var(--primary, #06b6d4) 72%, #0f172a),
                var(--primary, #06b6d4));
        border: 2px solid transparent;
        background-clip: padding-box;
        border-radius: 999px;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(90deg,
                color-mix(in srgb, var(--primary, #06b6d4) 82%, #0f172a),
                color-mix(in srgb, var(--primary, #06b6d4) 88%, #fff));
        background-clip: padding-box;
    }

    .team-presence-compact .team-chip {
        flex: 0 0 200px !important;
        min-width: 200px !important;
        max-width: 200px !important;
        scroll-snap-align: start;
        scroll-snap-stop: normal;
    }
}


@media (max-width: 760px) {

    .team-presence-compact::before,
    .team-presence-compact::after {
        width: 14px;
        bottom: 9px
    }

    .team-presence-compact .team-chip {
        flex-basis: 188px !important;
        min-width: 188px !important;
        max-width: 188px !important;
    }

    .team-presence-compact .team-presence-inline {
        padding-bottom: 8px !important;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar {
        height: 6px
    }
}


html[data-theme="dark"] .team-presence-compact::before {
    background: linear-gradient(90deg, transparent, var(--bg, #0f172a));
}

html[data-theme="dark"] .team-presence-compact::after {
    background: linear-gradient(270deg, transparent, var(--bg, #0f172a));
}



/* ===== اصلاح نهایی: فعال‌شدن اسکرول بر اساس عرض واقعی محل نمایش، نه فقط عرض مانیتور ===== */
.main,
.team-presence-compact {
    min-width: 0 !important;
    max-width: 100% !important;
}


.team-presence-compact {
    overflow: hidden !important;
}


.team-presence-compact .team-presence-inline {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 8px !important;

    /* همیشه قابل اسکرول است؛ فقط زمانی اسکرول ایجاد می‌شود که کارت‌ها واقعاً جا نشوند */
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 1px 2px 9px !important;

    scrollbar-width: thin !important;
    scrollbar-color:
        color-mix(in srgb, var(--primary, #06b6d4) 55%, #64748b) color-mix(in srgb, var(--primary, #06b6d4) 8%, transparent) !important;

    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 4px;
}


.team-presence-compact .team-presence-inline::-webkit-scrollbar {
    display: block !important;
    height: 7px !important;
}


.team-presence-compact .team-presence-inline::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--primary, #06b6d4) 8%, transparent) !important;
    border-radius: 999px !important;
    margin-inline: 6px !important;
}


.team-presence-compact .team-presence-inline::-webkit-scrollbar-thumb {
    min-width: 48px !important;
    border: 2px solid transparent !important;
    border-radius: 999px !important;
    background:
        linear-gradient(90deg,
            color-mix(in srgb, var(--primary, #06b6d4) 78%, #0f172a),
            var(--primary, #06b6d4)) padding-box !important;
}


.team-presence-compact .team-chip {
    /* در فضای کافی کارت‌ها کل عرض را پر می‌کنند؛ در فضای کم فشرده و خراب نمی‌شوند */
    flex: 1 0 205px !important;
    min-width: 205px !important;
    max-width: none !important;
    width: auto !important;
    box-sizing: border-box !important;
    scroll-snap-align: start;
}


/* لپ‌تاپ‌ها و رزولوشن‌های میانی */
@media (max-width:1400px) {
    .team-presence-compact .team-chip {
        flex-basis: 200px !important;
        min-width: 200px !important;
    }
}


/* تبلت و موبایل */
@media (max-width:760px) {
    .team-presence-compact .team-presence-inline {
        padding-bottom: 8px !important;
    }

    .team-presence-compact .team-chip {
        flex: 0 0 188px !important;
        min-width: 188px !important;
        max-width: 188px !important;
    }

    .team-presence-compact .team-presence-inline::-webkit-scrollbar {
        height: 6px !important;
    }
}


/* جلوگیری از بیرون‌زدگی اجزای داخلی کارت هنگام کم‌شدن عرض */
.team-presence-compact .presence-info,
.team-presence-compact .team-chip-meta {
    min-width: 0 !important;
    overflow: hidden !important;
}


.team-presence-compact .presence-info strong,
.team-presence-compact .team-chip-role {
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}


.team-presence-compact .team-chip-chat {
    flex-shrink: 0 !important;
}

/* ===== پیام خوانده‌نشده: برجسته‌سازی کل کارت پشتیبان در تمام صفحات ===== */
.team-chip.has-unread,
.presence-row.has-unread {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 52%, #ecfdf5 100%) !important;
    border-color: #22c55e !important;
    box-shadow: 0 12px 28px rgba(34, 197, 94, .24), 0 0 0 3px rgba(34, 197, 94, .11) !important;
    color: #14532d !important;
}
.team-chip.has-unread::before {
    background: linear-gradient(180deg, #16a34a, #22c55e) !important;
    width: 5px !important;
    opacity: 1 !important;
}
.team-chip.has-unread .presence-avatar,
.presence-row.has-unread .presence-avatar {
    background: linear-gradient(135deg, #16a34a, #15803d) !important;
    box-shadow: 0 8px 18px rgba(22, 163, 74, .28) !important;
}
.team-chip.has-unread .team-chip-chat,
.team-chip.has-unread .chat-preview,
.presence-row.has-unread .chat-preview {
    color: #166534 !important;
    font-weight: 900 !important;
}
.team-chip.has-unread:hover,
.presence-row.has-unread:hover {
    background: linear-gradient(135deg, #bbf7d0, #dcfce7) !important;
    border-color: #16a34a !important;
    box-shadow: 0 14px 32px rgba(34, 197, 94, .30), 0 0 0 4px rgba(34, 197, 94, .12) !important;
}
:root[data-theme="dark"] .team-chip.has-unread,
:root[data-theme="dark"] .presence-row.has-unread {
    background: linear-gradient(135deg, rgba(20,83,45,.96), rgba(22,101,52,.92)) !important;
    border-color: #4ade80 !important;
    color: #dcfce7 !important;
}

/* ویجت مشترک حضور در داشبورد و صفحه تیکت */
.shared-presence-widget { margin: 0 0 14px; }
.shared-presence-widget .team-presence-head { padding: 13px 16px 10px; }
.shared-presence-widget .presence-actions-inline { display:flex; gap:7px; flex-wrap:wrap; }
.shared-presence-widget .presence-action-mini { border:1px solid var(--line); background:var(--surface); color:var(--txt); border-radius:999px; padding:6px 10px; cursor:pointer; font-weight:800; font-size:11px; }
.shared-presence-widget .presence-action-mini.active { background:#0d9488; border-color:#0d9488; color:#fff; }
.shared-presence-widget .team-chip { cursor:pointer; }
