/* ==========================================================================
   Версия для слабовидящих и панель доступности (ГОСТ Р 52872-2019)
   ========================================================================== */

/* --- 1. Черно-белый режим (обесцвечивание сайта) --- */
body.special-bw .site-wrapper,
body.special-bw #doc-viewer-modal {
  filter: grayscale(1) !important;
}

/* --- 2. Режим подчеркивания ссылок --- */
body.special-underline a {
  text-decoration: underline !important;
}

/* --- 3. Высококонтрастный режим (черно-желтая схема по ГОСТ) --- */
body.special-version {
  background-color: #000000 !important;
  color: #ffff00 !important;
  letter-spacing: 0.04em !important;
}

/* Универсальное правило: гарантирует, что НИ ОДИН блок сайта не останется белым */
body.special-version .site-wrapper,
body.special-version .site-wrapper *,
body.special-version #doc-viewer-modal,
body.special-version #doc-viewer-modal * {
  background-color: #000000 !important;
  color: #ffff00 !important;
  border-color: #ffff00 !important;
  box-shadow: none !important;
  text-shadow: none !important;
  outline-color: #ffff00 !important;
}

/* Ссылки сайта в контрастном режиме */
body.special-version a:not(.special-panel-btn) {
  color: #ffff00 !important;
  text-decoration: underline !important;
  font-weight: 700 !important;
}

body.special-version a:not(.special-panel-btn):hover {
  text-decoration: none !important;
  background-color: #1a1a00 !important;
}

/* Изображения и векторные значки контента в контрастном режиме */
body.special-version .site-wrapper img,
body.special-version .site-wrapper svg {
  filter: grayscale(1) contrast(1.3) !important;
}

/* Таблицы контента */
body.special-version table,
body.special-version thead,
body.special-version tbody,
body.special-version tr,
body.special-version th,
body.special-version td {
  border: 1px solid #ffff00 !important;
  background-color: #000000 !important;
  color: #ffff00 !important;
}

body.special-version th {
  border-bottom: 2px solid #ffff00 !important;
  font-weight: 700 !important;
}

/* Плавающий скроллбар таблицы */
body.special-version .table-floating-scrollbar {
  background: #000000 !important;
  border: 1.5px solid #ffff00 !important;
}

body.special-version .table-scroll-thumb {
  background-color: #ffff00 !important;
}

/* Поля ввода и кнопки в основном контенте */
body.special-version input,
body.special-version textarea,
body.special-version select,
body.special-version button:not(#special-widget-root button) {
  background-color: #000000 !important;
  color: #ffff00 !important;
  border: 1.5px solid #ffff00 !important;
}

/* Активные пункты навигации */
body.special-version .main-nav a.active,
body.special-version .header-action-btn.active {
  background-color: #ffff00 !important;
  color: #000000 !important;
  font-weight: 700 !important;
}


/* ==========================================================================
   4. Плавающий виджет настроек доступности (#special-widget-root)
   ========================================================================== */

#special-widget-root {
  position: fixed !important;
  right: 20px !important;
  bottom: 20px !important;
  z-index: 2147483647 !important; /* Всегда поверх всех элементов */
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  user-select: none !important;
  font-family: var(--font-family, 'Montserrat', sans-serif) !important;
  filter: none !important;
  box-sizing: border-box !important;
  isolation: isolate;
}

#special-widget-root, 
#special-widget-root * {
  box-sizing: border-box !important;
}

/* Плавающая кнопка-таблетка */
#special-widget-btn {
  background: #ffffff;
  color: #1e293b;
  border: 2px solid #e2e8f0;
  border-radius: 9999px;
  height: 46px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
}

#special-widget-btn i {
  font-size: 1.15rem;
  color: var(--primary-color, #1976d2);
  transition: transform 0.2s ease, color 0.2s ease;
}

#special-widget-btn:hover {
  background: #ffffff;
  border-color: #93c5fd;
  color: var(--primary-color, #1976d2);
  box-shadow: 0 6px 24px rgba(25, 118, 210, 0.2);
  transform: translateY(-2px);
}

#special-widget-btn:hover i {
  transform: scale(1.1);
}

/* Индикатор активного спец-режима */
#special-widget-btn.is-active-mode {
  background: #eff6ff;
  border-color: var(--primary-color, #1976d2);
  color: var(--primary-color, #1976d2);
  box-shadow: 0 4px 18px rgba(21, 101, 192, 0.28);
}

/* Модальная панель настроек доступности */
#special-panel {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  width: 320px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: specialPanelFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes specialPanelFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.special-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #edf2f7;
}

.special-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.special-panel-title i {
  color: var(--primary-color, #1976d2);
}

.special-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.special-close-btn:hover {
  color: #ef4444;
}

.special-panel-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.special-setting-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.special-setting-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.special-btn-group {
  display: flex;
  gap: 8px;
}

.special-panel-btn {
  flex: 1;
  height: 38px;
  background: #f1f5f9;
  color: #334155;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.18s ease;
}

.special-panel-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.special-panel-btn.active {
  background: #eff6ff;
  border-color: var(--primary-color, #1976d2);
  color: var(--primary-color, #1976d2);
  font-weight: 700;
}

.special-panel-footer {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #edf2f7;
}

.special-reset-btn {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  color: #64748b;
}

.special-reset-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}


/* ==========================================================================
   5. Виджет в режиме высокой контрастности (body.special-version)
   ========================================================================== */

body.special-version #special-widget-btn {
  background: #000000 !important;
  color: #ffff00 !important;
  border: 2px solid #ffff00 !important;
  box-shadow: 0 0 16px rgba(255, 255, 0, 0.45) !important;
}

body.special-version #special-widget-btn i {
  color: #ffff00 !important;
}

body.special-version #special-widget-btn:hover {
  background: #ffff00 !important;
  color: #000000 !important;
  box-shadow: 0 0 20px rgba(255, 255, 0, 0.7) !important;
}

body.special-version #special-widget-btn:hover i {
  color: #000000 !important;
}

body.special-version #special-panel {
  background: #000000 !important;
  border: 2px solid #ffff00 !important;
  box-shadow: 0 0 24px rgba(255, 255, 0, 0.35) !important;
}

body.special-version .special-panel-header {
  background: #000000 !important;
  border-bottom: 1.5px solid #ffff00 !important;
}

body.special-version .special-panel-title {
  color: #ffff00 !important;
}

body.special-version .special-panel-title i {
  color: #ffff00 !important;
}

body.special-version .special-close-btn {
  color: #ffff00 !important;
}

body.special-version .special-close-btn:hover {
  color: #ffffff !important;
}

body.special-version .special-panel-body,
body.special-version .special-panel-footer {
  background: #000000 !important;
  border-top-color: #ffff00 !important;
}

body.special-version .special-setting-label {
  color: #ffff00 !important;
  font-weight: 700 !important;
}

body.special-version .special-panel-btn {
  background: #000000 !important;
  color: #ffff00 !important;
  border: 1.5px solid #ffff00 !important;
}

body.special-version .special-panel-btn:hover {
  background: #2a2a00 !important;
  color: #ffff00 !important;
}

body.special-version .special-panel-btn.active {
  background: #ffff00 !important;
  color: #000000 !important;
  border-color: #ffff00 !important;
  font-weight: 700 !important;
}

body.special-version .special-reset-btn {
  background: #000000 !important;
  color: #ffff00 !important;
  border: 1.5px solid #ffff00 !important;
}

body.special-version .special-reset-btn:hover {
  background: #ffff00 !important;
  color: #000000 !important;
}


/* ==========================================================================
   6. Виджет в черно-белом режиме (body.special-bw)
   ========================================================================== */

body.special-bw #special-widget-btn {
  background: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25) !important;
}

body.special-bw #special-widget-btn i {
  color: #000000 !important;
}

body.special-bw #special-widget-btn.is-active-mode {
  background: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #000000 !important;
}

body.special-bw #special-widget-btn.is-active-mode i {
  color: #ffffff !important;
}

body.special-bw #special-panel {
  background: #ffffff !important;
  border: 2px solid #000000 !important;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25) !important;
}

body.special-bw .special-panel-header {
  background: #f1f5f9 !important;
  border-bottom: 1.5px solid #000000 !important;
}

body.special-bw .special-panel-title,
body.special-bw .special-panel-title i {
  color: #000000 !important;
}

body.special-bw .special-close-btn {
  color: #000000 !important;
}

body.special-bw .special-setting-label {
  color: #1e293b !important;
}

body.special-bw .special-panel-btn {
  background: #f8fafc !important;
  color: #000000 !important;
  border: 1.5px solid #475569 !important;
}

body.special-bw .special-panel-btn:hover {
  background: #e2e8f0 !important;
  color: #000000 !important;
}

body.special-bw .special-panel-btn.active {
  background: #000000 !important;
  color: #ffffff !important;
  border-color: #000000 !important;
  font-weight: 700 !important;
}

body.special-bw .special-panel-footer {
  background: #f8fafc !important;
  border-top: 1.5px solid #000000 !important;
}

body.special-bw .special-reset-btn {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1.5px solid #000000 !important;
}

body.special-bw .special-reset-btn:hover {
  background: #000000 !important;
  color: #ffffff !important;
}


/* ==========================================================================
   7. Адаптивность виджета для мобильных экранов
   ========================================================================== */

@media (max-width: 640px) {
  #special-widget-root {
    right: 14px !important;
    bottom: 14px !important;
  }
  .special-btn-text {
    display: none;
  }
  #special-widget-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
  #special-panel {
    right: 0;
    bottom: 52px;
    width: 290px;
  }
}
