/* ============================================================
   MOBILE.CSS — адаптивная (мобильная) версия админ-панели MIGI Parser.
   Подключается ПОСЛЕДНИМ файлом стилей, чтобы аккуратно переопределять
   десктопные правила только на маленьких экранах. Ничего не удаляет
   и не ломает desktop-версию (все правила — внутри @media).
   ============================================================ */

/* Кнопка гамбургер-меню — по умолчанию скрыта, появляется только на мобильных */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 220;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 19px;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Затемнение позади выезжающего меню */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 399;
}

@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }

  #main-screen { position: relative; }

  /* Меню теперь выезжает поверх контента, а не сжимается в узкую полоску иконок —
     раньше подписи пунктов меню не помещались в 54px и «ломали» вёрстку. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 78vw;
    max-width: 300px;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  #main-screen.sidebar-open .sidebar { transform: translateX(0); box-shadow: 4px 0 28px rgba(0, 0, 0, .3); }
  #main-screen.sidebar-open .sidebar-backdrop { display: block; }

  .sidebar-logo, .sidebar-status, .logout-btn, .theme-toggle span { display: revert; }
  .nav-item { padding: 12px 16px; font-size: 14px; }

  .content { padding: 60px 16px 24px; }

  /* Заголовок страницы — вертикально, кнопки на всю ширину, ничего не обрезается */
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Сетки карточек — компактнее и без горизонтального выпирания */
  .stats-grid, .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .offers-grid, .persons-grid, .src-grid, .mk-grid, .tpl-grid,
  .type-cards, .preset-grid, .panel-grid-2, .kw-explain {
    grid-template-columns: 1fr !important;
  }

  /* Таблицы — горизонтальная прокрутка вместо раздавленных колонок */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  th, td { padding: 8px 10px; font-size: 12.5px; }

  /* Тулбары и фильтры — в столбик, инпуты на всю ширину */
  .filter-bar, .dash-toolbar, .tpl-toolbar, .kw-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar input, .filter-bar select,
  .tpl-toolbar input, .tpl-toolbar select,
  .kw-toolbar input, .kw-toolbar select { width: 100%; }

  /* Формы — всегда одна колонка */
  .form-row-2, .prs-form, .kw-cols { grid-template-columns: 1fr !important; }

  /* Модалки — на весь экран, удобнее пролистывать пальцем */
  .modal { width: 100vw !important; max-width: 100vw !important; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal-header, .modal-footer { border-radius: 0; flex-wrap: wrap; }
  .modal-body { padding: 16px; }

  /* Чаты — список и переписка друг под другом */
  .tg-wrap { flex-direction: column; height: auto; }
  .tg-side { width: 100%; max-width: 100%; max-height: 280px; border-right: none; border-bottom: 1px solid var(--nx-border, var(--border)); }
  .chats-layout { grid-template-columns: 1fr; height: auto; }
  .chats-sidebar { max-height: 220px; }

  /* Карточки офферов/аккаунтов/маркетплейса — кнопки переносятся, не вылезают за край экрана */
  .offer-card-actions, .acc-actions, .mk-actions, .acc-top, .acc-badges { flex-wrap: wrap; }
  .acc-badges { margin-left: 0; }

  /* Панель настроек колонок — не должна вылезать за правый край экрана */
  .col-settings-panel { right: 0; left: auto; max-width: 88vw; }

  /* Мастер настройки — шаги переносятся по нескольку в ряд */
  .steps { gap: 6px; }
  .step-pill { font-size: 11px; padding: 5px 10px; }
}

@media (max-width: 480px) {
  .stats-grid, .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 56px 12px 20px; }
  .login-box { width: 92vw; padding: 32px 20px; }
  .kpi-value { font-size: 22px; }
  .stat-card .stat-value { font-size: 24px; }
  .page-header h1 { font-size: 19px; }
  .btn { padding: 8px 12px; }
}
