/* ==========================================================================
   FlowForge Enterprise Product Documentation Portal — Stylesheet
   Matching Reference: docs.rudratic.com / Swot DAM
   ========================================================================== */

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

/* --- CSS Variables & Theme Tokens --- */
:root {
  --font-main: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Primary Accent & Brand */
  --primary: #6927ff;
  --primary-light: #8b5cf6;
  --primary-gradient: linear-gradient(135deg, #6927ff 0%, #a855f7 100%);
  --primary-glow: rgba(105, 39, 255, 0.25);
  
  /* Status Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.25);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);

  /* Dimensions */
  --header-height: 64px;
  --sidebar-left-width: 270px;
  --sidebar-right-width: 220px;
  --content-max-width: 980px;

  /* Transition */
  --theme-transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* --- Dark Theme (Default) --- */
html[data-theme="dark"],
html:not([data-theme="light"]) {
  --bg-page: #07090e;
  --bg-surface: #0d111a;
  --bg-surface-alt: #131926;
  --bg-card: #0f1523;
  --bg-card-hover: #151d30;
  --bg-code: #0a0e17;
  --bg-search: #111726;

  --border-color: #1a2337;
  --border-subtle: #141c2c;
  --border-focus: #6927ff;

  --text-main: #94a3b8;
  --text-heading: #f8fafc;
  --text-muted: #64748b;
  --text-light: #cbd5e1;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);

  --scroll-thumb: #1e293b;
  --scroll-thumb-hover: #334155;
}

/* --- Light Theme --- */
html[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-code: #0f172a;
  --bg-search: #f1f5f9;

  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #6927ff;

  --text-main: #475569;
  --text-heading: #0f172a;
  --text-muted: #64748b;
  --text-light: #334155;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);

  --scroll-thumb: #cbd5e1;
  --scroll-thumb-hover: #94a3b8;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.65;
  transition: var(--theme-transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

/* --- Top Navigation Header --- */
.docs-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--theme-transition);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 6px;
  cursor: pointer;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-heading);
}

.badge-doc {
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 8px var(--primary-glow);
  white-space: nowrap;
}

.badge-version {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Header Center Search */
.header-search {
  flex: 1;
  max-width: 440px;
  margin: 0 16px;
}

.search-trigger-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  background: var(--bg-search);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-trigger-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
  background: var(--bg-card);
}

.search-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd-badge {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  list-style: none;
}

.header-nav-link {
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.header-nav-link:hover {
  color: var(--primary);
}

.btn-demo-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--primary-gradient);
  color: #ffffff !important;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 10px var(--primary-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.btn-demo-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(105, 39, 255, 0.4);
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* --- Main Layout Grid --- */
.docs-layout {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: var(--sidebar-left-width) minmax(0, 1fr) var(--sidebar-right-width);
  gap: 28px;
  flex: 1;
}

/* --- Left Sidebar Navigation --- */
.sidebar-left {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 0 40px;
}

.nav-category {
  margin-bottom: 24px;
}

.nav-category-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 12px;
}

.nav-item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

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

.nav-item-link.active {
  background: var(--primary-gradient);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.nav-link-content {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.nav-link-content svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-tag-live {
  background: var(--info-bg);
  color: var(--info);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.nav-tag-core {
  background: var(--primary-glow);
  color: var(--primary-light);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.nav-item-link.active .nav-tag-live,
.nav-item-link.active .nav-tag-core {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* --- Central Content Column --- */
.content-main {
  min-width: 0;
  max-width: var(--content-max-width);
  padding: 30px 0 80px;
}

/* Breadcrumb */
.doc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.doc-breadcrumb svg {
  color: var(--primary);
}

/* Hero Section */
.doc-hero {
  margin-bottom: 40px;
}

.doc-hero h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-heading);
  line-height: 1.2;
  margin-bottom: 14px;
}

.doc-hero-subtitle {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-main);
  margin-bottom: 24px;
}

/* Quick Action Pills */
.hero-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.hero-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-surface-alt);
  transform: translateY(-1px);
}

.hero-pill.primary {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.hero-pill.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(105, 39, 255, 0.4);
}

/* --- Content Sections --- */
.doc-section {
  padding-top: 36px;
  margin-bottom: 50px;
  border-top: 1px solid var(--border-subtle);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.section-num-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-section h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-heading);
}

.doc-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
  margin: 26px 0 10px;
}

.doc-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  margin: 18px 0 8px;
}

.doc-section p {
  margin-bottom: 14px;
  color: var(--text-main);
  line-height: 1.7;
}

.doc-section ul, .doc-section ol {
  margin: 12px 0 16px 20px;
  color: var(--text-main);
}

.doc-section li {
  margin-bottom: 6px;
  line-height: 1.6;
}

/* --- Callout Alert Boxes --- */
.callout {
  padding: 14px 18px;
  border-radius: 8px;
  margin: 18px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.6;
}

.callout svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.callout.info {
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}
html[data-theme="light"] .callout.info { color: #1e40af; }

.callout.warning {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
}
html[data-theme="light"] .callout.warning { color: #92400e; }

.callout.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #a7f3d0;
}
html[data-theme="light"] .callout.success { color: #065f46; }

/* --- Code Snippet Blocks --- */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin: 18px 0;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
}

.code-lang-label {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.btn-copy-code {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 11px;
  font-family: inherit;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-copy-code:hover {
  color: var(--text-heading);
  border-color: var(--primary);
}

.code-block pre {
  padding: 14px 16px;
  margin: 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #e2e8f0;
}

/* --- Data & Parameter Tables --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
  background: var(--bg-surface);
}

.docs-table th {
  background: var(--bg-surface-alt);
  color: var(--text-heading);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.docs-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: top;
}

.docs-table tr:last-child td {
  border-bottom: none;
}

.docs-table tr:hover td {
  background: var(--bg-card-hover);
}

.param-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary-light);
}

.param-type {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Visual Architecture / Flow Cards --- */
.flow-diagram-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}

.diagram-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ascii-diagram {
  background: var(--bg-code);
  padding: 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.35;
  color: #cbd5e1;
  overflow-x: auto;
}

/* 3-Pillar Cards Grid */
.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card-item:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.card-item-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.card-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.card-item-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* --- Right Sidebar (On This Page Scrollspy) --- */
.sidebar-right {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 30px 0 40px;
}

.toc-wrap {
  border-left: 1px solid var(--border-color);
  padding-left: 14px;
}

.toc-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toc-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.4;
  display: block;
  transition: color 0.15s ease, transform 0.15s ease;
}

.toc-link:hover {
  color: var(--text-heading);
  transform: translateX(2px);
}

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

.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.back-to-top:hover {
  color: var(--primary);
}

/* --- Global Search Modal (Ctrl + K) --- */
.search-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 20px;
}

.search-modal-overlay.open {
  display: flex;
}

.search-modal-card {
  width: 100%;
  max-width: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.search-modal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-heading);
  font-family: inherit;
}

.search-modal-close-btn {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 7px;
  color: var(--text-muted);
  cursor: pointer;
}

.search-modal-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 10px 8px;
  list-style: none;
}

.search-result-item {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

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

.result-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-heading);
}

.result-item-category {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

.result-item-snippet {
  font-size: 12px;
  color: var(--text-muted);
}

.search-modal-footer {
  padding: 8px 16px;
  background: var(--bg-surface-alt);
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* --- Toast Notification --- */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  pointer-events: none;
}
.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
  .docs-layout {
    grid-template-columns: var(--sidebar-left-width) minmax(0, 1fr);
  }
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 860px) {
  .menu-toggle-btn {
    display: block;
  }
  .header-nav-links {
    display: none;
  }
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar-left {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    width: 280px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 90;
    transition: left 0.3s ease;
    padding: 20px;
  }
  .sidebar-left.open {
    left: 0;
  }
  .cards-grid-3 {
    grid-template-columns: 1fr;
  }
  .doc-hero h1 {
    font-size: 28px;
  }
}
