/**
 * PromptQT Documentation — Based on StudioLanding Design System
 * Bilingual (EN/FA) + Dark Theme
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --border: rgba(255, 255, 255, .11);
  --border-h: rgba(255, 255, 255, .2);
  --accent: #34d399;
  --accent-h: #10b981;
  --accent-glow: rgba(52, 211, 153, .35);
  --accent-muted: rgba(52, 211, 153, .14);
  --text: rgba(255, 255, 255, .97);
  --text2: rgba(255, 255, 255, .72);
  --text3: rgba(255, 255, 255, .48);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  
  /* Legacy vars for compatibility */
  --background-color: var(--bg);
  --surface-color: var(--surface);
  --text-primary: var(--text);
  --text-secondary: var(--text2);
  --border-color: var(--border);
  --code-bg: rgba(0, 0, 0, .3);
  --primary-color: var(--accent);
  --primary-hover: var(--accent-h);
  --header-height: 70px;
  --sidebar-width: 280px;
  --toc-width: 250px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-fa {
  font-family: 'Vazirmatn', 'Inter', sans-serif;
}

/* BG Elements */
.bg-grid {
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
              linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 140%;
  height: 70vh;
  top: -25vh;
  left: -20%;
  background: radial-gradient(ellipse 80% 55% at 50% 0%, rgba(52, 211, 153, .45) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.bg-aurora {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(16, 185, 129, .13), transparent 40%),
    radial-gradient(circle at 85% 65%, rgba(45, 212, 191, .09), transparent 40%);
  filter: blur(72px);
  pointer-events: none;
  z-index: 0;
}

/* Ensure background doesn't interfere with interactive elements */

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(10, 10, 10, .9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 2rem;
  /* max-width: 1600px; */
  margin: 0 auto;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: .55rem;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 800;
  font-size: .85rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* Theme and language switchers removed */

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
}

.hamburger {
  width: 25px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: all .3s ease;
}

/* ===== CONTAINER & LAYOUT ===== */
.container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height) - 60px);
  position: relative;
  z-index: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 2rem 0;
  transition: transform .3s ease;
  z-index: 100;
  pointer-events: auto;
}

body.rtl .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.nav-section {
  margin-bottom: 2rem;
  padding: 0 1.5rem;
}

.nav-section-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin-bottom: .8rem;
}

.nav-list {
  list-style: none;
}

.nav-list li {
  margin-bottom: .3rem;
}

.nav-item-container {
  display: flex;
  align-items: center;
  position: relative;
  pointer-events: auto;
}

.nav-list li a {
  display: flex;
  align-items: center;
  padding: .65rem 1rem;
  color: var(--text2);
  text-decoration: none;
  border-radius: 8px;
  font-size: .95rem;
  transition: all .2s ease;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.nav-list li a:hover {
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}

.nav-list li a.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid rgba(52, 211, 153, .2);
}

.nav-expand-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: .4rem;
  margin-right: .2rem;
  font-size: .7rem;
  transition: all .3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  pointer-events: auto;
  z-index: 10;
}

body.rtl .nav-expand-btn {
  margin-right: 0;
  margin-left: .2rem;
  transform: scaleX(-1);
}

.nav-expand-btn:hover {
  background: rgba(255, 255, 255, .05);
  color: var(--accent);
}

.nav-expand-btn.expanded {
  transform: rotate(90deg);
  color: var(--accent);
}

body.rtl .nav-expand-btn.expanded {
  transform: rotate(90deg) scaleX(-1);
}

.nav-item-container a {
  flex: 1;
}

.nav-children {
  list-style: none;
  margin-left: 1rem;
  margin-top: .3rem;
  padding-left: .8rem;
  border-left: 2px solid var(--border);
}

body.rtl .nav-children {
  margin-left: 0;
  margin-right: 1rem;
  padding-left: 0;
  padding-right: .8rem;
  border-left: none;
  border-right: 2px solid var(--border);
}

.nav-children li {
  margin-bottom: .2rem;
}

.nav-children li a {
  font-size: .9rem;
  padding: .5rem .8rem;
  color: var(--text3);
}

.nav-children li a:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, .05);
}

.nav-children li a.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}

/* ===== TABLE OF CONTENTS SIDEBAR ===== */
.toc-sidebar {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 2rem 1.5rem;
  transition: transform .3s ease;
  z-index: 90;
}

.toc-sidebar.hidden {
  transform: translateX(100%);
}

body.rtl .toc-sidebar {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border);
}

body.rtl .toc-sidebar.hidden {
  transform: translateX(-100%);
}

.toc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.toc-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: .5rem;
}

.toc-list li a {
  display: block;
  color: var(--text2);
  text-decoration: none;
  font-size: .9rem;
  padding: .4rem 0;
  border-left: 2px solid transparent;
  padding-left: .8rem;
  transition: all .2s ease;
}

body.rtl .toc-list li a {
  border-left: none;
  border-right: 2px solid transparent;
  padding-left: 0;
  padding-right: .8rem;
}

.toc-list li a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

body.rtl .toc-list li a:hover {
  border-right-color: var(--accent);
}

.toc-list li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

body.rtl .toc-list li a.active {
  border-right-color: var(--accent);
}

.toc-list li.toc-h3 a {
  padding-left: 1.5rem;
  font-size: .85rem;
}

body.rtl .toc-list li.toc-h3 a {
  padding-left: 0;
  padding-right: 1.5rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-right: 0;
  padding: 3rem;
  max-width: calc(100% - var(--sidebar-width) - var(--toc-width));
  width: 100%;
  position: relative;
  z-index: 1;
}

.main-content.with-toc {
  margin-right: var(--toc-width);
}

body.rtl .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

body.rtl .main-content.with-toc {
  margin-left: var(--toc-width);
  margin-right: var(--sidebar-width);
}

.content-area {
  background: var(--surface);
  padding: 3rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  min-height: 400px;
  max-width: 100%;
  overflow-x: auto;
}

/* Hero Section for Homepage */
.hero-section {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, rgba(52, 211, 153, .06) 0%, rgba(255, 255, 255, .02) 60%);
  border-radius: 16px;
  margin-bottom: 3rem;
  border: 1px solid rgba(52, 211, 153, .18);
  box-shadow: 0 0 60px rgba(52, 211, 153, .06) inset;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 200px;
  background: radial-gradient(ellipse, rgba(52, 211, 153, .12), transparent 70%);
  pointer-events: none;
}

.hero-section h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--text);
  letter-spacing: -.04em;
  line-height: 1.1;
}

.hero-section p {
  font-size: 1.05rem;
  color: var(--text2);
  margin-bottom: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

.hero-buttons {
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
}

.hero-btn {
  padding: .85rem 2rem;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  transition: all .22s ease;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 48px;
  letter-spacing: .01em;
  /* Override .content-area a styles */
  border-bottom: none !important;
  box-shadow: none;
  padding-left: 2rem !important;
  padding-right: 2rem !important;
}

.hero-btn:hover,
.hero-btn:focus-visible {
  /* Override .content-area a:hover styles */
  background: unset;
  border-bottom: none !important;
  box-shadow: unset;
  outline: none;
}

.hero-btn-primary {
  background: var(--accent) !important;
  color: #000 !important;
  border: 1.5px solid var(--accent) !important;
}

.hero-btn-primary:hover {
  background: var(--accent-h) !important;
  border-color: var(--accent-h) !important;
  box-shadow: 0 0 28px var(--accent-glow) !important;
  transform: translateY(-2px);
  color: #000 !important;
}

.hero-btn-secondary {
  background: transparent !important;
  color: var(--text2) !important;
  border: 1.5px solid var(--border-h) !important;
}

.hero-btn-secondary:hover {
  background: rgba(255,255,255,.06) !important;
  border-color: var(--text3) !important;
  color: var(--text) !important;
  transform: translateY(-2px);
}

/* Feature Cards */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 3rem;
}

.feature-card {
  padding: 1.4rem;
  background: linear-gradient(135deg, rgba(52, 211, 153, .05) 0%, rgba(255, 255, 255, .02) 100%);
  border: 1px solid rgba(52, 211, 153, .12);
  border-radius: 12px;
  transition: all .3s;
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at top right, rgba(52, 211, 153, .1), transparent 70%);
  pointer-events: none;
}

.feature-card:hover {
  border-color: rgba(52, 211, 153, .3);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3), 0 0 20px rgba(52, 211, 153, .07);
}

.feature-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-muted);
  border: 1px solid rgba(52, 211, 153, .2);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: .5rem;
  font-size: 1.2rem;
}

.feature-card h3 {
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .2rem;
  color: var(--text);
}

.feature-card p {
  font-size: .8rem;
  color: var(--text2);
  line-height: 1.55;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 1.5rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  color: var(--text2);
  font-size: 1.1rem;
}

/* ===== MARKDOWN CONTENT STYLES ===== */
.content-area h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  line-height: 1.2;
  scroll-margin-top: calc(var(--header-height) + 20px);
  letter-spacing: -.02em;
}

.content-area h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
  scroll-margin-top: calc(var(--header-height) + 20px);
  letter-spacing: -.02em;
}

.content-area h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: .8rem;
  color: var(--text);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.content-area h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: .6rem;
  color: var(--text);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.content-area p {
  margin-bottom: 1.2rem;
  line-height: 1.8;
  color: var(--text);
}

.content-area ul,
.content-area ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
  line-height: 1.8;
}

body.rtl .content-area ul,
body.rtl .content-area ol {
  padding-left: 0;
  padding-right: 2rem;
}

.content-area li {
  margin-bottom: .6rem;
  line-height: 1.7;
  color: var(--text2);
}

.content-area code {
  background: rgba(255, 255, 255, .08);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .85em;
  color: var(--accent);
  line-height: 1;
}

.content-area pre {
  background: rgba(0, 0, 0, .45);
  padding: 1.5rem;
  border-radius: 9px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  line-height: 1.5;
  direction: ltr;
  text-align: left;
}

.content-area pre code {
  background: none;
  padding: 0;
  color: var(--text2);
  font-size: .72rem;
  line-height: 1.6;
}

.content-area code {
    background: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--secondary-color);
    line-height: 1;
}

/* Code blocks are rendered as <pre><code>...raw text...</code></pre>.
   Avoid styling hacks for broken <p>-per-line output. */

/* .content-area pre {
    background: var(--code-bg);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    line-height: 1.5;
} */

/* .content-area pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
} */

.content-area blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text2);
  font-style: italic;
}

body.rtl .content-area blockquote {
  border-left: none;
  border-right: 4px solid var(--accent);
  padding-left: 0;
  padding-right: 1.5rem;
}

.content-area a:not(.hero-btn) {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(52, 211, 153, .45);
  transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
  border-radius: 4px;
  padding: 0 .15rem;
}

.content-area a:not(.hero-btn):visited {
  color: var(--accent);
}

.content-area a:not(.hero-btn):hover {
  color: var(--text);
  background: rgba(52, 211, 153, .22);
  border-bottom-color: transparent;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, .35) inset;
}

.content-area a:not(.hero-btn):focus-visible {
  outline: 2px solid rgba(52, 211, 153, .65);
  outline-offset: 2px;
  background: rgba(52, 211, 153, .18);
  border-bottom-color: transparent;
}

.content-area table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  overflow-x: auto;
  display: block;
}

.content-area table th,
.content-area table td {
  padding: .8rem;
  border: 1px solid var(--border);
  text-align: left;
}

body.rtl .content-area table th,
body.rtl .content-area table td {
  text-align: right;
}

.content-area table th {
  background: rgba(255, 255, 255, .02);
  font-weight: 600;
  color: var(--text);
}

.content-area table td {
  color: var(--text2);
}

.content-area img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.accent {
  color: var(--accent);
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 1.2rem 0;
  text-align: center;
  color: var(--text3);
  font-size: .9rem;
  position: relative;
  z-index: 1;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1400px) {
  .toc-sidebar {
    transform: translateX(100%);
  }
  
  body.rtl .toc-sidebar {
    transform: translateX(-100%);
  }
  
  .main-content {
    max-width: calc(100% - var(--sidebar-width));
    margin-right: 0;
  }
  
  body.rtl .main-content {
    margin-left: 0;
  }
}

@media (max-width: 1024px) {
  .main-content {
    padding: 2rem;
  }
  
  .content-area {
    padding: 2rem;
  }
  
  .hero-section h1 {
    font-size: 2.5rem;
  }
  
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    z-index: 999;
  }
  
  body.rtl .sidebar {
    transform: translateX(100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
    max-width: 100%;
  }
  
  body.rtl .main-content {
    margin-right: 0;
  }
  
  .content-area {
    padding: 1.5rem;
  }
  
  .hero-section {
    padding: 3rem 1.5rem;
  }
  
  .hero-section h1 {
    font-size: 2rem;
  }
  
  .hero-section p {
    font-size: 1.1rem;
  }
  
  .content-area h1 {
    font-size: 2rem;
  }
  
  .content-area h2 {
    font-size: 1.6rem;
  }
  
  .header-content {
    padding: 0 1rem;
  }
  
  .site-title {
    font-size: 1.2rem;
  }
  
  .lang-switcher {
    padding: .5rem 1rem;
    font-size: .85rem;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 1rem;
  }
  
  .site-title {
    font-size: 1rem;
  }
  
  .lang-icon,
  .theme-icon {
    font-size: 1rem;
  }
  
  .content-area {
    padding: 1rem;
  }
  
  .hero-section h1 {
    font-size: 1.75rem;
  }
  
  .content-area h1 {
    font-size: 1.75rem;
  }
  
  .hero-buttons {
    flex-direction: column;
  }
  
  .hero-btn {
    width: 100%;
    justify-content: center;
  }
}
