/* ================================================================
   ShaDey Inc. Documentation Pages — Confluence-like Styling
   ================================================================ */

/* ---------- PAGE LAYOUT ---------- */
.doc-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

@media (max-width: 768px) {
  .doc-page { padding: 24px 16px 60px; }
  .doc-title { font-size: 1.5rem; }
  .doc-subtitle { font-size: 0.875rem; }
  .doc-toc { padding: 14px 16px; }
  .doc-h2 { font-size: 1.25rem; }
  .entity-card-header { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .entity-card-name { font-size: 0.8rem; }
  .transform-block { font-size: 0.625rem; }
}

@media (max-width: 480px) {
  .doc-page { padding: 16px 12px 48px; }
  .doc-title { font-size: 1.25rem; }
  .doc-subtitle { font-size: 0.8125rem; }
  .doc-header { margin-bottom: 28px; padding-bottom: 24px; }
  .doc-breadcrumb { font-size: 0.625rem; }
  .doc-meta { gap: 10px; font-size: 0.6875rem; }
  .doc-toc { padding: 12px; }
  .doc-toc-list li { font-size: 0.75rem; }
  .doc-h2 { font-size: 1.125rem; }
  .doc-h3 { font-size: 1rem; }
  .doc-section-desc { font-size: 0.8125rem; }
  .doc-callout { padding: 10px 14px; font-size: 0.75rem; }
  .doc-table th { font-size: 0.5625rem; padding: 8px 10px; }
  .doc-table td { padding: 6px 10px; font-size: 0.75rem; }
  .doc-table code { font-size: 0.6875rem; }
  .entity-card-header { padding: 8px 12px; }
  .entity-card-name { font-size: 0.75rem; }
  .entity-card-purpose { font-size: 0.75rem; padding: 10px 12px; }
  .doc-stat-value { font-size: 1.25rem; }
  .transform-block { font-size: 0.5625rem; padding: 8px 10px; }
  .doc-related-grid { grid-template-columns: 1fr; }
  .doc-related-link { padding: 10px 14px; }
  [id] { scroll-margin-top: 80px; }
}

/* ---------- PAGE HEADER ---------- */
.doc-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.doc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted, #747878);
  margin-bottom: 16px;
}

.doc-breadcrumb a {
  color: var(--color-secondary, #735a3a);
  text-decoration: none;
}

.doc-breadcrumb a:hover {
  text-decoration: underline;
}

.doc-breadcrumb .sep {
  color: var(--color-border, #c4c7c7);
}

.doc-title {
  font-family: var(--font-headline, 'Noto Serif', Georgia, serif);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 8px;
}

.doc-subtitle {
  font-size: 1rem;
  color: var(--color-text-secondary, #444748);
  line-height: 1.6;
  max-width: 720px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--color-text-muted, #747878);
}

.doc-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-meta-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.625rem;
}

/* ---------- TABLE OF CONTENTS ---------- */
.doc-toc {
  background: var(--color-surface-container-low, #f3f3f3);
  border: 1px solid var(--color-border, #e2e8f0);
  padding: 20px 24px;
  margin-bottom: 40px;
}

.doc-toc-title {
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #747878);
  margin-bottom: 12px;
}

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

.doc-toc-list li {
  font-size: 0.8125rem;
  line-height: 1.4;
}

.doc-toc-list a {
  color: var(--color-secondary, #735a3a);
  text-decoration: none;
  font-weight: 500;
}

.doc-toc-list a:hover {
  text-decoration: underline;
}

.doc-toc-list .toc-l2 {
  padding-left: 16px;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #444748);
}

/* ---------- SECTION HEADINGS ---------- */
.doc-section {
  margin-bottom: 48px;
}

.doc-section:last-child {
  margin-bottom: 0;
}

.doc-h2 {
  font-family: var(--font-headline, 'Noto Serif', Georgia, serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 8px;
  padding-top: 8px;
}

.doc-h3 {
  font-family: var(--font-headline, 'Noto Serif', Georgia, serif);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 6px;
  margin-top: 32px;
}

.doc-h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 4px;
  margin-top: 24px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.doc-section-desc {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #444748);
  line-height: 1.65;
  margin-bottom: 20px;
  max-width: 720px;
}

/* ---------- CALLOUT BOXES ---------- */
.doc-callout {
  border-left: 3px solid var(--color-secondary, #735a3a);
  background: var(--color-surface-container-low, #f3f3f3);
  padding: 14px 18px;
  margin: 16px 0 24px;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text-secondary, #444748);
}

.doc-callout-title {
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 4px;
}

.doc-callout.info {
  border-left-color: #3b82f6;
}

.doc-callout.warning {
  border-left-color: #f59e0b;
  background: #fefce8;
}

.doc-callout.s4-note {
  border-left-color: #14b8a6;
  background: #f0fdfa;
}

.doc-callout.assumption {
  border-left-color: #8b5cf6;
  background: #f5f3ff;
}

/* ---------- DATA TABLES ---------- */
.doc-table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--color-border, #e2e8f0);
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.doc-table th {
  background: var(--color-surface-container, #eaeaea);
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted, #747878);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--color-border, #e2e8f0);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.doc-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  vertical-align: top;
  line-height: 1.5;
  color: var(--color-text-secondary, #444748);
}

.doc-table tbody tr:hover td {
  background: var(--color-surface-container-lowest, #f9f9f9);
}

.doc-table code {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-surface-container-low, #f3f3f3);
  padding: 1px 5px;
  color: var(--color-text, #1a1c1c);
}

.doc-table .section-row td {
  background: var(--color-surface-container, #eaeaea);
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--color-text, #1a1c1c);
  padding: 10px 14px;
  letter-spacing: -0.01em;
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-master { background: #dbeafe; color: #1e40af; }
.badge-txn { background: #fce7f3; color: #9d174d; }
.badge-ref { background: #f1f5f9; color: #475569; }
.badge-plan { background: #ede9fe; color: #5b21b6; }
.badge-inv { background: #fef3c7; color: #92400e; }
.badge-quality { background: #d1fae5; color: #065f46; }
.badge-analytics { background: #ccfbf1; color: #115e59; }
.badge-finance { background: #fee2e2; color: #991b1b; }
.badge-service { background: #e0e7ff; color: #3730a3; }
.badge-logistics { background: #ffedd5; color: #9a3412; }
.badge-sales { background: #ecfdf5; color: #166534; }
.badge-procurement { background: #fef9c3; color: #854d0e; }
.badge-production { background: #ffe4e6; color: #be123c; }
.badge-plm { background: #f3e8ff; color: #7c3aed; }

.badge-explicit { background: #d1fae5; color: #065f46; }
.badge-inferred { background: #fef3c7; color: #92400e; }

.badge-core { background: #dbeafe; color: #1e40af; }
.badge-dp { background: #d1fae5; color: #065f46; }
.badge-ml { background: #ede9fe; color: #5b21b6; }
.badge-dim { background: #f1f5f9; color: #475569; }
.badge-fact { background: #fce7f3; color: #9d174d; }

/* ---------- KEY FIELD INDICATORS ---------- */
.key-pk {
  font-size: 0.5rem;
  font-weight: 900;
  color: #ef4444;
  margin-right: 2px;
}

.key-fk {
  font-size: 0.5rem;
  font-weight: 900;
  color: #8b5cf6;
  margin-right: 2px;
}

/* ---------- ENTITY HEADER CARD ---------- */
.entity-card {
  border: 1px solid var(--color-border, #e2e8f0);
  margin: 24px 0;
}

.entity-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--color-surface-container, #eaeaea);
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.entity-card-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text, #1a1c1c);
}

.entity-card-purpose {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #444748);
  padding: 12px 18px;
  line-height: 1.6;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.entity-card-body {
  padding: 0;
}

/* ---------- RELATED PAGES NAV ---------- */
.doc-related {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.doc-related-title {
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #747878);
  margin-bottom: 12px;
}

.doc-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.doc-related-link {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--color-border, #e2e8f0);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.doc-related-link:hover {
  border-color: var(--color-secondary, #735a3a);
  background: var(--color-surface-container-lowest, #f9f9f9);
}

.doc-related-link-title {
  font-family: var(--font-headline, 'Noto Serif', Georgia, serif);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text, #1a1c1c);
  margin-bottom: 2px;
}

.doc-related-link-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted, #747878);
}

/* ---------- CONFIDENCE INDICATOR ---------- */
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.confidence-explicit {
  color: #059669;
}

.confidence-explicit::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #059669;
  display: inline-block;
}

.confidence-inferred {
  color: #d97706;
}

.confidence-inferred::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #d97706;
  display: inline-block;
}

/* ---------- STATS ROW ---------- */
.doc-stats {
  display: flex;
  gap: 24px;
  margin: 20px 0;
  flex-wrap: wrap;
}

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

.doc-stat-value {
  font-family: var(--font-headline, 'Noto Serif', Georgia, serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text, #1a1c1c);
  line-height: 1;
}

.doc-stat-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted, #747878);
  margin-top: 2px;
}

/* ---------- TRANSFORM BLOCK ---------- */
.transform-block {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  line-height: 1.6;
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 14px;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid #334155;
}

/* ---------- DOC FOOTER ---------- */
.doc-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border, #e2e8f0);
  font-size: 0.75rem;
  color: var(--color-text-muted, #747878);
  line-height: 1.6;
}

/* ---------- ANCHOR OFFSET ---------- */
[id] {
  scroll-margin-top: 100px;
}

/* ---------- PRINT ---------- */
@media print {
  .doc-page { max-width: 100%; padding: 20px; }
  .doc-toc { break-inside: avoid; }
  .doc-table-wrap { overflow: visible; }
  .doc-related { display: none; }
  .entity-card { break-inside: avoid; }
}
