/* ==========================================================================
   Shrelix ERP Documentation Portal - Core Stylesheet
   Designed with Stripe / Linear / Vercel modern enterprise design language.
   Supports native Light & Dark modes, CSS variables, and fluid typography.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Color Palette - Light Mode */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  
  --border-light: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-tertiary: #94a3b8;

  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.08);
  --primary-border: rgba(59, 130, 246, 0.2);

  --accent-color: #6366f1;
  --success-color: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning-color: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --danger-color: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);

  --sidebar-width: 290px;
  --toc-width: 240px;
  --header-height: 64px;
  --content-max-width: 860px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-surface: #131d33;
  --bg-elevated: #1e293b;
  --bg-hover: #1e293b;
  --bg-active: #334155;

  --border-light: #1e293b;
  --border-color: #334155;
  --border-focus: #60a5fa;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-tertiary: #64748b;

  --primary-color: #38bdf8;
  --primary-hover: #60a5fa;
  --primary-light: rgba(56, 189, 248, 0.12);
  --primary-border: rgba(56, 189, 248, 0.25);

  --success-bg: rgba(16, 185, 129, 0.15);
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger-bg: rgba(239, 68, 68, 0.15);
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.docs-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  transition: background-color 0.2s, border-color 0.2s;
}

[data-theme="dark"] .docs-header {
  background: rgba(9, 13, 22, 0.85);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-logo-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid var(--primary-border);
}

/* Global Search Trigger Bar */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  width: 340px;
  transition: all 0.2s ease;
}

.search-trigger:hover {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.search-trigger kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-tertiary);
}

/* Header Navigation & Tools */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.header-nav-link:hover, .header-nav-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.mobile-menu-btn {
  display: none;
}

/* Layout Wrapper */
.docs-layout {
  display: flex;
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* Left Sidebar */
.docs-sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
}

.sidebar-search {
  position: relative;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.sidebar-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 16px;
  height: 16px;
}

/* Navigation Groups */
.nav-group {
  margin-bottom: 1.25rem;
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.nav-group-title:hover {
  color: var(--text-primary);
}

.nav-group-title i.chevron {
  transition: transform 0.2s ease;
  width: 14px;
  height: 14px;
}

.nav-group.collapsed .nav-group-title i.chevron {
  transform: rotate(-90deg);
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav-group-items {
  list-style: none;
  margin-top: 4px;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

.nav-item-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
  border-left-color: var(--primary-color);
  font-weight: 600;
}

.subgroup {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
  margin-top: 4px;
}

.subgroup-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main Content Viewport */
.docs-main {
  flex: 1;
  min-width: 0;
  padding: 3rem 4rem;
  display: flex;
  flex-direction: column;
}

.content-container {
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumbs a:hover {
  color: var(--primary-color);
}

.breadcrumbs span.current {
  color: var(--text-primary);
  font-weight: 500;
}

/* Article Typography */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-category-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-color);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.article-title {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.article-description {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* Markdown Rendered Content */
.markdown-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 80px;
}

.markdown-body h2 {
  font-size: 1.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.markdown-body h3 {
  font-size: 1.3rem;
}

.markdown-body p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
  color: var(--text-secondary);
}

.markdown-body li {
  margin-bottom: 0.4rem;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 3rem 0;
}

/* Inline Code & Code Blocks */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-hover);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #0d1117;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  color: #8b949e;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.copy-code-btn {
  background: transparent;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.copy-code-btn:hover {
  background: #21262d;
  color: #ffffff;
}

.markdown-body pre {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: #c9d1d9;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: inherit;
}

/* Data Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
}

.markdown-body td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: var(--bg-hover);
}

/* Callouts / Alerts (GitHub Markdown Style) */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  border-left: 4px solid;
  font-size: 0.95rem;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
}

.callout-note {
  border-left-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--text-primary);
}

.callout-tip {
  border-left-color: var(--success-color);
  background: var(--success-bg);
  color: var(--text-primary);
}

.callout-important {
  border-left-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.callout-warning {
  border-left-color: var(--warning-color);
  background: var(--warning-bg);
  color: var(--text-primary);
}

/* Right Sidebar Table of Contents */
.docs-toc {
  width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  padding: 2.5rem 1rem;
  flex-shrink: 0;
}

.toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
  font-size: 0.85rem;
}

.toc-item {
  margin-bottom: 8px;
}

.toc-item.level-3 {
  margin-left: 14px;
}

.toc-link {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.toc-link:hover, .toc-link.active {
  color: var(--primary-color);
  font-weight: 600;
}

/* Previous / Next Article Navigation Cards */
.article-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.article-nav-card {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  text-decoration: none;
  background: var(--bg-surface);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.article-nav-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.nav-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.nav-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Homepage Hero & Cards */
.home-hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--primary-border);
  margin-bottom: 1.25rem;
}

.home-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.home-title span {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.home-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}

.home-search-box {
  max-width: 600px;
  margin: 0 auto;
}

.home-categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 3rem 0;
}

.category-card {
  padding: 1.75rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  text-decoration: none;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.category-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
}

.category-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.category-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.category-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Search Modal */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-modal-backdrop.active {
  display: flex;
}

.search-modal {
  width: 100%;
  max-width: 640px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.search-modal-input-wrap {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.search-modal-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 1.15rem;
  color: var(--text-primary);
  outline: none;
}

.search-modal-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  display: block;
  transition: all 0.15s ease;
  cursor: pointer;
}

.search-result-item:hover, .search-result-item.selected {
  background: var(--bg-hover);
}

.search-result-item.selected .result-title {
  color: var(--primary-color);
}

.result-category {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.result-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.result-excerpt {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.highlight-match {
  background: rgba(254, 240, 138, 0.5);
  color: #854d0e;
  padding: 1px 3px;
  border-radius: 2px;
}

[data-theme="dark"] .highlight-match {
  background: rgba(234, 179, 8, 0.3);
  color: #fef08a;
}

.search-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Responsive Behavior */
@media (max-width: 1200px) {
  .docs-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .search-trigger {
    width: 200px;
  }
  .header-nav-link {
    display: none;
  }
}

@media (max-width: 768px) {
  .docs-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease-in-out;
    box-shadow: var(--shadow-xl);
  }

  .docs-sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .docs-main {
    padding: 1.5rem 1rem;
  }

  .search-trigger span {
    display: none;
  }

  .search-trigger {
    width: auto;
    padding: 8px;
  }

  .home-title {
    font-size: 2.2rem;
  }

  .article-title {
    font-size: 1.8rem;
  }

  .article-nav-grid {
    grid-template-columns: 1fr;
  }
}
