/* ═══════════════════════════════════════════════════════════
   Recruix ATS – Web Help Stylesheet
   Modern documentation style (inspired by Stripe/Notion docs)
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --brand-primary:   #4F46E5;
  --brand-secondary: #7C3AED;
  --brand-accent:    #06B6D4;
  --brand-gradient:  linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);

  --bg-base:         #F8F9FC;
  --bg-sidebar:      #FFFFFF;
  --bg-content:      #FFFFFF;
  --bg-header:       #FFFFFF;
  --bg-code:         #F3F4F6;
  --bg-table-head:   #EEF2FF;
  --bg-table-alt:    #F9FAFB;
  --bg-badge:        #EEF2FF;

  --text-primary:    #111827;
  --text-secondary:  #4B5563;
  --text-muted:      #9CA3AF;
  --text-brand:      #4F46E5;
  --text-on-brand:   #FFFFFF;

  --border-color:    #E5E7EB;
  --border-subtle:   #F3F4F6;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:       0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:       0 10px 30px rgba(0,0,0,.12);

  --topbar-h:        64px;
  --sidebar-w:       300px;
  --content-max:     900px;
  --radius:          10px;
  --radius-sm:       6px;
  --transition:      0.2s ease;

  --font-body:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'Fira Code', 'Cascadia Code', monospace;
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ── Top Navigation Bar ──────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  z-index: 999;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
#logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
}
.topbar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: -0.3px;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 7px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
#search-input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-primary);
  width: 220px;
}
#search-input::placeholder { color: var(--text-muted); }
#sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: background var(--transition);
}
#sidebar-toggle:hover { background: var(--bg-base); }

/* ── Search Results Overlay ──────────────────────────────── */
.search-results {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 24px;
  width: 420px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg-content);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 8px 0;
}
.search-results.hidden { display: none; }
.search-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-base); }
.search-item-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.search-item-ctx {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.search-highlight { background: #FEF08A; border-radius: 2px; padding: 0 1px; }

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  transition: transform var(--transition);
  z-index: 100;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

#toc { padding: 20px 0 40px; }
.toc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}
.toc-title { color: var(--text-muted); }
.toc-list { list-style: none; }
.toc-list li a {
  display: block;
  padding: 5px 20px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
  word-break: break-word;
}
.toc-list li a:hover {
  color: var(--brand-primary);
  background: var(--bg-table-head);
  border-left-color: var(--brand-primary);
  text-decoration: none;
}
.toc-list li.active > a {
  color: var(--brand-primary);
  font-weight: 600;
  background: var(--bg-badge);
  border-left-color: var(--brand-primary);
}
.toc-l1 > a { font-weight: 600; color: var(--text-primary); padding-left: 20px; }
.toc-l2 > a { padding-left: 32px; font-size: 0.82rem; }
.toc-l3 > a { padding-left: 46px; font-size: 0.79rem; color: var(--text-muted); }

/* ── Main Content ────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
}
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}
.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breadcrumb span:first-child { color: var(--brand-primary); font-weight: 500; }
.bc-sep { margin: 0 6px; color: var(--text-muted); }
.doc-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-badge {
  display: inline-block;
  background: var(--bg-badge);
  color: var(--brand-primary);
  border: 1px solid #C7D2FE;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ── Article Typography ──────────────────────────────────── */
#doc-body { max-width: var(--content-max); }

#doc-body h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
  border-bottom: 2px solid var(--brand-primary);
  padding-bottom: 0.5rem;
  letter-spacing: -0.4px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
#doc-body h1:first-of-type { margin-top: 0; }

#doc-body h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem;
  padding-top: 0.5rem;
  letter-spacing: -0.3px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
  display: flex;
  align-items: center;
  gap: 8px;
}
#doc-body h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.3em;
  background: var(--brand-gradient);
  border-radius: 2px;
  flex-shrink: 0;
}

#doc-body h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--brand-secondary);
  margin: 1.5rem 0 0.5rem;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}

#doc-body p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.94rem;
}
#doc-body strong { color: var(--text-primary); font-weight: 600; }
#doc-body em { color: var(--brand-secondary); }

#doc-body ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 1rem;
}
#doc-body ul li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}
#doc-body ul li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0.6em;
  width: 6px;
  height: 6px;
  background: var(--brand-primary);
  border-radius: 50%;
}
#doc-body ul ul li::before { background: var(--brand-secondary); width: 5px; height: 5px; }

/* ── Images ──────────────────────────────────────────────── */
.img-wrap {
  margin: 24px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #fff;
  display: inline-block;
  max-width: 100%;
}
.img-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}
.table-wrap th {
  background: var(--bg-table-head);
  color: var(--brand-primary);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid #C7D2FE;
  white-space: nowrap;
}
.table-wrap td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:nth-child(even) td { background: var(--bg-table-alt); }
.table-wrap tr:hover td { background: #EEF2FF; transition: background 0.15s; }
.table-wrap img { max-width: 320px; border-radius: 4px; }

/* ── Doc Footer ──────────────────────────────────────────── */
.doc-footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Back to Top ─────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 42px;
  height: 42px;
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
}
#back-to-top.visible { opacity: 1; transform: translateY(0); }
#back-to-top:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* ── Section highlight animation ────────────────────────── */
@keyframes sectionHighlight {
  0%   { background: #EEF2FF; }
  100% { background: transparent; }
}
.section-flash { animation: sectionHighlight 1.2s ease-out; border-radius: 6px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 260px; }
  #main-content { padding: 32px 32px 60px; }
}
@media (max-width: 768px) {
  #sidebar-toggle { display: flex; }
  #sidebar {
    transform: translateX(-100%);
    z-index: 500;
    box-shadow: var(--shadow-lg);
  }
  #sidebar.open { transform: translateX(0); }
  .layout { display: block; }
  #main-content { margin-left: 0; padding: 24px 20px 60px; }
  .search-results { left: 16px; right: 16px; width: auto; }
  #search-input { width: 140px; }
  .content-header { flex-direction: column; align-items: flex-start; }
}

/* ── Sidebar overlay for mobile ─────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 499;
}
#sidebar-overlay.visible { display: block; }
