/* ==================== فونت IRANSans ==================== */
@font-face {
    font-family: 'IRANSans';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url('../fonts/IRANSansWeb.woff2') format('woff2'),
         url('../fonts/IRANSansWeb.woff') format('woff'),
         url('../fonts/IRANSansWeb.ttf') format('truetype'),
         url('../fonts/IRANSansWeb.eot');
}
@font-face {
    font-family: 'IRANSans';
    font-style: normal;
    font-weight: bold;
    font-display: swap;
    src: url('../fonts/IRANSansWeb_Bold.woff2') format('woff2'),
         url('../fonts/IRANSansWeb_Bold.woff') format('woff'),
         url('../fonts/IRANSansWeb_Bold.ttf') format('truetype'),
         url('../fonts/IRANSansWeb_Bold.eot');
}

/* ==================== متغیرها ==================== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --purple: #7c3aed;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.08);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ==================== ریست ==================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'IRANSans', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
.mono { font-family: 'IRANSans', monospace; direction: ltr; display: inline-block; }

/* ==================== لایوت ==================== */
.layout { display: flex; min-height: 100vh; }

/* ==================== سایدبار ==================== */
.sidebar {
  width: 250px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 4px 24px; }
.brand-logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: bold; font-size: 20px; color: #fff;
}
.brand-title { font-weight: bold; font-size: 15px; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 14px;
  transition: all .2s;
}
.nav-item:hover:not(.disabled) { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.nav-item.disabled { opacity: .4; cursor: not-allowed; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.admin-name { font-weight: bold; font-size: 13px; }
.admin-role { font-size: 11px; color: #94a3b8; }
.logout-btn {
  text-align: center;
  padding: 8px;
  background: rgba(220,38,38,.15);
  color: #fca5a5;
  border-radius: 8px;
  font-size: 13px;
  transition: all .2s;
}
.logout-btn:hover { background: rgba(220,38,38,.25); }

/* ==================== محتوا ==================== */
.content { flex: 1; padding: 28px 32px; max-width: 1400px; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: bold; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ==================== کارت آماری ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 20px;
}
.stat-icon.purple { background: #ede9fe; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.orange { background: #fef3c7; }
.stat-value { font-size: 22px; font-weight: bold; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ==================== فیلتر ==================== */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  background: var(--card);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border .2s, box-shadow .2s;
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-input { flex: 1; min-width: 220px; }

/* ==================== دکمه‌ها ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: bold;
  transition: all .18s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.92); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.92); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ==================== جدول ==================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-card { padding: 4px 0; }
.table-head-row { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 10px; }
.table-title { font-size: 15px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.count-badge {
  background: #eff6ff; color: var(--primary);
  padding: 2px 10px; border-radius: 20px;
  font-size: 12px;
}

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: bold;
  font-size: 12px;
  white-space: nowrap;
}
.data-table tbody tr.main-row { transition: background .15s; }
.data-table tbody tr.main-row:hover { background: #f8fafc; }
.empty-row { text-align: center; padding: 40px; color: var(--muted); }

/* ==================== سلول کاربر ==================== */
.user-cell { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.user-name { font-weight: bold; font-size: 13px; }
.user-sub { font-size: 11px; color: var(--muted); }

/* ==================== بج‌ها ==================== */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-orange { background: #fef3c7; color: #b45309; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-success{ background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning{ background: #fef3c7; color: #b45309; }

/* ==================== اکشن‌ها ==================== */
.actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #f1f5f9;
  display: grid; place-items: center;
  font-size: 14px;
  transition: all .18s;
  color: var(--text);
}
.icon-btn:hover { background: #e2e8f0; transform: scale(1.05); }

/* ==================== ردیف جزئیات ==================== */
.detail-row td { background: #f8fafc; padding: 20px !important; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.detail-box {
  background: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.detail-box.full { grid-column: 1 / -1; }
.detail-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.detail-value { font-size: 13px; font-weight: bold; }
.detail-actions {
  grid-column: 1 / -1;
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}

/* ==================== صفحه‌بندی ==================== */
.pagination {
  display: flex; gap: 6px; justify-content: center;
  padding: 18px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: #f1f5f9;
  color: var(--text);
  font-size: 13px;
  transition: all .18s;
}
.page-btn:hover { background: #e2e8f0; }
.page-btn.active { background: var(--primary); color: #fff; }

/* ==================== پروفایل ==================== */
.profile-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.profile-card { padding: 28px 20px; text-align: center; }
.profile-avatar-wrap { position: relative; display: inline-block; margin-bottom: 14px; }
.profile-avatar {
  width: 110px; height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--border), var(--shadow);
}
.profile-name { font-size: 17px; font-weight: bold; margin-bottom: 8px; }
.profile-info { padding: 24px; }
.card-title { font-size: 16px; font-weight: bold; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: 10px;
}
.info-item.full { grid-column: 1 / -1; }
.info-item span { font-size: 11px; color: var(--muted); }
.info-item b { font-size: 13px; }
.profile-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ==================== هشدار ==================== */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13px;
}
.alert-danger { background: #fee2e2; color: #991b1b; border-right: 4px solid var(--danger); }
.alert-success { background: #dcfce7; color: #166534; border-right: 4px solid var(--success); }

/* ==================== صفحه ورود ==================== */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #0f172a, #1e293b); }
.login-card {
  background: #fff;
  padding: 36px 32px;
  border-radius: 18px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 19px; margin-bottom: 22px; text-align: center; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card .input { width: 100%; margin-top: 6px; }

/* ==================== ریسپانسیو ==================== */
@media (max-width: 900px) {
  .sidebar { width: 70px; padding: 16px 8px; }
  .brand-title, .brand-sub, .nav-item span:not(.nav-icon), .admin-info { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px; }
  .profile-layout { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}
/* ============================================================
   سایدبار جمع‌شو (Collapsible Sidebar)
   ============================================================ */

.sidebar {
  transition: width .28s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}

/* بالای سایدبار: برند + دکمه جمع */
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px 24px;
}

.brand { padding: 0 !important; }
.brand-text { overflow: hidden; white-space: nowrap; }

.collapse-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: bold;
  transition: all .2s;
  flex-shrink: 0;
}
.collapse-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.collapse-icon {
  display: inline-block;
  transition: transform .28s;
  transform: rotate(0deg); /* ‹  →  برای جمع شدن */
  line-height: 1;
}

/* عناصر داخلی سایدبار */
.nav-item { position: relative; }
.nav-icon { flex-shrink: 0; }
.nav-text { white-space: nowrap; transition: opacity .2s; }

/* پاورقی */
.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.admin-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.admin-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid; place-items: center;
  color: #fff; font-weight: bold; font-size: 14px;
  flex-shrink: 0;
}
.admin-text { overflow: hidden; white-space: nowrap; }
.admin-name { font-weight: bold; font-size: 13px; }
.admin-role { font-size: 11px; color: #94a3b8; }

.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  padding: 9px 12px;
  background: rgba(220,38,38,.15);
  color: #fca5a5;
  border-radius: 8px;
  font-size: 13px;
  transition: all .2s;
  white-space: nowrap;
  overflow: hidden;
}
.logout-btn:hover { background: rgba(220,38,38,.25); }
.logout-icon { font-size: 15px; flex-shrink: 0; }

/* ============================================================
   حالت جمع‌شده (Collapsed)
   ============================================================ */

.layout.collapsed .sidebar { width: 74px; padding: 20px 8px; }
.layout.collapsed .brand-text,
.layout.collapsed .nav-text,
.layout.collapsed .admin-text { display: none; }
.layout.collapsed .brand { justify-content: center; }
.layout.collapsed .sidebar-top { justify-content: center; padding: 8px 0 24px; }
.layout.collapsed .collapse-icon { transform: rotate(180deg); } /* › */
.layout.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.layout.collapsed .nav-icon { font-size: 18px; }
.layout.collapsed .admin-info { justify-content: center; }
.layout.collapsed .logout-btn { padding: 9px 0; justify-content: center; }
.layout.collapsed .logout-icon { font-size: 17px; }
.layout.collapsed .content { padding: 28px 24px; }

/* Tooltip در حالت جمع‌شده */
.layout.collapsed .nav-item[data-tooltip]:hover::after,
.layout.collapsed .logout-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 100;
  pointer-events: none;
}
.layout.collapsed .nav-item[data-tooltip]:hover::before,
.layout.collapsed .logout-btn[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #0f172a;
  z-index: 100;
}
.layout.collapsed .logout-btn[data-tooltip] { position: relative; }

/* موبایل: همیشه جمع‌شو در حالت بسته */
@media (max-width: 900px) {
  .sidebar { width: 70px; padding: 16px 8px; }
  .brand-text, .nav-text, .admin-text { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-top { justify-content: center; }
  .collapse-btn { display: none; }
  .content { padding: 18px; }
}