/* =====================================================
   حسابداری قارچ رباط — استایل اصلی
   ===================================================== */

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Light.woff2') format('woff2');
    font-weight: 300;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-light: #a78bfa;
    --primary-soft: #ede9fe;
    --sidebar-bg: #5b21b6;
    --bg-body: #f5f3ff;
    --bg-card: #ffffff;
    --text-primary: #1e1b4b;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border: #e9e4f5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 3px rgba(30, 27, 75, 0.06);
    --shadow: 0 4px 12px rgba(30, 27, 75, 0.07);
    --shadow-md: 0 12px 28px rgba(30, 27, 75, 0.09);
    --shadow-lg: 0 24px 48px rgba(30, 27, 75, 0.12);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

/* ===== صفحه ورود ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 15% 20%, rgba(124, 58, 237, 0.15), transparent 45%),
                radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.15), transparent 45%),
                linear-gradient(135deg, #f5f3ff 0%, #eef2ff 100%);
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    border-radius: 24px;
    font-size: 42px;
    box-shadow: 0 20px 40px rgba(124, 58, 237, 0.35);
}
.login-logo h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-logo p { font-size: 13px; color: var(--text-muted); }

.form-group { margin-bottom: 22px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-control {
    width: 100%;
    padding: 13px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: #fff;
    box-shadow: 0 12px 28px rgba(124, 58, 237, 0.28);
    padding: 14px 24px;
}
.btn-primary:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 20px 40px rgba(124, 58, 237, 0.35);
    color: #fff;
}

.alert { padding: 14px 18px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 20px; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.login-footer { text-align: center; margin-top: 32px; font-size: 12px; color: var(--text-muted); }

/* ===================================================== */
/* ===== لایه اصلی اپ ===== */
/* ===================================================== */
.app-layout { display: flex; min-height: 100vh; background: var(--bg-body); }

/* ===================================================== */
/* ===== سایدبار (ثابت و بدون دکمه) ===== */
/* ===================================================== */
.sidebar {
    width: 268px;
    background: linear-gradient(180deg, #6d28d9 0%, #5b21b6 50%, #4c1d95 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    color: #ddd6fe;
    box-shadow: -8px 0 32px rgba(76, 29, 149, 0.25);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    font-size: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.sidebar-brand-text h2 { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.3; }
.sidebar-brand-text p { font-size: 11px; color: rgba(255, 255, 255, 0.7); }
.sidebar-nav { flex: 1; padding: 20px 14px; overflow-y: auto; }
.nav-section { margin-bottom: 26px; }
.nav-section-title { font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.45); padding: 0 12px 10px; letter-spacing: 1px; text-transform: uppercase; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: #ddd6fe;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 4px;
    position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; transform: translateX(-3px); }
.nav-item.active { background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.nav-item-icon { font-size: 18px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }

/* ===================================================== */
/* ===== محتوای اصلی ===== */
/* ===================================================== */
.main-content { flex: 1; margin-right: 268px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 16px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title h1 { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.topbar-title p { font-size: 12px; color: var(--text-muted); }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.topbar-user-info { text-align: left; }
.topbar-user-name { font-size: 13px; font-weight: 600; }
.topbar-user-role { font-size: 11px; color: var(--text-muted); }
.topbar-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}
.btn-logout {
    padding: 9px 16px;
    font-size: 13px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.btn-logout:hover { background: #fee2e2; transform: translateY(-2px); color: #b91c1c; }
.content-area { flex: 1; padding: 30px; }
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.page-header p { font-size: 14px; color: var(--text-secondary); }

/* ===== کارت‌های آماری ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid transparent; transition: var(--transition); }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-card-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.stat-card-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 14px; font-size: 22px; }
.stat-card-icon.purple { background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%); color: #7c3aed; }
.stat-card-icon.green { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); color: #059669; }
.stat-card-icon.orange { background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%); color: #ea580c; }
.stat-card-icon.blue { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #2563eb; }
.stat-card-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.stat-card-change { font-size: 12px; color: var(--text-muted); }

/* ===== کارت عمومی ===== */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid transparent; transition: var(--transition); }
.card-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.card-steps { color: var(--text-secondary); line-height: 2.2; font-size: 14px; }

/* ===== اسکرول‌بار ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); background-clip: content-box; }

/* ===================================================== */
/* ===== ریسپانسیو (موبایل) ===== */
/* ===================================================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .main-content { margin-right: 0 !important; }
    
    .topbar { padding: 12px 16px; }
    .topbar-title h1 { font-size: 16px; }
    .topbar-user-info { display: none; }
    
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr !important; }
    .stat-card { padding: 16px; }
    .stat-card-value { font-size: 22px; }
    
    .form-row, .form-row.three, .info-grid, .client-grid { grid-template-columns: 1fr !important; }
    .invoice-paper { padding: 20px !important; }
    .invoice-header { flex-direction: column !important; align-items: flex-start !important; gap: 16px; }
    .invoice-meta { text-align: right !important; width: 100%; }
    .items-table-wrapper, .tree-container { overflow-x: auto; }
    .action-bar { flex-direction: column; gap: 12px; }
    .btn-action { width: 100%; justify-content: center; }
    
    .chat-container { height: calc(100vh - 160px) !important; border-radius: 16px; }
    .message { max-width: 95% !important; }
}

/* ===== استایل اختصاصی صفحه چت ===== */
.chat-page {
    display: flex; flex-direction: column; height: calc(100vh - 160px);
    background: #fff; border-radius: 20px; box-shadow: 0 8px 32px rgba(30, 27, 75, 0.08); overflow: hidden;
}
.chat-header {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    padding: 20px 24px; display: flex; align-items: center; gap: 16px;
}
.chat-header-avatar {
    width: 48px; height: 48px; background: rgba(255,255,255,0.2);
    border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.chat-header-info h3 { font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 2px; }
.chat-header-info p { font-size: 12px; color: rgba(255,255,255,0.8); }
.chat-messages {
    flex: 1; padding: 20px; overflow-y: auto; background: #faf9fe;
    display: flex; flex-direction: column; gap: 20px;
}
.message { display: flex; gap: 12px; max-width: 85%; }
.message.user { align-self: flex-start; flex-direction: row-reverse; }
.message.bot { align-self: flex-end; }
.message-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.message.user .message-avatar { background: #ede9fe; color: #7c3aed; }
.message.bot .message-avatar { background: #d1fae5; color: #059669; }
.message-bubble { padding: 14px 18px; border-radius: 16px; font-size: 14px; line-height: 1.8; }
.message.user .message-bubble {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
    color: #fff; border-top-right-radius: 4px;
}
.message.bot .message-bubble {
    background: #fff; color: #1e1b4b; border: 1px solid #f0edf7; border-top-left-radius: 4px;
}
.chat-input-area {
    padding: 16px 20px; background: #fff; border-top: 1px solid #f0edf7;
    display: flex; gap: 12px;
}
.chat-input {
    flex: 1; padding: 14px 18px; background: #faf9fe; border: 1