/* livechat-hub-mobile.css — phone layer for this app's own shell (loaded LAST).
   Targets ~400px: no horizontal page scroll, 44px touch targets, 16px inputs
   (stops iOS focus-zoom), safe-area insets, collapsing top-bar nav.
   chatkit (Master inbox) has its own phone layout — nothing here edits it; we
   only give it a full-bleed, inset-aware host (#lch-master). */

/* ── all widths ── */
html, body { max-width: 100%; overflow-x: hidden; }
body:not(.lch-ch) { height: 100%; }
@supports (height: 100dvh) { body:not(.lch-ch) { height: 100dvh; } }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); box-sizing: border-box; }
#lch-topbar { position: relative; z-index: 70; padding-top: max(10px, env(safe-area-inset-top)); }
#lch-login-card { width: min(320px, calc(100vw - 32px)); max-height: 100%; overflow-y: auto; }
#lch-more-btn { display: none; }
#lch-nav { display: contents; }
#profile-switcher { order: 2; }
#lch-tools { order: 0; }
#lch-back-to-rainbow { order: 1; }
#lch-logout-btn { order: 3; }
#toast-container { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); max-width: calc(100vw - 32px); }

/* ── phone ── */
@media (max-width: 640px) {
  /* inputs: 16px or iOS zooms on focus; 44px tall */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select { min-height: 44px; }
  #lch-login-card input { padding: 10px 12px; min-height: 44px; }
  #lch-login-card button { min-height: 44px; font-size: 16px; }
  #lch-login-overlay { padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); box-sizing: border-box; }

  /* top bar: brand + business switcher + ⋯ ; everything else folds into a panel */
  #lch-topbar { padding-left: 10px; padding-right: 10px; }
  #lch-right { gap: 6px; min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
  #lch-more-btn { display: inline-flex; align-items: center; justify-content: center; order: 4; width: 44px; height: 44px; padding: 0; border: none; background: none; border-radius: 10px; color: #00a884; cursor: pointer; flex: 0 0 auto; }
  #lch-more-btn[aria-expanded="true"] { background: #e7fbf6; }
  #profile-switcher { min-width: 0; }
  #profile-switcher-btn { min-height: 44px; max-width: 100%; }
  #profile-switcher-dropdown { max-width: calc(100vw - 20px); }
  #profile-switcher-dropdown > * { min-height: 44px; }
  #lch-nav { display: none; position: absolute; top: 100%; left: 8px; right: 8px; margin-top: 4px; padding: 6px; flex-direction: column; gap: 2px; z-index: 75;
    background: var(--lch-surface, #fff); border: 1px solid var(--wa-border, #e9edef); border-radius: 12px; box-shadow: 0 8px 24px rgba(11, 20, 26, .18); }
  #lch-topbar.lch-nav-open #lch-nav { display: flex; }
  #lch-nav .lch-link-btn { width: 100%; min-height: 48px; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 15px; order: 0; }
  #lch-nav .lch-hide-sm { display: inline !important; }
  #lch-nav #lch-tools { width: 100%; display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0 6px; border-bottom: 1px solid var(--wa-border, #e9edef); order: 0; }
  #lch-nav .lch-tool { width: 44px; height: 44px; }

  /* touch targets: 44px */
  .lch-tool, .lch-link-btn { min-width: 44px; min-height: 44px; }
  .lc-sidebar-action-btn, .lc-sidebar-menu-btn, .lc-header-menu-btn, .lc-search-btn, .lc-back-btn,
  .lc-emoji-btn, .lch-comp-btn, .lc-schedule-btn, .lc-attach-btn, .lc-send-btn, .lc-mic-btn,
  .lch-hdr-btn, .lc-header-actions button { min-width: 44px; min-height: 44px; }
  .lch-hdr-btn { width: 44px; }
  .lc-input-area .lch-comp-btn { width: 44px; }
  .lc-chip { min-height: 44px; min-width: 44px; justify-content: center; }
  .lc-search { min-height: 44px; }
  .lc-header-info { min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
  .lch-select, .lch-pill-btn, .lch-linkish { min-height: 44px; }
  .lch-radio, .lch-check { min-height: 44px; align-items: center; }
  /* tiny in-row controls keep their look; the tap area grows around them */
  .lc-bubble-chevron, .lc-ha-btn { position: relative; }
  .lc-bubble-chevron::after, .lc-ha-btn::after { content: ''; position: absolute; inset: -12px; }

  /* composer + chat list clear the home indicator */
  .lc-input-area { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .lc-sidebar { padding-bottom: env(safe-area-inset-bottom); }
  #lc-input-box { min-height: 44px; }
  .lch-popover { left: 8px; right: 8px; }
  .lch-settings { width: calc(100vw - 24px); }

  /* Master (chatkit) mounts full-bleed; chatkit owns the layout inside */
  #lch-master { padding: 0 !important; }
}

/* ── channels page shell ── */
@media (max-width: 640px) {
  .lch-ch header { padding: max(12px, env(safe-area-inset-top)) 16px 12px; }
  .lch-ch header a { min-height: 44px; display: inline-flex; align-items: center; }
  .lch-ch main { padding: 12px 12px max(16px, env(safe-area-inset-bottom)); }
  .lch-ch .card { padding: 12px; }
  .lch-ch table, .lch-ch tbody, .lch-ch tr, .lch-ch td { display: block; width: 100%; }
  .lch-ch thead { display: none; }
  .lch-ch tr { border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
  .lch-ch td { display: flex; justify-content: space-between; align-items: center; gap: 12px; white-space: normal; border-bottom: 1px solid var(--border); padding: 8px 0; min-width: 0; text-align: right; }
  .lch-ch td:last-child { border-bottom: none; }
  .lch-ch td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex: 0 0 auto; text-align: left; }
  .lch-ch td[colspan]::before { content: none; }
  .lch-ch td.hub code { max-width: 60vw; }
  .lch-ch .switch { min-height: 44px; min-width: 88px; font-size: 14px; }
  .lch-ch form { grid-template-columns: 1fr; }
  .lch-ch input, .lch-ch select { font-size: 16px; min-height: 44px; }
  .lch-ch button.primary { min-height: 44px; font-size: 16px; }
}

/* ── pinned like the WhatsApp app (2026-10-17): the page itself never scrolls or rubber-bands on a phone;
   only the chat list / message list scroll inside it ── */
@media (max-width: 640px) {
  html, body:not(.lch-ch) { overflow: hidden; overscroll-behavior: none; }
  .lc-container { height: 100%; max-height: 100%; }
  .lc-messages, .lc-chat-list { overscroll-behavior: contain; }
}
