/* === Documentation: sidebar groups, content viewer, code typography === */

.docs-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 70vh;
}

/* --- Sidebar --- */

.docs-sidebar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  align-self: start;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.docs-sidebar h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.docs-sidebar select {
  margin-bottom: 10px;
}

/* Секции сайдбара */
.docs-section {
  margin-bottom: 20px;
}

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

.docs-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 8px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

/* Группы-аккордеоны */
.docs-group {
  margin-bottom: 2px;
}

.docs-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
  transition: background 0.15s;
}

.docs-group-header:hover {
  background: var(--accent-light);
}

.docs-group-chevron {
  display: inline-flex;
  transition: transform 0.2s;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.docs-group-chevron.open {
  transform: rotate(90deg);
}

.docs-group-icon {
  display: inline-flex;
  color: var(--accent);
  flex-shrink: 0;
}

.docs-group-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-group-count {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.docs-group-items {
  padding-left: 12px;
}

/* Ссылки на файлы */
.docs-file-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docs-file-link:hover {
  background: var(--accent-light);
  color: var(--text);
}

.docs-file-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.docs-file-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.docs-file-link.active .docs-file-icon {
  color: var(--accent);
}

.docs-file-nested {
  padding-left: 16px;
}

.docs-product-dir {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 8px;
}

.docs-product-dir:first-child {
  margin-top: 0;
}

.docs-empty {
  color: var(--text-tertiary);
  font-size: 0.82rem;
  padding: 8px 0;
}

/* --- Content viewer --- */

.docs-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 44px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  min-height: 400px;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
}

.docs-placeholder {
  color: var(--text-tertiary);
  text-align: center;
  padding: 80px 0;
  font-size: 0.95rem;
}

/* --- Markdown typography --- */

.docs-content h1 {
  font-size: 1.5rem;
  margin: 0 0 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.docs-content h2 {
  font-size: 1.15rem;
  margin: 32px 0 14px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
  line-height: 1.4;
}

.docs-content h3 {
  font-size: 1rem;
  margin: 24px 0 10px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
}

.docs-content h4 {
  font-size: 0.9rem;
  margin: 20px 0 8px;
  font-weight: 600;
  color: var(--text-secondary);
}

.docs-content p {
  margin-bottom: 14px;
}

.docs-content ul,
.docs-content ol {
  margin: 8px 0 14px 20px;
}

.docs-content li {
  margin-bottom: 5px;
  line-height: 1.65;
}

.docs-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.docs-content a:hover {
  border-bottom-color: var(--accent);
}

.docs-content strong {
  font-weight: 600;
}

.docs-content em {
  font-style: italic;
  color: var(--text-secondary);
}

.docs-content hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 24px 0;
}

/* --- Inline code --- */

.docs-content code.inline {
  background: var(--bg-secondary);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.84em;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  color: var(--accent-dark, #b35c38);
  word-break: break-word;
}

/* --- Code blocks --- */

.code-block {
  margin: 16px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-light);
}

.code-block-lang {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

.code-block-path {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

.code-block pre {
  background: var(--bg);
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border: none;
  border-left: none;
  border-radius: 0;
}

.code-block pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  tab-size: 4;
  color: var(--text);
  background: none;
  padding: 0;
}

/* Fallback для pre без .code-block обёртки */
.docs-content pre {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  overflow-x: auto;
  margin: 14px 0;
}

.docs-content pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  tab-size: 4;
  color: var(--text);
  background: none;
  padding: 0;
}

/* --- Tables --- */

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.85rem;
}

.docs-content table th,
.docs-content table td {
  border: 1px solid var(--border-light);
  padding: 9px 14px;
  text-align: left;
  line-height: 1.5;
}

.docs-content table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
}

.docs-content table tr:hover td {
  background: var(--surface-hover);
}

/* --- Blockquotes --- */

.docs-content blockquote {
  border-left: 3px solid var(--accent-border);
  padding: 10px 18px;
  margin: 14px 0;
  color: var(--text-secondary);
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
}

/* --- Notes ({% note %} tags from Bitrix docs) --- */

.docs-note {
  padding: 12px 18px;
  margin: 14px 0;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.6;
  border-left: 3px solid var(--accent-border);
  background: var(--accent-light);
  color: var(--text-secondary);
}

.docs-note strong {
  color: var(--text);
}

.docs-note-warning {
  border-left-color: #e8a94f;
  background: #fdf6e8;
}

.docs-note-danger {
  border-left-color: #d35f5f;
  background: #fdf0f0;
}

.docs-note-tip {
  border-left-color: #5fa85f;
  background: #f0fdf0;
}

.docs-note-info {
  border-left-color: var(--accent-border);
  background: var(--accent-light);
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-sidebar {
    position: static;
    max-height: none;
  }
  .docs-content {
    padding: 20px 24px;
  }
}
