/* ============================================================
   Раздел «Справка» — Potree Cloud Manager
   Только для роли «Админ проекта» (project_admin).
   Поддерживает тёмную/светлую тему через CSS-переменные app.
   ============================================================ */

/* Лэйаут справки: оглавление слева, контент справа */
.help-layout {
  display: flex;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 20px 40px;
  align-items: flex-start;
}

/* ---- Оглавление (sticky) ---- */
.help-toc {
  position: sticky;
  top: 12px;
  flex: 0 0 280px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  box-shadow: var(--shadow-sm);
}
.help-toc .toc-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text2);
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.help-toc .toc-search {
  width: 100%;
  margin: 0 0 8px;
  padding: 7px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}
.help-toc .toc-search:focus { border-color: var(--accent); }
.help-toc a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text2);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1.35;
}
.help-toc a:hover { background: var(--bg3); color: var(--text); }
.help-toc a.active { background: var(--accent); color: #fff; font-weight: 600; }
.help-toc a.toc-hidden { display: none; }
.help-toc a .toc-emoji { margin-right: 6px; }

/* ---- Контент ---- */
.help-content {
  flex: 1 1 auto;
  min-width: 0; /* чтобы изображения не раздували flex */
}
.help-content .help-sec {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 12px;
}
.help-content .help-sec.hidden-by-search { display: none; }
.help-content h2 {
  font-size: 22px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.help-content h3 {
  font-size: 17px;
  margin: 22px 0 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.help-content h4 {
  font-size: 14px;
  margin: 16px 0 6px;
  color: var(--text);
}
.help-content p { margin: 0 0 10px; line-height: 1.65; color: var(--text); font-size: 14px; }
.help-content ul, .help-content ol { margin: 0 0 12px; padding-left: 22px; }
.help-content li { margin-bottom: 5px; line-height: 1.55; font-size: 14px; color: var(--text); }
.help-content li::marker { color: var(--text2); }
.help-content a { color: var(--accent); }
.help-content strong { color: var(--text); font-weight: 600; }
.help-content code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12.5px;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  color: var(--accent3);
}
.help-content kbd {
  display: inline-block;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  color: var(--text);
  line-height: 1.5;
}

/* ---- Изображения ---- */
.help-fig {
  margin: 14px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* предотвращает «схлопывание» и скачки вёрстки до загрузки картинки */
  min-width: 0;
}
.help-fig img {
  display: block;
  max-width: 100%;
  height: auto;
  width: 100%;            /* адаптивно занимает доступную ширину контента */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  background: var(--bg3);
  object-fit: contain;    /* никогда не обрезает содержимое */
}
.help-fig .help-cap {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.4;
}
.help-fig.compact img { max-width: 560px; width: auto; }   /* модалки/диалоги — компактно */
.help-img-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.help-img-row .help-fig { flex: 1 1 300px; min-width: 240px; margin: 8px 0; }

/* ---- Бейджи ---- */
.help-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.help-badge.pc { background: rgba(37,99,235,0.16); color: var(--accent); border: 1px solid rgba(37,99,235,0.35); }
.help-badge.mob { background: rgba(0,194,168,0.16); color: var(--accent3); border: 1px solid rgba(0,194,168,0.35); }
.help-badge.both { background: rgba(40,167,69,0.16); color: var(--success); border: 1px solid rgba(40,167,69,0.35); }
.help-badge.note { background: rgba(255,193,7,0.16); color: var(--warning); border: 1px solid rgba(255,193,7,0.35); }

/* ---- Заметки/предупреждения ---- */
.help-note {
  background: var(--bg3);
  border-left: 3px solid var(--accent3);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.55;
}
.help-note.warn { border-left-color: var(--warning); }
.help-note.danger { border-left-color: var(--danger); }
.help-note.info { border-left-color: var(--accent); }
.help-note .nb-title { font-weight: 600; display: block; margin-bottom: 3px; }

/* ---- Таблицы ---- */
.help-table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.help-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 480px;
}
.help-content table th,
.help-content table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}
.help-content table thead th {
  background: var(--bg3);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text2);
  white-space: nowrap;
}
.help-content table tbody tr:last-child td { border-bottom: none; }
.help-content table tbody tr:hover td { background: var(--bg3); }
.help-content table td .mono { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; }

/* ---- Карточки-сетки ---- */
.help-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.help-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.help-card .hc-title { font-weight: 600; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; }
.help-card .hc-desc { color: var(--text2); font-size: 12.5px; }

/* ---- Кнопка-переключатель видов (ПК/Мобайл) ---- */
.help-platform-tabs {
  display: inline-flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 4px;
}
.help-platform-tabs button {
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.help-platform-tabs button.active { background: var(--accent); color: #fff; }

/* ---- Кнопка «наверх» + прогресс ---- */
.help-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.help-top.show { opacity: 1; pointer-events: auto; }
.help-top:hover { transform: translateY(-2px); }

/* Загрузка / ошибки */
.help-loading, .help-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--text2);
  font-size: 15px;
}
.help-error { color: var(--danger); }

/* Шапка раздела */
.help-hero {
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 22px;
  color: #fff;
}
.help-hero h1 { margin: 0 0 6px; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.help-hero p { margin: 0; opacity: 0.92; font-size: 14px; line-height: 1.5; max-width: 720px; }
.help-hero .help-hero-tags { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.help-hero .help-hero-tags span {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ============================================================
   Адаптив: от больших мониторов до телефонов
   Точки: >1400 широкий ПК · 1100-1400 ноут · 768-1100 планшет/узкий · 480-768 телефон · <480 маленький
   ============================================================ */
.help-mobile-toggle { display: none; } /* кнопка-бургер оглавления на мобиле */

/* Широкий ПК: ограничиваем максимальную ширину, чтобы строки не растягивались */
@media (min-width: 1500px) {
  .help-layout { max-width: 1320px; }
  .help-toc { flex-basis: 300px; }
}

/* Ноутбук (1100-1500): оглавление чуть уже */
@media (max-width: 1400px) and (min-width: 1101px) {
  .help-toc { flex-basis: 260px; }
  .help-content .help-sec { padding: 20px 22px; }
}

/* Планшет / узкий десктоп (768-1100) */
@media (max-width: 1100px) {
  .help-layout { padding: 8px 16px 32px; gap: 16px; }
  .help-toc { flex-basis: 240px; }
  .help-content .help-sec { padding: 18px 20px; }
  .help-cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Планшерт/телефон: оглавление сворачивается в кнопку (≤980) */
@media (max-width: 980px) {
  .help-layout { flex-direction: column; padding: 8px 12px 32px; gap: 12px; }
  .help-toc {
    position: static;
    flex: none;
    width: 100%;
    max-height: none;
    overflow: visible;
    order: 1;
  }
  .help-toc.collapsed .help-toc-list,
  .help-toc.collapsed .toc-search { display: none; }
  .help-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
  }
  .help-mobile-toggle .chev { transition: transform 0.2s; }
  .help-toc.collapsed .help-mobile-toggle .chev { transform: rotate(180deg); }
  .help-content { order: 2; width: 100%; }
  .help-content .help-sec { padding: 16px; }
  .help-content h2 { font-size: 19px; }
  .help-content h3 { font-size: 16px; }
  .help-img-row { flex-direction: column; }
  .help-img-row .help-fig { flex: 1 1 auto; min-width: 0; }
  .help-top { right: 14px; bottom: 14px; }
  .help-hero { padding: 20px 18px; }
  .help-hero h1 { font-size: 20px; }
  .help-hero p { font-size: 13px; }
}

/* Телефон (≤768) */
@media (max-width: 768px) {
  .help-layout { padding: 6px 8px 28px; gap: 10px; }
  .help-content .help-sec { padding: 14px 12px; margin-bottom: 14px; border-radius: 10px; }
  .help-content h2 { font-size: 18px; }
  .help-content h3 { font-size: 15px; margin: 16px 0 6px; }
  .help-content p, .help-content li { font-size: 13.5px; }
  .help-content code, .help-content kbd { font-size: 11.5px; }
  /* Таблицы становятся горизонтально-прокручиваемыми, не ломают вёрстку */
  .help-table-wrap { margin: 10px -12px; border-radius: 0; border-left: none; border-right: none; }
  .help-content table { font-size: 12.5px; min-width: 100%; }
  .help-fig { margin: 10px 0 12px; }
  .help-fig.compact img { max-width: 100%; width: 100%; }
  .help-cards { grid-template-columns: 1fr; gap: 10px; }
  .help-card { padding: 12px; }
  .help-badge { font-size: 10px; padding: 2px 7px; }
  .help-hero { padding: 16px 14px; border-radius: 10px; }
  .help-hero h1 { font-size: 18px; }
  .help-hero .help-hero-tags span { font-size: 10.5px; }
  .help-top { width: 38px; height: 38px; font-size: 16px; right: 10px; bottom: 10px; }
}

/* Маленький телефон (≤480) */
@media (max-width: 480px) {
  .help-content .help-sec { padding: 12px 10px; }
  .help-content h2 { font-size: 17px; }
  .help-content h3 { font-size: 14.5px; }
  .help-content p, .help-content li { font-size: 13px; line-height: 1.55; }
  .help-content ul, .help-content ol { padding-left: 18px; }
  .help-content table { font-size: 12px; }
  .help-content th, .help-content td { padding: 7px 8px; }
  .help-fig .help-cap { font-size: 11.5px; }
  .help-note { padding: 8px 10px; font-size: 12.5px; }
}

/* Сильное увеличение для доступности (предпочтение крупного шрифта) */
@media (min-resolution: 2dppx) {
  .help-content code, .help-content kbd { border-width: 1px; }
}

/* Печать */
@media print {
  .help-toc, .help-top, .help-mobile-toggle { display: none !important; }
  .help-layout { display: block; }
  .help-content .help-sec { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .help-fig img { box-shadow: none; }
  body { background: #fff !important; }
}
