/* چک‌لیست‌یار — green (Everforest-inspired) light/dark theme */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-VF.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ece7d4;
  --bg-soft: #f4efe0;
  --card: #fdfaf0;
  --ink: #3a453b;
  --muted: #6b7561;
  --line: #d9d1b6;
  --primary: #4e7a1a;
  --primary-d: #3c5f13;
  --primary-soft: #e3ebc6;
  --visited: #3f6214;
  --danger: #c14e4e;
  --danger-soft: #f6d9d4;
  --sidebar-bg: linear-gradient(180deg, #232d18 0%, #35491f 60%, #476227 100%);
  --sidebar-ink: #f0f4e0;
  --sidebar-dim: #c3d0a2;
  --shadow: 0 1px 2px rgba(60, 70, 40, 0.08), 0 8px 24px -12px rgba(78, 122, 26, 0.35);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #1d2225;
  --bg-soft: #272e33;
  --card: #2d353b;
  --ink: #e4dcc3;
  --muted: #a7b199;
  --line: #49534b;
  --primary: #a7c080;
  --primary-d: #c2daa5;
  --primary-soft: #37452c;
  --visited: #8fb377;
  --danger: #e67e80;
  --danger-soft: #4c2a2e;
  --sidebar-bg: linear-gradient(180deg, #121712 0%, #1a2318 60%, #22331f 100%);
  --sidebar-ink: #dde5cf;
  --sidebar-dim: #93a284;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 28px -12px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Vazirmatn", "IRANSans", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.25s ease, color 0.25s ease;
}

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

/* ---------- sidebar ---------- */
.sidebar {
  width: 248px;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  box-shadow: var(--shadow);
  z-index: 10;
}

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: -0.5px;
}

.brand-sub { text-align: center; color: var(--sidebar-dim); font-size: 0.8rem; margin-bottom: 22px; }

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1;
  padding-bottom: 8px;
  scrollbar-width: auto;
  direction: ltr; /* scrollbar on the right edge */
}

.sidebar nav > * { direction: rtl; }

.sidebar nav::-webkit-scrollbar { width: 12px; }
.sidebar nav::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.06); border-radius: 8px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.28); border-radius: 8px; }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.45); }

.nav-group {
  color: var(--sidebar-dim);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 12px 15px 2px;
}

.sidebar nav a {
  color: var(--sidebar-ink);
  text-decoration: none;
  padding: 11px 15px;
  border-radius: 10px;
  font-weight: 500;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.12); transform: translateX(-2px); }
.sidebar nav a.active { background: rgba(255, 255, 255, 0.2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }

.side-foot { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.side-foot .logout-btn {
  display: block;
  text-align: center;
  color: #f6d9d4;
  background: rgba(230, 126, 128, 0.16);
  border: 1px solid rgba(230, 126, 128, 0.45);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.side-foot .logout-btn:hover { background: rgba(230, 126, 128, 0.32); text-decoration: none; }

.version-tag {
  text-align: center;
  color: var(--sidebar-dim);
  font-size: 0.78rem;
  direction: ltr;
}

.theme-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-ink);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.15s ease;
}

.theme-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- content ---------- */
.content { flex: 1; padding: 30px 34px; max-width: 1150px; margin-right: 248px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 9px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  color: var(--muted);
}

.topbar-clock { margin-inline-start: auto; font-variant-numeric: tabular-nums; direction: rtl; }

h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -0.5px; }
h2 { margin: 30px 0 10px; font-size: 1.15rem; }

.page-sub { color: var(--muted); margin-top: 0; }

/* ---------- stat cards ---------- */
.cards { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 22px;
  min-width: 150px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.card:hover { transform: translateY(-2px); }
.card .num { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.card .lbl { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }
.card.small { min-width: 120px; padding: 12px 16px; }

/* ---------- tables ---------- */
table {
  width: 100%;
  background: var(--card);
  border-collapse: collapse;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 12px 0 24px;
  border: 1px solid var(--line);
}

th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: right; }
th { background: var(--bg-soft); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
tbody tr:hover { background: var(--bg-soft); }
tr:last-child td { border-bottom: none; }
td input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.95rem;
  font-family: inherit;
}

.ltr { direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }

/* Links readable in both themes, before and after visiting */
a { color: var(--primary); text-decoration: none; }
a:visited { color: var(--visited); }
a:hover { text-decoration: underline; }
.sidebar nav a, .sidebar .side-foot a, .btn { text-decoration: none; }
.sidebar nav a:hover, .btn:hover { text-decoration: none; }

/* ---------- badges / buttons ---------- */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.approved { background: #d9e8c3; color: #3c5f13; }
.badge.completed { background: #cfe3d4; color: #1f5c46; }
.badge.revision_requested { background: var(--danger-soft); color: var(--danger); }
.badge.kind-photo { background: #cfe3d4; color: #1f5c46; }
.badge.kind-video { background: #e4d9ec; color: #6b3d8f; }
.badge.kind-audio { background: #f2e3bb; color: #7c5a12; }
.badge.kind-text { background: #d9e8c3; color: #3c5f13; }
.badge.kind-other { background: #e7e2d2; color: #5c6152; }

[data-theme="dark"] .badge.approved,
[data-theme="dark"] .badge.kind-text { background: #2f4a2c; color: #c5e0a8; }
[data-theme="dark"] .badge.completed,
[data-theme="dark"] .badge.kind-photo { background: #23403c; color: #9fd8cb; }
[data-theme="dark"] .badge.kind-video { background: #46304a; color: #e3b8cf; }
[data-theme="dark"] .badge.kind-audio { background: #4a3a1f; color: #e8c87e; }
[data-theme="dark"] .badge.kind-other { background: #39412f; color: #c9d1b8; }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 15px;
  margin: 3px 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn:hover { filter: brightness(0.96); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--line); }
.btn.danger:hover { background: var(--danger-soft); }

form.inline { display: inline-block; margin: 4px 10px 4px 0; vertical-align: middle; }
form.inline input, form.inline select {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 11px;
  margin: 2px 5px;
  font-size: 0.9rem;
  font-family: inherit;
}

.filters { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- forms ---------- */
.form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  box-shadow: var(--shadow);
}

.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form input, .form select, .form textarea {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 1rem;
  font-family: inherit;
}

.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  background: var(--card);
}

fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
legend { padding: 0 8px; font-weight: 700; }
.radio, .check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 400; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row label { flex-direction: row; align-items: center; }

/* ---------- lists / flashes ---------- */
.items { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 38px; box-shadow: var(--shadow); }
.items li { padding: 6px 0; }

.flash { padding: 11px 17px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: #d9e8c3; color: #3c5f13; }
.flash.err { background: var(--danger-soft); color: var(--danger); }
[data-theme="dark"] .flash.ok { background: #2f4a2c; color: #c5e0a8; }

.banner.warn {
  background: #fef9c3;
  color: #854d0e;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
}

[data-theme="dark"] .banner.warn { background: #422006; color: #fde68a; }

/* ---------- attachment preview cards ---------- */
.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 12px 0 24px;
}

.attach-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.attach-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.9rem;
}

.attach-preview { background: var(--bg-soft); min-height: 120px; display: flex; align-items: center; justify-content: center; }
.attach-preview img { width: 100%; max-height: 260px; object-fit: cover; display: block; }
.attach-preview video { width: 100%; max-height: 260px; background: #000; }
.audio-wrap { padding: 22px 14px; text-align: center; font-size: 1.6rem; width: 100%; }
.audio-wrap audio { width: 100%; margin-top: 8px; }
.text-snippet {
  margin: 0;
  padding: 14px 16px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  text-align: right;
  width: 100%;
}
.file-icon { font-size: 3rem; padding: 28px; }
.file-missing { padding: 24px; color: var(--danger); }

.attach-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.attach-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attach-meta .ltr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

.revision-box {
  background: var(--primary-soft);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
}

.revision-box p { margin: 6px 0 0; white-space: pre-wrap; }

/* chat bubbles */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 24px; }
.bubble {
  max-width: 75%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.bubble.user, .bubble.worker { align-self: flex-start; border-inline-start: 4px solid var(--primary); }
.bubble.unit, .bubble.manager { align-self: flex-end; border-inline-end: 4px solid #c08a1d; text-align: right; }
.bubble-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; }

.time-pill {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
}

input[type="time"] { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1c2618 0%, #2f4a1e 55%, #4e7a1a 100%);
}
.login-card {
  background: var(--card);
  border-radius: 18px;
  padding: 38px 36px;
  width: 370px;
  text-align: center;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 { font-size: 1.5rem; }
.login-card input {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 1rem;
  text-align: center;
  font-family: inherit;
}

/* ---------- monitoring ---------- */
.monitor-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  margin: 12px 0 24px;
}

.panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.monitor-grid { margin-bottom: 0; }

.duo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.week-pie.single { text-align: center; max-width: 240px; margin: 0 auto; }
.week-pie.single .legend { justify-content: center; }

.panel-card h2 { margin-top: 0; }

.pie { width: 100%; max-width: 240px; display: block; margin: 0 auto; }
.pie-pct { font-size: 26px; font-weight: 800; fill: var(--ink); }
.pie-sub { font-size: 13px; fill: var(--muted); }

.area { width: 100%; height: auto; display: block; }
.gridline { stroke: var(--line); stroke-width: 1; }
.axis { font-size: 12px; fill: var(--muted); }
.axis.sm { font-size: 9px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 0.9rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-inline-end: 6px; vertical-align: baseline; }

.week-pies { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: center; }
.week-pie { text-align: center; max-width: 240px; }
.week-pie .pie { height: 170px; }
.mgr-pies { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mgr-pie { text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.pie.small { max-width: 170px; }

.pie-glow path, .pie-glow circle[fill^="#"], .pie-glow circle[fill^="url"] {
  filter: drop-shadow(0 2px 7px rgba(0, 0, 0, 0.4));
}

.ring-g { filter: drop-shadow(0 0 6px rgba(124, 195, 95, 0.65)); }
.ring-r { filter: drop-shadow(0 0 6px rgba(224, 138, 138, 0.65)); }
.ring-c1 { font-size: 17px; font-weight: 800; fill: var(--ink); }
.ring-c2 { font-size: 13px; fill: var(--muted); }

@media (max-width: 1000px) {
  .monitor-grid { grid-template-columns: 1fr; }
  .duo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; max-height: none; }
  .sidebar nav { overflow-y: visible; }
  .content { padding: 16px; margin-right: 0; }
}
