/* iOS PWA layout — fill real window height (not Safari address-bar svh). */
:root {
  --app-height: 100%;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  background: #ffffff !important;
}

html,
body {
  background: #ffffff !important;
  margin: 0;
  padding: 0;
}

html,
body,
#root,
.app-root {
  height: var(--app-height, 100%) !important;
  min-height: var(--app-height, 100%) !important;
  overflow: hidden !important;
}

/* WebView اندروید (JamNative): max-height باعث صفحه سفید/کلیپ می‌شد */
html.jam-native,
html.jam-native body,
html.jam-native #root,
html.jam-native .app-root {
  height: 100% !important;
  min-height: 100% !important;
  max-height: none !important;
}

#root,
.app-root {
  background: #ffffff !important;
}

@media all and (display-mode: browser) {
  @supports (height: 100svh) {
    html:not(.jam-native),
    html:not(.jam-native) body,
    html:not(.jam-native) #root {
      height: 100svh !important;
      min-height: 100svh !important;
      max-height: 100svh !important;
    }
  }
  /* The fixed app follows the visual viewport (the loader keeps --app-height in sync), so
     a keyboard that only shrinks the visual viewport does not cover the composer. */
  html:not(.jam-native) .app-root {
    height: var(--app-height, 100svh) !important;
    min-height: var(--app-height, 100svh) !important;
    max-height: var(--app-height, 100svh) !important;
  }
}

@media all and (display-mode: standalone),
  all and (display-mode: fullscreen),
  all and (display-mode: minimal-ui) {
  html:not(.jam-native),
  html:not(.jam-native) body,
  html:not(.jam-native) #root,
  html:not(.jam-native) .app-root {
    height: var(--app-height, 100dvh) !important;
    min-height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    background: #ffffff !important;
  }

  @supports (height: 100lvh) {
    html:not(.jam-native),
    html:not(.jam-native) body,
    html:not(.jam-native) #root,
    html:not(.jam-native) .app-root {
      height: var(--app-height, 100lvh) !important;
      min-height: var(--app-height, 100lvh) !important;
      max-height: var(--app-height, 100lvh) !important;
    }
  }
}

.messenger {
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  background: #f1ede7;
}

@media (max-width: 768px) {
  .list-header {
    padding-top: max(14px, env(safe-area-inset-top, 0px)) !important;
    background: #ffffff !important;
  }

  .chat-header,
  .settings-panel .settings-header {
    padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
    background: #ffffff !important;
  }

  .nav-rail {
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* The app's own dark theme (chosen in its settings; the phone's dark mode is ignored). */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] #root,
html[data-theme="dark"] .app-root {
  background: #12141a !important;
}

@media (max-width: 768px) {
  html[data-theme="dark"] .list-header,
  html[data-theme="dark"] .chat-header,
  html[data-theme="dark"] .settings-panel .settings-header {
    background: #1f2c34 !important;
  }
}
