/* ---------- فونت وزیرمتن ---------- */
@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-SemiBold.woff2') format('woff2');
    font-weight: 600; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-ExtraBold.woff2') format('woff2');
    font-weight: 800; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Black.woff2') format('woff2');
    font-weight: 900; font-display: swap;
}

/* ---------- پایه ---------- */
* {
    box-sizing: border-box;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}
body {
    margin: 0;
    background: #f0f2f7;
    color: #2c3e50;
    direction: rtl;
    font-size: 14.5px;
    line-height: 1.7;
}

/* ---------- Layout ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar (سمت راست) ---------- */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #cbd5e1;
    padding: 22px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
}
.sidebar .brand {
    padding: 0 24px 22px;
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    border-bottom: 1px solid #334155;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}
.sidebar .brand span {
    color: #38bdf8;
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 14.5px;
    border-right: 3px solid transparent;
    transition: all 0.15s;
}
.sidebar nav a:hover {
    background: #1e293b;
    color: #fff;
}
.sidebar nav a.active {
    background: #1e293b;
    color: #fff;
    border-right-color: #38bdf8;
}
.sidebar nav a .icon {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- Topbar ---------- */
.topbar {
    background: #fff;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar .date-box {
    font-weight: 500;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.topbar .date-box b {
    color: #1e293b;
    font-weight: 700;
}
.topbar .date-box .dot {
    color: #cbd5e1;
}
.topbar .right-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ---------- Notif bell ---------- */
.notif {
    position: relative;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f1f5f9;
    transition: 0.15s;
}
.notif:hover { background: #e2e8f0; }
.notif .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* ---------- Container ---------- */
.container {
    padding: 26px 28px 40px;
    flex: 1;
}
.page-title {
    margin: 0 0 22px;
    font-size: 22px;
    font-weight: 900;
    color: #0f172a;
}

/* ---------- Card ---------- */
.card {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    margin-bottom: 18px;
    border: 1px solid #eef2f7;
}
.card h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

/* ---------- KPI ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

/* تبلت: ۲ ستون */
@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* موبایل: ۱ ستون */
@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
.kpi {
    background: #fff;
    padding: 22px;
    border-radius: 14px;
    border: 1px solid #eef2f7;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: var(--accent, #3b82f6);
}
.kpi .kpi-label {
    color: #64748b;
    font-size: 13.5px;
    margin-bottom: 8px;
    font-weight: 500;
}
.kpi .kpi-num {
    font-size: 30px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.1;
}
.kpi .kpi-sub {
    color: #94a3b8;
    font-size: 12.5px;
    margin-top: 6px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3b82f6;
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.15s;
}
.btn:hover { background: #2563eb; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ok { background: #10b981; }
.btn-ok:hover { background: #059669; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost {
    background: #f1f5f9;
    color: #334155;
}
.btn-ghost:hover { background: #e2e8f0; }
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 7px;
}

/* ---------- Forms ---------- */
input, textarea, select {
    width: 100%;
    padding: 10px 13px;
    margin: 6px 0 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    transition: 0.15s;
    color: #1e293b;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
label {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
    color: #334155;
    margin-top: 8px;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
}
th {
    background: #f8fafc;
    font-weight: 700;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
tbody tr {
    transition: 0.1s;
    border-right: 4px solid transparent;
}
tbody tr:hover {
    background: #f8fafc;
}

/* وضعیتها */
tr.status-new { border-right-color: #94a3b8; }
tr.status-contacted { border-right-color: #3b82f6; background: rgba(59,130,246,0.03); }
tr.status-interested { border-right-color: #f59e0b; background: rgba(245,158,11,0.04); }
tr.status-converted { border-right-color: #10b981; background: rgba(16,185,129,0.05); }
tr.status-lost { border-right-color: #ef4444; background: rgba(239,68,68,0.04); }

/* Badges */
.badge-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
}
.badge-new { background: #f1f5f9; color: #475569; }
.badge-contacted { background: #dbeafe; color: #1e40af; }
.badge-interested { background: #fef3c7; color: #92400e; }
.badge-converted { background: #d1fae5; color: #065f46; }
.badge-lost { background: #fee2e2; color: #991b1b; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-box {
    background: #fff;
    padding: 40px 36px;
    border-radius: 16px;
    width: 380px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.login-box h2 {
    margin: 0 0 26px;
    text-align: center;
    color: #0f172a;
    font-weight: 900;
    font-size: 22px;
}
.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.login-box .err {
    color: #ef4444;
    text-align: center;
    margin-top: 12px;
    font-size: 13.5px;
    font-weight: 500;
}

/* ---------- Misc ---------- */
.empty {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-size: 15px;
}
.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ---------- Lead detail ---------- */
.report-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.report-item {
    background: #f8fafc;
    border-right: 3px solid #3b82f6;
    border-radius: 10px;
    padding: 12px 14px;
}
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.report-type {
    font-weight: 700;
    font-size: 13px;
    color: #1e40af;
}
.report-date {
    color: #94a3b8;
    font-size: 12px;
}
.report-body {
    color: #334155;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- Leads table ---------- */
.leads-table {
    table-layout: fixed;
    width: 100%;
}
.leads-table th,
.leads-table td {
    padding: 10px 12px;
    vertical-align: middle;
}
.leads-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* سلول آخرین گزارش: تک‌خطی با سه‌نقطه */
.leads-table .last-report-line {
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    overflow: hidden;
}
.leads-table .last-report-icon {
    flex-shrink: 0;
    font-size: 13px;
}
.leads-table .last-report-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    color: #334155;
}

/* دکمه‌های عملیات کوچیک‌تر و کنار هم */
.leads-table .btn-sm {
    padding: 5px 9px;
    font-size: 13px;
}
.leads-table .row-actions {
    gap: 5px;
    justify-content: flex-start;
}

/* روی موبایل، اجازه بده جدول اسکرول افقی بشه */
@media (max-width: 1100px) {
    .leads-table {
        table-layout: auto;
    }
    .leads-table td,
    .leads-table th {
        white-space: nowrap;
    }
}

/* ==================== Dashboard ==================== */

/* KPI قبلاً بود ولی یه سری ریزه‌کاری */
.kpi .kpi-num {
    font-variant-numeric: tabular-nums;
}

/* چیدمان دو ستونه داشبورد */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
@media (max-width: 1000px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Funnel ---------- */
.funnel {
    padding: 8px 0;
}
.funnel-step {
    margin-bottom: 16px;
}
.funnel-bar {
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    transition: width 0.6s ease;
    min-width: 100px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.funnel-bar span {
    white-space: nowrap;
}
.funnel-label {
    font-size: 12.5px;
    color: #64748b;
    margin-top: 5px;
    font-weight: 500;
}

/* ---------- Bar chart ---------- */
.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12.5px;
    color: #475569;
    margin-bottom: 14px;
}
.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.chart-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 200px;
    gap: 8px;
    padding: 10px 4px 0;
    border-bottom: 1px solid #e2e8f0;
}
.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}
.bar-group .bars {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 100%;
}
.bar-group .bar {
    width: 8px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    transition: 0.3s;
    position: relative;
}
.bar-group .bar:hover {
    opacity: 0.75;
}
.bar-group .bar-label {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    padding-top: 8px;
    white-space: nowrap;
    font-weight: 500;
}

/* ---------- Mini tables ---------- */
.mini-table {
    width: 100%;
    border-collapse: collapse;
}
.mini-table td {
    padding: 9px 6px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.mini-table tr:last-child td {
    border-bottom: none;
}
.mini-table tr:hover {
    background: #f8fafc;
}