/* docs-viewer.css — Google Docs-style sidebar document viewer */
/* Reusable: include in any HTML guide with docs-viewer.js */
/* Uses the standard app CSS framework variables (Tailwind Slate dark theme) */

:root {
  /* === Standard App Framework Variables === */
  --bg-body:        #0f172a;   /* Page background (slate-900) */
  --bg-card:        #1e293b;   /* Cards, panels, nav (slate-800) */
  --bg-input:       #0f172a;   /* Input fields */
  --border-default: #1e293b;   /* Default borders */
  --border-card:    #334155;   /* Card borders (slate-700) */
  --border-input:   #334155;   /* Input borders */
  --text-bright:    #f8fafc;   /* Brightest white (slate-50) */
  --text-heading:   #f1f5f9;   /* Headings (slate-100) */
  --text-primary:   #e2e8f0;   /* Body text (slate-200) */
  --text-secondary: #94a3b8;   /* Secondary/muted (slate-400) */
  --text-muted:     #64748b;   /* Labels, metadata (slate-500) */
  --text-dim:       #475569;   /* Disabled, faint (slate-600) */
  --accent-blue:      #60a5fa; /* Primary accent (blue-400) */
  --accent-blue-dark: #3b82f6; /* Links, borders (blue-500) */
  --accent-indigo:    #6366f1; /* Buttons, active states */
  --color-success:    #4ade80; /* Green */
  --color-warning:    #fbbf24; /* Amber */
  --color-danger:     #f87171; /* Red */
  --color-info:       #38bdf8; /* Sky */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* === Docs Viewer Tokens (derived from framework) === */
  --dv-sidebar-width: 280px;
  --dv-content-max: 900px;
  --dv-highlight: #fde047;
}

body {
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
}

/* Layout */
.dv-wrapper {
  min-height: calc(100vh - 76px);
  background: var(--bg-body);
}

/* Sidebar */
.dv-sidebar {
  position: fixed;
  top: 76px;
  left: 0;
  width: var(--dv-sidebar-width);
  height: calc(100vh - 76px);
  background: var(--bg-card);
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  z-index: 100;
  font-family: var(--font-sans);
}

.dv-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-card);
  flex-shrink: 0;
}

.dv-sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search */
.dv-search-wrap {
  position: relative;
}

.dv-search {
  width: 100%;
  padding: 8px 32px 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}

.dv-search:focus {
  border-color: var(--accent-blue-dark);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

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

.dv-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  display: none;
}

.dv-search-clear:hover {
  color: var(--text-primary);
}

.dv-search-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  min-height: 16px;
}

.dv-search-kbd {
  font-size: 10px;
  color: var(--text-muted);
  float: right;
  background: var(--border-card);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
}

/* Nav list */
.dv-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.dv-nav::-webkit-scrollbar {
  width: 4px;
}

.dv-nav::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 2px;
}

/* Nav items */
.dv-nav-item {
  display: block;
  padding: 6px 16px 6px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.dv-nav-item:hover {
  background: var(--border-card);
  color: var(--text-primary);
}

.dv-nav-item.dv-active {
  color: var(--text-primary);
  font-weight: 600;
  border-left-color: var(--accent-blue-dark);
  background: rgba(59, 130, 246, 0.1);
}

/* H3 items — indented */
.dv-nav-item[data-level="3"] {
  padding-left: 28px;
  font-size: 12px;
}

/* H3 items hidden by default, shown when parent is active or expanded */
.dv-nav-group .dv-nav-item[data-level="3"] {
  display: none;
}

.dv-nav-group.dv-expanded .dv-nav-item[data-level="3"],
.dv-nav-group.dv-search-match .dv-nav-item[data-level="3"] {
  display: block;
}

/* Expand arrow on H2 items that have children */
.dv-nav-item.dv-has-children::before {
  content: '\25B8';
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  transition: transform 0.15s ease;
}

.dv-expanded > .dv-nav-item.dv-has-children::before {
  transform: rotate(90deg);
}

/* Search match count badge */
.dv-match-count {
  float: right;
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* Content area */
.dv-content {
  margin-left: var(--dv-sidebar-width);
  padding-top: 76px;
  padding: 32px 48px;
  max-width: calc(var(--dv-content-max) + var(--dv-sidebar-width) + 96px);
  min-height: calc(100vh - 76px);
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

/* === Document Content Styles (dark theme) === */

#doc-content {
  font-size: 14px;
  line-height: 1.7;
}

#doc-content h1 {
  font-size: 28px;
  color: var(--text-bright);
  border-bottom: 2px solid var(--accent-blue-dark);
  padding-bottom: 12px;
  margin-top: 0;
  line-height: 1.3;
}

#doc-content h2 {
  font-size: 20px;
  color: var(--accent-blue);
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 8px;
  margin-top: 40px;
}

#doc-content h3 {
  font-size: 16px;
  color: var(--color-info);
  margin-top: 28px;
}

#doc-content h4 {
  font-size: 14px;
  color: var(--text-heading);
  font-weight: bold;
  margin-top: 16px;
}

#doc-content p {
  margin: 8px 0 14px 0;
}

#doc-content ul, #doc-content ol {
  margin: 8px 0 14px 0;
  padding-left: 24px;
}

#doc-content li {
  margin-bottom: 6px;
}

#doc-content a {
  color: var(--accent-blue);
  text-decoration: none;
}

#doc-content a:hover {
  text-decoration: underline;
  color: var(--text-bright);
}

/* Tables — wrap for mobile scroll */
#doc-content .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
}

#doc-content table {
  border-collapse: collapse;
  width: 100%;
  min-width: 400px;
  margin: 16px 0;
  font-size: 13px;
}

#doc-content th {
  background: var(--accent-blue-dark);
  color: var(--text-bright);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
}

#doc-content td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-card);
  vertical-align: top;
  color: var(--text-primary);
}

#doc-content tr:nth-child(even) td {
  background: rgba(30, 41, 59, 0.5);
}

#doc-content tr:hover td {
  background: rgba(59, 130, 246, 0.08);
}

/* Info/tip/warn boxes */
#doc-content .tip-box {
  background: rgba(74, 222, 128, 0.08);
  border-left: 4px solid var(--color-success);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  color: var(--text-primary);
}

#doc-content .tip-box strong {
  color: var(--color-success);
}

#doc-content .warn-box {
  background: rgba(251, 191, 36, 0.08);
  border-left: 4px solid var(--color-warning);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  color: var(--text-primary);
}

#doc-content .warn-box strong {
  color: var(--color-warning);
}

#doc-content .info-box {
  background: rgba(56, 189, 248, 0.08);
  border-left: 4px solid var(--color-info);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 6px 6px 0;
  color: var(--text-primary);
}

#doc-content .info-box strong {
  color: var(--color-info);
}

/* Step numbers */
#doc-content .step {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}

#doc-content .step-num {
  background: var(--accent-blue-dark);
  color: var(--text-bright);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
  font-size: 13px;
}

#doc-content .step-body {
  flex: 1;
}

/* Screenshots */
#doc-content .page-screenshot {
  border: 1px solid var(--border-card);
  border-radius: 6px;
  max-width: 100%;
  margin: 16px 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* Badges */
#doc-content .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
}

#doc-content .badge-green {
  background: rgba(74, 222, 128, 0.15);
  color: var(--color-success);
}

#doc-content .badge-blue {
  background: rgba(96, 165, 250, 0.15);
  color: var(--accent-blue);
}

#doc-content .badge-orange {
  background: rgba(251, 191, 36, 0.15);
  color: var(--color-warning);
}

#doc-content .badge-purple {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

/* Nav bar mockup in docs */
#doc-content .nav-bar {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  border: 1px solid var(--border-card);
}

#doc-content .nav-bar a {
  color: var(--accent-blue);
  margin-right: 14px;
  text-decoration: none;
}

/* Horizontal rules */
#doc-content hr {
  border: none;
  border-top: 1px solid var(--border-card);
  margin: 32px 0;
}

/* Code */
#doc-content code {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-card);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--color-info);
}

/* Model cards */
#doc-content .model-card {
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 8px 0;
  background: var(--bg-card);
}

#doc-content .model-card h4 {
  margin: 0 0 6px 0;
}

/* Document highlight from search */
.dv-highlight {
  background: var(--dv-highlight);
  color: #000;
  padding: 1px 2px;
  border-radius: 2px;
}

/* Mobile hamburger */
.dv-hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

/* Responsive */
@media (max-width: 900px) {
  .dv-wrapper {
    grid-template-columns: 1fr;
  }

  .dv-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

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

  .dv-content {
    margin-left: 0;
    padding: 24px 16px;
    padding-top: 60px;
  }

  .dv-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Overlay when sidebar open */
  .dv-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 50;
  }

  .dv-sidebar.dv-open ~ .dv-overlay {
    display: block;
  }
}

/* Print */
@media print {
  .dv-sidebar,
  .dv-hamburger,
  .dv-overlay {
    display: none !important;
  }

  .dv-content {
    margin-left: 0 !important;
    max-width: 100% !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  #doc-content h1,
  #doc-content h2,
  #doc-content h3,
  #doc-content h4 {
    color: #000 !important;
  }

  #doc-content td,
  #doc-content th {
    color: #000 !important;
    border: 1px solid #ccc !important;
  }

  .dv-wrapper {
    display: block;
  }
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
  background: var(--bg-body);
}
