/* ============================================================
   پنل مدیریت وب — پروژه و تسک
   فونت وزیر (Vazir) · فارسی · ریسپانسیو
   ============================================================ */

@font-face {
  font-family: "Vazir";
  src: url("/static/fonts/vazir/Vazir.woff2") format("woff2"),
       url("/static/fonts/vazir/Vazir.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --success-dark: #047857;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14);
  --sidebar-w: 250px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Vazir", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------------
   چیدمان کلی
   ------------------------------------------------------------------ */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: #e0e7ff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.5; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { color: #a5b4fc; font-size: 11px; }

.nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #c7d2fe;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .45);
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }

.admin-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  margin-bottom: 10px;
}

.admin-chip > span {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}

.admin-chip strong { color: #fff; font-size: 13px; display: block; line-height: 1.4; }
.admin-chip small { color: #a5b4fc; font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 700; flex: 1; }

.hamburger {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}

.content { padding: 24px; flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; }

.footer {
  text-align: center;
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 55;
}

.overlay.show { display: block; }

/* ------------------------------------------------------------------
   کارت‌ها و گرید
   ------------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 20px; }

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

.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }

.grid { display: grid; gap: 16px; }

.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------
   آمار (Stat cards)
   ------------------------------------------------------------------ */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-value { font-size: 22px; font-weight: 800; line-height: 1.3; }
.stat-label { color: var(--muted); font-size: 12.5px; }

.tint-primary { background: var(--primary-soft); }
.tint-success { background: var(--success-soft); }
.tint-warning { background: var(--warning-soft); }
.tint-info { background: var(--info-soft); }
.tint-danger { background: var(--danger-soft); }

/* ------------------------------------------------------------------
   دکمه‌ها
   ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.6;
  background: var(--surface-2);
  color: var(--text);
}

.btn:hover { filter: brightness(.97); }

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

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

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

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .25); }
.btn-light:hover { background: rgba(255, 255, 255, .22); }

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

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

/* ------------------------------------------------------------------
   نشان‌ها (Badge)
   ------------------------------------------------------------------ */

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

.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.badge-pending { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-completed { background: var(--success-soft); color: var(--success-dark); border: 1px solid var(--success-border); }

.badge-platform { background: var(--info-soft); color: #1d4ed8; border: 1px solid var(--info-border); }
.badge-platform::before { display: none; }

/* ------------------------------------------------------------------
   جدول‌ها
   ------------------------------------------------------------------ */

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

table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }

.tbl th {
  text-align: right;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tbl tbody tr:hover { background: #fafbff; }
.tbl tbody tr:last-child td { border-bottom: none; }

.tbl .task-text { max-width: 380px; }

.tbl .task-text p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  word-break: break-word;
  cursor: pointer;
  transition: color .15s, background-color .15s;
  border-radius: 6px;
  padding: 2px 6px;
}

.tbl .task-text p:hover {
  color: var(--primary);
  background-color: var(--primary-soft);
}

.copied-highlight {
  animation: copyPulse .5s ease;
}

@keyframes copyPulse {
  0% { transform: scale(1); background-color: var(--success-soft); color: var(--success-dark); }
  50% { transform: scale(1.02); background-color: var(--success-soft); color: var(--success-dark); }
  100% { transform: scale(1); }
}

.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.muted { color: var(--muted); font-size: 12.5px; }
.strong { font-weight: 700; }

/* ------------------------------------------------------------------
   فرم‌ها
   ------------------------------------------------------------------ */

.field { margin-bottom: 14px; }

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

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

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

.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar .field { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ------------------------------------------------------------------
   هشدارها
   ------------------------------------------------------------------ */

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: var(--success-dark); border-color: var(--success-border); }
.alert-error { background: var(--danger-soft); color: #b91c1c; border-color: var(--danger-border); }

/* ------------------------------------------------------------------
   وضعیت خالی
   ------------------------------------------------------------------ */

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

.empty .empty-icon { font-size: 42px; display: block; margin-bottom: 8px; }

/* ------------------------------------------------------------------
   نوار پیشرفت
   ------------------------------------------------------------------ */

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #818cf8); border-radius: 999px; }
.progress.success > span { background: linear-gradient(90deg, var(--success), #34d399); }

/* ------------------------------------------------------------------
   مودال
   ------------------------------------------------------------------ */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .55);
}

.modal.open { display: flex; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
}

.modal-card h3 { margin: 0 0 4px; font-size: 16px; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 6px; }

/* ------------------------------------------------------------------
   توست (اعلان کوتاه)
   ------------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 50%;
  transform: translate(50%, 20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 200;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translate(50%, 0); }
.toast.error { background: var(--danger); }

/* ------------------------------------------------------------------
   صفحه ورود
   ------------------------------------------------------------------ */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 45%, #4f46e5 100%);
  position: relative;
  overflow: hidden;
}

.login-body::before, .login-body::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
}

.login-body::before { width: 340px; height: 340px; background: #818cf8; top: -80px; left: -80px; }
.login-body::after { width: 300px; height: 300px; background: #a78bfa; bottom: -90px; right: -70px; }

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 34px 30px;
}

.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}

.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 19px; }
.login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }

/* ------------------------------------------------------------------
   ریسپانسیو (موبایل)
   ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform .25s ease;
  }

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

  .hamburger { display: inline-flex; align-items: center; justify-content: center; }

  .content { padding: 16px; }

  .hide-mobile { display: none; }
}

@media (max-width: 560px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-value { font-size: 18px; }
  .topbar { padding: 0 14px; }
  .card-pad { padding: 16px; }
}
