/* My Work — Sidebar */

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  padding: 20px 16px;
  overflow-y: auto;
  background: var(--background);
  border-right: 1px solid var(--border);
}

/* Логотип */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--text);
  text-decoration: none;
}

.sidebar-brand-text {
  white-space: nowrap;
}

/* Навигация */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 20px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sidebar-link:hover:not(:disabled) {
  background: var(--hover);
}

.sidebar-link.active {
  background: var(--hover);
}

.sidebar-link:disabled {
  cursor: default;
  opacity: 0.7;
}

.nav-icon img {
  display: none;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.sidebar-owner {
  margin-top: 20px;
}

.sidebar [hidden] {
  display: none !important;
}

/* Нижняя область */

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-top: 20px;
}

/* Аватар и имя */

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;

  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.sidebar-user:hover {
  background: var(--hover);
}

.sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--hover);
  color: var(--text);
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-info {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sidebar-user-info strong {
  overflow-wrap: anywhere;
}

.sidebar-user-info small {
  color: var(--text-muted);
}

/* Идеи и предложения */

.sidebar-feedback {
  margin-top: 20px;
}

/* Футер */

.sidebar-footer {
  margin-top: 20px;
  padding: 0;
  color: var(--text-muted);
}

.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ==========================================================
   MY WORK — ИСТОРИЯ ОБНОВЛЕНИЙ
   ========================================================== */

/* Копирайт одновременно служит кнопкой открытия истории */
.sidebar-copyright {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease;
}

.sidebar-copyright:hover {
  color: var(--text);
}

.sidebar-copyright:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 3px;
}

/* Модальное окно истории обновлений */
.sidebar-history-dialog {
  position: fixed;
  width: min(480px, calc(100vw - 32px));
  max-height: min(700px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--background);
  color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / 20%);
}

.sidebar-history-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

/* Заголовок и кнопка закрытия */
.sidebar-history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-history-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
}

.sidebar-history-header form {
  margin: 0;
}

/* Версии располагаются сверху вниз, от новых к старым */
.sidebar-history-list {
  padding: 0 24px;
}

.sidebar-history-entry {
  padding: 22px 0;
}

.sidebar-history-entry + .sidebar-history-entry {
  border-top: 1px solid var(--border);
}

.sidebar-history-entry-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sidebar-history-entry h3 {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgb(59 130 246 / 12%);
  color: #3b82f6;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}

/* Дата публикации рядом с номером версии */
.sidebar-history-date {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-history-description {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sidebar-history-description p {
  margin: 0 0 8px;
}

.sidebar-history-description ul,
.sidebar-history-description ol {
  margin: 12px 0;
  padding-left: 20px;
}

.sidebar-history-description li {
  margin: 8px 0;
  padding-left: 3px;
}

.sidebar-history-description strong {
  font-weight: 650;
}

.sidebar-history-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 480px) {
  .sidebar-history-header {
    padding: 20px;
  }

  .sidebar-history-list {
    padding: 4px 20px;
  }

  .sidebar-history-footer {
    padding: 16px 20px;
  }
}

/* ==========================================================
   MY WORK — ТУМБЛЕР СВЕТЛОЙ И ТЁМНОЙ ТЕМЫ
   ========================================================== */

/* Основа переключателя без текстовой подписи */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 58px;
  height: 30px;
  flex: 0 0 58px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--hover);
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

/* Подвижный кружок с иконкой */
.theme-toggle-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--background);
  box-shadow: 0 1px 4px rgb(0 0 0 / 12%);
  transform: translateX(0);
  transition:
    transform 0.25s ease,
    background-color 0.2s ease;
}

/* В тёмной теме кружок находится справа */
:root[data-theme='dark'] .theme-toggle-thumb {
  transform: translateX(28px);
}

/* Оформление SVG внутри ползунка */
.theme-toggle-thumb svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* В светлой теме отображаем солнце */
.theme-toggle .theme-icon-dark {
  display: none;
}

.theme-toggle .theme-icon-light {
  display: block;
}

/* В тёмной теме отображаем луну */
:root[data-theme='dark'] .theme-toggle .theme-icon-light {
  display: none;
}

:root[data-theme='dark'] .theme-toggle .theme-icon-dark {
  display: block;
}

/* Доступность при управлении клавиатурой */
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* На время анимации исключаем повторное нажатие */
.theme-toggle:disabled {
  cursor: default;
}

/* Учитываем настройки уменьшенной анимации */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle-thumb {
    transition: none;
  }
}

/* Счётчик непрочитанных уведомлений */

.sidebar-notification-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  margin-left: auto;

  border-radius: 50px;
  background: var(--accent);
  color: var(--button-text);

  line-height: 1;
  font-weight: var(--weight-button);
  font-variant-numeric: tabular-nums;
}

.sidebar-notification-count[hidden] {
  display: none;
}

/* Независимая прокрутка основного контента */

@media (min-width: 769px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  #sidebar-container {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #page-container {
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* MOBILE: hide sidebar */

@media (max-width: 768px) {
  .app-shell {
    display: block;
    width: 100%;
    min-height: 100dvh;
  }

  #sidebar-container {
    display: none;
  }

  #page-container {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  html,
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
}

/* ========================================
   МНОГОСЛОЙНЫЙ ИНТЕРФЕЙС MY WORK
   ======================================== */

@media (min-width: 769px) {
  /* Общий фон приложения — нижний слой */
  .app-shell {
    background: var(--sidebar-bg, var(--background));
  }

  /* Сайдбар без рамок, контуров и теней */
  #sidebar-container,
  #sidebar-container .sidebar {
    border: 0;
    outline: 0;
    box-shadow: none;
  }

  /* Рабочая панель — верхний слой интерфейса */
  #page-container {
    position: relative;
    z-index: 1;

    /* Отступы: сверху, справа, снизу, слева */
    margin: 12px 20px 12px -8px;

    /* Высота с учётом внешних отступов */
    height: calc(100dvh - 24px);
    min-height: 0;

    /* Тонкая рамка панели */
    border: 1px solid var(--border);

    /* Скругление всех углов */
    border-radius: 18px;

    /* Фон рабочей области */
    background: var(--workspace);

    /* Независимая прокрутка содержимого */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;

    /* Мягкая тень подчёркивает наложение рабочей панели на сайдбар */
    box-shadow: -4px 0 18px rgb(0 0 0 / 4%);
  }
}