@font-face { font-family: 'Vazir'; src: url('Vazirmatn-Regular.ttf') format('truetype'); font-weight: normal; }
@font-face { font-family: 'Vazir'; src: url('Vazirmatn-Bold.ttf') format('truetype'); font-weight: bold; }

:root {
    --primary: #1565c0;
    --primary-light: #1e88e5;
    --primary-dark: #0d47a1;
    --bg: #f5f7fa;
    --text: #333;
    --text-light: #777;
    --card-bg: #fff;
    --card-shadow: 0 2px 12px rgba(0,0,0,.06);
    --card-radius: 14px;
    --sidebar-active: #1565c0;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Vazir', Tahoma, Arial, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    direction: rtl;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
::selection { background: var(--primary); color: #fff; }

/* ═══ Layout ═══ */
.main-content { margin-right: 260px; min-height: 100vh; padding: 24px; }
.container { max-width: 1200px; margin: 0 auto; }

/* ═══ Cards ═══ */
.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    overflow: hidden;
    border: none;
}
.card-header {
    background: var(--card-bg);
    padding: 16px 20px;
    border-bottom: 1px solid #eef0f4;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    flex-wrap: wrap;
    gap: 8px;
}
.card-body { padding: 20px; }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px;
    border: none; border-radius: 10px;
    font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all .2s;
    font-family: inherit;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 12px rgba(21,101,192,.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 5px 16px rgba(21,101,192,.4); }
.btn-success { background: #2e7d32; color: #fff; box-shadow: 0 3px 12px rgba(46,125,50,.3); }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: #c62828; color: #fff; box-shadow: 0 3px 12px rgba(198,40,40,.3); }
.btn-danger:hover { background: #b71c1c; }
.btn-warning { background: #f9a825; color: #333; }
.btn-warning:hover { background: #f57f17; }
.btn-info { background: #00838f; color: #fff; }
.btn-info:hover { background: #006064; }
.btn-secondary { background: #546e7a; color: #fff; }
.btn-secondary:hover { background: #37474f; }
.btn-sm { padding: 6px 14px; font-size: 11.5px; border-radius: 8px; }

/* ═══ Forms ═══ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-weight: 600;
    margin-bottom: 6px; font-size: 13px; color: #555;
}
.form-control {
    width: 100%; padding: 10px 14px;
    border: 2px solid #e0e4ea; border-radius: 10px;
    font-size: 13px; font-family: inherit;
    color: #333; background: #fafbfc;
    transition: all .2s;
    -webkit-appearance: none;
}
.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(21,101,192,.1);
    background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ═══ Tables ═══ */
.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
table th {
    background: var(--primary);
    color: #fff !important;
    font-weight: 600;
    padding: 12px 14px;
    text-align: right;
    white-space: nowrap;
    font-size: 12px;
    position: sticky; top: 0;
}
table td {
    padding: 11px 14px;
    text-align: right;
    border-bottom: 1px solid #f0f2f5;
    color: var(--text);
}
table tbody tr { background: #fff !important; }
table tbody tr:hover { background: #f5f8ff !important; }
table tbody tr:nth-child(even) { background: #fff !important; }

/* ═══ Alerts ═══ */
.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    animation: slideDown .3s ease;
    word-break: break-word;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-danger { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }
.alert-info { background: #e1f5fe; color: #01579b; border: 1px solid #81d4fa; }

/* ═══ Modal ═══ */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(3px);
    z-index: 2000;
    justify-content: center; align-items: center;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%; max-width: 600px;
    max-height: 80vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid #eef0f4;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 700;
}
.modal-body { padding: 20px; }
.modal-close {
    background: #f5f5f5; border: none;
    width: 32px; height: 32px; border-radius: 8px;
    font-size: 16px; cursor: pointer; color: #777;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
}
.modal-close:hover { background: #e0e0e0; color: #333; }

/* ═══ Stats ═══ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px 14px;
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: all .3s;
    cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-card .label { font-size: 11px; color: #888; margin-top: 4px; }

/* ═══ Utilities ═══ */
strong { color: var(--text); font-weight: 700; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-body a:not(.btn) { color: var(--primary); text-decoration: none; font-weight: 500; }
.card-body a:not(.btn):hover { text-decoration: underline; }

/* ═══ Letter ═══ */
.letter-wrapper { background: #fff; padding: 40px; max-width: 210mm; margin: 0 auto; box-shadow: 0 4px 20px rgba(0,0,0,.12); font-family: Tahoma, Arial, sans-serif; color: #000; border-radius: 4px; }
.letter-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 12px; }
.letter-table th, .letter-table td { border: 1px solid #000; padding: 6px 8px; text-align: center; color: #000 !important; }
.letter-table th { background: #e8eaed; font-weight: bold; }
.letter-table tr { background: transparent !important; }

/* ═══ Suggest ═══ */
.suggest-item {
    padding: 12px 14px;
    border: 1px solid #e0e4ea;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all .2s;
    cursor: pointer;
}
.suggest-item:hover { border-color: var(--primary); background: #f5f8ff; }

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ═══ Sidebar ═══ */
.sidebar {
    position: fixed; top: 0; right: 0;
    width: 260px; height: 100vh;
    background: #f5f7fa;
    z-index: 1000;
    display: flex; flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,.08);
    overflow: hidden;
}
.sb-header {
    background: linear-gradient(135deg, #1565c0, #1e88e5);
    padding: 20px 18px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}
.sb-header-icon {
    width: 48px; height: 48px;
    background: rgba(255,255,255,.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.sb-header-text { flex: 1; }
.sb-header-title { font-size: 16px; font-weight: 700; color: #fff; }
.sb-header-sub { font-size: 11px; color: rgba(255,255,255,.75); margin-top: 2px; }
.sb-menu { flex: 1; padding: 12px; overflow-y: auto; overflow-x: hidden; }
.sb-menu::-webkit-scrollbar { width: 3px; }
.sb-menu::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.sb-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin-bottom: 6px;
    background: #fff; border-radius: 12px;
    text-decoration: none; color: #333;
    font-size: 14px; font-weight: 500;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: all .2s; cursor: pointer;
}
.sb-item:hover { box-shadow: 0 3px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.sb-item.active { background: var(--primary); color: #fff; box-shadow: 0 3px 12px rgba(0,0,0,.15); }
.sb-item.active .sb-item-icon { background: rgba(255,255,255,.25) !important; color: #fff !important; }
.sb-item-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; flex-shrink: 0;
}
.sb-item-text { flex: 1; }
.sb-arrow { font-size: 11px; color: #aaa; transition: transform .25s; }
.sb-dropdown.open .sb-arrow { transform: rotate(90deg); }
.sb-sub { display: none; padding: 4px 0 4px 20px; margin-bottom: 6px; }
.sb-sub.open { display: block; }
.sb-subitem {
    display: block; padding: 9px 14px; margin-bottom: 3px;
    background: #fff; border-radius: 10px;
    text-decoration: none; color: #555; font-size: 13px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    transition: all .2s;
}
.sb-subitem:hover { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.sb-subitem.active { background: var(--primary); color: #fff; font-weight: 600; }
.sb-footer { padding: 10px 12px; border-top: 1px solid #e8ecf0; flex-shrink: 0; }
.sb-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: #fff;
    border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sb-user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #1565c0, #42a5f5);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: 12px; font-weight: 600; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 10px; color: #999; }
.sb-act {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; background: #f5f5f5;
    color: #777; text-decoration: none; font-size: 13px;
    transition: all .2s;
}
.sb-act:hover { background: #e0e0e0; color: #333; }
.sb-logout:hover { background: #ffebee; color: #e53935; }

/* ═══ Toggle & Overlay ═══ */
.sb-toggle {
    display: none;
    position: fixed; top: 12px; right: 12px; z-index: 1100;
    width: 40px; height: 40px;
    background: var(--primary); border: none; border-radius: 10px;
    color: #fff; font-size: 20px; cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,.2);
}
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; }
.sb-overlay.show { display: block; }

/* ═══ Print ═══ */
@media print {
    body { background: #fff; }
    .sidebar, .no-print, .sb-toggle, .sb-overlay { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ═══ Responsive ═══ */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .main-content { margin-right: 240px; padding: 20px; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); transition: transform .3s; width: 270px; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; padding: 56px 12px 20px; }
    .sb-toggle { display: block !important; }
    .card { margin-bottom: 16px; }
    .card-header { padding: 12px 14px; font-size: 13px; flex-direction: column; align-items: flex-start; }
    .card-body { padding: 14px; }
    .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 14px 8px; }
    .stat-card .num { font-size: 22px; }
    .form-row { grid-template-columns: 1fr; }
    .form-control { padding: 10px 12px; font-size: 14px; }
    .btn { padding: 10px 16px; font-size: 13px; width: 100%; justify-content: center; }
    .table-wrap { margin: 0 -12px; border-radius: 0; }
    table { min-width: 500px; font-size: 12px; }
    .modal-content { width: 95%; max-height: 90vh; }
}
