/* Fold Schema Documentation - Stripe-inspired Design */

:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f6f9fc;
  --color-bg-tertiary: #e3e8ee;
  --color-text: #1a1a1a;
  --color-text-secondary: #5e6977;
  --color-text-muted: #8898aa;
  --color-border: #e3e8ee;
  --color-border-light: #f0f3f7;
  --color-primary: #635bff;
  --color-primary-light: #7a73ff;
  --color-success: #24b47e;
  --color-warning: #f5a623;
  --color-danger: #e25950;
  
  --sidebar-width: 260px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 0;
}

.sidebar-header {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.logo-link {
  text-decoration: none;
  color: inherit;
}

.subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
}

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

.nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.nav-link {
  display: block;
  padding: 8px 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  flex: 1;
}

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

.nav-link.active {
  color: var(--color-primary);
  background: rgba(99, 91, 255, 0.1);
  font-weight: 500;
}

.nav-count {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 10px;
  margin-right: 12px;
}

.nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 12px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  padding: 8px 12px;
}

/* Main Content */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px 48px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 8px;
}

.page-desc {
  font-size: 16px;
  color: var(--color-text-secondary);
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 48px;
  padding: 24px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 32px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--color-primary);
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search */
.search-section {
  margin-bottom: 32px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  transition: all 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

/* Global Search Results */
.global-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}

.global-search-results.visible {
  display: block;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: inherit;
}

.search-result-item:hover {
  background: var(--color-bg-secondary);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-model {
  font-weight: 600;
  color: var(--color-text);
}

.search-result-category {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: 8px;
}

.search-result-field {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Categories Grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.category-card {
  display: block;
  padding: 20px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

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

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.category-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.model-count {
  font-size: 12px;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.category-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.category-models {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* Diagram Section */
.diagram-section {
  margin-top: 48px;
}

.diagram-section h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.diagram {
  background: var(--color-bg-secondary);
  padding: 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
  color: var(--color-text-secondary);
}

/* Mermaid Diagram */
.mermaid-section {
  margin: 32px 0;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.mermaid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  cursor: pointer;
  user-select: none;
}

.mermaid-header:hover {
  background: var(--color-bg);
}

.mermaid-header h3 {
  font-size: 16px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mermaid-toggle {
  font-size: 18px;
  font-weight: 300;
  color: var(--color-text-muted);
  width: 20px;
  text-align: center;
}

.mermaid-content {
  display: none;
  border-top: 1px solid var(--color-border);
}

.mermaid-section.expanded .mermaid-content {
  display: block;
}

.mermaid-hint {
  display: flex;
  gap: 24px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 12px;
  color: var(--color-text-muted);
}

.mermaid-hint span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mermaid-hint span::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--color-border);
  border-radius: 50%;
}

.mermaid-hint .zoom-level {
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.mermaid-hint .zoom-level::before {
  display: none;
}

.fullscreen-btn {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-left: 12px;
}

.fullscreen-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.mermaid-section.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  margin: 0;
  border-radius: 0;
  background: white;
}

.mermaid-section.fullscreen .mermaid-content {
  height: calc(100vh - 60px);
}

.mermaid-section.fullscreen .mermaid-container {
  height: calc(100vh - 110px);
}

.mermaid-container {
  overflow: hidden;
  padding: 24px;
  height: 500px;
  position: relative;
  background: 
    linear-gradient(90deg, var(--color-border-light) 1px, transparent 1px),
    linear-gradient(var(--color-border-light) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
}

.mermaid {
  transform-origin: 0 0;
  position: absolute;
  top: 0;
  left: 0;
}

/* TOC */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.toc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 8px;
}

.toc-item {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 4px 10px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.toc-item:hover {
  background: var(--color-primary);
  color: white;
}

/* Model Card */
.model-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 32px;
  overflow: hidden;
}

.model-card.hidden {
  display: none;
}

.model-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.model-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.model-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.meta-item {
  margin-right: 16px;
}

.meta-item code {
  font-family: var(--font-mono);
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Fields Table */
.fields-table {
  width: 100%;
  border-collapse: collapse;
}

.fields-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.fields-table td {
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: top;
}

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

.field-row:hover {
  background: var(--color-bg-secondary);
}

.field-row.hidden {
  display: none;
}

.field-name code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text);
}

.field-type {
  white-space: nowrap;
}

/* Type Badges */
.type-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.type-string {
  background: #e3f2fd;
  color: #1565c0;
}

.type-number {
  background: #e8f5e9;
  color: #2e7d32;
}

.type-datetime {
  background: #fff3e0;
  color: #ef6c00;
}

.type-boolean {
  background: #fce4ec;
  color: #c2185b;
}

.type-relation {
  background: #f3e5f5;
  color: #7b1fa2;
}

.type-m2m {
  background: #ede7f6;
  color: #512da8;
}

.type-uuid {
  background: #e0f7fa;
  color: #00838f;
}

.type-json {
  background: #fff8e1;
  color: #ff8f00;
}

.type-file {
  background: #efebe9;
  color: #5d4037;
}

.type-other {
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}

/* Constraints */
.field-constraints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.constraint {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Choices */
.choices-toggle {
  font-size: 11px;
  color: var(--color-primary);
  cursor: pointer;
  margin-left: 8px;
  text-decoration: underline;
}

.choices-list {
  display: none;
  margin-top: 8px;
  padding: 12px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.choices-list.visible {
  display: block;
}

.choice-item {
  display: flex;
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.choice-db-value {
  color: var(--color-primary);
  font-weight: 600;
  min-width: 60px;
}

.choice-value {
  color: var(--color-text);
  min-width: 150px;
}

.choice-label {
  color: var(--color-text-secondary);
}

/* Relationships */
.relationships {
  padding: 16px 24px;
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
}

.relationships h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.relationship {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 24px;
  margin-bottom: 8px;
  font-size: 13px;
}

.relationship code {
  font-family: var(--font-mono);
  color: var(--color-text);
}

.rel-arrow {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-weight: 600;
}

.rel-target {
  color: var(--color-primary);
  font-weight: 500;
}

/* Reverse Relationships */
.reverse-relationships {
  padding: 16px 24px;
  background: #fafbfc;
  border-top: 1px solid var(--color-border);
}

.reverse-relationships h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.reverse-rel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 24px;
  margin-bottom: 8px;
  font-size: 13px;
}

/* Sample Queries */
.sample-queries {
  padding: 16px 24px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.sample-queries h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  cursor: pointer;
}

.sample-queries h4:hover {
  color: var(--color-primary);
}

.queries-content {
  display: none;
}

.queries-content.visible {
  display: block;
}

.query-item {
  margin-bottom: 16px;
}

.query-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.query-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.query-tab {
  font-size: 11px;
  padding: 4px 12px;
  background: var(--color-bg-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-secondary);
}

.query-tab.active {
  background: var(--color-primary);
  color: white;
}

.query-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-bg-secondary);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}

/* Migration History */
.migration-history {
  padding: 16px 24px;
  background: #fffbf0;
  border-top: 1px solid var(--color-border);
}

.migration-history h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  cursor: pointer;
}

.migration-history h4:hover {
  color: var(--color-primary);
}

.migrations-content {
  display: none;
}

.migrations-content.visible {
  display: block;
}

.migration-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13px;
}

.migration-item:last-child {
  border-bottom: none;
}

.migration-number {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  min-width: 50px;
}

.migration-op {
  font-weight: 500;
  color: var(--color-text);
}

.migration-date {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-left: auto;
}

/* Model links in type badges and relationships */
.model-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  transition: all 0.15s ease;
}

.model-link:hover {
  color: var(--color-primary);
  border-bottom-style: solid;
}

.type-badge .model-link {
  color: inherit;
}

.type-badge .model-link:hover {
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  
  .content {
    margin-left: 0;
    padding: 24px;
  }
  
  .categories-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-bar {
    flex-wrap: wrap;
    gap: 24px;
  }
}

/* Print */
@media print {
  .sidebar, .search-section, .toc {
    display: none;
  }
  
  .content {
    margin-left: 0;
  }
  
  .model-card {
    break-inside: avoid;
  }
}
