/* ==========================================================
   Rabbit Family & Friends v1
   FIX P v12400 - MOBILE SAFE AREA + HEADER LOGOUT UI
   Presentation-only patch.
   Does NOT modify chat upload/send APIs or database schema.
   ========================================================== */

:root{
  --rabbit-fixp-safe-top:max(env(safe-area-inset-top,0px),26px);
  --rabbit-fixp-safe-bottom:max(env(safe-area-inset-bottom,0px),20px);
  --rabbit-fixp-topbar-content:62px;
  --rabbit-fixp-bottomnav-content:68px;
}

/* Home: remove the old greeting/profile hero completely from view. */
.welcome-strip,
.welcome-strip.welcome-profile-rich,
.welcome-profile-rich{
  display:none !important;
}

/* Home composer becomes the first visible block. */
.rabbit-composer{
  margin-top:4px !important;
}
.rabbit-composer > .row{
  gap:12px !important;
  align-items:center !important;
}
.rabbit-composer > .row > .avatar{
  width:58px !important;
  height:58px !important;
  min-width:58px !important;
  flex:0 0 58px !important;
  border:3px solid #fff !important;
  box-shadow:0 6px 16px rgba(73,52,10,.13) !important;
}

/* Header logout button injected by fix-p-mobile-app-ui.js */
.top-actions{
  min-width:0;
  flex:0 0 auto;
}
.logout-head-btn{
  height:40px;
  min-width:88px;
  padding:0 10px;
  border:1px solid var(--border,#ece8dc);
  border-radius:13px;
  background:#fff;
  color:#8b3535;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  font-weight:850;
  line-height:1;
  white-space:nowrap;
  touch-action:manipulation;
}
.logout-head-btn:active{
  transform:translateY(1px);
}
.logout-head-icon{
  font-size:17px;
  line-height:1;
}
.logout-head-text{
  font-size:11px;
}

/* Profile edit modal must stay above the Android navigation area. */
.modal-bg{
  overflow:hidden !important;
}
.profile-edit-modal{
  overflow-x:hidden !important;
  overflow-y:auto !important;
  overscroll-behavior:contain !important;
  -webkit-overflow-scrolling:touch !important;
}

/* Sticker / emoji trays always open upward, never under bottom navigation. */
.chat-compose.chat-compose-fixed .chat-sticker-tray-v11800,
.chat-compose.chat-compose-fixed .chat-emoji-tray,
.rabbit-chat-fixed .chat-sticker-drawer{
  top:auto !important;
  bottom:calc(100% + 8px) !important;
  max-height:min(320px,42dvh) !important;
  overflow-y:auto !important;
  overscroll-behavior:contain !important;
  z-index:95 !important;
}

@media(max-width:800px){
  /* Header sits below Android/iOS status area. */
  .topbar.rabbit-topbar,
  .rabbit-topbar{
    height:auto !important;
    min-height:calc(var(--rabbit-fixp-topbar-content) + var(--rabbit-fixp-safe-top)) !important;
    padding:calc(7px + var(--rabbit-fixp-safe-top)) 9px 7px !important;
    align-items:center !important;
  }
  .rabbit-topbar .rabbit-brand{
    min-width:0 !important;
    flex:1 1 auto !important;
  }
  .rabbit-topbar .rabbit-logo{
    width:42px !important;
    height:42px !important;
    flex:0 0 42px !important;
  }
  .rabbit-topbar .brand-copy{
    min-width:0 !important;
  }
  .rabbit-topbar .brand-copy strong{
    display:block !important;
    max-width:clamp(90px,29vw,165px) !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
  }
  .rabbit-topbar .brand-copy small{
    display:block;
    max-width:clamp(90px,29vw,165px) !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
  }
  .rabbit-topbar .top-actions{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    gap:5px !important;
    flex:0 0 auto !important;
  }
  .rabbit-topbar .top-actions .icon-btn{
    width:40px !important;
    height:40px !important;
    flex:0 0 40px !important;
  }
  .rabbit-topbar .logout-head-btn{
    height:40px !important;
    min-width:82px !important;
    padding:0 8px !important;
    border-radius:12px !important;
  }

  /* General pages and "ฉัน": keep content above fixed bottom nav + phone nav area. */
  .rabbit-layout,
  .layout{
    padding-bottom:calc(var(--rabbit-fixp-bottomnav-content) + var(--rabbit-fixp-safe-bottom) + 18px) !important;
  }
  .rabbit-bottom-nav,
  .bottom-nav{
    min-height:calc(var(--rabbit-fixp-bottomnav-content) + var(--rabbit-fixp-safe-bottom)) !important;
    padding:6px 4px calc(7px + var(--rabbit-fixp-safe-bottom)) !important;
  }

  /* Home: larger profile photo beside composer. */
  .rabbit-composer{
    padding:14px 12px !important;
    border-radius:20px !important;
  }
  .rabbit-composer > .row > .avatar{
    width:66px !important;
    height:66px !important;
    min-width:66px !important;
    flex-basis:66px !important;
  }
  .rabbit-composer .create-post-trigger{
    min-height:74px !important;
    border-radius:18px !important;
  }

  /* Profile edit safe area. */
  .modal-bg{
    padding:calc(8px + var(--rabbit-fixp-safe-top)) 7px calc(8px + var(--rabbit-fixp-safe-bottom)) !important;
    align-items:center !important;
  }
  .profile-edit-modal{
    width:100% !important;
    max-width:760px !important;
    max-height:calc(100dvh - var(--rabbit-fixp-safe-top) - var(--rabbit-fixp-safe-bottom) - 18px) !important;
    margin:0 !important;
    padding-bottom:28px !important;
    border-radius:22px !important;
  }
  .profile-edit-modal .profile-edit-form{
    padding-bottom:18px !important;
  }

  /* Chat room: explicitly reserve header + Rabbit bottom nav + phone safe area. */
  .rabbit-chat-fixed.chat-room-screen{
    height:calc(100dvh - var(--rabbit-fixp-topbar-content) - var(--rabbit-fixp-safe-top) - var(--rabbit-fixp-bottomnav-content) - var(--rabbit-fixp-safe-bottom) - 14px) !important;
    min-height:0 !important;
    max-height:none !important;
    margin:0 !important;
    overflow:hidden !important;
    display:flex !important;
    flex-direction:column !important;
  }
  .rabbit-chat-fixed .chat-room-header{
    flex:0 0 auto !important;
  }
  .rabbit-chat-fixed .chat-message-scroll{
    flex:1 1 auto !important;
    min-height:0 !important;
    overflow-y:auto !important;
    overscroll-behavior:contain !important;
    padding-bottom:12px !important;
  }
  .rabbit-chat-fixed .chat-compose.chat-compose-fixed{
    flex:0 0 auto !important;
    position:relative !important;
    bottom:auto !important;
    z-index:90 !important;
  }
}

@media(max-width:430px){
  .rabbit-topbar .brand-copy strong{
    max-width:105px !important;
    font-size:14px !important;
  }
  .rabbit-topbar .brand-copy small{
    display:none !important;
  }
  .rabbit-topbar .logout-head-btn{
    min-width:76px !important;
    padding:0 6px !important;
  }
  .rabbit-topbar .logout-head-text{
    font-size:10px !important;
  }
  .rabbit-composer > .row > .avatar{
    width:62px !important;
    height:62px !important;
    min-width:62px !important;
    flex-basis:62px !important;
  }
}

@media(max-width:360px){
  .rabbit-topbar .rabbit-logo{
    width:38px !important;
    height:38px !important;
    flex-basis:38px !important;
  }
  .rabbit-topbar .brand-copy strong{
    max-width:82px !important;
    font-size:13px !important;
  }
  .rabbit-topbar .logout-head-btn{
    min-width:70px !important;
    padding:0 5px !important;
  }
  .rabbit-topbar .logout-head-icon{
    font-size:15px !important;
  }
  .rabbit-topbar .logout-head-text{
    font-size:9px !important;
  }
}
