﻿html {
  position: relative;
  min-height: 100%;
}

body {
  font-family: "Inter", sans-serif;
  color: #222222;
  background-color: #ffffff;
}

code {
  font-family: "JetBrains Mono", monospace;
  font-variant-ligatures: none;
  border-radius: 5px;
  line-height: initial;
  font-size: 14px !important;
}

img {
  width: 100%;
  height: auto;
}

blockquote {
  border-left: 2px solid #8b6cef;
  padding: 0 0 0 16px;
  margin-inline-start: 0;
  margin-inline-end: 0;
}

a {
  color: #9275f0;
  outline: none;
  text-decoration-line: underline;
  text-decoration-thickness: auto;
}

a:hover {
  color: #a48cf2;
}

h1 .header-anchor,
h2 .header-anchor,
h3 .header-anchor,
h4 .header-anchor,
h5 .header-anchor,
h6 .header-anchor {
  visibility: hidden;
}

h1:hover .header-anchor,
h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor,
h5:hover .header-anchor,
h6:hover .header-anchor {
  visibility: visible;
}

.hljs {
  background-color: #fafafa;
}

/* Стили для тёмной темы */
body.dark-theme {
  color: #dadada;
  background-color: #1e1e1e;
}

body.dark-theme .hljs {
  background-color: #242424;
}

body.dark-theme input[type="checkbox"]:checked:after {
  background-color: #1e1e1e;
}

body.dark-theme .table-expand-toggle button {
  color: #e0e0e0;
}

.content {
  max-width: 800px;
  margin: 40px auto 80px;
  line-height: 1.5;
  font-size: 15px;
}

.center-message {
  position: absolute;
  text-align: center;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -60%);
}

#footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  margin-top: 40px;
  text-align: center;
}

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 4px;
  border: 1px solid #5c5c5c;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  margin-inline-end: 6px;
  width: 16px;
  height: 16px;
  position: relative;
  transition: box-shadow 0.15s ease-in-out;
}

input[type="checkbox"]:hover,
input[type="checkbox"]:active,
input[type="checkbox"]:focus {
  outline: 0;
  border-color: #ababab;
}

input[type="checkbox"]:checked {
  background-color: #9275f0;
  border-color: #9275f0;
}

input[type="checkbox"]:checked:hover {
  background-color: #a48cf2;
  border-color: #a48cf2;
}

input[type="checkbox"]:checked:after {
  content: "";
  top: -1px;
  left: -1px;
  position: absolute;
  width: 16px;
  height: 16px;
  display: block;
  background-color: #ffffff;
  -webkit-mask-position: 52% 52%;
  -webkit-mask-size: 65%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-image: url('data:image/svg+xml; utf8, <svg width="12px" height="10px" viewBox="0 0 12 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-4.000000, -6.000000)" fill="%23000000"><path d="M8.1043257,14.0367999 L4.52468714,10.5420499 C4.32525014,10.3497722 4.32525014,10.0368095 4.52468714,9.8424863 L5.24777413,9.1439454 C5.44721114,8.95166768 5.77142411,8.95166768 5.97086112,9.1439454 L8.46638057,11.5903727 L14.0291389,6.1442083 C14.2285759,5.95193057 14.5527889,5.95193057 14.7522259,6.1442083 L15.4753129,6.84377194 C15.6747499,7.03604967 15.6747499,7.35003511 15.4753129,7.54129009 L8.82741268,14.0367999 C8.62797568,14.2290777 8.3037627,14.2290777 8.1043257,14.0367999"></path></g></g></svg>');
}

/* Контейнер для переключателя */
.theme-switch-container {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000; /* Чтобы переключатель был поверх других элементов */
}

/* Стили для переключателя */
.theme-toggle {
  position: relative;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

/* Стили иконок */
.theme-toggle .ph {
  position: absolute;
  font-size: 28px;
  transition: opacity 0.3s;
}

.sun-icon {
  color: #000;
}
.moon-icon {
  color: #fff;
  opacity: 0;
}

/* Состояние в темной теме */
body.dark-theme .theme-toggle {
  .sun-icon {
    opacity: 0;
  }
  .moon-icon {
    opacity: 1;
  }
}

/* Анимация переключения */
@keyframes icon-fade {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.theme-toggle:active {
  animation: icon-fade 0.3s ease;
}

/* Скрытие иконок при переключении */
input:checked + .slider .sun {
  opacity: 0; /* Скрываем солнце в тёмной теме */
}

input:not(:checked) + .slider .moon {
  opacity: 0; /* Скрываем луну в светлой теме */
}

/* Стили для блока кода */
pre {
  position: relative;
  overflow-x: auto;
}

/* Кнопка "Копировать" */
.copy-button {
  position: absolute;
  top: 5px;
  right: 5px;
  background-color: #9275f0;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0; /* Скрываем кнопку по умолчанию */
  transition: opacity 0.3s ease;
}

/* Показываем кнопку при наведении на блок кода */
pre:hover .copy-button {
  opacity: 1;
}

/* Изменение стиля кнопки при наведении */
.copy-button:hover {
  background-color: #a48cf2;
}

/* Стилизация полосы прокрутки для WebKit-браузеров (Chrome, Safari, Edge) */
pre {
  overflow-x: auto; /* Включаем горизонтальную прокрутку */
  scrollbar-width: thin; /* Для Firefox: тонкая полоса прокрутки */
  scrollbar-color: #4a4a4a transparent; /* Для Firefox: цвет ползунка и фона */
}

/* Стиль для полосы прокрутки (WebKit) */
pre::-webkit-scrollbar {
  height: 8px; /* Высота горизонтальной полосы прокрутки */
}

/* Стиль для "дорожки" полосы прокрутки */
pre::-webkit-scrollbar-track {
  background: transparent; /* Фон дорожки */
}

/* Стиль для "ползунка" полосы прокрутки */
pre::-webkit-scrollbar-thumb {
  background: #4a4a4a; /* Цвет ползунка */
  border-radius: 4px; /* Закругление углов */
}

/* Стиль для ползунка при наведении */
pre::-webkit-scrollbar-thumb:hover {
  background: #a48cf2; /* Цвет ползунка при наведении */
}

/* Базовые стили таблицы */
.markdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.9em;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  overflow-x: auto;
  display: block;
  background-color: var(--table-bg, #ffffff);
}

/* Заголовки таблицы */
.markdown-table th {
  background-color: var(--th-bg, #f8f9fa);
  color: var(--th-color, #333);
  text-align: center;
  padding: 12px 15px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--border-color, #e9ecef);
}

/* Ячейки таблицы */
.markdown-table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color, #e9ecef);
  vertical-align: top;
  color: var(--td-color, #222222);
}

/* Четные строки */
.markdown-table tr:nth-child(even) {
  background-color: var(--tr-even-bg, #f9f9f9);
}

/* Ховер эффект */
.markdown-table tr:hover {
  background-color: var(--tr-hover-bg, #f1f3f5);
}

/* Стили для темной темы */
body.dark-theme .markdown-table {
  --table-bg: #2d2d2d;
  --th-bg: #3a3a3a;
  --th-color: #e0e0e0;
  --td-color: #dadada;
  --border-color: #404040;
  --tr-even-bg: #363636;
  --tr-hover-bg: #404040;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* Обертка для горизонтальной прокрутки */
.table-container {
  max-width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
  -webkit-overflow-scrolling: touch;
}

.table-expand-toggle {
  text-align: right;
  margin-bottom: 4px;
}

.table-expand-toggle button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #9275f0;
  transition: transform 0.2s ease;
}

.table-container.fullscreen {
  position: relative;
  width: 95vw;
  max-width: 100vw;
  left: 50%;
  right: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background-color: inherit;
  overflow-x: auto;
}

.table-expand-toggle button {
  font-size: 20px;
  color: var(--th-color, #9275f0);
  padding: 4px;
}

/* Стили для изображений */
img {
  max-width: 400px;
  height: auto;
  box-shadow: var(--img-shadow);
  border-radius: 4px;
  transition: transform 0.2s;
  display: block;
  margin: 12px auto;
}

/* Для больших изображений добавим растягивание */
.img-large {
  width: 100%;
}

/* Для маленьких изображений уберем растягивание */
.img-small {
  width: auto;
  max-width: min-content;
  box-shadow: none;
}

body {
  --img-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-theme {
  --img-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* Класс для кликабельных изображений */
.img-zoomable {
  cursor: pointer;
}

.img-zoomable:hover {
  transform: scale(1.02);
}

/* Модальное окно */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.modal-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark-theme) {
  body {
    color: #dadada;
    background-color: #1e1e1e;
  }

  .hljs {
    background-color: #242424;
  }

  input[type="checkbox"]:checked:after {
    background-color: #1e1e1e;
  }
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
  .theme-switch-container {
    top: 32px;
    left: 32px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .theme-toggle .ph {
    font-size: 48px;
  }

  .markdown-table {
    font-size: 0.8em;
  }

  .markdown-table td,
  .markdown-table th {
    padding: 8px 10px;
  }
}

/* Медиа-запросы для очень маленьких экранов */
@media (max-width: 360px) {
  .theme-switch-container {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  .theme-toggle .ph {
    font-size: 20px;
  }
}

@media print {
  #footer {
    position: relative;
  }
}
