/* Quantra Documentation - Main Stylesheet */

:root {
  --primary: #0056b3;
  --primary-dark: #004494;
  --primary-light: #e8eefb;
  --sidebar-bg: #0056b3;
  --sidebar-text: rgba(255,255,255,0.85);
  --sidebar-hover: rgba(255,255,255,0.12);
  --sidebar-active: rgba(255,255,255,0.2);
  --bg: #f4f4f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #475569;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --code-border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --header-height: 64px;
}

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

html { scroll-behavior: smooth; }

/* Keep anchor targets clear of the fixed header bar */
h1[id], h2[id], h3[id], h4[id], h5[id], h6[id], [id]:target {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

/* Highlight the heading the user has clicked through to */
:target {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 6px 12px;
  border-radius: 4px;
}

body {
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header bar */
.header-bar {
  width: 100%;
  background-color: #0056b3;
  color: #fff;
  padding: 0 1rem;
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-bar img {
  height: 48px;
  vertical-align: middle;
  margin-right: 12px;
}

.header-bar .header-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  opacity: 0.9;
}

.header-bar .header-version {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-left: 12px;
}

.docs-wrapper {
  display: flex;
  flex: 1;
  margin-top: var(--header-height);
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-left-color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-section {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  padding: 18px 20px 6px;
}

.sidebar-nav .nav-number {
  display: inline-block;
  width: 22px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}

/* Sidebar sub-navigation (collapsible sections) */
.sidebar-nav .nav-row {
  display: flex;
  align-items: stretch;
}

.sidebar-nav .nav-row > a {
  flex: 1;
  min-width: 0;
}

.sidebar-nav .nav-toggle {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  width: 32px;
  padding: 0 6px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.sidebar-nav .nav-toggle:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.sidebar-nav .nav-toggle .nav-toggle-icon::before {
  content: "\25B6"; /* right-pointing triangle */
  display: inline-block;
  font-size: 0.6rem;
  transition: transform 0.15s ease;
}

.sidebar-nav .nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  transform: rotate(90deg);
}

.sidebar-nav .nav-sub {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  background: rgba(0,0,0,0.12);
}

.sidebar-nav .nav-sub.expanded {
  display: block;
}

.sidebar-nav .nav-sub li {
  margin: 0;
}

.sidebar-nav .nav-sub a {
  padding: 6px 20px 6px 47px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  border-left: 3px solid transparent;
  line-height: 1.4;
}

.sidebar-nav .nav-sub a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-nav .nav-sub a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-left-color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

/* Main content */
.main {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
}

.content {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 48px 120px;
}

/* Top bar (breadcrumb) */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 48px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .breadcrumb {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.topbar .breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

/* Typography */
h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.2;
}

h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 16px;
  color: var(--text);
}

.lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.8;
}

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

/* Lists */
ul, ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

li {
  margin-bottom: 6px;
}

li > ul, li > ol {
  margin-top: 6px;
  margin-bottom: 0;
}

/* Code */
code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 2px 6px;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

th {
  background: var(--code-bg);
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

td {
  padding: 10px 14px;
  border: 1px solid var(--border);
}

tr:nth-child(even) td {
  background: #fafbfc;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Info boxes */
.info-box {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 4px solid;
  font-size: 0.92rem;
}

.info-box.note {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}

.info-box.warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.info-box.tip {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #166534;
}

.info-box.danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

.info-box strong {
  display: block;
  margin-bottom: 4px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Diagrams */
.diagram {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

/* Feature list */
.feature-list {
  list-style: none;
  padding: 0;
}

.feature-list li {
  padding: 8px 0 8px 28px;
  position: relative;
}

.feature-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

/* Steps */
.step {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
  padding-top: 4px;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 24px; }
  .header-bar img { height: 36px; }
}

/* Page header */
.page-header {
  margin-bottom: 40px;
}

.page-header h1 {
  margin-bottom: 8px;
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.2s;
}

.back-to-top.visible {
  opacity: 1;
}

/* Search */
.search-box {
  padding: 8px 12px;
  margin: 0 16px 8px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: #e2e8f0;
  font-size: 0.85rem;
  width: calc(100% - 32px);
  outline: none;
}

.search-box::placeholder {
  color: #64748b;
}

.search-box:focus {
  border-color: var(--sidebar-active);
  background: rgba(255,255,255,0.08);
}

/* Print styles */
@media print {
  .sidebar, .topbar, .back-to-top, .header-bar { display: none; }
  .docs-wrapper { margin-top: 0; }
  .main { margin-left: 0; }
  .content { max-width: 100%; padding: 0; }
  pre { white-space: pre-wrap; }
}
