/* mobile.css — адаптация ЛК для телефонов (до 767px) */
#nav-menu .mb-ic, #nav-menu .mb-short { display: none; }
@media (max-width: 767px) {
  html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  body { --mb-tab-h: 62px; }
  #app { padding: 12px !important; padding-bottom: calc(var(--mb-tab-h) + 16px + env(safe-area-inset-bottom)) !important; }

  /* Шапка */
  #app > div:first-child { margin-bottom: 14px !important; gap: 8px; justify-content: space-between; }
  #app > div:first-child > div:first-child { min-width: 0 !important; gap: 8px !important; }
  #app > div:first-child > div:first-child > div:first-child { width: 34px; height: 34px; }
  #app > div:first-child h1 { font-size: 19px !important; line-height: 1.2; }
  #cabinet-id { display: none !important; }
  #user-menu-container { min-width: 0 !important; gap: 6px !important; }
  #user-menu-container .text-right { display: none !important; }
  #user-menu-container button { padding: 8px 10px !important; font-size: 0 !important; gap: 0 !important; border-radius: 10px !important; }
  #user-menu-container button svg, #user-menu-container button i { width: 18px !important; height: 18px !important; }

  /* Нижнее меню вкладок */
  #nav-menu {
    position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 900;
    display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 0 !important;
    background: rgba(255,255,255,.97); border-top: 1px solid #e5e7eb;
    padding: 4px 4px env(safe-area-inset-bottom) !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,.05);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  #nav-menu > button {
    position: relative; display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: var(--mb-tab-h); padding: 6px 2px !important; margin: 0 !important;
    background: transparent !important; border: 0 !important; border-radius: 12px !important;
    color: #6b7280 !important; font-size: 11px !important; font-weight: 500 !important; line-height: 1.1 !important;
    -webkit-tap-highlight-color: transparent; white-space: nowrap;
  }
  #nav-menu > button.bg-gray-900 { color: #111827 !important; font-weight: 600 !important; }
  #nav-menu > button.bg-gray-900 .mb-ic { background: #111827; color: #fff; }
  #nav-menu .mb-ic { display: flex; align-items: center; justify-content: center; width: 44px; height: 28px; border-radius: 14px; transition: background .15s; }
  #nav-menu .mb-ic svg { width: 20px; height: 20px; }
  #nav-menu .mb-long { display: none; }
  #nav-menu .mb-short { display: inline; }
  #nav-menu .mb-lbl { display: block; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #nav-menu .mx-nav-badge { position: absolute !important; top: 4px; left: 50%; margin-left: 8px !important; z-index: 1; }

  /* Поля ввода: 16px, чтобы iOS не увеличивал страницу */
  input, textarea, select { font-size: 16px !important; }

  /* Модальные окна — «шторка» снизу */
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal-content, .modal-overlay > div {
    width: 100% !important; max-width: 100% !important; max-height: 92vh !important; max-height: 92dvh !important;
    border-radius: 18px 18px 0 0 !important; margin: 0 !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; overflow-y: auto !important;
  }
  .modal-content .grid { grid-template-columns: 1fr !important; }

  /* Широкие таблицы — горизонтальная прокрутка внутри блока */
  #views-container table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #views-container { min-width: 0; }

  /* ===== Чат ===== */
  #mx-root .mx-tabs { overflow-x: auto; }
  #mx-root .mx-chat { height: var(--mb-chat-h, calc(100vh - 200px)) !important; min-height: 360px !important; gap: 0 !important; }
  #mx-root .mx-list { border-radius: 14px; }
  #mx-root .mx-item { padding-top: 12px; padding-bottom: 12px; }

  /* Открытый диалог — на весь экран */
  #mx-root .mx-chat.show-dialog .mx-dialog {
    position: fixed !important; left: 0; right: 0; top: var(--mb-vvt, 0); z-index: 950;
    height: var(--mb-vvh, 100vh) !important; height: var(--mb-vvh, 100dvh) !important;
    border-radius: 0 !important; border: 0 !important; margin: 0 !important; background: #fff;
  }
  #mx-root .mx-dlg-head { padding: 8px 10px !important; padding-top: calc(8px + env(safe-area-inset-top)) !important; gap: 8px !important; min-height: 56px; }
  #mx-root .mx-dlg-head .mx-icon-btn { width: 40px; height: 40px; }
  #mx-root .mx-msgs { padding: 12px 10px !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  #mx-root .mx-bubble { max-width: 84% !important; font-size: 15px; }
  #mx-root .mx-img { max-width: 220px; max-height: 220px; }
  #mx-root .mx-composer { padding: 8px !important; padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important; gap: 6px !important; }
  #mx-root .mx-input { border-radius: 20px !important; padding: 9px 14px !important; max-height: 120px !important; min-height: 42px; }
  #mx-root .mx-send { width: 42px; height: 42px !important; padding: 0 !important; border-radius: 50% !important; justify-content: center; flex: none; }
  #mx-root .mx-send span { display: none; }
  #mx-root .mx-send svg { width: 18px !important; height: 18px !important; }
  #mx-root .mx-info { position: fixed !important; inset: 0 !important; width: 100% !important; z-index: 960; padding-top: calc(16px + env(safe-area-inset-top)) !important; }

  body.mb-dialog-open { overflow: hidden !important; }
  body.mb-dialog-open #nav-menu { display: none !important; }

  /* Настройки бота */
  #mx-root .mx-row, #mx-root .mx-row-flex { flex-wrap: wrap; }
  #mx-root .mx-savebar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); bottom: calc(var(--mb-tab-h) + env(safe-area-inset-bottom)) !important; }
}
