/* ── Vazirmatn font (download from https://github.com/rastikerdar/vazirmatn/releases
   and place woff2 files in assets/fonts/Vazirmatn/) ── */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3350;
  --text:      #e8eaf0;
  --muted:     #8892b0;
  --accent:    #3B82F6;

  --sev-critical: #ef4444;
  --sev-high:     #f97316;
  --sev-medium:   #eab308;
  --sev-low:      #3b82f6;

  --status-active:    #10b981;
  --status-hold:      #f59e0b;
  --status-done:      #6b7280;
  --status-cancelled: #ef4444;

  --sidebar-w: 240px;
  --header-h:  56px;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.45);
}

html {
  direction: rtl;
  font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; direction: rtl; }

/* ── Layout shell ── */
.shell {
  display: flex;
  flex-direction: row-reverse; /* RTL: sidebar on right */
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  letter-spacing: .01em;
}

.sidebar-brand span {
  display: block;
  font-size: .7rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .88rem;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.15); color: #93c5fd; }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--muted);
}
.sidebar-footer a { color: #f87171; }
.sidebar-footer a:hover { text-decoration: underline; }

/* ── Main content ── */
.main {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Mobile top bar ── */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title { font-weight: 700; font-size: .95rem; }
.hamburger { background: none; border: none; color: var(--text); font-size: 1.4rem; padding: 4px; }

/* ── Page content ── */
.page { padding: 28px 28px 48px; }
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-sub { color: var(--muted); font-size: .85rem; margin-bottom: 24px; }

/* ── KPI row ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.kpi-label { font-size: .75rem; color: var(--muted); margin-bottom: 8px; }
.kpi-value { font-size: 2rem; font-weight: 700; }
.kpi-value.red  { color: #f87171; }
.kpi-value.amber { color: #fbbf24; }
.kpi-value.blue  { color: #60a5fa; }
.kpi-value.green { color: #34d399; }

/* ── Section card ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-body { padding: 14px 18px; }
.section-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 24px; }

/* ── List rows ── */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

.ws-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.row-title { flex: 1; font-size: .88rem; }
.row-meta  { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active    { background: rgba(16,185,129,.15); color: #34d399; }
.badge-on_hold   { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-completed { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-cancelled { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-waiting   { background: rgba(59,130,246,.15);  color: #93c5fd; }
.badge-received  { background: rgba(16,185,129,.15);  color: #34d399; }
.badge-upcoming  { background: rgba(59,130,246,.15);  color: #93c5fd; }
.badge-overdue   { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-open      { background: rgba(59,130,246,.15);  color: #93c5fd; }
.badge-resolved  { background: rgba(16,185,129,.15);  color: #34d399; }
.badge-closed    { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-in_progress { background: rgba(245,158,11,.15); color: #fbbf24; }

.badge-high   { background: rgba(249,115,22,.15); color: #fb923c; }
.badge-medium { background: rgba(234,179,8,.15);  color: #facc15; }
.badge-low    { background: rgba(59,130,246,.15); color: #93c5fd; }

/* ── Severity indicator ── */
.sev-bar {
  width: 4px;
  border-radius: 4px;
  align-self: stretch;
  flex-shrink: 0;
}
.sev-critical .sev-bar, .sev-bar.sev-critical { background: var(--sev-critical); }
.sev-high     .sev-bar, .sev-bar.sev-high     { background: var(--sev-high); }
.sev-medium   .sev-bar, .sev-bar.sev-medium   { background: var(--sev-medium); }
.sev-low      .sev-bar, .sev-bar.sev-low      { background: var(--sev-low); }

.sev-label.sev-critical { color: var(--sev-critical); }
.sev-label.sev-high     { color: var(--sev-high); }
.sev-label.sev-medium   { color: var(--sev-medium); }
.sev-label.sev-low      { color: var(--sev-low); }

/* ── Project cards (project wall) ── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  border-top: 3px solid var(--border);
  transition: box-shadow .15s;
}
.project-card:hover { box-shadow: var(--shadow); }
.project-card-name { font-weight: 600; margin-bottom: 6px; }
.project-card-desc { color: var(--muted); font-size: .8rem; margin-bottom: 14px; min-height: 2em; }
.project-card-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.project-card-ws { font-size: .75rem; color: var(--muted); }

/* ── Task checkbox ── */
.task-check {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: #34d399;
  transition: border-color .15s;
}
.task-check.checked { border-color: #34d399; background: rgba(52,211,153,.1); }
.task-row-title { flex: 1; font-size: .88rem; }
.task-row-title.done { text-decoration: line-through; color: var(--muted); }

/* ── Progress bar ── */
.progress-wrap { background: var(--surface2); border-radius: 4px; height: 8px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }

/* ── Budget rows ── */
.budget-row { margin-bottom: 18px; }
.budget-meta { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: .82rem; }
.budget-ws { display: flex; align-items: center; gap: 8px; }

/* ── Timeline ── */
.timeline { position: relative; padding-right: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  right: 10px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; margin-bottom: 20px; }
.tl-dot {
  position: absolute;
  right: -26px;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.tl-dot.overdue  { background: var(--sev-critical); }
.tl-dot.completed{ background: #34d399; }
.tl-title { font-size: .88rem; font-weight: 500; }
.tl-date  { font-size: .76rem; color: var(--muted); margin-top: 2px; }

/* ── Idea cards ── */
.idea-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.idea-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.idea-title { font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
.idea-desc  { font-size: .78rem; color: var(--muted); }
.idea-ws    { font-size: .72rem; margin-top: 10px; color: var(--muted); }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; text-align: center; }
.login-sub   { font-size: .8rem; color: var(--muted); text-align: center; margin-bottom: 28px; }
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.form-input  {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.alert-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .83rem;
  margin-bottom: 16px;
}

/* ── Delegated groups ── */
.person-group { margin-bottom: 22px; }
.person-name { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* ── "Show more" mobile button ── */
.show-more-wrap { display: none; text-align: center; padding: 14px 0; }
.btn-show-more {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 8px 24px;
  font-size: .85rem;
}

/* ── Overdue highlight ── */
.overdue-date { color: #f87171; }

/* ── Mobile overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .topbar { display: flex; }

  .main { margin-right: 0; }

  .page { padding: 20px 16px 48px; }

  .kpi-row { grid-template-columns: 1fr 1fr; }

  .project-grid { grid-template-columns: 1fr; }

  .deeper-sections { display: none; }
  .deeper-sections.visible { display: block; }
  .show-more-wrap { display: block; }
}
