/*
 * e2mp mobile app presentation
 *
 * These rules activate only after the Android/iOS WebView adds the
 * e2mp-native-navigation class. Browser pages keep their existing appearance.
 */

html.e2mp-native-navigation {
  scroll-padding-top: 12px;
  font-size: 16px;
}

html.e2mp-native-navigation header.topbar {
  display: none !important;
}

html.e2mp-native-navigation body {
  overflow-x: hidden !important;
  padding-bottom: 88px !important;
  background: #f3f6f8 !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.e2mp-native-navigation img,
html.e2mp-native-navigation video,
html.e2mp-native-navigation iframe {
  max-width: 100%;
}

/* Consistent spacing for the five main app destinations. */
html.e2mp-native-navigation body.dashboard-page .dashboard {
  padding: 12px !important;
}

html.e2mp-native-navigation body .qf-page {
  padding: 12px 12px 30px !important;
}

html.e2mp-native-navigation body .mr-wrap,
html.e2mp-native-navigation body .messages-view,
html.e2mp-native-navigation body .acct {
  padding: 14px 12px 32px !important;
}

html.e2mp-native-navigation body .profile-edit {
  width: calc(100% - 24px) !important;
  padding: 14px 0 32px !important;
}

html.e2mp-native-navigation body.dashboard-page .card,
html.e2mp-native-navigation body .qf-form-card,
html.e2mp-native-navigation body .mr-card,
html.e2mp-native-navigation body .messages-card,
html.e2mp-native-navigation body .acct-card,
html.e2mp-native-navigation body .profile-edit .pe-card {
  border-color: #dfe7eb !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 16px rgba(16, 42, 67, 0.06) !important;
}

/* Messages: readable type and touch targets on a phone. */
html.e2mp-native-navigation body.messages-page .messages-view {
  font-size: 15px !important;
  line-height: 1.55 !important;
}

html.e2mp-native-navigation body.messages-page .messages-head {
  gap: 11px !important;
  margin-bottom: 12px !important;
}

html.e2mp-native-navigation body.messages-page .messages-head-icon {
  width: 40px !important;
  height: 40px !important;
  flex-basis: 40px !important;
  font-size: 15px !important;
}

html.e2mp-native-navigation body.messages-page .messages-head p,
html.e2mp-native-navigation body.messages-page .messages-kicker {
  font-size: 11px !important;
}

html.e2mp-native-navigation body.messages-page .messages-head h1 {
  font-size: 21px !important;
}

html.e2mp-native-navigation body.messages-page .messages-card-top,
html.e2mp-native-navigation body.messages-page .messages-body {
  padding: 18px !important;
}

html.e2mp-native-navigation body.messages-page .messages-card h2 {
  font-size: 18px !important;
  line-height: 1.35 !important;
}

html.e2mp-native-navigation body.messages-page .messages-card-top p,
html.e2mp-native-navigation body.messages-page .messages-body > p {
  font-size: 14px !important;
  line-height: 1.6 !important;
}

html.e2mp-native-navigation body.messages-page .messages-role,
html.e2mp-native-navigation body.messages-page .messages-help-copy span,
html.e2mp-native-navigation body.messages-page .messages-signoff {
  font-size: 12px !important;
}

html.e2mp-native-navigation body.messages-page .messages-help {
  gap: 10px !important;
  margin-top: 16px !important;
}

html.e2mp-native-navigation body.messages-page .messages-help-card {
  min-height: 54px;
  padding: 11px !important;
}

html.e2mp-native-navigation body.messages-page .messages-help-copy strong {
  font-size: 13px !important;
}

html.e2mp-native-navigation body.messages-page .messages-signoff strong {
  font-size: 16px !important;
}

/* App-provided file preview and camera controls. */
html.e2mp-native-navigation [data-e2mp-attachments] {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 8px 0 12px;
  box-sizing: border-box;
}

html.e2mp-native-navigation [data-e2mp-attachments] * {
  box-sizing: border-box;
}

html.e2mp-native-navigation .e2mp-attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 8px;
  border-radius: 8px;
  background: #f2f6f5;
  color: #153b3c;
  font: 14px/1.4 sans-serif;
}

html.e2mp-native-navigation .e2mp-attachment-file img {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: contain;
}

html.e2mp-native-navigation .e2mp-attachment-file span {
  min-width: 0;
  overflow-wrap: anywhere;
}

html.e2mp-native-navigation .e2mp-attachment-hint {
  margin: 0 0 8px;
  color: #536965;
  font: 13px/1.45 sans-serif;
  overflow-wrap: normal;
  word-break: normal;
}

html.e2mp-native-navigation .e2mp-attachment-camera {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #ccdcd6;
  border-radius: 8px;
  background: #eef5f2;
  color: #17584b;
  font: 14px sans-serif;
}

@media (max-width: 480px) {
  html.e2mp-native-navigation body.messages-page .messages-help {
    grid-template-columns: 1fr !important;
  }
}

/* Shared safeguards for phones, foldables, tablets and landscape layouts. */
html.e2mp-native-navigation,
html.e2mp-native-navigation body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

html.e2mp-native-navigation body *,
html.e2mp-native-navigation body *::before,
html.e2mp-native-navigation body *::after {
  box-sizing: border-box;
}

html.e2mp-native-navigation body main,
html.e2mp-native-navigation body section,
html.e2mp-native-navigation body form,
html.e2mp-native-navigation body .container,
html.e2mp-native-navigation body .dashboard,
html.e2mp-native-navigation body .qf-page,
html.e2mp-native-navigation body .mr-wrap,
html.e2mp-native-navigation body .messages-shell,
html.e2mp-native-navigation body .acct,
html.e2mp-native-navigation body .profile-edit {
  min-width: 0;
  max-width: 100%;
}

html.e2mp-native-navigation body input,
html.e2mp-native-navigation body select,
html.e2mp-native-navigation body textarea,
html.e2mp-native-navigation body button {
  max-width: 100%;
}

html.e2mp-native-navigation body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html.e2mp-native-navigation body select,
html.e2mp-native-navigation body textarea {
  font-size: 16px !important;
}

html.e2mp-native-navigation body p,
html.e2mp-native-navigation body label,
html.e2mp-native-navigation body a,
html.e2mp-native-navigation body td,
html.e2mp-native-navigation body th,
html.e2mp-native-navigation body dd,
html.e2mp-native-navigation body span {
  overflow-wrap: anywhere;
}

html.e2mp-native-navigation body .table-responsive,
html.e2mp-native-navigation body .table-scroll,
html.e2mp-native-navigation body .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Restore readable dashboard type where the legacy phone stylesheet is tiny. */
html.e2mp-native-navigation body.dashboard-page .meta-item,
html.e2mp-native-navigation body.dashboard-page .premium-card p,
html.e2mp-native-navigation body.dashboard-page .action-card p {
  font-size: 12px !important;
  line-height: 1.4 !important;
}

html.e2mp-native-navigation body.dashboard-page .info-box .label {
  font-size: 11px !important;
}

html.e2mp-native-navigation body.dashboard-page .info-box .value,
html.e2mp-native-navigation body.dashboard-page .premium-card h3,
html.e2mp-native-navigation body.dashboard-page .action-card h4 {
  font-size: 13px !important;
  line-height: 1.35 !important;
}

html.e2mp-native-navigation body.dashboard-page .section-title h3,
html.e2mp-native-navigation body.dashboard-page .menu-title h3,
html.e2mp-native-navigation body.dashboard-page .list-head h3,
html.e2mp-native-navigation body.dashboard-page .side-header h3 {
  font-size: 15px !important;
}

html.e2mp-native-navigation body.dashboard-page .premium-card .btn {
  min-height: 44px;
  font-size: 12px !important;
}

/* Centre content on tablets while allowing cards to use the available width. */
@media (min-width: 768px) {
  html.e2mp-native-navigation body.dashboard-page .dashboard,
  html.e2mp-native-navigation body .qf-page,
  html.e2mp-native-navigation body .mr-wrap,
  html.e2mp-native-navigation body .messages-view,
  html.e2mp-native-navigation body .acct {
    width: min(100%, 1100px) !important;
    margin-right: auto !important;
    margin-left: auto !important;
    padding: 20px !important;
  }

  html.e2mp-native-navigation body .profile-edit {
    width: min(calc(100% - 40px), 1100px) !important;
    margin-right: auto !important;
    margin-left: auto !important;
  }

  html.e2mp-native-navigation body.messages-page .messages-shell {
    width: min(100%, 900px);
  }
}

/* Small phones: preserve useful space without allowing horizontal clipping. */
@media (max-width: 370px) {
  html.e2mp-native-navigation body.dashboard-page .dashboard,
  html.e2mp-native-navigation body .qf-page,
  html.e2mp-native-navigation body .mr-wrap,
  html.e2mp-native-navigation body .messages-view,
  html.e2mp-native-navigation body .acct {
    padding-right: 8px !important;
    padding-left: 8px !important;
  }

  html.e2mp-native-navigation body .profile-edit {
    width: calc(100% - 16px) !important;
  }

  html.e2mp-native-navigation body.dashboard-page .premium-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html.e2mp-native-navigation body.dashboard-page .premium-card .btn {
    width: 100%;
  }
}

/* Landscape phones have limited height: keep content usable with one page scroll. */
@media (max-height: 500px) and (orientation: landscape) {
  html.e2mp-native-navigation body {
    padding-bottom: 78px !important;
  }

  html.e2mp-native-navigation body.dashboard-page .menu-list.scroll-cap,
  html.e2mp-native-navigation body.dashboard-page .historical-body.scroll-cap,
  html.e2mp-native-navigation body.dashboard-page .list-table.scroll-cap {
    max-height: none !important;
  }
}

/* Shared authenticated mobile topbar.
   Keep the same two-row header on every portal module: account controls on
   top, primary navigation directly below. Native apps retain their own nav. */
@media (min-width: 981px) {
  html:not(.e2mp-native-navigation) body header.topbar .topbar-inner {
    width: 100% !important;
    max-width: 1800px !important;
    min-height: 58px !important;
    margin: 0 auto !important;
    padding: 7px 10px !important;
    gap: 18px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .brand {
    flex: 0 0 auto !important;
    margin: 0 !important;
    font-size: 23px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav {
    gap: 8px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav > a {
    min-height: 36px !important;
    padding: 8px 12px !important;
    gap: 7px !important;
    font-size: 12px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .topbar-actions {
    gap: 10px !important;
    padding-right: 0 !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .icon-btn {
    flex-basis: 34px !important;
    width: 34px !important;
    height: 34px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .user-chip {
    min-height: 40px !important;
    padding: 4px 10px 4px 4px !important;
    gap: 8px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .avatar {
    width: 32px !important;
    height: 32px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .user-meta .name {
    max-width: 140px !important;
    font-size: 11.5px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .user-meta .sub {
    font-size: 9.5px !important;
  }
}

@media (max-width: 767px) {
  html:not(.e2mp-native-navigation) body {
    padding-bottom: 0 !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar {
    position: sticky !important;
    inset: 0 auto auto 0 !important;
    z-index: 1000 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    background: rgba(255, 255, 255, .98) !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 3px 12px rgba(13, 36, 71, .06) !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .topbar-inner {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 11px 12px 0 !important;
    gap: 7px 10px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .brand {
    order: 1 !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    font-size: 23px !important;
    line-height: 38px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .topbar-actions {
    order: 2 !important;
    display: flex !important;
    flex: 1 1 auto !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
    margin: 0 !important;
    gap: 7px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .icon-btn {
    flex: 0 0 36px !important;
    width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .user-chip {
    width: auto !important;
    min-width: 0 !important;
    min-height: 38px !important;
    padding: 3px 7px 3px 3px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .user-meta {
    display: none !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .avatar {
    flex: 0 0 32px !important;
    width: 32px !important;
    height: 32px !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar .menu-pop {
    position: fixed !important;
    top: 106px !important;
    right: 9px !important;
    min-width: 210px !important;
    max-width: calc(100vw - 18px) !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav {
    order: 3 !important;
    position: static !important;
    inset: auto !important;
    display: flex !important;
    flex: 0 0 calc(100% + 24px) !important;
    align-items: stretch !important;
    width: calc(100% + 24px) !important;
    height: auto !important;
    min-height: 49px !important;
    margin: 0 -12px !important;
    padding: 4px 8px 5px !important;
    gap: 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    background: #fff !important;
    border-top: 1px solid #edf1f5 !important;
    border-bottom: 0 !important;
    box-shadow: none !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav::-webkit-scrollbar {
    display: none;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav > a {
    display: inline-flex !important;
    flex: 1 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    min-width: 86px !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 7px 9px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  html:not(.e2mp-native-navigation) body header.topbar nav.nav > a i {
    flex: 0 0 auto;
    font-size: 12px !important;
  }
}
