/* ============================================================
   داشبورد داخلی — Design System (local, RTL, light/dark)
   ============================================================ */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e6e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a; --success-soft: #dcfce7;
  --warning: #d97706; --warning-soft: #fef3c7;
  --danger: #dc2626;  --danger-soft: #fee2e2;
  --info: #0284c7;    --info-soft: #e0f2fe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
  --shadow-lg: 0 20px 45px rgba(16,24,40,.14);
  --sidebar-w: 260px;
}
html[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #1a243b;
  --border: #26324d;
  --text: #e8edf7;
  --muted: #93a1bd;
  --primary: #818cf8;
  --primary-600: #6366f1;
  --primary-soft: #1e2a4a;
  --success-soft: #10331f;
  --warning-soft: #3a2a0c;
  --danger-soft: #3a1414;
  --info-soft: #0b2f45;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

*,*::before,*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.7; font-size: 14.5px;
  transition: background .25s, color .25s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
.ico { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.btn .ico { width: 16px; height: 16px; }
.ico-wrap .ico { width: 22px; height: 22px; }
.card-head h3 .ico { width: 18px; height: 18px; }
.brand-logo .ico { width: 22px; height: 22px; }
h1,h2,h3,h4 { margin: 0 0 .4rem; line-height: 1.35; font-weight: 700; }
p { margin: 0 0 .6rem; }
small, .muted { color: var(--muted); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-left: 1px solid var(--border); padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; font-size: 20px;
  box-shadow: 0 8px 18px rgba(79,70,229,.35);
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label { font-size: 11px; color: var(--muted); padding: 14px 10px 6px; letter-spacing: .3px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--text); font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav a .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav a .badge-dot { margin-right: auto; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar .spacer { flex: 1; }
.content { padding: 24px 22px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; margin: 0; }
.page-header .sub { color: var(--muted); font-size: 13px; }
.page-header .actions { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap; color: var(--text); background: var(--surface-2);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(79,70,229,.3); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 8px; width: 38px; height: 38px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; margin: 0; }
.card-head .actions { margin-right: auto; display: flex; gap: 6px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 6px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { display: flex; align-items: center; gap: 14px; }
.stat .ico-wrap { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.stat .val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 12.5px; }
.ico-primary { background: var(--primary-soft); color: var(--primary); }
.ico-success { background: var(--success-soft); color: var(--success); }
.ico-warning { background: var(--warning-soft); color: var(--warning); }
.ico-danger  { background: var(--danger-soft); color: var(--danger); }
.ico-info    { background: var(--info-soft); color: var(--info); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px;
  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 color-mix(in srgb, var(--primary) 20%, transparent);
}
.textarea { min-height: 90px; resize: vertical; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.b-primary { background: var(--primary-soft); color: var(--primary); }
.b-success { background: var(--success-soft); color: var(--success); }
.b-warning { background: var(--warning-soft); color: var(--warning); }
.b-danger  { background: var(--danger-soft); color: var(--danger); }
.b-info    { background: var(--info-soft); color: var(--info); }
.b-muted   { background: var(--surface-2); color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); }
.table th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #8b5cf6); transition: width .4s; }

/* ---------- Lists / empty ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .6; }

/* ---------- Avatar ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 180px; border: 1px solid transparent; transition: border-color .15s, background .15s; }
.kcol.dragover { border-color: var(--primary); background: var(--primary-soft); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 13px; }
.kcol-head .count { margin-right: auto; background: var(--surface); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px; margin-bottom: 9px; cursor: grab; box-shadow: 0 1px 2px rgba(16,24,40,.05);
  transition: box-shadow .15s, transform .12s;
}
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard .title { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.kcard .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }

/* ---------- Chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); height: calc(100vh - 160px); min-height: 480px; }
.chat-side { border-left: 1px solid var(--border); overflow-y: auto; background: var(--surface-2); }
.chat-side .chat-side-head { padding: 14px; font-weight: 700; border-bottom: 1px solid var(--border); }
.chat-side a { display: block; padding: 11px 14px; color: var(--text); border-bottom: 1px solid var(--border); font-size: 13px; }
.chat-side a.active, .chat-side a:hover { background: var(--surface); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { max-width: 78%; }
.msg .bubble { padding: 9px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg .meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg.own { align-self: flex-start; }
.msg.own .bubble { background: var(--primary); color: #fff; border-color: transparent; }
.msg.own .meta { text-align: left; }
.msg.other { align-self: flex-end; }
.msg.other .meta { text-align: right; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input .input { flex: 1; }

/* ---------- Modal / dialog ---------- */
dialog.modal {
  border: none; border-radius: var(--radius); padding: 0; width: min(560px, 94vw);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(8,12,24,.55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { margin-right: auto; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 18px; left: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface); border: 1px solid var(--border); border-right: 4px solid var(--primary); border-radius: 10px; padding: 11px 15px; box-shadow: var(--shadow-lg); font-size: 13px; min-width: 220px; animation: slideIn .25s ease; }
.toast.ok { border-right-color: var(--success); }
.toast.err { border-right-color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 9px 14px; border: none; background: none; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- File grid ---------- */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.file-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: box-shadow .15s, transform .12s; }
.file-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.file-thumb { height: 110px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .ext { font-weight: 700; color: var(--muted); font-size: 13px; text-transform: uppercase; }
.file-info { padding: 9px 11px; }
.file-info .name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info .meta { font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 3px; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; border: none; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.mt-0{margin-top:0}.mt-1{margin-top:6px}.mt-2{margin-top:12px}.mt-3{margin-top:18px}.mt-4{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:6px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}
.p-0{padding:0}.text-sm{font-size:12.5px}.text-xs{font-size:11px}
.nowrap{white-space:nowrap}.w-full{width:100%}.text-left{text-align:left}.text-center{text-align:center}
.hidden{display:none !important}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Auth page ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1000px 500px at 80% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent),
  radial-gradient(800px 400px at 0% 110%, color-mix(in srgb, #8b5cf6 16%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 30px; }
.auth-logo { width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 30px; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6); box-shadow: 0 12px 28px rgba(79,70,229,.35); }
.auth-title { text-align: center; font-size: 19px; margin-bottom: 2px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--info-soft); color: var(--info); }

.pw-value { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; }

/* ---------- File picker ---------- */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px dashed var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface-2); }
.file-input-wrap:focus-within { border-color: var(--primary); }

/* ---------- Lightbox ---------- */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 200; cursor: zoom-out; padding: 30px; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* ---------- Mobile ---------- */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 260px); }
  .chat-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .chat-side { display: flex; align-items: center; gap: 6px; overflow-x: auto; overflow-y: hidden; border-left: 0; border-bottom: 1px solid var(--border); padding: 8px 10px; }
  .chat-side .chat-side-head { display: none; }
  .chat-side a { display: inline-block; white-space: nowrap; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--surface); font-size: 12.5px; }
  .chat-side a.active { background: var(--primary); color: #fff; }
  .chat-side a:hover { background: var(--primary-soft); }
  .chat-side a.active:hover { background: var(--primary); }
  .sidebar { position: fixed; right: 0; transform: translateX(100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 14px; }
  .content { padding: 16px 14px 60px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 19px; }
  .user-name { display: none; }
  .topbar { gap: 6px; }
  .topbar strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
}
