/*
 * avia-spektr.ru — Мобильная адаптация (все страницы)
 * =====================================================
 * Подключить в <head> КАЖДОГО PHP-файла сайта,
 * после основного style.css:
 *
 *   <meta name="viewport" content="width=device-width, initial-scale=1">
 *   <link href="mobile.css" rel="stylesheet">
 *
 * Десктопная вёрстка (≥ 960px) НЕ затрагивается.
 * Все правила обёрнуты в @media (max-width: 959px).
 */

/* ════════════════════════════════════════════════════
   ПЛАНШЕТ + МОБИЛЬНЫЙ  (< 960px)
   ════════════════════════════════════════════════════ */
@media screen and (max-width: 959px) {

  /* ── Глобальный сброс ── */
  html {
    overflow-x: hidden;
  }
  body {
    overflow-x: hidden;
    min-width: 0 !important;
    background-size: auto !important;
  }

  /* ── Все таблицы-обёртки → блоки ── */
  table,
  tbody,
  tr,
  td,
  th {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box !important;
  }

  /* Исключение: таблицы внутри контента (не структурные),
     отмечены классом .data-table — оставляем table-layout */
  table.data-table,
  table.data-table tbody,
  table.data-table tr,
  table.data-table td,
  table.data-table th {
    display: table !important;
    display: revert !important;
  }

  /* ── Баннер ── */
  #Table_01,
  #Table_01 td,
  #Table_01 tr {
    height: auto !important;
  }
  #Table_01 img,
  img[width="960"],
  img[style*="width: 960px"] {
    width: 100% !important;
    height: auto !important;
    display: block !important;
  }

  /* ── Навигационное меню #Table_02 ── */
  #Table_02 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: #1d4189 !important;
    padding: 4px 2px !important;
    gap: 2px !important;
    width: 100% !important;
    height: auto !important;
    box-sizing: border-box !important;
  }
  #Table_02 tbody,
  #Table_02 tr {
    display: contents !important;
    width: auto !important;
  }
  #Table_02 td {
    display: inline-flex !important;
    width: auto !important;
    height: auto !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  /* Кнопки меню — картинки скрываем, делаем текстовые ссылки */
  #Table_02 td a img {
    display: none !important;
  }
  #Table_02 td a {
    display: inline-block !important;
    padding: 7px 11px !important;
    color: #fff !important;
    font-family: tahoma, verdana, sans-serif !important;
    font-size: 12px !important;
    font-weight: bold !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    border-radius: 3px !important;
    background: rgba(255,255,255,0.08) !important;
  }
  #Table_02 td a:active {
    background: rgba(255,255,255,0.22) !important;
  }

  /* Текст кнопок из alt-атрибута img */
  #Table_02 td a[href="work.php"]::after        { content: "Авиаработы"; }
  #Table_02 td a[href="publication.php"]::after { content: "Публикации"; }
  #Table_02 td a[href="demand.php"]::after      { content: "Наши партнеры"; }
  #Table_02 td a[href="photo1.php"]::after      { content: "Фото и видео"; }
  #Table_02 td a[href="price.php"]::after       { content: "Цены"; }
  #Table_02 td a[href="contact.php"]::after     { content: "Контакты"; }

  /* ── Основной контент #Table_03 ── */
  #Table_03 {
    width: 100% !important;
    padding: 0 !important;
  }
  #Table_03 > tbody > tr > td {
    padding: 10px 12px !important;
    width: 100% !important;
  }

  /* ── Подменю «Авиаработы» (work_menu) ── */
  p.topmenu {
    text-align: center !important;
    line-height: 2.2 !important;
    font-size: 13px !important;
    padding: 4px 8px !important;
  }
  p.topmenu a.topmenu {
    display: inline-block !important;
    white-space: nowrap !important;
  }

  /* ── Типографика ── */
  p, span, div, li, td, th {
    word-break: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
  }

  /* Снимаем фиксированный text-indent на мобиле */
  p[style*="text-indent"],
  .MsoNormal[style*="text-indent"],
  .MsoNoSpacing[style*="text-indent"] {
    text-indent: 0 !important;
  }

  /* Размеры шрифтов */
  span[style*="font-size: 11pt"] { font-size: 14px !important; }
  span[style*="font-size: 14pt"] { font-size: 17px !important; }
  span[style*="font-size: 20pt"] { font-size: 18px !important; }
  big { font-size: 105% !important; }
  big big { font-size: 110% !important; }
  big big big { font-size: 16px !important; }
  big big big big { font-size: 17px !important; }

  /* ── Изображения в тексте ── */
  img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
  }

  /* Убираем фиксированные размеры у картинок контента */
  img[style*="width: 460px"],
  img[style*="width: 697px"],
  img[style*="width: 252px"],
  img[style*="width: 500px"] {
    width: 100% !important;
    height: auto !important;
  }

  /* ── Страница ФОТО: сетка 2 колонки → 1 колонка ── */
  /* Таблица с фотогалереей */
  #Table_03 table[align="center"][border="0"] td {
    display: block !important;
    width: 100% !important;
    padding: 4px 0 !important;
  }
  #Table_03 table[align="center"][border="0"] tr {
    display: block !important;
    width: 100% !important;
  }
  #Table_03 table[align="center"][border="0"] img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
  }

  /* ── Страница ВИДЕО: iframe ── */
  iframe {
    width: 100% !important;
    height: auto !important;
    min-height: 200px !important;
    aspect-ratio: 16/9 !important;
    display: block !important;
    margin: 8px auto !important;
  }

  /* ── Страница КОНТАКТЫ ── */
  /* Таблица с реквизитами */
  table[style*="width: 935px"],
  table[style*="width: 100%"] {
    width: 100% !important;
  }
  /* Телефоны в колонке контактов */
  td small b,
  td b small {
    font-size: 15px !important;
    display: inline-block !important;
    line-height: 1.8 !important;
  }

  /* ── Страница ОСТАВИТЬ ЗАЯВКУ (demand.php) ── */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="date"],
  textarea,
  select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 14px !important;
    padding: 7px 8px !important;
    margin: 3px 0 !important;
  }
  .selectlist,
  select.selectlist {
    width: 100% !important;
    max-width: 100% !important;
  }
  input[type="radio"],
  input[type="checkbox"] {
    width: auto !important;
    margin-right: 6px !important;
  }
  input[type="submit"],
  input[type="button"],
  button {
    padding: 10px 16px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    min-height: 40px !important;
  }
  /* Таблица формы */
  table[style*="cellpadding"],
  table.table {
    width: 100% !important;
    font-size: 13px !important;
  }
  /* Календарь (popup) */
  #popup_container {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 9999 !important;
  }

  /* ── Страница РЕКЛАМНЫЕ МАТЕРИАЛЫ ── */
  img[style*="width: 697px"] {
    width: 100% !important;
    height: auto !important;
  }
  /* Две картинки side-by-side → стопкой */
  table[style*="width: 100%"] td[style*="vertical-align: top"] {
    display: block !important;
    width: 100% !important;
  }

  /* ── Нижнее меню (bottommenu) ── */
  tr[valign="bottom"] > td[align="center"] {
    padding: 10px 8px !important;
    text-align: center !important;
    line-height: 2.4 !important;
  }
  a.bottommenu {
    display: inline-block !important;
    white-space: nowrap !important;
    font-size: 12px !important;
    padding: 2px 4px !important;
  }

  /* ── Числовое меню фотогалереи (numericmenu) ── */
  tr[valign="bottom"] td p.bottommenu {
    line-height: 2.2 !important;
    font-size: 13px !important;
  }

  /* ── Футер — строка с телефонами и копирайтом ── */
  tr[valign="middle"] > td {
    padding: 10px 12px !important;
    text-align: left !important;
  }
  /* Таблица футера: flex-колонка */
  tr[valign="middle"] table,
  tr[valign="middle"] table tbody,
  tr[valign="middle"] table tr {
    display: block !important;
    width: 100% !important;
  }
  tr[valign="middle"] table td {
    display: block !important;
    width: 100% !important;
    text-align: left !important;
    height: auto !important;
  }
  /* Телефоны кликабельны */
  .phone, nobr.phone {
    font-size: 15px !important;
    display: block !important;
    margin: 4px 0 !important;
  }
  p.copymenu {
    text-align: left !important;
    margin-top: 8px !important;
    font-size: 12px !important;
    color: #555 !important;
  }

  /* ── Удаляем лишние отступы ── */
  td[style*="height: 48px"],
  td[height="48"],
  td[height="28"] {
    height: auto !important;
    min-height: 0 !important;
  }
  td[width="35%"] {
    width: 100% !important;
  }

  /* ── Убираем горизонтальный скролл от фиксированных ширин ── */
  [width="960"], [style*="width: 960px"],
  [width="964"], [style*="width: 964px"],
  [width="935"], [style*="width: 935px"],
  [style*="width: 960"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ── Таблицы с данными внутри контента ── */
  table.table td,
  table.table th {
    padding: 4px 6px !important;
    font-size: 12px !important;
    word-break: break-word !important;
  }

  /* ── h1 (заголовок «Наши партнёры» на demand.php) ── */
  h1 {
    font-size: 20px !important;
    text-align: center !important;
    margin: 8px 0 !important;
  }

  /* ── Списки (demand.php, avia.php) ── */
  li {
    margin-left: 16px !important;
    margin-right: 8px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  /* ── Ссылки на PDF в publication.php ── */
  a[href$=".pdf"] big big big big,
  a[href$=".pdf"] big big big,
  a[href$=".pdf"] big big {
    font-size: 15px !important;
    line-height: 1.7 !important;
    display: block !important;
    padding: 4px 0 !important;
  }

  /* ── Спецификация самолёта Спектр-30 (work.php) ──
     таблица характеристик — горизонтальный скролл */
  table[class="table"] {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

} /* конец @media max-width: 959px */


/* ════════════════════════════════════════════════════
   ТОЛЬКО СМАРТФОНЫ  (< 500px)
   ════════════════════════════════════════════════════ */
@media screen and (max-width: 499px) {

  /* Меню: 3 кнопки в ряд максимум */
  #Table_02 td a {
    font-size: 11px !important;
    padding: 6px 8px !important;
  }

  /* Подменю «Авиаработы» — каждая ссылка на новой строке */
  p.topmenu {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 0 !important;
    line-height: 2 !important;
  }

  /* Нижнее меню на маленьком экране */
  a.bottommenu {
    font-size: 11px !important;
  }

  /* Телефоны в футере — крупнее */
  small b,
  b small {
    font-size: 16px !important;
  }

  /* Фото галерея: чуть меньший отступ */
  #Table_03 table[align="center"][border="0"] td {
    padding: 3px 0 !important;
  }

  /* iframe видео */
  iframe {
    min-height: 180px !important;
  }

  /* Форма заявки */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px !important; /* предотвращает zoom на iOS */
  }

} /* конец @media max-width: 499px */

/* ════════════════════════════════════════════════════
   СТРАНИЦА КОНТАКТЫ — переструктурированный мобайл
   ════════════════════════════════════════════════════ */

/* Десктоп: скрываем мобильный блок */
.contact-mobile { display: none; }

@media screen and (max-width: 959px) {

  /* Скрываем оригинальную таблицу, показываем мобильный блок */
  .contact-desktop { display: none !important; }
  .contact-mobile  { display: block !important; }

  /* Блок с информацией */
  .contact-mobile-info {
    background: #f8f8f8;
    border-left: 4px solid #1d4189;
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: 0 4px 4px 0;
    font-family: 'Times New Roman', serif;
    font-size: 15px;
    line-height: 1.7;
  }
  .contact-mobile-info p { margin: 0 0 10px; }
  .contact-mobile-info p:last-child { margin: 0; }
  .contact-mobile-info a { color: #1d4189; }

  /* Блок с телефонами */
  .contact-mobile-phones {
    background: #1d4189;
    padding: 14px 16px;
    border-radius: 4px;
    margin-bottom: 12px;
  }
  .contact-mobile-phones p {
    margin: 0 0 8px !important;
    color: #fff !important;
    font-size: 15px !important;
  }
  .contact-mobile-phones p:last-child { margin: 0 !important; }
  .contact-mobile-phones strong { color: #fff; font-size: 13px; opacity: 0.75; }
  .contact-mobile-phones a {
    color: #fff !important;
    font-size: 18px !important;
    font-weight: bold !important;
    text-decoration: none !important;
    display: block !important;
    padding: 4px 0 !important;
  }
  .contact-mobile-phones a:active { opacity: 0.75; }
}
