/* mobile.css — мобильная адаптация админки iPrime (PWA).
   Подключается на всех страницах; на десктопе (>900px) ничего не меняет.
   Базовая вёрстка: body{display:flex}, .sidebar{position:fixed}, .main{margin-left:228px}.
   На мобильном sidebar остаётся fixed, но превращается в верхнюю панель в 48px. */

@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; }

  body { display: block; min-height: auto; padding-top: 48px; }

  /* Верхняя панель вместо бокового меню */
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; width: 100%;
    height: 48px; min-height: 0; flex-direction: row; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--border);
    overflow: visible; z-index: 100;
  }
  .sidebar-brand { height: 48px; padding: 0 10px; border-bottom: 0; flex: 0 0 auto; }
  .sidebar-brand .logo-text { display: none; }
  .sidebar-brand img { height: 20px !important; width: auto !important; }

  .sidebar-nav {
    display: flex; flex-direction: row; align-items: center;
    gap: 2px; height: 48px; padding: 0 6px; margin: 0;
    overflow-x: auto; overflow-y: hidden; flex: 1 1 auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav .nav-group { display: none; }
  .sidebar-nav .nav-item {
    white-space: nowrap; margin: 0; flex: 0 0 auto;
    padding: 7px 9px; font-size: 12.5px;
  }
  .sidebar-nav .nav-item .icon svg { width: 15px; height: 15px; }

  .sidebar-footer {
    height: 48px; display: flex; align-items: center;
    padding: 0 6px; border-top: 0; margin: 0; flex: 0 0 auto;
  }
  .sidebar-footer .nav-item { font-size: 12px; padding: 7px 9px; }

  .main { margin-left: 0 !important; width: 100%; min-height: auto; flex: none; }
  .page { padding: 10px 12px 48px; max-width: none; }

  /* Верхняя панель страницы */
  .topbar { height: auto; min-height: 46px; padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-breadcrumb { display: none; }

  /* Сетки */
  .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .card { border-radius: var(--r-lg, 12px); }

  /* Списки */
  .list-row { flex-wrap: wrap; gap: 6px; }
  .list-row-content { min-width: 0; }
  .list-row-title { overflow-wrap: anywhere; }
  .list-row-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .list-row-actions .btn, .list-row-actions a { padding: 7px 10px; font-size: 12.5px; }

  /* Таблицы: прокрутка вместо сжатия */
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  /* Модалки — bottom-sheet */
  .modal-overlay { align-items: flex-end; }
  .modal { max-width: 100%; margin: 0 6px; max-height: 92vh; border-radius: 16px 16px 0 0; }

  /* Крупные тапы, без автозума на iOS */
  .btn { padding: 9px 14px; font-size: 13px; }
  .form-input, .form-select, textarea, input[type="text"], input[type="password"], input[type="number"] { font-size: 16px; }
  .modal-close { width: 34px; height: 34px; }

  /* Кнопка установки приложения */
  .pwa-install-btn {
    position: fixed; right: 12px; bottom: 12px; z-index: 300;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 14px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
    box-shadow: 0 6px 18px rgba(36,105,227,.35); border: 0;
  }
  .pwa-ios-hint {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 300;
    background: #1f2430; color: #fff; border-radius: 12px;
    padding: 10px 12px; font-size: 12.5px; line-height: 1.4;
    display: flex; gap: 8px; align-items: flex-start;
    box-shadow: 0 6px 18px rgba(0,0,0,.3);
  }
  .pwa-ios-hint button { background: none; border: 0; color: #9bb8f0; font-size: 12.5px; margin-left: auto; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .page { padding: 8px 10px 44px; }
  .topbar-title { font-size: 13px; }
  .card-header { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .modal-body { padding: 14px; }
  .sidebar-nav .nav-item { font-size: 12px; padding: 6px 8px; }
}

/* В установленном приложении учитываем «вырезы» экрана */
@media (display-mode: standalone) {
  body { padding-top: calc(48px + env(safe-area-inset-top)); }
  .sidebar { padding-top: env(safe-area-inset-top); height: calc(48px + env(safe-area-inset-top)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
