/* Mobile-first additions (desktop preserved via md+ breakpoints)
   Keep this file focused on mobile UX patterns.
*/

/* Smooth page transitions (applies to desktop and mobile) */
body.ui-page-transition #app-main {
  transition: opacity 160ms ease, transform 160ms ease;
  will-change: opacity, transform;
}

body.ui-page-transition.ui-page-out #app-main {
  opacity: 0;
  transform: translateY(6px);
}

/* Messenger: scope transition only to dialog area (do not fade chats list) */
body.ui-page-transition.ui-page-scope-messenger #app-main {
  transition: none;
  will-change: auto;
}

body.ui-page-transition.ui-page-scope-messenger.ui-page-out #app-main {
  opacity: 1;
  transform: none;
}

body.ui-page-transition.ui-page-scope-messenger .ui-messenger-dialog {
  transition: opacity 160ms ease, transform 160ms ease;
  will-change: opacity, transform;
}

body.ui-page-transition.ui-page-scope-messenger.ui-page-out .ui-messenger-dialog {
  opacity: 0;
  transform: translateY(6px);
}

@media (max-width: 767px) {
  #app-shell {
    position: relative;
  }

  /* Sidebar becomes a left drawer */
  #app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(84vw, 320px) !important;
    max-width: 320px;
    transform: translateX(-104%);
    transition: transform 200ms ease;
    will-change: transform;
  }

  body.ui-mobile-sidebar-open #app-sidebar {
    transform: translateX(0);
  }

  #app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.35);
    display: none;
  }

  body.ui-mobile-sidebar-open #app-sidebar-backdrop {
    display: block;
  }

  /* Off-canvas becomes a bottom sheet */
  #app-offcanvas-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    border-left: none;
    border-top: 1px solid rgb(226 232 240);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    max-height: 92vh;
  }

  #offcanvas-body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(92vh - 52px);
  }

  /* Bottom nav */
  #app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ui-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    border-top: 1px solid rgb(226 232 240);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 8px 10px;
  }

  .ui-bottom-nav__item {
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    border-radius: 12px;
    padding: 6px 4px;
    color: rgb(15 23 42);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    cursor: pointer;
  }

  .ui-bottom-nav__item:active {
    background: rgb(241 245 249);
  }

  .ui-bottom-nav__text {
    font-size: 11px;
    line-height: 1;
    color: rgb(71 85 105);
    white-space: nowrap;
  }

  .ui-bottom-nav__item--primary {
    background: rgb(79 70 229);
    border-color: rgb(79 70 229);
  }

  .ui-bottom-nav__item--primary .ui-bottom-nav__text {
    color: rgba(255, 255, 255, 0.92);
    font-weight: 600;
  }

  /* Messenger: chats list as fullscreen panel */
  .ui-messenger-chats {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 55;
    border-radius: 0;
    transform: translateX(-104%);
    transition: transform 200ms ease;
    will-change: transform;
  }

  body.ui-messenger-chats-open .ui-messenger-chats {
    transform: translateX(0);
  }

  .ui-messenger-chats.ui-messenger-chats--open {
    transform: translateX(0);
  }

  .ui-messenger-chats.ui-messenger-chats--enter {
    animation: uiMessengerChatsEnter 240ms ease both;
  }

  @keyframes uiMessengerChatsEnter {
    from {
      opacity: 0;
      transform: translateX(-12px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}
