/* ===================================================
   دوره جامع مهندسی پرامپت — Custom Stylesheet
=================================================== */

/* ---------- فونت فارسی ---------- */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1e40af;
  --primary-light: #dbeafe;
  --secondary:     #7c3aed;
  --accent:        #0ea5e9;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --info:          #0891b2;
  --bg:            #f0f4ff;
  --surface:       #ffffff;
  --text:          #1e293b;
  --muted:         #64748b;
  --border:        #e2e8f0;
  --radius:        0.875rem;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:        0 4px 16px rgba(37,99,235,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 40px rgba(37,99,235,.15), 0 4px 12px rgba(0,0,0,.08);
  --transition:    .25s cubic-bezier(.4,0,.2,1);
  --hero-grad-1:   #1e40af;
  --hero-grad-2:   #2563eb;
  --hero-grad-3:   #7c3aed;
  --navbar-grad-1: var(--primary-dark);
  --navbar-grad-2: var(--primary);
  --navbar-grad-3: var(--secondary);
  --surface-soft:  #f8fafc;
  --ring:          rgba(37,99,235,.18);
}

/* ---------- پایه ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.75;
  direction: rtl;
  text-align: right;
}

body[data-theme="emerald"] {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --secondary: #15803d;
  --accent: #059669;
  --success: #15803d;
  --warning: #a16207;
  --danger: #b91c1c;
  --info: #0f766e;
  --bg: #ecfdf5;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #d1fae5;
  --hero-grad-1: #115e59;
  --hero-grad-2: #0f766e;
  --hero-grad-3: #15803d;
  --navbar-grad-1: #115e59;
  --navbar-grad-2: #0f766e;
  --navbar-grad-3: #15803d;
  --surface-soft: #f0fdfa;
  --ring: rgba(15,118,110,.2);
}

body[data-theme="sunset"] {
  --primary: #ea580c;
  --primary-dark: #9a3412;
  --primary-light: #ffedd5;
  --secondary: #db2777;
  --accent: #f59e0b;
  --success: #ca8a04;
  --warning: #ea580c;
  --danger: #be123c;
  --info: #c2410c;
  --bg: #fff7ed;
  --surface: #fff;
  --text: #431407;
  --muted: #7c2d12;
  --border: #fed7aa;
  --hero-grad-1: #9a3412;
  --hero-grad-2: #ea580c;
  --hero-grad-3: #db2777;
  --navbar-grad-1: #9a3412;
  --navbar-grad-2: #ea580c;
  --navbar-grad-3: #db2777;
  --surface-soft: #fff7ed;
  --ring: rgba(234,88,12,.2);
}

body[data-theme="royal"] {
  --primary: #4338ca;
  --primary-dark: #312e81;
  --primary-light: #e0e7ff;
  --secondary: #7e22ce;
  --accent: #6366f1;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --info: #4f46e5;
  --bg: #eef2ff;
  --surface: #ffffff;
  --text: #1e1b4b;
  --muted: #4338ca;
  --border: #c7d2fe;
  --hero-grad-1: #312e81;
  --hero-grad-2: #4338ca;
  --hero-grad-3: #7e22ce;
  --navbar-grad-1: #312e81;
  --navbar-grad-2: #4338ca;
  --navbar-grad-3: #7e22ce;
  --surface-soft: #eef2ff;
  --ring: rgba(67,56,202,.25);
}

body[data-theme="rose"] {
  --primary: #be185d;
  --primary-dark: #831843;
  --primary-light: #fce7f3;
  --secondary: #9d174d;
  --accent: #ec4899;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #be123c;
  --info: #db2777;
  --bg: #fff1f2;
  --surface: #ffffff;
  --text: #500724;
  --muted: #9d174d;
  --border: #fbcfe8;
  --hero-grad-1: #831843;
  --hero-grad-2: #be185d;
  --hero-grad-3: #db2777;
  --navbar-grad-1: #831843;
  --navbar-grad-2: #be185d;
  --navbar-grad-3: #db2777;
  --surface-soft: #fff1f2;
  --ring: rgba(190,24,93,.22);
}

body[data-theme="midnight"] {
  --primary: #0ea5e9;
  --primary-dark: #0f172a;
  --primary-light: #1e293b;
  --secondary: #6366f1;
  --accent: #22d3ee;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f43f5e;
  --info: #38bdf8;
  --bg: #020617;
  --surface: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1e293b;
  --hero-grad-1: #0f172a;
  --hero-grad-2: #0b2447;
  --hero-grad-3: #312e81;
  --navbar-grad-1: #020617;
  --navbar-grad-2: #0f172a;
  --navbar-grad-3: #1e1b4b;
  --surface-soft: #111827;
  --ring: rgba(14,165,233,.3);
}

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: visible !important;
  z-index: 1400;
}

.top-toolbar {
  position: sticky;
  top: 78px;
  z-index: 1410;
}

.theme-panel {
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}

.settings-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  z-index: 1500;
}

.theme-popover {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  left: auto;
  min-width: 260px;
  width: max-content;
  max-width: min(90vw, 360px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .85rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
  padding: .8rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.985);
  transition: opacity .18s ease, transform .2s ease, visibility .2s ease;
  z-index: 1200;
}

.theme-popover.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.settings-trigger {
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .9rem;
}

.theme-palette {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.theme-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: .32rem .7rem;
  font-size: .82rem;
  line-height: 1.2;
  transition: .2s ease;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.theme-pill::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.theme-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.theme-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.theme-pill[data-theme="default"]::before { background: linear-gradient(135deg, #2563eb, #7c3aed); }
.theme-pill[data-theme="emerald"]::before { background: linear-gradient(135deg, #0f766e, #15803d); }
.theme-pill[data-theme="sunset"]::before { background: linear-gradient(135deg, #ea580c, #db2777); }
.theme-pill[data-theme="royal"]::before { background: linear-gradient(135deg, #4338ca, #7e22ce); }
.theme-pill[data-theme="rose"]::before { background: linear-gradient(135deg, #be185d, #db2777); }
.theme-pill[data-theme="midnight"]::before { background: linear-gradient(135deg, #0ea5e9, #312e81); }

/* ===================================================
   PROGRESS BAR
=================================================== */
#read-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #34d399, #60a5fa, #a78bfa);
  width: 0%;
  z-index: 1060;
  transition: width .1s linear;
}

/* ===================================================
   NAVBAR
=================================================== */
.navbar {
  background: linear-gradient(135deg, var(--navbar-grad-1) 0%, var(--navbar-grad-2) 60%, var(--navbar-grad-3) 100%) !important;
  box-shadow: 0 2px 20px rgba(37,99,235,.35) !important;
  padding-top: .75rem;
  padding-bottom: .75rem;
  transition: padding var(--transition), box-shadow var(--transition);
}
.navbar.scrolled {
  padding-top: .4rem;
  padding-bottom: .4rem;
  box-shadow: 0 4px 30px rgba(37,99,235,.45) !important;
}
.navbar-brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff !important;
  transition: opacity var(--transition);
}
.navbar-brand:hover { opacity: .85; }

.nav-link {
  font-weight: 500;
  padding: .4rem .75rem !important;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  color: rgba(255,255,255,.85) !important;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff !important;
}

/* ===================================================
   HERO SECTION
=================================================== */
.hero-section {
  background: linear-gradient(135deg, var(--hero-grad-1) 0%, var(--hero-grad-2) 45%, var(--hero-grad-3) 100%);
  border-radius: var(--radius);
  color: #fff;
  position: relative;
  overflow: hidden;
  padding: 4rem 2.5rem !important;
  box-shadow: var(--shadow-lg);
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 50%, rgba(255,255,255,.06) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255,255,255,.04) 0%, transparent 40%);
  pointer-events: none;
}
.hero-section .display-4 {
  color: #fff !important;
  text-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.hero-section .lead {
  color: rgba(255,255,255,.88) !important;
  font-size: 1.15rem;
}
.hero-section .badge {
  font-weight: 600;
  padding: .55em 1.1em;
  border-radius: 50px;
  font-size: .85rem !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: transform var(--transition), box-shadow var(--transition);
}
.hero-section .badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

/* ===================================================
   CHAPTER SECTIONS
=================================================== */
.chapter-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
}
.chapter-section::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.chapter-section:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.chapter-header {
  background: linear-gradient(90deg, var(--primary-light) 0%, rgba(219,234,254,.25) 100%);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.chapter-header h2 {
  font-size: 1.3rem;
  color: var(--primary-dark) !important;
  margin-bottom: 0;
}

/* ===================================================
   CARDS
=================================================== */
.card {
  border-radius: var(--radius) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm);
  background-color: var(--surface) !important;
  color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
}
.bg-light {
  background-color: var(--surface-soft) !important;
  color: var(--text) !important;
}
.text-muted {
  color: var(--muted) !important;
}
.form-select,
.form-control {
  border-color: var(--border);
  background-color: var(--surface);
  color: var(--text);
}
.form-select:focus,
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .25rem var(--ring);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-color: transparent;
}
.btn-primary:hover {
  filter: brightness(1.05);
}
.btn {
  border-radius: .7rem;
}
.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-outline-secondary {
  border-color: var(--border);
  color: var(--muted);
}
.btn-outline-secondary:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
}
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.card-body { padding: 1.4rem; }
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: .6rem; }

.card.border-primary { border-top: 3px solid var(--primary) !important; }
.card.border-success  { border-top: 3px solid var(--success) !important; }
.card.border-warning  { border-top: 3px solid var(--warning) !important; }
.card.border-danger   { border-top: 3px solid var(--danger) !important; }
.card.border-info     { border-top: 3px solid var(--info) !important; }
.card.border-dark     { border-top: 3px solid var(--text) !important; }

/* ===================================================
   ALERTS
=================================================== */
.alert {
  border-radius: var(--radius) !important;
  padding: 1.1rem 1.3rem;
}
.alert-info {
  background: linear-gradient(135deg, #ecfeff, #cffafe);
  border-color: #a5f3fc !important;
  color: #164e63;
}
.alert-success {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #86efac !important;
  color: #14532d;
}
.alert-warning {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: #fcd34d !important;
  color: #78350f;
}
.alert-danger {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  border-color: #fca5a5 !important;
  color: #7f1d1d;
}
.alert-primary {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: #93c5fd !important;
  color: #1e3a8a;
}
.alert-secondary {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-color: #c4b5fd !important;
  color: #3b0764;
}
body[data-theme="midnight"] .alert {
  border-color: var(--border) !important;
  color: var(--text);
}
body[data-theme="midnight"] .alert-info,
body[data-theme="midnight"] .alert-success,
body[data-theme="midnight"] .alert-warning,
body[data-theme="midnight"] .alert-danger,
body[data-theme="midnight"] .alert-primary,
body[data-theme="midnight"] .alert-secondary {
  background: linear-gradient(135deg, #111827, #0b1220);
}
body[data-theme="midnight"] .chapter-header {
  background: linear-gradient(90deg, #0b1220 0%, #111827 100%);
}
body[data-theme="midnight"] pre,
body[data-theme="midnight"] .bg-light.border.rounded {
  background: #020617 !important;
  border-color: #1e293b !important;
}
body[data-theme="midnight"] .table {
  color: var(--text);
}
body[data-theme="midnight"] .table-bordered > :not(caption) > * > * {
  border-color: #334155 !important;
}
body[data-theme="midnight"] .table tbody tr:hover {
  background: #111827 !important;
}
body[data-theme="midnight"] .card-header,
body[data-theme="midnight"] .card-footer {
  border-color: #334155 !important;
}
body[data-theme="midnight"] .badge.bg-warning.text-dark {
  color: #111827 !important;
  background: linear-gradient(135deg, #f59e0b, #fbbf24) !important;
}
body[data-theme="midnight"] .text-dark {
  color: #e5e7eb !important;
}
body[data-theme="midnight"] .bg-white,
body[data-theme="midnight"] .bg-body,
body[data-theme="midnight"] .bg-body-tertiary {
  background-color: #0f172a !important;
  color: var(--text) !important;
}
body[data-theme="midnight"] .border,
body[data-theme="midnight"] .border-start,
body[data-theme="midnight"] .border-end,
body[data-theme="midnight"] .border-top,
body[data-theme="midnight"] .border-bottom {
  border-color: #334155 !important;
}
body[data-theme="midnight"] .card,
body[data-theme="midnight"] .filter-panel,
body[data-theme="midnight"] .theme-popover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
body[data-theme="midnight"] .card-header,
body[data-theme="midnight"] .card-body,
body[data-theme="midnight"] .card-footer {
  background-color: #0f172a !important;
  color: var(--text) !important;
}
body[data-theme="midnight"] .card-header.bg-success,
body[data-theme="midnight"] .card-header.bg-danger,
body[data-theme="midnight"] .card-header.bg-primary,
body[data-theme="midnight"] .card-header.bg-warning,
body[data-theme="midnight"] .card-header.bg-info {
  background: linear-gradient(135deg, #111827, #1e293b) !important;
  color: #e2e8f0 !important;
}
body[data-theme="midnight"] .chapter-section .bg-light,
body[data-theme="midnight"] .chapter-section .bg-white,
body[data-theme="midnight"] .chapter-section .bg-body,
body[data-theme="midnight"] .chapter-section .bg-body-tertiary,
body[data-theme="midnight"] .chapter-section .list-group-item,
body[data-theme="midnight"] .chapter-section .accordion-item,
body[data-theme="midnight"] .chapter-section .accordion-button {
  background: #0b1220 !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
body[data-theme="midnight"] .chapter-section .text-dark,
body[data-theme="midnight"] .chapter-section .text-black,
body[data-theme="midnight"] .chapter-section .text-muted {
  color: #cbd5e1 !important;
}
body[data-theme="midnight"] .chapter-section [style*="background: #fff"],
body[data-theme="midnight"] .chapter-section [style*="background:#fff"],
body[data-theme="midnight"] .chapter-section [style*="background-color: #fff"],
body[data-theme="midnight"] .chapter-section [style*="background-color:#fff"],
body[data-theme="midnight"] .chapter-section [style*="background: white"],
body[data-theme="midnight"] .chapter-section [style*="background-color: white"] {
  background: #0b1220 !important;
  color: #e2e8f0 !important;
}

/* ===================================================
   CODE BLOCKS
=================================================== */
pre, .bg-light.border.rounded {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-radius: var(--radius) !important;
  border-color: #334155 !important;
  padding: 1.25rem 1.5rem !important;
  font-family: 'Courier New', monospace;
  font-size: .875rem;
  line-height: 1.7;
  overflow-x: auto;
}
code {
  background: rgba(37,99,235,.1);
  color: var(--primary);
  padding: .15em .45em;
  border-radius: 4px;
  font-size: .9em;
}

/* ===================================================
   TYPOGRAPHY
=================================================== */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.35; }

h3.h4 {
  font-size: 1.1rem;
  color: var(--primary-dark) !important;
  padding-bottom: .5rem;
  border-bottom: 2px dashed var(--primary-light);
  margin-bottom: 1rem !important;
}

.border-end.border-primary {
  border-right: 5px solid var(--primary) !important;
  border-left: none !important;
  padding-right: 1rem;
  padding-left: 0;
}

ul, ol { padding-right: 1.4rem; padding-left: 0; }
li { margin-bottom: .35rem; }

/* ===================================================
   TABLES
=================================================== */
.table { border-radius: var(--radius); overflow: hidden; }
.table thead th {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: 600;
  border: none;
}
.table tbody tr:hover { background: var(--primary-light); }

/* ===================================================
   SCROLL-TO-TOP BUTTON
=================================================== */
#scrollTopBtn {
  position: fixed;
  bottom: 2rem;
  left: 1.5rem;
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(37,99,235,.45);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#scrollTopBtn.show { opacity: 1; transform: translateY(0); }
#scrollTopBtn:hover {
  box-shadow: 0 8px 28px rgba(37,99,235,.55);
  transform: translateY(-3px);
}

/* ===================================================
   FADE-IN ON SCROLL
=================================================== */
.fade-in {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .55s ease, transform .55s ease;
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ===================================================
   RESPONSIVE
=================================================== */
@media (max-width: 768px) {
  .hero-section { padding: 2.5rem 1.25rem !important; }
  .hero-section .display-4 { font-size: 1.8rem; }
  .chapter-section { padding: 1.25rem !important; }
  #scrollTopBtn { bottom: 1.25rem; left: 1rem; }
  .top-toolbar { top: 70px; }
}
@media (max-width: 576px) {
  .hero-section .badge { font-size: .75rem !important; }
  .navbar-brand { font-size: 1rem; }
}
