/* هموار — سیستم طراحی جامع نسخه ۲ (Modern GovTech & LegalTech UI)
   تایپوگرافی: Vazirmatn | جهت: RTL | پشتیبانی کامل از تم روشن و تیره */

:root {
  --font-main: 'Estedad', 'Vazirmatn', -apple-system, BlinkMacSystemFont, Tahoma, 'Segoe UI', sans-serif;
  --bg-primary: #FBFAF8;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --bg-muted: #F2EFE9;
  --border-subtle: #E9E5DF;
  --border-strong: #DED8D0;
  --text-primary: #1C1A17;
  --text-secondary: #6B6660;
  --text-muted: #9A948C;
  --accent-primary: #17140F;
  --accent-hover: #000000;
  --accent-ink: #FFFFFF;
  --accent-light: #F2EFE9;
  --brand-navy: #17140F;
  --brand-emerald: #3F7D5C;
  --brand-amber: #B07A2E;
  --brand-rose: #B24A3C;
  --shadow-sm: 0 1px 2px 0 rgb(28 26 23 / 0.05);
  --shadow-md: 0 4px 10px -2px rgb(28 26 23 / 0.08), 0 2px 4px -2px rgb(28 26 23 / 0.05);
  --shadow-lg: 0 12px 28px -6px rgb(28 26 23 / 0.10), 0 4px 8px -4px rgb(28 26 23 / 0.04);
  --shadow-glow: 0 0 0 3px rgb(28 26 23 / 0.06);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
}

.dark {
  --bg-primary: #141210;
  --bg-surface: #1E1B18;
  --bg-surface-elevated: #26221D;
  --bg-muted: #26221D;
  --border-subtle: #2A2620;
  --border-strong: #3A342C;
  --text-primary: #F2EEE8;
  --text-secondary: #A9A199;
  --text-muted: #7C756C;
  --accent-primary: #F2EEE8;
  --accent-hover: #FFFFFF;
  --accent-ink: #1A1714;
  --accent-light: #26221D;
  --brand-emerald: #6FB08A;
  --brand-amber: #D0A45C;
  --brand-rose: #D98A7C;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 10px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 12px 28px -6px rgb(0 0 0 / 0.55);
  --shadow-glow: 0 0 0 3px rgb(255 255 255 / 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14.5px;
  line-height: 1.8;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* اسکرول‌بار سفارشی شکیل */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 9999px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* لینک‌ها و فوکوس */
a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* هدر و گلس‌مورفیسم */
.nav-blur {
  background: rgba(251, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.dark .nav-blur {
  background: rgba(20, 18, 16, 0.85);
  border-bottom: 1px solid rgba(42, 38, 32, 0.7);
}

/* کارت‌های پایه و مدرن */
.modern-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.modern-card:hover {
  box-shadow: var(--shadow-md);
}

.interactive-card {
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.interactive-card::before {
  display: none;
}
.interactive-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-lg);
}
.interactive-card:hover::before {
  background: var(--accent-primary);
}
.interactive-card.on,
.interactive-card.selected {
  border-color: var(--accent-primary);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px var(--accent-primary);
}
.interactive-card.on::before,
.interactive-card.selected::before {
  background: var(--accent-primary);
}

/* فرم‌ها و اینپوت‌های پیشرفته */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.925rem;
  line-height: 1.6;
  transition: all 0.15s ease;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-textarea {
  min-height: 110px;
  resize: vertical;
}

/* دکمه‌ها */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-ink) !important;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink) !important;
}
.btn-emerald {
  background: var(--accent-primary);
  color: var(--accent-ink) !important;
  box-shadow: var(--shadow-sm);
}
.btn-emerald:hover {
  background: var(--accent-hover);
  color: var(--accent-ink) !important;
}
.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}
.btn-danger {
  background: #e11d48;
  color: #ffffff !important;
}
.btn-danger:hover {
  background: #be123c;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.825rem;
  border-radius: 6px;
}
.btn-lg {
  padding: 0.8rem 1.6rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

/* استپر ویزارد */
.stepper-container {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding: 0 1rem;
}
.stepper-line {
  position: absolute;
  top: 21px;
  left: 3rem;
  right: 3rem;
  height: 3px;
  background: var(--border-strong);
  transform: translateY(-50%);
  z-index: 1;
}
.stepper-line-progress {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.35s ease;
}
.step-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.step-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}
.step-node.active .step-circle {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px var(--accent-light);
  transform: scale(1.08);
}
.step-node.done .step-circle {
  background: var(--brand-emerald);
  border-color: var(--brand-emerald);
  color: #ffffff;
}
.step-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.step-node.active .step-label {
  color: var(--text-primary);
  font-weight: 700;
}
.step-node.done .step-label {
  color: var(--brand-emerald);
}

/* گام‌های فرم */
.step-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}
.step-pane.on {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* دستیار هوش مصنوعی */
.ai-assistant-card {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.05) 0%, rgba(56, 189, 248, 0.02) 100%);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin: 1.25rem 0;
  position: relative;
  overflow: hidden;
}
.dark .ai-assistant-card {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.12) 0%, rgba(30, 41, 59, 0.6) 100%);
  border-color: rgba(56, 189, 248, 0.3);
}
.ai-assistant-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #0284c7, #38bdf8);
}

/* نشان‌ها و بج‌ها */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.775rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-pill.blue {
  background: #F2EFE9;
  color: #6B6660;
  border: 1px solid #E9E5DF;
}
.dark .badge-pill.blue {
  background: #26221D;
  color: #A9A199;
  border-color: #2A2620;
}
.badge-pill.emerald {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.dark .badge-pill.emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.25);
}
.badge-pill.amber {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.dark .badge-pill.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}
.badge-pill.rose {
  background: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fecdd3;
}
.dark .badge-pill.rose {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(251, 113, 133, 0.25);
}
.badge-pill.slate {
  background: #F2EFE9;
  color: #6B6660;
  border: 1px solid #E9E5DF;
}
.dark .badge-pill.slate {
  background: #26221D;
  color: #A9A199;
  border-color: #2A2620;
}

/* استناد قانونی (Citations) */
.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(23, 20, 15, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0.25rem 0.25rem 0.25rem 0;
  transition: all 0.15s ease;
}
.dark .citation-chip {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.citation-chip:hover {
  background: rgba(2, 132, 199, 0.16);
}

/* تایم‌لاین شکیل شاخه‌ای */
.timeline-track {
  position: relative;
  padding-inline-start: 2rem;
  margin: 1rem 0;
}
.timeline-track::before {
  content: '';
  position: absolute;
  top: 0.6rem;
  bottom: 0.6rem;
  right: 0.65rem;
  width: 2px;
  background: var(--border-strong);
}
.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}
.timeline-marker {
  position: absolute;
  top: 0.35rem;
  right: -1.75rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 1;
}
.timeline-item.done .timeline-marker {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}
.timeline-item.current .timeline-marker {
  background: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 0 0 4px var(--accent-light);
}

/* پالس وضعیت زنده */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}
.pulse-dot.green {
  background: #10b981;
}
.pulse-dot.green::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: pulseGreen 1.8s infinite;
}
@keyframes pulseGreen {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.6); opacity: 0; }
}

.pulse-dot.amber {
  background: #f59e0b;
}

/* سیستم توست نوتیفیکیشن */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}
.toast-msg {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* گفتگوی دستیار هوشمند */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.5rem;
}
.chat-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 0.9rem;
  max-width: 78%;
  font-size: 0.875rem;
  line-height: 1.7;
  position: relative;
  word-wrap: break-word;
}
.chat-bubble.user {
  background: var(--accent-primary);
  color: var(--accent-ink);
  align-self: flex-start;
  border-bottom-right-radius: 4px;
}
.chat-bubble.ai {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* جداول مدرن */
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
.modern-table th {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.85rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  font-size: 0.8rem;
}
.modern-table th:first-child { border-start-start-radius: 0.75rem; }
.modern-table th:last-child { border-start-end-radius: 0.75rem; }
.modern-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.modern-table td .badge-pill,
.modern-table td .font-mono { white-space: nowrap; }
.modern-table td .font-mono { direction: ltr; unicode-bidi: isolate; }
.modern-table tbody tr {
  transition: background 0.15s ease;
}
.modern-table tbody tr:hover {
  background: var(--bg-muted);
}

/* بنر اطلاعاتی با تم نرم */
.callout-banner {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  font-size: 0.925rem;
  line-height: 1.7;
}
.callout-banner.info {
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.dark .callout-banner.info {
  background: var(--bg-muted);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}
.callout-banner.warning {
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: #92400e;
}
.dark .callout-banner.warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
  color: #fde68a;
}
