/* ==========================================================================
   دارونیک - پنل مدیریت | Design system (hand-authored, no build step)
   Apex-dashboard inspired: dark sidebar, light content, brand green.
   ========================================================================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("/assets/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --brand-50: #ecfdf5;
  --brand-100: #d1fae5;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;

  --sidebar-bg: #0f1729;
  --sidebar-bg-2: #131c31;
  --sidebar-muted: #8b98b3;
  --sidebar-active: #1c2942;

  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f0;
  --canvas: #f5f7fb;
  --surface: #ffffff;

  --amber: #f59e0b;
  --sky: #0ea5e9;
  --violet: #8b5cf6;
  --rose: #f43f5e;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: #e6ebf5;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a3854; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid #22304d;
  margin-bottom: 12px;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.brand b { font-size: 15px; display: block; }
.brand span { font-size: 10px; letter-spacing: 2px; color: var(--sidebar-muted); }

.nav-group { margin: 16px 0 6px; padding: 0 10px; font-size: 10px; letter-spacing: 1px; color: #5c6a88; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px; color: var(--sidebar-muted);
  font-size: 13px; margin-bottom: 2px; transition: all .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, var(--brand-600), var(--brand-500)); color: #fff; }
.nav-link .badge-count {
  margin-inline-start: auto; background: var(--rose); color: #fff;
  font-size: 11px; border-radius: 999px; padding: 1px 7px;
}

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

.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .search {
  flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.topbar .search input { border: 0; background: transparent; outline: none; width: 100%; font-family: inherit; }
.topbar .search svg, .topbar .icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link svg, .btn svg { width: 18px; height: 18px; }
.btn svg { width: 15px; height: 15px; }
.stat .ico svg { width: 20px; height: 20px; }
.topbar .spacer { flex: 1; }
.topbar .icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; position: relative;
}
.topbar .icon-btn .dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; background: var(--rose); border-radius: 50%; }
.topbar .avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; }

.content { padding: 24px; flex: 1; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.stat .row { display: flex; justify-content: space-between; align-items: flex-start; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 800; margin: 8px 0 6px; }
.stat .chip { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.stat .chip.up { color: var(--brand-600); }
.stat .chip.down { color: var(--rose); }
.stat .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.ico.emerald { background: var(--brand-50); color: var(--brand-600); }
.ico.sky { background: #e0f2fe; color: var(--sky); }
.ico.violet { background: #ede9fe; color: var(--violet); }
.ico.amber { background: #fef3c7; color: var(--amber); }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 300px; }
.tabs { display: inline-flex; background: var(--canvas); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

.donut-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.donut-legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .li .k { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .li .v { margin-inline-start: auto; font-weight: 700; }

.goal { margin-bottom: 16px; }
.goal .g-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.goal .g-top b { color: var(--brand-600); }
.bar { height: 8px; border-radius: 999px; background: var(--canvas); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-500), var(--brand-400)); }
.goal .g-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.table-card { overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 16px; text-align: right; font-size: 13px; }
table.data thead th { background: var(--canvas); color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: #fafcff; }
.table-scroll { overflow-x: auto; }

.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: var(--canvas); border: 1px solid var(--line); }

/* ---------- badges / pills ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--brand-50); color: var(--brand-700); }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.sky { background: #e0f2fe; color: #0369a1; }
.badge.rose { background: #ffe4e6; color: #be123c; }
.badge.gray { background: #f1f5f9; color: #475569; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand-400); }
.btn-danger { background: #fff1f2; color: var(--rose); border-color: #fecdd3; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: #475569; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=datetime-local], .field input[type=date],
.field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: 13px; outline: none; background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-500); }
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 11px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- alerts ---------- */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 13px; margin-bottom: 16px; }
.alert.success { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }
.alert.error { background: #fff1f2; color: var(--rose); border: 1px solid #fecdd3; }
.field-error { color: var(--rose); font-size: 11px; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; background: var(--surface);
}
.pagination .active span, .pagination span[aria-current] { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.pagination .disabled span { opacity: .4; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 80% -10%, #0f1729 0%, #0b1220 60%); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login-card .brand { border: 0; justify-content: center; margin-bottom: 8px; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; direction: ltr; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap { gap: 10px; }
.mt { margin-top: 16px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }

/* ---------- home sections (drag-and-drop layout builder) ---------- */
.sections-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.section-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  cursor: grab; transition: box-shadow .15s, opacity .15s;
}
.section-row.is-inactive { opacity: .55; }
.section-row.dragging { opacity: .4; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.section-row .drag-handle { color: var(--muted); flex: 0 0 auto; display: flex; }
.section-row .drag-handle svg { width: 20px; height: 20px; }
.section-row-main { flex: 1; min-width: 0; }
.section-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-row-meta { font-size: 12px; margin-top: 4px; }
.section-row-actions { flex: 0 0 auto; }
.section-row-actions form { display: contents; }

/* ---------- notification bell ---------- */
.topbar .icon-btn .badge-dot {
  position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 999px; background: var(--rose); color: #fff;
  font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1;
  border: 2px solid var(--surface);
}
.topbar .icon-btn .badge-dot[hidden] { display: none; }
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: 340px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18); z-index: 50; overflow: hidden;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.notif-panel-head b { font-size: 13px; }
.notif-panel-head button {
  background: none; border: 0; color: var(--brand-600); font-size: 12px; cursor: pointer; padding: 0;
}
.notif-panel-head button:disabled { color: var(--muted); cursor: default; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: block; padding: 11px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; position: relative;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--canvas); }
.notif-item.is-unread { background: var(--brand-50); }
.notif-item.is-unread:hover { background: var(--brand-100); }
.notif-item .notif-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.notif-item .notif-title .unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600); flex-shrink: 0; }
.notif-item .notif-body { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.notif-item .notif-time { font-size: 11px; color: var(--muted); margin-top: 5px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
