/* ============================= */
/* Общие стили */
/* ============================= */
body {
  margin: 0;
  display: flex;
  font-family: Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
}

/* h1 — основной заголовок */
h1 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 1rem 0 0.5rem 0;
}

/* h2 — разделы с тонкой линией */
h2 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 1rem 0 0.5rem 0;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid var(--accent-color1);
}

/* h3 — подразделы с тонкой линией */
h3 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0.8rem 0 0.4rem 0;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--accent-color1);
}

/* h4 — маленькие заголовки */
h4 {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0.6rem 0 0.3rem 0;
}

:root {
  --accent-color1: rgb(93, 107, 87);
  --accent-color2: rgb(248, 196, 0);
}

/* Светлая тема */
body.light {
  --bg-color: #ffffff;
  --text-color: #000000;
  --sidebar-bg: rgb(87, 149, 204);
  --sidebar-link-hover: rgba(255, 255, 255, 0.2);
  --footer-bg: #f1f1f1;
  --search-color: black;
}

/* Тёмная тема */
body.dark {
  --bg-color: #000000;
  --text-color: #ffffff;
  --sidebar-bg: rgb(40, 40, 40);
  --sidebar-link-hover: rgba(255, 255, 255, 0.2);
  --footer-bg: #111111;
  --search-color: white;
}

/* ============================= */
/* Sidebar */
/* ============================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100%;
  background: var(--sidebar-bg);
  color: white;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  box-sizing: border-box;
}

/* Sidebar header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sidebar-logo {
  height: 40px;
  margin-right: 0.5rem;
}

.sidebar-title {
  font-size: 1.2rem;
  margin: 0;
}
.sidebar-title-link {
  display: block;
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
  margin-top: 0.5rem;
}

.sidebar-title-link:hover {
  text-decoration: underline;
  color: var(--accent-color2);
}

/* Поиск */
.search-box {
  width: 100%;
  max-width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  background: transparent;
  color: var(--search-color);
  box-sizing: border-box;
  display: block;
}
.search-box::placeholder {
  color: white;
  opacity: 1;
}

/* ============================= */
/* Меню */
/* ============================= */
.menu, .submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.submenu {
  display: none;
  padding-left: 1rem;
  flex-direction: column;
}
.open > .submenu {
  display: flex;
}

/* Минималистичные кнопки */
.menu-item-with-arrow .menu-header,
.doc-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  text-decoration: none;
  box-sizing: border-box;
}
.menu-item-with-arrow .menu-header:hover,
.doc-link:hover {
  background: var(--sidebar-link-hover);
  color: var(--accent-color2);
  border-color: rgba(255,255,255,0.5);
}
a.active,
.doc-link.active {
  background: var(--sidebar-link-hover);
  color: var(--accent-color2);
}
.arrow {
  margin-left: 0.5rem;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.menu-item-with-arrow.open .arrow {
  transform: rotate(90deg);
}
.menu a {
  color: inherit;
  text-decoration: none;
  display: block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: background 0.2s;
  box-sizing: border-box;
}
.menu a:hover {
  background: var(--sidebar-link-hover);
  color: var(--accent-color2);
}

/* ============================= */
/* Основная часть */
/* ============================= */
.main-content {
  margin-left: 250px;
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  height: 40px;
  margin-right: 0.5rem;
}
.logo-title {
  display: flex;
  align-items: center;
}
.site-title {
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--text-color);
}
.site-title:hover {
  text-decoration: underline;
  color: var(--accent-color2);
}

#theme-toggle {
  width: 32px;
  height: 32px;
  background: transparent no-repeat center/contain;
  border: none;
  cursor: pointer;
  flex-shrink: 0;                 /* чтобы кнопка не сжималась */
   margin-left: auto;
}
body.dark #theme-toggle {
  background-image: url("/images/icon/dark.svg");
}

body.light #theme-toggle {
  background-image: url("/images/icon/light.svg");
}

/* Контент */
.content {
  flex: 1;
}

/* ============================= */
/* Footer */
/* ============================= */
footer {
  text-align: center;
  padding: 1rem;
  background: var(--footer-bg);
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
}
.footer-links a {
  margin: 0 0.5rem;
  color: var(--text-color);
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent-color2);
}

/* ============================= */
/* Адаптивность */
/* ============================= */

/* Таблицы */
.table-wrap {
 width: auto; /* ширина под контент */
  max-width: 100%; /* но не больше контейнера */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}
.table-wrap table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.table-wrap th, .table-wrap td {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  padding: 6px 8px;
}
.table-custom th,
.table-custom td {
  border: 1px solid #dddddd;
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  white-space: normal; /* перенос строк */
}

/* Заголовок таблицы */
.table-custom thead th {
  font-weight: bold;
  color: #fff;
}

/* Светлая тема — голубой */
body.light .table-custom thead th {
  background: rgb(87, 149, 204);
}

/* Тёмная тема — зелёный */
body.dark .table-custom thead th {
  background: rgb(93, 107, 87);
}

/* Чередование строк для удобства чтения */
.table-custom tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.03);
}

body.dark .table-custom tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

/* ============================= */
/* Примечания с лампочкой */
/* ============================= */
.note {
  display: flex;
  align-items: flex-start;
  background-color: var(--note-bg);
  border-left: 4px solid var(--note-border);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  font-style: normal;
  font-size: 0.95rem;
  border-radius: 4px;
  color: var(--note-text);
}

.note-icon {
  flex-shrink: 0;
  margin-right: 0.5rem;
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--note-border); /* иконка того же цвета, что и полоска */
  line-height: 1;
}
/* Светлая тема */
body.light .note {
  background-color: rgba(87, 149, 204, 0.15); /* голубой фон для светлой темы */
}

/* Тёмная тема */
body.dark .note {
  background-color: rgba(93, 107, 87, 0.25); /* зелёный фон для тёмной темы */
}
/* ----------------------------- */
/* Подсветка текущей страницы */
/* ----------------------------- */
.menu a.active,
.doc-link.active {
  background: var(--sidebar-link-hover);
  color: var(--accent-color2); /* контрастный цвет для текста */
  border-color: rgba(255,255,255,0.5);
  font-weight: bold;
}

/* ----------------------------- */
/* Родительский пункт при раскрытии */
/* ----------------------------- */
.menu-item-with-arrow.open > .menu-header {
  border-color: rgba(255,255,255,0.5); /* тонкая подсветка рамки */
}

.menu-item-with-arrow.open > .menu-header .arrow {
  color: var(--accent-color2); /* стрелка выделена акцентным цветом */
}


/* Код */
pre, code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.4;
  background: #1e1e1e;
  color: #eee;
  padding: 8px 12px;
  border-radius: 6px;
  display: block;
  max-width: 100%;
  box-sizing: border-box;
}
body.light pre, body.light code {
  background: #f5f5f5;
  color: #111;
}


/* Гамбургер */
#menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1200;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.8rem;
  color: var(--text-color);
}

/* На планшетах/телефонах */
@media (max-width: 768px) {
  .sidebar {
    left: -250px;
    transition: left 0.3s ease;
    z-index: 1100;
  }
  .sidebar.open {
    left: 0;
  }
  .main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
  }
  #menu-toggle {
    display: block;
  }
  #theme-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1200;
  }
}

/* Совсем маленькие экраны */
@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  h3, h4 { font-size: 1rem; }
  body { font-size: 15px; }
}
* Блокируем прокрутку фона, когда открыта модалка */
body.modal-open { overflow: hidden; }

/* Затемнение фона — по умолчанию спрятано */
.image-modal {
  display: none;                 /* скрыто по умолчанию */
  position: fixed;
  inset: 0;                      /* top:0; right:0; bottom:0; left:0 */
  z-index: 3000;
  background-color: rgba(0,0,0,0.9);

  /* центровка содержимого */
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

/* Показ модалки */
.image-modal.open {
  display: flex;                 /* показываем как flex-контейнер */
}

/* Картинка внутри модалки */
.image-modal .modal-content {
  max-width: 90vw;
  max-height: 80vh;
  border: 3px solid var(--accent-color2);
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
}

/* Подпись */
#caption {
  margin-top: 10rem;
  text-align: center;
  color: #ccc;
  font-size: 1.2rem;
  font-weight: bold;   /* сделали жирным */

}

/* Кнопка закрытия */
.image-modal .close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s;
  line-height: 1;
}
.image-modal .close:hover { color: var(--accent-color2); }
/* Картинки внутри текста */
.content img {
  max-width: 100%;     /* не шире контейнера */
  height: auto;        /* сохраняем пропорции */
  display: block;      /* убираем лишние пробелы снизу */
  margin: 1.2rem 0;   /* центрируем */
}

/* Если хочешь компактные картинки (например схемы) */
.content-image img {
  max-width: 1080px;    /* ограничение в пикселях */
  width: 100%;         /* но всё ещё адаптивные */
}

:root {
  --table-border-light: #ddd;
  --table-border-dark: #555;
  --table-text-light: #222;
  --table-text-dark: #eee;
}
