/* ==========================================================================
   تمیزکار متن فارسی — شیوه‌نامهٔ ظاهری
   ========================================================================== */

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

:root {
  --bg: #f4f6fb;
  --bg-grad-1: #e8ecff;
  --bg-grad-2: #f7f4ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #1a2233;
  --text-soft: #5b6780;
  --text-faint: #8d98ad;
  --accent: #3d5afe;
  --accent-soft: #eaeeff;
  --accent-2: #00897b;
  --warn: #b26a00;
  --warn-soft: #fff5e2;
  --danger: #c62828;
  --ok: #2e7d32;
  --ok-soft: #e8f6ea;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0e1118;
  --bg-grad-1: #141a26;
  --bg-grad-2: #10141d;
  --surface: #171c26;
  --surface-2: #1d2430;
  --border: #2a3240;
  --text: #e7ecf5;
  --text-soft: #a3aec2;
  --text-faint: #6f7c93;
  --accent: #7c8cff;
  --accent-soft: #1e2540;
  --accent-2: #4db6ac;
  --warn: #ffb74d;
  --warn-soft: #2c2416;
  --danger: #ef5350;
  --ok: #66bb6a;
  --ok-soft: #17251a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 500px at 85% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, var(--bg-grad-2), transparent 55%);
  color: var(--text);
  direction: rtl;
  line-height: 1.9;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- سربرگ ---------- */
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.logo {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 6px 18px rgba(61, 90, 254, .28);
}
.head h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.head p { margin: 2px 0 0; font-size: 13px; color: var(--text-soft); }
.head .spacer { flex: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft); cursor: pointer; font-size: 17px;
  display: grid; place-items: center; transition: .18s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

/* ---------- کارت ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; margin: 0; font-weight: 700; color: var(--text); }
.card-head .hint { font-size: 12px; color: var(--text-faint); }
.card-head .spacer { flex: 1; }

/* ---------- ورودی و خروجی ---------- */
textarea#input, .output {
  width: 100%;
  min-height: 230px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 2.05;
  padding: 16px;
  resize: vertical;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
textarea#input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.output {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  min-height: 200px;
  max-height: 60vh;
  overflow-y: auto;
}
.output.empty { color: var(--text-faint); }

/* ---------- دکمه‌ها ---------- */
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 11px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: .18s; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(61, 90, 254, .25);
}
.btn.primary:hover { color: #fff; filter: brightness(1.06); transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.ok:hover { background: var(--ok-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.active {
  background: var(--warn-soft); border-color: var(--warn); color: var(--warn);
  box-shadow: inset 0 0 0 1px var(--warn);
}
.btn.active:hover { color: var(--warn); border-color: var(--warn); }
.row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 12px; }

/* ---------- تنظیمات ---------- */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 999px; padding: 6px 13px 6px 10px; cursor: pointer;
  font-size: 12.5px; color: var(--text-soft); transition: .16s; user-select: none;
}
.opt input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- تب‌ها ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-soft); padding: 9px 14px; margin-bottom: -1px; transition: .16s;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px;
  display: inline-grid; place-items: center; font-weight: 700;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.zero { background: var(--surface-2); color: var(--text-faint); }
.pane { display: none; }
.pane.active { display: block; }

/* ---------- آمار ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 13px; font-size: 12.5px; color: var(--text-soft);
}
.stat b { color: var(--text); font-weight: 700; font-size: 14px; }

/* ---------- گزارش تغییرات ---------- */
.group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.group > summary {
  list-style: none; cursor: pointer; padding: 11px 14px; background: var(--surface-2);
  display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: '▾'; color: var(--text-faint); font-size: 11px; transition: transform .18s;
  display: inline-block; transform: rotate(90deg);
}
.group[open] > summary::before { transform: rotate(0deg); }
.group .cnt { margin-inline-start: auto; font-size: 12px; color: var(--text-faint); font-weight: 500; }
.group .body { padding: 6px 14px 12px; }

.pairs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pair {
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  padding: 3px 10px; font-size: 13px; direction: ltr; unicode-bidi: isolate;
}
.pair .n { color: var(--text-faint); font-size: 11px; }

table.log { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.log th {
  text-align: right; color: var(--text-faint); font-weight: 600; font-size: 11.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.log td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.log tr:last-child td { border-bottom: none; }
.pos { color: var(--text-faint); white-space: nowrap; font-size: 11.5px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 7px; background: var(--surface-2);
  border: 1px solid var(--border); unicode-bidi: isolate; min-width: 24px; text-align: center;
}
.chip.b { color: var(--danger); }
.chip.a { color: var(--ok); }
.ctx { color: var(--text-soft); font-size: 12px; }
.more { text-align: center; padding-top: 8px; }

/* ---------- هشدارهای املایی ---------- */
.warn-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 9px; display: flex; gap: 12px; align-items: center;
  background: var(--surface-2); transition: .18s;
}
.warn-item.done { background: var(--ok-soft); border-color: var(--ok); }
.warn-item .txt { flex: 1; min-width: 0; }
.warn-item .line1 { font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.warn-item .arrow { color: var(--text-faint); }
.warn-item .wrong { color: var(--danger); font-weight: 700; }
.warn-item .right { color: var(--ok); font-weight: 700; }
.warn-item .meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.kind {
  font-size: 11px; padding: 1px 8px; border-radius: 6px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid transparent;
}
.empty-state { text-align: center; color: var(--text-faint); padding: 34px 10px; font-size: 13.5px; }
.empty-state .big { font-size: 30px; display: block; margin-bottom: 8px; }

/* ---------- پیام کپی ---------- */
.toast {
  position: fixed; inset-inline-start: 50%; transform: translateX(50%) translateY(20px);
  bottom: 26px; background: var(--text); color: var(--surface);
  padding: 10px 20px; border-radius: 11px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

footer { text-align: center; color: var(--text-faint); font-size: 12px; margin-top: 26px; }

@media (max-width: 640px) {
  .wrap { padding: 18px 13px 44px; }
  .head h1 { font-size: 17px; }
  .card { padding: 14px; }
  table.log .ctx { display: none; }
}
