/* ============================================================
   پلتفرم مدیریت داده — Admin UI (RTL / Farsi / Vazirmatn)
   ============================================================ */

@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-active: #ffffff;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --font: 'Vazirmatn', 'Tahoma', sans-serif;
    --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; line-height: 1.4; }
.h1 { font-size: 22px; }
.h2 { font-size: 19px; }
.h3 { font-size: 17px; }
.h4 { font-size: 15px; }

.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 20px; }

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

/* ============ Layout ============ */

.layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transform: translateX(105%);
    transition: transform .25s ease;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand .logo-badge {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-size: 18px;
}

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.sidebar-nav .nav-section-title {
    font-size: 11px;
    color: #475569;
    padding: 10px 12px 4px;
    letter-spacing: .5px;
}

.sidebar-nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    transition: background .15s, color .15s;
}

.sidebar-nav a.nav-link .nav-icon { width: 22px; text-align: center; font-size: 16px; }

.sidebar-nav a.nav-link:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-text-hover); }

.sidebar-nav a.nav-link.active {
    background: var(--primary);
    color: var(--sidebar-active);
    font-weight: 500;
}

.sidebar-nav .nav-badge {
    margin-inline-start: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 8px;
    min-width: 22px;
    text-align: center;
}

.sidebar-nav a.nav-link.active .nav-badge {
    background: rgba(255, 255, 255, .22);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.sidebar-footer .user-meta { overflow: hidden; }
.sidebar-footer .user-meta strong { color: #e2e8f0; display: block; font-size: 13px; }
.sidebar-footer .user-meta span { font-size: 11px; color: #64748b; }

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 40;
    display: none;
}
.sidebar-backdrop.show { display: block; }

.main { margin-right: 0; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0;
    height: 64px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    z-index: 30;
}

.topbar-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
    width: 40px; height: 40px;
    display: none;
    place-items: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
}
.icon-btn:hover { background: var(--bg); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
}

.user-chip .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
}

.content { flex: 1; padding: 24px; }

/* ============ Cards ============ */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.card-header h3 { margin: 0; font-size: 15px; }

.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.stat-card { display: flex; align-items: center; gap: 16px; }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: grid; place-items: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }

.stat-label { color: var(--text-muted); font-size: 13px; }

/* ============ Buttons ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }

.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }

/* ============ Forms ============ */

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.textarea { resize: vertical; min-height: 90px; }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }

.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ============ Alerts / Flash ============ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: #075985; border-color: #bae6fd; }

.alert .alert-close { margin-inline-start: auto; cursor: pointer; background: none; border: none; font-size: 16px; color: inherit; opacity: .6; }

/* ============ Badges ============ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: #166534; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: var(--info-bg); color: #075985; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ============ Tables ============ */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th, .table td { padding: 11px 16px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }

.table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.table tbody tr:hover { background: #f8fafc; }

.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.table .primary-cell { font-weight: 500; }
.table .primary-cell small { display: block; color: var(--text-muted); font-weight: 400; font-size: 12px; }

/* ============ Pagination ============ */

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.pagination .page-info { color: var(--text-muted); font-size: 13px; }

.pagination .page-links { display: flex; gap: 6px; flex-wrap: wrap; }

.pagination .page-link {
    min-width: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 13px;
    color: var(--text);
    background: #fff;
}
.pagination .page-link:hover { border-color: var(--primary); color: var(--primary); }
.pagination .page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.pagination .page-link.disabled { opacity: .45; pointer-events: none; }

/* ============ Search & filters ============ */

.search-bar { display: flex; gap: 10px; }

.search-bar .input { max-width: 420px; }

.filters-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; align-items: end; }

.filters-panel .form-group { margin-bottom: 0; }

.filters-actions { display: flex; gap: 8px; align-items: center; }

/* ============ Dropzone (upload) ============ */

.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 42px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
}

.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }

.dropzone .dz-icon { font-size: 42px; margin-bottom: 8px; }

.dropzone .dz-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }

.dropzone .dz-hint { color: var(--text-muted); font-size: 13px; }

.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-chip {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; margin-top: 14px;
}

/* ============ Progress ============ */

.progress { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }

.progress .progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; width: 0; }

.import-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }

.import-summary .sum-item { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; text-align: center; }

.import-summary .sum-item .num { font-size: 20px; font-weight: 700; }
.import-summary .sum-item .lbl { color: var(--text-muted); font-size: 12px; }

/* ============ Empty state ============ */

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }

.empty-state .es-icon { font-size: 46px; margin-bottom: 10px; opacity: .7; }

/* ============ Dashboard chart (pure CSS bars) ============ */

.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }

.chart-bars .bar {
    flex: 1;
    background: var(--primary);
    border-radius: 5px 5px 0 0;
    min-height: 2px;
    opacity: .85;
    transition: opacity .15s;
    position: relative;
}
.chart-bars .bar:hover { opacity: 1; }
.chart-bars .bar span {
    position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
    font-size: 10px; color: var(--text-muted); white-space: nowrap;
}
.chart-bars .bar i {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    font-size: 10px; font-style: normal; color: var(--primary-dark); font-weight: 700;
}

/* ============ Contact detail ============ */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.detail-item .d-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.detail-item .d-value { font-size: 14px; font-weight: 500; word-break: break-word; }

.list-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.type-tag { font-size: 11px; background: #f1f5f9; border-radius: 6px; padding: 2px 8px; color: #475569; }

/* ============ Auth pages ============ */

.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%); padding: 16px; }

.auth-card { width: 100%; max-width: 400px; }

.auth-card .logo-badge {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: var(--primary);
    color: #fff;
    display: grid; place-items: center;
    font-size: 26px;
    margin: 0 auto 12px;
    box-shadow: var(--shadow);
}

.logo-badge { width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 20px; }

/* ============ Responsive ============ */

@media (min-width: 992px) {
    .sidebar { transform: none; }
    .sidebar-backdrop { display: none !important; }
    .main { margin-right: var(--sidebar-w); }
}

@media (max-width: 991px) {
    .content { padding: 16px; }
    .search-bar { flex-wrap: wrap; }
    .search-bar .input { max-width: 100%; flex: 1 1 100%; }
    .card-header { padding: 12px 16px; }
    .card-body { padding: 16px; }
    .topbar { padding: 0 14px; }
    .icon-btn { display: grid; }
}

@media print {
    .sidebar, .topbar { display: none !important; }
    .main { margin-right: 0; }
}
