/* WATranslate v4.2 — Mobile App Mode
   Loaded after v4.1; desktop remains unchanged.
*/

.mobile-title-block,
.mobile-app-menu-wrap,
.mobile-search-wrap {
  display: none;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
}

.app-modal.hidden {
  display: none;
}

.app-modal-card {
  position: relative;
  width: min(420px, 100%);
  padding: 24px 22px 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: #202c33;
  color: #e9edef;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}

.app-modal-card h2 {
  margin: 8px 0 12px;
  text-align: center;
}

.app-modal-close {
  position: absolute;
  right: 10px;
  top: 7px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #aebac1;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.app-modal-icon {
  display: flex;
  justify-content: center;
}

.app-modal-icon img {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.install-instructions {
  color: #d5dfe4;
  line-height: 1.45;
}

.install-instructions ol {
  padding-left: 22px;
}

.install-instructions li {
  margin: 7px 0;
}

.install-note {
  color: #9fb0b8;
  font-size: 13px;
}

@media (max-width: 760px) {
  .desktop-brand-block {
    display: none;
  }

  .mobile-title-block {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    justify-content: center;
  }

  .mobile-title-block span {
    margin-bottom: 1px;
    color: #25d366;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
  }

  .mobile-title-block strong {
    color: #e9edef;
    font-size: 24px;
    line-height: 1.05;
    letter-spacing: -.02em;
  }

  #logoutButton {
    display: none;
  }

  .mobile-app-menu-wrap {
    position: relative;
    display: block;
    flex: 0 0 auto;
  }

  .mobile-app-menu-button {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #dfe7ea;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }

  .mobile-app-menu-button:active {
    background: rgba(255,255,255,.08);
  }

  .mobile-app-menu {
    position: absolute;
    z-index: 300;
    right: 0;
    top: 44px;
    display: none;
    min-width: 190px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    background: #233138;
    box-shadow: 0 10px 28px rgba(0,0,0,.45);
  }

  .mobile-app-menu.open {
    display: block;
  }

  .mobile-app-menu button {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #e9edef;
    text-align: left;
    font-size: 15px;
    cursor: pointer;
  }

  .mobile-app-menu button:active {
    background: rgba(255,255,255,.08);
  }

  .mobile-app-menu button + button {
    border-top: 1px solid rgba(255,255,255,.06);
  }

  .mobile-search-wrap {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    padding:
      8px
      max(12px, env(safe-area-inset-right))
      9px
      max(12px, env(safe-area-inset-left));
    background: #111b21;
  }

  .mobile-search-icon {
    position: absolute;
    z-index: 2;
    left: max(27px, calc(env(safe-area-inset-left) + 27px));
    top: 50%;
    transform: translateY(-50%);
    color: #8696a0;
    font-size: 22px;
    pointer-events: none;
  }

  #mobileContactSearch {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    padding: 0 16px 0 42px;
    border: 0;
    border-radius: 10px;
    outline: 0;
    background: #202c33;
    color: #e9edef;
    font: inherit;
    font-size: 15px;
    -webkit-appearance: none;
  }

  #mobileContactSearch::placeholder {
    color: #8696a0;
  }

  #mobileContactSearch::-webkit-search-cancel-button {
    filter: invert(.8);
  }

  .archive-view-button {
    border-top: 0;
  }

  /* In standalone mode the content touches the iPhone safe area directly,
     so make the top header slightly more native-app-like. */
  @media (display-mode: standalone) {
    .sidebar-header,
    .chat-header {
      background: #202c33;
    }

    .sidebar-header {
      min-height: calc(64px + env(safe-area-inset-top));
      padding-bottom: 7px;
    }

    .mobile-title-block strong {
      font-size: 27px;
    }
  }

  .app-modal {
    align-items: flex-end;
    padding:
      12px
      max(12px, env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .app-modal-card {
    width: 100%;
    max-width: none;
    border-radius: 20px;
    padding-bottom: 24px;
  }
}

@media (max-width: 390px) {
  .mobile-title-block strong {
    font-size: 22px;
  }

  .mobile-title-block span {
    font-size: 10px;
  }

  .mobile-search-wrap {
    padding-top: 7px;
    padding-bottom: 8px;
  }
}
