/* ═══════════════════════════════════════════════════════════════
   AI-BPMS Design System — شرکت فناوری پارسیان
   فونت: Vazirmatn | جهت: RTL | تم: Navy + Teal
═══════════════════════════════════════════════════════════════ */

/* ─── Custom Properties (Design Tokens) ─────────────────────── */
:root {
    /* رنگ‌های اصلی */
    --navy-950:    #050d1a;
    --navy-900:    #0a1628;
    --navy-800:    #0f2040;
    --navy-700:    #162b55;
    --navy-600:    #1e3a6e;
    --navy-500:    #2a5298;

    /* تیل / آبی‌فیروزه‌ای */
    --teal-400:    #2dd4bf;
    --teal-500:    #14b8a6;
    --teal-600:    #0d9488;
    --teal-glow:   rgba(20, 184, 166, 0.25);

    /* رنگ‌های محتوا */
    --bg-light:    #f0f4f8;
    --bg-card:     #ffffff;
    --bg-card-alt: #f8fafc;
    --text-primary:   #1a2744;
    --text-secondary: #4a5a78;
    --text-muted:     #7a8ba8;
    --text-light:     #b8c5d6;

    /* وضعیت‌ها */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger:  #ef4444;
    --color-info:    #3b82f6;

    /* سایه‌ها */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --shadow-lg:  0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.06);
    --shadow-xl:  0 20px 50px rgba(0,0,0,.15);
    --shadow-teal: 0 0 25px rgba(20, 184, 166, 0.3);

    /* مسیرها */
    --sidebar-w:     260px;
    --topbar-h:      64px;
    --footer-h:      44px;
    --border-radius: 12px;
    --border-radius-lg: 18px;

    /* انیمیشن */
    --transition: all .22s cubic-bezier(.4, 0, .2, 1);
    --transition-slow: all .4s cubic-bezier(.4, 0, .2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--teal-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-500); }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--navy-900);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition-slow);
    border-left: 1px solid rgba(255,255,255,.05);
    box-shadow: -5px 0 25px rgba(0,0,0,.3);
}

/* لوگو */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--teal-500), var(--navy-500));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-teal);
    flex-shrink: 0;
}

.logo-glyph {
    color: #fff;
    font-size: 1.4rem;
    font-weight: 900;
    font-style: italic;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-title {
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
}

.logo-sub {
    color: var(--teal-400);
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .05em;
    direction: ltr;
    text-align: right;
}

/* نام شرکت */
.sidebar-company {
    padding: 10px 20px 14px;
}

.company-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: .75rem;
    color: var(--text-light);
}

.company-dot {
    width: 7px;
    height: 7px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

/* ناوبری */
.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.nav-section-label {
    display: block;
    font-size: .67rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .1em;
    padding: 10px 8px 6px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 10px;
    color: #8fa3c1;
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 3px;
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
    transform: translateX(-2px);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(20,184,166,.18), rgba(42,82,152,.25));
    color: var(--teal-400);
    border: 1px solid rgba(20,184,166,.2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: var(--teal-500);
    border-radius: 2px 0 0 2px;
}

.nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: .8;
}

.nav-badge {
    margin-right: auto;
    background: var(--color-danger);
    color: #fff;
    font-size: .65rem;
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
}

/* کاربر */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    margin-top: auto;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--teal-600), var(--navy-500));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.user-name {
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--text-muted);
    font-size: .7rem;
}

.user-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--navy-900);
    flex-shrink: 0;
}

.user-status.online { background: var(--color-success); }

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition-slow);
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid rgba(0,0,0,.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
    gap: 16px;
}

.topbar-right,
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Toggle Button */
.sidebar-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
}

.sidebar-toggle:hover { background: var(--bg-light); }

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    color: var(--text-muted);
}

.breadcrumb-home { color: var(--teal-600); font-weight: 600; }
.breadcrumb-sep  { opacity: .5; }
.breadcrumb-current { color: var(--text-primary); font-weight: 600; }

/* Search */
.topbar-search {
    position: relative;
}

.topbar-search input {
    background: var(--bg-light);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 16px 8px 36px;
    font-family: inherit;
    font-size: .82rem;
    color: var(--text-primary);
    width: 220px;
    transition: var(--transition);
    direction: rtl;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--teal-500);
    background: #fff;
    box-shadow: 0 0 0 3px var(--teal-glow);
    width: 280px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

/* Topbar Buttons */
.topbar-btn {
    width: 38px;
    height: 38px;
    background: var(--bg-light);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    position: relative;
    transition: var(--transition);
    color: var(--text-secondary);
}

.topbar-btn:hover {
    background: var(--teal-glow);
    color: var(--teal-600);
}

.notif-badge {
    position: absolute;
    top: -3px;
    left: -3px;
    background: var(--color-danger);
    color: #fff;
    font-size: .6rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid var(--bg-card);
}

/* Clock */
.topbar-clock {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 7px 14px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    direction: ltr;
}

/* AI Status */
.ai-status {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(20,184,166,.08);
    border: 1px solid rgba(20,184,166,.2);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--teal-600);
    cursor: pointer;
    transition: var(--transition);
}

.ai-status:hover { background: var(--teal-glow); }

.ai-dot {
    width: 8px;
    height: 8px;
    background: var(--teal-500);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* ─── Notification Panel ─────────────────────────────────────── */
.notif-panel {
    position: fixed;
    left: 24px;
    top: var(--topbar-h);
    width: 340px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    border: 1px solid rgba(0,0,0,.06);
    overflow: hidden;
    animation: slideDown .2s ease;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-weight: 700;
    font-size: .9rem;
}

.notif-clear {
    background: none;
    border: none;
    color: var(--teal-600);
    cursor: pointer;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 600;
    transition: var(--transition);
}

.notif-clear:hover { color: var(--teal-500); }

.notif-list { max-height: 380px; overflow-y: auto; }

.notif-item {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0,0,0,.04);
    transition: var(--transition);
    cursor: pointer;
}

.notif-item:hover { background: var(--bg-light); }
.notif-item.unread { background: rgba(20,184,166,.04); }

.notif-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.notif-item-icon.info    { background: rgba(59,130,246,.1);  color: var(--color-info); }
.notif-item-icon.success { background: rgba(16,185,129,.1);  color: var(--color-success); }
.notif-item-icon.warning { background: rgba(245,158,11,.1);  color: var(--color-warning); }
.notif-item-icon.error   { background: rgba(239,68,68,.1);   color: var(--color-danger); }

.notif-item-body { flex: 1; }
.notif-item-title { font-size: .83rem; font-weight: 600; margin-bottom: 3px; }
.notif-item-text  { font-size: .77rem; color: var(--text-muted); line-height: 1.5; }
.notif-item-time  { font-size: .68rem; color: var(--text-light); margin-top: 4px; }

/* ─── Page Content ───────────────────────────────────────────── */
.page-content {
    flex: 1;
    padding: 28px;
    overflow-x: hidden;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.app-footer {
    height: var(--footer-h);
    background: var(--bg-card);
    border-top: 1px solid rgba(0,0,0,.06);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: .75rem;
    color: var(--text-muted);
}

.footer-sep { opacity: .4; }

/* ═══════════════════════════════════════════════════════════════
   CARDS & LAYOUT COMPONENTS
═══════════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,.05);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(0,0,0,.05);
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--teal-500), var(--navy-500));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    color: #fff;
}

.card-body { padding: 20px 22px; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ─── KPI Cards (Stat Cards) ─────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,.05);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.stat-card.teal::before   { background: var(--teal-500); }
.stat-card.blue::before   { background: var(--color-info); }
.stat-card.green::before  { background: var(--color-success); }
.stat-card.orange::before { background: var(--color-warning); }
.stat-card.red::before    { background: var(--color-danger); }

.stat-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-card-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card.teal   .stat-card-icon { background: rgba(20,184,166,.1);  color: var(--teal-500); }
.stat-card.blue   .stat-card-icon { background: rgba(59,130,246,.1);  color: var(--color-info); }
.stat-card.green  .stat-card-icon { background: rgba(16,185,129,.1);  color: var(--color-success); }
.stat-card.orange .stat-card-icon { background: rgba(245,158,11,.1);  color: var(--color-warning); }
.stat-card.red    .stat-card-icon { background: rgba(239,68,68,.1);   color: var(--color-danger); }

.stat-card-change {
    font-size: .73rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
}

.stat-card-change.up   { background: rgba(16,185,129,.1);  color: var(--color-success); }
.stat-card-change.down { background: rgba(239,68,68,.1);   color: var(--color-danger); }

.stat-card-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card-label {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    color: #fff;
    box-shadow: 0 4px 12px rgba(20,184,166,.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20,184,166,.45);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid rgba(0,0,0,.08);
}

.btn-secondary:hover:not(:disabled) { background: #e8edf3; }

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239,68,68,.3);
}

.btn-ghost {
    background: transparent;
    color: var(--teal-600);
    border: 1px solid rgba(20,184,166,.3);
}

.btn-ghost:hover { background: var(--teal-glow); }

.btn-sm  { padding: 6px 14px; font-size: .78rem; }
.btn-lg  { padding: 13px 28px; font-size: .95rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    background: var(--bg-light);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: .88rem;
    color: var(--text-primary);
    width: 100%;
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--teal-500);
    background: #fff;
    box-shadow: 0 0 0 3px var(--teal-glow);
}

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success { background: rgba(16,185,129,.12);  color: #059669; }
.badge-warning { background: rgba(245,158,11,.12);  color: #d97706; }
.badge-danger  { background: rgba(239,68,68,.12);   color: #dc2626; }
.badge-info    { background: rgba(59,130,246,.12);  color: #2563eb; }
.badge-muted   { background: rgba(0,0,0,.06);        color: var(--text-muted); }
.badge-teal    { background: rgba(20,184,166,.12);  color: var(--teal-600); }

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.table thead th {
    background: var(--bg-card-alt);
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid rgba(0,0,0,.07);
    white-space: nowrap;
}

.table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid rgba(0,0,0,.04);
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover { background: rgba(20,184,166,.04); }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0,0,0,.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal-600), var(--teal-400));
    border-radius: 3px;
    transition: width .6s ease;
}

/* ─── Status Indicators ──────────────────────────────────────── */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
}

.status-dot.running   { background: var(--color-info);    animation: pulse 2s infinite; }
.status-dot.completed { background: var(--color-success); }
.status-dot.pending   { background: var(--color-warning); }
.status-dot.cancelled { background: var(--color-danger); }

/* ═══════════════════════════════════════════════════════════════
   AI COMPONENTS
═══════════════════════════════════════════════════════════════ */

/* FAB دکمه شناور */
.ai-fab {
    position: fixed;
    bottom: 28px;
    left: 28px;
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, var(--teal-500), var(--navy-600));
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(20,184,166,.5);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    overflow: hidden;
}

.ai-fab:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 12px 35px rgba(20,184,166,.6);
}

.ai-fab-icon { position: relative; z-index: 2; }

.ai-fab-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    animation: ripplePulse 2.5s infinite;
}

/* پنل چت هوش مصنوعی */
.ai-chat-panel {
    position: fixed;
    bottom: 100px;
    left: 28px;
    width: 380px;
    height: 500px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 149;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.08);
    animation: slideUp .3s cubic-bezier(.4,0,.2,1);
}

.ai-chat-header {
    background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: .88rem;
    font-weight: 700;
}

.ai-chat-icon {
    color: var(--teal-400);
    font-size: 1.1rem;
    animation: spin 4s linear infinite;
}

.ai-chat-close {
    background: rgba(255,255,255,.1);
    border: none;
    color: rgba(255,255,255,.7);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .8rem;
    transition: var(--transition);
}

.ai-chat-close:hover { background: rgba(255,255,255,.2); color: #fff; }

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    gap: 4px;
}

.ai-message--bot  { align-self: flex-start; }
.ai-message--user { align-self: flex-end; }

.ai-message-content {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: .84rem;
    line-height: 1.6;
}

.ai-message--bot .ai-message-content {
    background: var(--bg-light);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.ai-message--user .ai-message-content {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    color: #fff;
    border-bottom-left-radius: 4px;
    direction: rtl;
}

.ai-message-time {
    font-size: .67rem;
    color: var(--text-muted);
    padding: 0 4px;
}

.ai-message--user .ai-message-time { text-align: left; }

.ai-chat-input {
    padding: 14px;
    border-top: 1px solid rgba(0,0,0,.06);
    display: flex;
    gap: 10px;
}

.ai-chat-input textarea {
    flex: 1;
    background: var(--bg-light);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: .83rem;
    color: var(--text-primary);
    resize: none;
    transition: var(--transition);
    direction: rtl;
}

.ai-chat-input textarea:focus {
    outline: none;
    border-color: var(--teal-400);
    background: #fff;
}

.ai-send-btn {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.ai-send-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-teal); }

.send-arrow { font-size: 1rem; }

/* Typewriter */
.typewriter::after {
    content: '▊';
    animation: blink .75s step-start infinite;
    color: var(--teal-500);
    font-size: .8em;
}

/* AI Loading */
.ai-thinking {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    background: var(--bg-light);
    border-radius: 14px;
    width: fit-content;
}

.ai-thinking span {
    width: 8px;
    height: 8px;
    background: var(--teal-400);
    border-radius: 50%;
    animation: thinking .9s infinite ease-in-out;
}

.ai-thinking span:nth-child(2) { animation-delay: .2s; }
.ai-thinking span:nth-child(3) { animation-delay: .4s; }

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 16px);
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow-lg);
    border-right: 4px solid;
    min-width: 300px;
    max-width: 380px;
    animation: slideInLeft .3s ease;
    transition: var(--transition);
}

.toast.removing {
    animation: slideOutLeft .25s ease forwards;
}

.toast-success { border-color: var(--color-success); }
.toast-warning { border-color: var(--color-warning); }
.toast-error   { border-color: var(--color-danger); }
.toast-info    { border-color: var(--color-info); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-size: .85rem; font-weight: 700; margin-bottom: 3px; }
.toast-text  { font-size: .78rem; color: var(--text-muted); line-height: 1.4; }
.toast-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: .9rem; padding: 0;
    line-height: 1; transition: var(--transition);
}
.toast-close:hover { color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════════
   LOADING STATES
═══════════════════════════════════════════════════════════════ */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(20,184,166,.2);
    border-top-color: var(--teal-500);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, #f0f4f8 25%, #e8edf3 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   PROCESS FLOW (BPMN-like)
═══════════════════════════════════════════════════════════════ */
.process-flow {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 20px 0;
}

.process-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 120px;
    position: relative;
}

.process-step-node {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid transparent;
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.process-step-node.completed {
    background: rgba(16,185,129,.1);
    border-color: var(--color-success);
    color: var(--color-success);
}

.process-step-node.in-progress {
    background: rgba(59,130,246,.1);
    border-color: var(--color-info);
    color: var(--color-info);
    animation: glowPulse 2s infinite;
}

.process-step-node.pending {
    background: rgba(0,0,0,.05);
    border-color: rgba(0,0,0,.12);
    color: var(--text-muted);
}

.process-step-node.rejected {
    background: rgba(239,68,68,.1);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

.process-step-label {
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    max-width: 110px;
    line-height: 1.4;
}

.process-connector {
    width: 40px;
    height: 2px;
    background: rgba(0,0,0,.1);
    flex-shrink: 0;
    position: relative;
}

.process-connector.completed { background: var(--color-success); }
.process-connector.active    { background: var(--color-info); }

.process-connector::after {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 8px solid rgba(0,0,0,.15);
}

.process-connector.completed::after { border-right-color: var(--color-success); }
.process-connector.active::after    { border-right-color: var(--color-info); }

/* ═══════════════════════════════════════════════════════════════
   HEATMAP (Process Mining)
═══════════════════════════════════════════════════════════════ */
.heatmap-cell {
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    transition: var(--transition);
    cursor: pointer;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.heatmap-cell:hover { transform: scale(1.05); box-shadow: var(--shadow-md); }

/* ═══════════════════════════════════════════════════════════════
   KANBAN BOARD (CRM)
═══════════════════════════════════════════════════════════════ */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
    align-items: flex-start;
}

.kanban-column {
    min-width: 230px;
    max-width: 250px;
    flex-shrink: 0;
    background: var(--bg-card-alt);
    border-radius: var(--border-radius);
    padding: 14px;
    border: 1px solid rgba(0,0,0,.06);
}

.kanban-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.kanban-col-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.kanban-col-count {
    font-size: .72rem;
    background: rgba(0,0,0,.08);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

.kanban-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 13px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,.04);
    cursor: pointer;
    transition: var(--transition);
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kanban-card-name  { font-size: .85rem; font-weight: 700; margin-bottom: 6px; }
.kanban-card-company { font-size: .75rem; color: var(--text-muted); margin-bottom: 10px; }

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lead-score {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lead-score-bar {
    width: 40px;
    height: 4px;
    background: rgba(0,0,0,.1);
    border-radius: 2px;
    overflow: hidden;
}

.lead-score-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--color-warning), var(--color-success));
}

.lead-score-num {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Sentiment */
.sentiment { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.sentiment-positive { background: rgba(16,185,129,.1);  color: #059669; }
.sentiment-neutral  { background: rgba(0,0,0,.06);       color: var(--text-muted); }
.sentiment-negative { background: rgba(239,68,68,.1);   color: #dc2626; }

/* ═══════════════════════════════════════════════════════════════
   GANTT CHART
═══════════════════════════════════════════════════════════════ */
.gantt-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

.gantt-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,.05);
    min-height: 44px;
}

.gantt-row:hover { background: rgba(20,184,166,.04); }

.gantt-task-name {
    min-width: 200px;
    max-width: 200px;
    padding: 10px 16px;
    font-size: .82rem;
    font-weight: 600;
    border-left: 1px solid rgba(0,0,0,.06);
    color: var(--text-primary);
}

.gantt-bar-area {
    flex: 1;
    position: relative;
    height: 44px;
    display: flex;
    align-items: center;
}

.gantt-bar {
    position: absolute;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: var(--transition);
}

.gantt-bar:hover { filter: brightness(1.1); transform: scaleY(1.1); }

.gantt-bar.done        { background: linear-gradient(90deg, #059669, #10b981); }
.gantt-bar.in_progress { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.gantt-bar.todo        { background: linear-gradient(90deg, #64748b, #94a3b8); }
.gantt-bar.review      { background: linear-gradient(90deg, #d97706, #f59e0b); }

/* ═══════════════════════════════════════════════════════════════
   OVERLAY
═══════════════════════════════════════════════════════════════ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(2px);
    z-index: 140;
    transition: var(--transition);
}

/* ═══════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn .25s cubic-bezier(.4,0,.2,1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: var(--bg-light);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    transition: var(--transition);
    color: var(--text-muted);
}

.modal-close:hover { background: rgba(239,68,68,.1); color: var(--color-danger); }

.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid rgba(0,0,0,.06); display: flex; gap: 10px; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 20px;
}

.page-header-text {}
.page-header-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header-subtitle {
    font-size: .85rem;
    color: var(--text-muted);
}

.page-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
═══════════════════════════════════════════════════════════════ */
.hidden    { display: none !important; }
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.w-full { width: 100%; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: .82rem; }
.font-bold   { font-weight: 700; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
}

.empty-state-icon { font-size: 3rem; opacity: .3; }
.empty-state-title { font-size: 1rem; font-weight: 700; color: var(--text-secondary); }
.empty-state-text  { font-size: .83rem; color: var(--text-muted); max-width: 300px; line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════════ */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .7; transform: scale(.9); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes blink {
    50% { opacity: 0; }
}

@keyframes thinking {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30%           { transform: translateY(-8px); opacity: 1; }
}

@keyframes ripplePulse {
    0%   { transform: scale(.8); opacity: .8; }
    100% { transform: scale(1.8); opacity: 0; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,.3); }
    50%       { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutLeft {
    to { opacity: 0; transform: translateX(-20px); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(100%);
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
        --sidebar-w: 260px;
    }

    .main-content { margin-right: 0; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .topbar-search { display: none; }

    .page-content { padding: 16px; }

    .ai-chat-panel { left: 12px; right: 12px; width: auto; }

    .kanban-board { flex-direction: column; }
    .kanban-column { min-width: unset; max-width: 100%; }

    .page-header { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════════
   CHART.JS OVERRIDE (RTL-friendly)
═══════════════════════════════════════════════════════════════ */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-wrapper canvas { max-height: 100%; }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR COLLAPSED STATE
═══════════════════════════════════════════════════════════════ */
body.sidebar-collapsed .sidebar {
    width: 64px;
}

body.sidebar-collapsed .sidebar .logo-text,
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .nav-badge,
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .company-badge,
body.sidebar-collapsed .sidebar .user-info,
body.sidebar-collapsed .sidebar .user-status {
    display: none;
}

body.sidebar-collapsed .sidebar .logo-icon { margin: 0 auto; }
body.sidebar-collapsed .sidebar .sidebar-logo { justify-content: center; }
body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 12px; }
body.sidebar-collapsed .sidebar .nav-item.active::before { display: none; }
body.sidebar-collapsed .sidebar .sidebar-user { justify-content: center; }

body.sidebar-collapsed .main-content { margin-right: 64px; }

/* ─── Transition for collapse ───── */
.sidebar, .main-content,
.logo-text, .nav-label, .user-info,
.nav-section-label, .company-badge {
    transition: var(--transition-slow);
}
/* Pagination CSS در main.css اضافه کن */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 0;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: var(--transition);
    padding: 0 10px;
}

.page-btn:hover {
    background: var(--teal-glow);
    border-color: var(--teal-500);
    color: var(--teal-600);
}

.page-btn.active {
    background: var(--teal-600);
    color: #fff;
    border-color: var(--teal-600);
}

.page-dots {
    color: var(--text-muted);
    font-size: .85rem;
}
/* در main.css */
.field-error {
    color: var(--color-danger);
    font-size: .75rem;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-group.has-error .form-control {
    border-color: var(--color-danger);
    background: rgba(239,68,68,.04);
}