/* Переключатель темы: базовые стили в site.css (шапка на всех страницах). */

/* Заголовок рядом с кнопкой настроек — без нижней линии (h1 + класс — выше специфичность) */
h1.section-settings-title-inline {
  margin: 0;
  padding: 0;
  border: none;
  border-bottom: none;
  border-style: none;
  border-width: 0;
  box-shadow: none;
  text-decoration: none;
  text-decoration-line: none;
  background-image: none;
}

/* Кнопка настроек раздела */
.section-settings-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.site-nav .section-settings-btn,
.site-nav-settings-btn,
.nav-actions .nav-comments-btn,
.bible-reader-header-actions .section-settings-btn {
  display: inline-flex;
}

/* Tabs overflow — горизонтальный скролл при 5+ вкладках */
.section-settings-tabs {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.section-settings-tabs::-webkit-scrollbar {
  display: none;
}

.section-settings-btn:hover {
  background: hsl(var(--gold) / 0.12);
  border-color: hsl(var(--gold) / 0.5);
  color: hsl(var(--gold-dark));
}

/* =====================
   Settings — правая боковая панель
   Общие токены для всех выезжающих справа панелей (настройки, словарь, комментарии, толкования…)
   ===================== */

:root {
  --portal-right-drawer-width: min(540px, 50vw);
  --portal-right-drawer-height: 100dvh;
  --portal-right-drawer-radius: var(--radius) 0 0 var(--radius);
  --portal-right-drawer-shadow: -4px 0 32px hsl(0 0% 0% / 0.2);
  --portal-right-drawer-border: 1px solid hsl(var(--border));
  --portal-right-drawer-bg: hsl(var(--card));
  --portal-right-drawer-backdrop: hsl(0 0% 0% / 0.45);
  --portal-right-drawer-backdrop-blur: blur(1px);
  --portal-right-drawer-duration: 0.28s;
  --portal-right-drawer-ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Общая оболочка правых модальных панелей (настройки, навигатор книг/глав и т.д.) */
dialog.portal-right-drawer-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: var(--portal-right-drawer-width);
  height: var(--portal-right-drawer-height);
  max-height: var(--portal-right-drawer-height);
  border: none;
  border-left: var(--portal-right-drawer-border);
  border-radius: var(--portal-right-drawer-radius);
  background: var(--portal-right-drawer-bg);
  box-shadow: var(--portal-right-drawer-shadow);
  padding: 0;
  overflow: hidden;
  /* НЕ ставить display здесь — браузер сам скрывает закрытый <dialog> */
}

dialog.portal-right-drawer-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.portal-right-drawer-dialog::backdrop {
  background: var(--portal-right-drawer-backdrop);
  backdrop-filter: var(--portal-right-drawer-backdrop-blur);
}

/* Анимация выезда справа (dialog + общее имя для согласованности) */
@keyframes panelSlideIn {
  from { transform: translateX(100%); opacity: 0.4; }
  to   { transform: translateX(0);    opacity: 1;   }
}

dialog.portal-right-drawer-dialog[open] {
  animation: panelSlideIn var(--portal-right-drawer-duration) var(--portal-right-drawer-ease);
}

@media (prefers-reduced-motion: reduce) {
  dialog.portal-right-drawer-dialog[open] {
    animation: none;
  }
}

/* Заголовок попапа */
.section-settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
}

.section-settings-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* Кнопка закрытия */
.section-settings-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  padding: 0.25rem;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.section-settings-close:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.5);
}

/* Тело попапа */
.section-settings-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
}

/* Вкладки (для Фазы 6: История/Закладки) */
.section-settings-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0;
}

.section-settings-tab {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: none;
  background: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.section-settings-tab.active,
.section-settings-tab:hover {
  color: hsl(var(--foreground));
}

.section-settings-tab.active {
  border-bottom-color: hsl(var(--gold, var(--primary)));
}

.section-settings-tab-panel {
  display: none;
}

.section-settings-tab-panel.active {
  display: block;
}

/* Общие стили контента */
.section-settings-panel-body select,
.section-settings-panel-body .bible-select,
.section-settings-panel-body .bible-reader-select,
.section-settings-panel-body .cmd-select,
.section-settings-panel-body .ency-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 1rem;
  background: hsl(var(--background));
}

.section-settings-panel-body .bible-reader-select {
  color: inherit;
}

.section-settings-panel-body .bible-select,
.section-settings-panel-body .cmd-select,
.section-settings-panel-body .ency-select {
  color: hsl(var(--foreground));
}

.section-settings-panel-body .bible-reader-select.multi {
  min-width: 0;
  max-height: 6rem;
}

.section-settings-panel-body select option {
  white-space: normal;
  word-wrap: break-word;
}

.section-settings-panel-body label {
  min-width: 0;
  max-width: 100%;
}

.section-settings-panel-body .bible-reader-filters,
.section-settings-panel-body .bible-reader-modules,
.section-settings-panel-body .commandments-filters,
.section-settings-panel-body .bible-filters,
.section-settings-panel-body .encyclopedia-filters {
  max-width: 100%;
}

/* На мобиле — на всю ширину (768px как у bible-reader-panel) */
@media (max-width: 768px) {
  :root {
    --portal-right-drawer-width: 100vw;
    --portal-right-drawer-radius: 0;
  }

  dialog.portal-right-drawer-dialog {
    width: var(--portal-right-drawer-width);
    max-width: 100vw;
    border-radius: var(--portal-right-drawer-radius);
    border-left: none;
  }
}
