/* راهنمای کاربری سامانه — استایل اصلی و چاپ */

@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Vazir;
  src: url('../fonts/Vazir-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --help-primary: #00796b;
  --help-primary-dark: #004d40;
  --help-primary-light: #e0f2f1;
  --help-accent: #2e7d32;
  --help-warning: #f57c00;
  --help-danger: #d32f2f;
  --help-info: #1976d2;
  --help-bg: #f5f7f8;
  --help-surface: #ffffff;
  --help-text: #212121;
  --help-muted: #616161;
  --help-border: #e0e0e0;
  --help-sidebar-w: 280px;
  --help-radius: 12px;
  --help-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Vazir, Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--help-text);
  background: var(--help-bg);
  direction: rtl;
}

a {
  color: var(--help-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ─── هدر ─── */
.help-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--help-surface);
  border-bottom: 1px solid var(--help-border);
  box-shadow: var(--help-shadow);
}

.help-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.help-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.help-brand__logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: block;
}

.help-brand__icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--help-primary), var(--help-primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.help-brand__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.help-brand__sub {
  font-size: 0.78rem;
  color: var(--help-muted);
  margin: 0;
}

.help-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--help-border);
  background: var(--help-surface);
  color: var(--help-text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.help-btn:hover {
  background: var(--help-primary-light);
  border-color: var(--help-primary);
}

.help-btn--primary {
  background: var(--help-primary);
  border-color: var(--help-primary);
  color: #fff;
}

.help-btn--primary:hover {
  background: var(--help-primary-dark);
  border-color: var(--help-primary-dark);
  color: #fff;
}

/* ─── تب نقش‌ها ─── */
.help-roles {
  background: var(--help-primary-light);
  border-bottom: 1px solid var(--help-border);
}

.help-roles__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.help-roles__label {
  font-size: 0.82rem;
  color: var(--help-muted);
  margin-left: 0.5rem;
}

.help-role-tab {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--help-surface);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.help-role-tab:hover {
  border-color: var(--help-primary);
}

.help-role-tab.is-active {
  background: var(--help-primary);
  color: #fff;
  border-color: var(--help-primary);
  font-weight: 700;
}

.help-role-tab[data-role="counter"].is-active { background: #0288d1; border-color: #0288d1; }
.help-role-tab[data-role="expert"].is-active { background: #2e7d32; border-color: #2e7d32; }
.help-role-tab[data-role="finance"].is-active { background: #f57c00; border-color: #f57c00; }
.help-role-tab[data-role="admin"].is-active { background: #00796b; border-color: #00796b; }

/* ─── چیدمان ─── */
.help-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: var(--help-sidebar-w) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.help-sidebar {
  position: sticky;
  top: 120px;
  background: var(--help-surface);
  border: 1px solid var(--help-border);
  border-radius: var(--help-radius);
  padding: 1rem;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.help-sidebar__title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--help-muted);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--help-border);
}

.help-toc {
  list-style: none;
  margin: 0;
  padding: 0;
}

.help-toc li {
  margin-bottom: 0.15rem;
}

.help-toc a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--help-text);
  text-decoration: none;
}

.help-toc a:hover,
.help-toc a.is-active {
  background: var(--help-primary-light);
  color: var(--help-primary-dark);
  font-weight: 600;
}

.help-toc .help-toc__subs {
  list-style: none;
  margin: 0.15rem 0 0.35rem;
  padding: 0 0.75rem 0 0;
}

.help-toc .help-toc__sub a {
  padding-right: 1.25rem;
  font-size: 0.78rem;
  color: var(--help-muted);
}

.help-main {
  min-width: 0;
}

/* ─── محتوا ─── */
.help-section {
  background: var(--help-surface);
  border: 1px solid var(--help-border);
  border-radius: var(--help-radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  scroll-margin-top: 130px;
}

.help-section.is-hidden {
  display: none;
}

.help-main.is-filtering {
  opacity: 0.35;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.help-main:not(.is-filtering) {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.help-role-banner {
  display: none;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
  max-width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--role-color, var(--help-primary)) 12%, white);
  border: 1px solid color-mix(in srgb, var(--role-color, var(--help-primary)) 35%, white);
  color: var(--help-primary-dark);
  font-size: 0.92rem;
  animation: helpBannerIn 0.35s ease;
}

.help-role-banner.is-visible {
  display: flex;
}

.help-role-banner__icon {
  color: var(--role-color, var(--help-primary));
  font-size: 0.75rem;
  animation: helpPulse 1.4s ease infinite;
}

@keyframes helpBannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes helpPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.help-section h2 {
  font-size: 1.35rem;
  color: var(--help-primary-dark);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--help-primary-light);
}

.help-section h3[id],
.help-section h4[id] {
  scroll-margin-top: 130px;
}

.help-section h3 {
  font-size: 1.05rem;
  color: var(--help-primary);
  margin: 1.5rem 0 0.6rem;
}

.help-section h4 {
  font-size: 0.95rem;
  margin: 1rem 0 0.4rem;
}

.help-section p {
  margin: 0 0 0.75rem;
}

.help-section ul,
.help-section ol {
  margin: 0 0 1rem;
  padding-right: 1.25rem;
}

.help-section li {
  margin-bottom: 0.35rem;
}

.help-cover {
  text-align: center;
  padding: 2.5rem 1rem;
  background: linear-gradient(180deg, var(--help-primary-light), var(--help-surface));
}

.help-cover h1 {
  font-size: 1.75rem;
  color: var(--help-primary-dark);
  margin: 0 0 0.5rem;
}

.help-cover .help-cover__ver {
  font-size: 0.85rem;
  color: var(--help-muted);
}

/* ─── باکس‌ها ─── */
.help-box {
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.help-box--tip {
  background: #e8f5e9;
  border-right: 4px solid var(--help-accent);
}

.help-box--warn {
  background: #fff3e0;
  border-right: 4px solid var(--help-warning);
}

.help-box--info {
  background: #e3f2fd;
  border-right: 4px solid var(--help-info);
}

.help-box--danger {
  background: #ffebee;
  border-right: 4px solid var(--help-danger);
}

.help-box strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* ─── مراحل ─── */
.help-steps {
  counter-reset: help-step;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.help-steps > li {
  counter-increment: help-step;
  position: relative;
  padding: 0.75rem 0.75rem 0.75rem 0;
  padding-right: 3rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--help-border);
  border-radius: 10px;
  background: #fafafa;
}

.help-steps > li::before {
  content: counter(help-step);
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--help-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-steps > li strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--help-primary-dark);
}

/* ─── جدول ─── */
.help-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.help-table th,
.help-table td {
  border: 1px solid var(--help-border);
  padding: 0.55rem 0.75rem;
  text-align: right;
}

.help-table th {
  background: var(--help-primary-light);
  font-weight: 700;
}

.help-table tr:nth-child(even) td {
  background: #fafafa;
}

/* ─── نشان نقش ─── */
.help-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.help-badge--all { background: #eceff1; color: #455a64; }
.help-badge--counter { background: #e1f5fe; color: #0277bd; }
.help-badge--expert { background: #e8f5e9; color: #2e7d32; }
.help-badge--finance { background: #fff3e0; color: #e65100; }
.help-badge--admin { background: #e0f2f1; color: #00695c; }

/* ─── منوی سامانه (شماتیک) ─── */
.help-menu-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.help-menu-item {
  border: 1px solid var(--help-border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fafafa;
}

.help-menu-item strong {
  display: block;
  color: var(--help-primary-dark);
  margin-bottom: 0.25rem;
}

.help-menu-item span {
  font-size: 0.82rem;
  color: var(--help-muted);
}

.help-toc-toggle {
  display: none;
}

.help-sidebar-backdrop {
  display: none;
}

/* ─── فوتر ─── */
.help-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--help-muted);
  font-size: 0.82rem;
}

/* ─── لودینگ ─── */
.help-loading {
  text-align: center;
  padding: 3rem;
  color: var(--help-muted);
}

/* ─── چاپ ─── */
@media print {
  @page {
    size: A4;
    margin: 15mm 12mm;
  }

  body {
    background: #fff;
    font-size: 11pt;
    line-height: 1.6;
  }

  .help-header,
  .help-roles,
  .help-sidebar,
  .help-toolbar,
  .no-print {
    display: none !important;
  }

  .help-layout {
    display: block;
    padding: 0;
    max-width: none;
  }

  .help-section {
    border: none;
    border-radius: 0;
    padding: 0 0 1rem;
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
    box-shadow: none;
  }

  .help-section.is-hidden {
    display: block !important;
  }

  .help-section h2 {
    page-break-after: avoid;
    font-size: 14pt;
  }

  .help-cover {
    page-break-after: always;
    padding: 4rem 0;
    background: none;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  .help-box {
    border: 1px solid #ccc;
    background: #f9f9f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .help-steps > li {
    page-break-inside: avoid;
  }

  .help-role-filter-note {
    display: block !important;
    text-align: center;
    font-size: 10pt;
    color: #666;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border: 1px dashed #999;
  }
}

@media (max-width: 900px) {
  .help-layout {
    grid-template-columns: 1fr;
    padding: 0.85rem;
    gap: 0;
  }

  .help-header__inner {
    padding: 0.65rem 1rem;
  }

  .help-brand__title {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  .help-roles__inner {
    padding: 0.5rem 1rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .help-roles__inner::-webkit-scrollbar {
    display: none;
  }

  .help-roles__label {
    flex-shrink: 0;
  }

  .help-role-tab {
    flex-shrink: 0;
  }

  .help-section {
    padding: 1.1rem 1rem;
    margin-bottom: 0.85rem;
  }

  .help-section h2 {
    font-size: 1.15rem;
  }

  .help-cover h1 {
    font-size: 1.35rem;
  }

  .help-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: -0.25rem;
    padding-inline: 0.25rem;
  }

  .help-table {
    font-size: 0.8rem;
    min-width: 480px;
  }

  .help-menu-map {
    grid-template-columns: 1fr;
  }

  .help-steps > li {
    padding-right: 2.75rem;
  }

  /* فهرست مطالب — کشوی موبایل */
  .help-toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    z-index: 150;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--help-primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(0, 77, 64, 0.35);
    cursor: pointer;
  }

  .help-toc-toggle svg {
    flex-shrink: 0;
  }

  .help-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }

  body.help-toc-open .help-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .help-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 300px);
    z-index: 190;
    max-height: none;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--help-border);
    transform: translateX(100%);
    transition: transform 0.28s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 1rem;
  }

  body.help-toc-open .help-sidebar {
    transform: translateX(0);
  }

  .help-main {
    padding-bottom: 4.5rem;
  }

  .help-footer {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 901px) {
  .help-toc-toggle,
  .help-sidebar-backdrop {
    display: none !important;
  }
}
