/* ================================================================
   ООО «ЗНГО-Импульс» — Финальная версия стилей
   Таблицы переведены на table-layout: auto — колонки сами
   подстраиваются под содержимое, текст не выходит за границы.
   ================================================================ */

/* ================= 1. ПЕРЕМЕННЫЕ И БАЗОВЫЕ НАСТРОЙКИ ================= */
:root {
  --accent: #2b7de1;
  --accent-dark: #2265b8;
  --text-color: #333333;
  --text-muted: #555555;
  --border: #e0e0e0;
  --font-stack: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-stack);
  line-height: 1.6;
  color: var(--text-color);
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

.menu-hidden {
  display: none !important;
}

/* Единая подсветка фокуса для клавиатурной навигации */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ================= 2. ФОН И КОНТЕНТ (Оверлей) ================= */
body.with-bg {
  background-image: url('../img/bg-main.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
  position: relative;
}

.content-overlay {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ================= 3. ШАПКА (HEADER) ================= */
.header {
  position: relative;
  height: 160px;
  background-image: url('../img/logo-wide.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  z-index: 600;
}

.header-logo-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.header-contacts {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  z-index: 101;
}

.contact-link {
  text-decoration: none;
  color: #333;
  font-weight: 600;
  transition: color 0.2s;
  white-space: nowrap;
}

.contact-phone { font-size: 16px; }
.contact-email { font-size: 14px; }
.contact-link:hover { color: var(--accent); }

.main-nav {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.nav-list {
  display: flex;
  list-style: none;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
}

.nav-list > li { position: relative; }

.main-nav a {
  display: block;
  padding: 8px 16px;
  text-decoration: none;
  color: #1a1a1a;
  font-weight: 600;
  font-size: 18px;
  transition: color 0.2s;
}

.main-nav a:hover { color: var(--accent); }

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 300px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  z-index: 1100;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease-in-out 0.2s, visibility 0.2s ease-in-out 0.2s, transform 0.2s ease-in-out 0.2s;
}

.has-dropdown:hover > .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

.has-submenu { position: relative; }

.submenu {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: -1px;
  min-width: 240px;
  padding: 12px 16px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 1101;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);
  transition: opacity 0.2s ease-in-out 0.2s, visibility 0.2s ease-in-out 0.2s, transform 0.2s ease-in-out 0.2s;
}

.has-submenu:hover > .submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition-delay: 0s;
}

.has-dropdown > a::after { content: ' ▼'; font-size: 0.7em; vertical-align: middle; }
.has-submenu > a::after { content: ''; }

/* ================= КНОПКА "НАВЕРХ" ================= */
.scroll-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(43, 125, 225, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
  z-index: 900;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn:hover { background: var(--accent-dark); }

/* ================= КНОПКИ СКАЧИВАНИЯ ================= */
.download-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 15px;
  margin-bottom: 15px;
}

/* ================= 4. ГАМБУРГЕР И ЗАТЕМНЕНИЕ ================= */
.mobile-toggle {
  display: none;
  position: absolute;
  top: 12px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  z-index: 1001;
  padding: 8px;
}

.mobile-toggle span {
  display: block;
  width: 26px;
  height: 3px;
  background: #1a1a1a;
  margin: 5px 0;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
.mobile-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 500;
}

body.menu-overlay-active::before {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ================= 5. ОСНОВНОЙ КОНТЕНТ ================= */
.page-main { padding: 40px 0; }
h1 { font-size: 28px; margin-bottom: 20px; color: #1a1a1a; }
h2 { font-size: 24px; margin: 30px 0 15px; color: #1a1a1a; }
h3 { font-size: 20px; margin: 25px 0 12px; color: #1a1a1a; }
p { margin-bottom: 15px; }

.simple-list { list-style: none; padding-left: 0; margin: 12px 0 24px 0; }
.simple-list li { position: relative; padding-left: 24px; margin-bottom: 8px; }
.simple-list li::before { content: "•"; position: absolute; left: 0; color: var(--accent); font-size: 20px; }

.content-overlay a:not(.download-btn):not(.footer-link):not(.pump-type-card):not(.product-card) {
  color: var(--accent); text-decoration: none;
}
.content-overlay a:not(.download-btn):not(.footer-link):not(.pump-type-card):not(.product-card):hover {
  text-decoration: underline;
}

.membrane-intro-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
}

.membrane-main-image {
  width: 100%;
  max-width: 220px;
  height: 220px;
  object-fit: contain;
  flex: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.membrane-text-block { flex: 1; }

/* Маркировка (тултипы) */
.h2-centered { text-align: center; margin-bottom: 24px; }
.marking-scheme-container { max-width: 1200px; margin: 0 auto; }
.marking-scheme { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.mark-item { position: relative; cursor: pointer; }
.mark-block { display: inline-block; padding: 8px 12px; background: #f5f5f5; border-radius: 4px; font-weight: 600; }
.mark-desc {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(-10px);
  max-width: 300px; width: max-content; min-width: 200px; background: #fff; border: 1px solid #ddd;
  border-radius: 6px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  font-size: 13px; opacity: 0; visibility: hidden; transition: all 0.2s ease; z-index: 10;
}
.mark-item:hover .mark-desc { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
/* Раскрытие расшифровки по нажатию — работает на всех страницах со схемой */
.mark-item.tip-open .mark-desc { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.mark-item.gap-wide { margin-left: 16px; }

/* ================= ТАБЛИЦЫ (базовые, десктоп) =================
   table-layout: auto — ширина колонок считается по содержимому,
   поэтому длинные слова никогда не вылезают за границы ячеек. */
.table-responsive {
  overflow-x: auto;
  margin: 24px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) #eef2f7;
}

.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #eef2f7; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }

/* Прокрутка внутри всплывающих окон — в стиле сайта (все ширины) */
.info-popup {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) #eef2f7;
}
.info-popup::-webkit-scrollbar { width: 8px; }
.info-popup::-webkit-scrollbar-track { background: #eef2f7; border-radius: 4px; }
.info-popup::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }
.info-popup::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }

.spec-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  margin: 16px 0;
  font-size: 14px;
}

.spec-table th,
.spec-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--border);
}

.spec-table thead th { background-color: #f8f9fa; font-weight: 600; }
.spec-table tbody tr:nth-child(even) { background-color: rgba(43, 125, 225, 0.02); }

.first-column {
  min-width: 140px;
  text-align: left;
  background-color: #fafafa;
}

/* Заголовок первой колонки не переносится по словам —
   «Номинальная» и «подача, л/ч» всегда целиком в ячейке */
.spec-table thead .first-column { white-space: nowrap; }

/* ================= КАРТОЧКИ =================
   min(...) в minmax защищает сетку от переполнения на узких экранах. */
.dosage-pump-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 24px;
  margin-top: 20px;
}
.pump-type-card, .product-card {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease; text-decoration: none; color: inherit;
}
.pump-type-card:hover, .product-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); }
.card-image { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; display: block; }
.pump-type-card h3, .product-card h3 { margin: 0 0 8px; font-size: 18px; }
.pump-type-card p, .product-card p { margin: 0; font-size: 14px; color: var(--text-muted); }

/* Карточки каталога комплектующих на span-разметке */
.product-card .product-title {
  font-size: 17px; font-weight: 600; color: #1a1a1a; line-height: 1.35; margin-bottom: 8px;
}
.product-card .product-desc {
  font-size: 14px; color: var(--text-muted); line-height: 1.5;
}

.download-btn {
  display: inline-block; padding: 12px 28px; border-radius: 8px; background-color: var(--accent);
  color: #ffffff !important; text-decoration: none; font-weight: 500; transition: all 0.15s ease;
}
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(43, 125, 225, 0.35); background-color: var(--accent-dark); }
.download-btn + .download-btn { margin-left: 10px; }

.contacts-wrapper { display: flex; flex-wrap: wrap; gap: 30px; margin-top: 30px; }
.contacts-info, .contacts-map { flex: 1; min-width: min(300px, 100%); }
.contacts-map iframe { width: 100%; height: 100%; min-height: 320px; border-radius: 8px; border: none; }

.mark-sep {
  align-self: flex-start;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  padding: 10px 2px 0;
  color: #333;
}

/* ================= 6. ПОДВАЛ (FOOTER) ================= */
.footer { background-color: #f5f7fa; padding: 40px 0 20px; margin-top: 60px; }
.footer-container { max-width: 1440px; margin: 0 auto; padding: 0 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 30px; }
.footer-col h4 { font-size: 18px; margin-bottom: 20px; }
.footer-links a { display: block; color: var(--text-muted); text-decoration: none; margin-bottom: 8px; transition: color 0.2s; }
.footer-links a:hover { color: var(--accent); }
.copyright { margin-top: 30px; padding-top: 20px; border-top: 1px solid #e0e0e0; text-align: center; font-size: 13px; color: var(--text-muted); }
.privacy-btn {
  display: inline-block; padding: 8px 16px; background-color: #f5f5f5; border: 1px solid #e0e0e0;
  border-radius: 6px; color: #222; text-decoration: none; font-size: 14px; transition: all 0.2s;
}
.privacy-btn:hover { background-color: #fff; border-color: #ccc; }

/* ================= ПОЛОСА КОНТАКТОВ (мобильная) ================= */
.mobile-contacts-bar {
  display: none;
  position: relative;
  background: #f5f7fa;
  border-bottom: 1px solid var(--border);
  padding: 10px 15px;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  z-index: 99;
  flex-wrap: wrap;
}

.mobile-contact-link {
  text-decoration: none;
  color: var(--text-color);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.2s;
}

.mobile-contact-link:hover { color: var(--accent); }

/* ================= 7. АДАПТИВ (MOBILE ≤ 768px) ================= */
@media (max-width: 768px) {
  html, body {
    width: 100%;
    overflow-x: hidden;
    position: relative;
  }

  /* Фиксированный фон на мобильных браузерах работает некорректно */
  body.with-bg { background-attachment: scroll; }

  .header {
    height: 100px;
    background-position: center left;
  }

  .mobile-toggle {
    display: flex;
    position: fixed;
    top: 108px;
    right: 15px;
    margin-top: 0;
    transform: none;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  .header-contacts { display: none; }
  .mobile-contacts-bar { display: flex; }

  .main-nav {
    position: static;
    transform: none;
    width: 100%;
  }

  .main-nav .nav-list {
    position: fixed;
    top: 170px;
    right: -100%;
    left: auto;
    width: 85vw;
    max-width: 320px;
    height: calc(100vh - 170px);
    background: #fff;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    padding: 20px 0;
    z-index: 999;
    display: block;
    flex-direction: column;
    transition: right 0.3s ease;
    overflow-y: auto;
  }

  .main-nav .nav-list.active { right: 0; }

  .nav-list a, .has-dropdown > a, .has-submenu > a {
    display: block; padding: 14px 20px; border-bottom: 1px solid #eee;
  }

  .dropdown-menu, .submenu {
    position: static;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  }
  .dropdown-menu { border-left: 2px solid var(--accent); margin-left: 20px; }
  .submenu { border-top: 1px solid #eee; padding-left: 15px; }

  .has-dropdown.dropdown-open > .dropdown-menu,
  .has-submenu.submenu-open > .submenu {
    max-height: 1000px; opacity: 1; padding-top: 10px; padding-bottom: 10px;
  }

  .has-dropdown > a::after, .has-submenu > a::after {
    content: ' ▼'; float: right; font-size: 0.7em; margin-top: 6px; transition: transform 0.3s ease;
  }
  .has-dropdown.dropdown-open > a::after,
  .has-submenu.submenu-open > a::after { transform: rotate(180deg); }

  .membrane-intro-wrapper { flex-direction: column; }
  .membrane-main-image { width: 100%; margin-bottom: 16px; }

  .container { width: 100%; padding: 0 15px; }

  .scroll-top-btn {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .download-buttons { flex-direction: column; width: 100%; }

  .download-buttons .download-btn {
    width: 100%;
    text-align: center;
    margin-left: 0 !important;
    padding: 14px 20px;
  }

  .marking-scheme { justify-content: center; }
  .mark-sep { font-size: 18px; padding: 8px 2px 0; }

  .mark-desc {
    bottom: auto !important;
    top: calc(100% + 8px);
    width: auto !important;
    max-width: min(300px, calc(100vw - 30px)) !important;
    min-width: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(10px);
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .mark-item:hover .mark-desc,
  .mark-item:focus .mark-desc,
  .mark-item:focus-within .mark-desc,
  .mark-item.tip-open .mark-desc {
    transform: translateX(-50%) translateY(0);
  }

  .mark-item:first-child .mark-desc {
    left: 0 !important;
    transform: translateX(0) translateY(0);
  }

  .mark-item:last-child .mark-desc {
    left: auto !important;
    right: 0 !important;
    transform: translateX(0) translateY(0);
  }

  .mark-item.tip-open:first-child .mark-desc,
  .mark-item.tip-open:last-child .mark-desc {
    transform: translateX(0) translateY(0);
  }

  /* ===== ТАБЛИЦА 1 (основной ряд до 4 кВт) на мобильных =====
     Первая колонка — вертикальный текст, остальные сжимаются,
     значения переносятся по словам и остаются в границах ячеек. */
  .table-responsive:first-of-type .spec-table th,
  .table-responsive:first-of-type .spec-table td {
    padding: 6px 2px;
    font-size: 12px;
    line-height: 1.25;
  }

  .table-responsive:first-of-type .spec-table .first-column {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    width: 40px;
    min-width: 40px !important;
    max-width: 40px;
    padding: 6px 2px;
    vertical-align: middle;
    text-align: center;
    font-size: 12px;
    line-height: 1.15;
    letter-spacing: 0;
    height: auto;
  }

  /* ===== ТАБЛИЦА 2 (приводы 5,5 и 7,5 кВт) на мобильных =====
     Колонки растягиваются по содержимому (table-layout: auto),
     текст не переносится и не накладывается; при нехватке места
     появляется аккуратная горизонтальная прокрутка контейнера. */
  .table-responsive ~ .table-responsive .spec-table {
    width: auto;
    min-width: 100%;
    table-layout: auto;
  }

  .table-responsive ~ .table-responsive .spec-table th,
  .table-responsive ~ .table-responsive .spec-table td {
    white-space: nowrap;
    font-size: 13px;
    padding: 8px 10px;
    line-height: 1.3;
  }

  .table-responsive ~ .table-responsive .spec-table .first-column {
    writing-mode: horizontal-tb;
    min-width: 0;
    max-width: none;
    width: auto;
    text-align: center;
  }
}

/* ================= 8. АДАПТИВ (МАЛЕНЬКИЕ ЭКРАНЫ ≤ 320px) ================= */
@media (max-width: 320px) {
  .header {
    height: auto;
    padding: 15px 0;
    min-height: 80px;
  }

  .main-nav {
    position: static;
    transform: none;
    text-align: center;
    margin-top: 0;
  }

  .content-overlay { padding: 20px; }

  /* Гамбургер остаётся в шапке, а не в середине экрана */
  .mobile-toggle {
    top: 14px;
    margin-top: 0;
  }

  /* Полоса контактов в одну строку, чтобы меню не смещалось */
  .mobile-contacts-bar { padding: 8px 12px; gap: 8px; }
  .mobile-contact-link { font-size: 11.5px; }

  .main-nav .nav-list {
    top: 116px;
    height: calc(100vh - 116px);
  }

  .dosage-pump-types { gap: 16px; }
  .pump-type-card, .product-card { padding: 18px; }
}

/* ================= 9. СНИЖЕНИЕ АНИМАЦИИ ================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }
  .pump-type-card:hover, .product-card:hover,
  .download-btn:hover, .scroll-top-btn.visible { transform: none !important; }
}