/*
 * ABDD Messages — Stage 4.1 desktop geometry polish
 * ABDD-STAGE-4-1
 *
 * Real staging validation of Stage 4 confirmed the three-column design in
 * both ABDD Clair and ABDD Sombre, but also exposed two structural defects:
 *
 * 1. the global 56px header offset was being applied to multiple nested
 *    Element wrappers, producing an empty row below the ABDD navigation;
 * 2. the fixed Discussions column could expose an internal horizontal
 *    scrollbar even though the product does not use horizontal room-list
 *    navigation.
 *
 * This late-loading layer corrects geometry only. It does not change Matrix,
 * room, message, authentication, encryption, consent or RightPanel state.
 */

@media (min-width: 1181px) {
  /* ----------------------------------------------------------------------
     SINGLE HEADER OFFSET

     Stage 1/2 applied margin-top to both the outer layout and several nested
     children. Because those margins are cumulative, RoomView / LeftPanel /
     RightPanel began roughly one extra header-height below the top navigation.

     The correct model is:
       top navigation (fixed 56px)
       + one offset on each top-level application column wrapper
       + zero additional offset on descendants.
     ---------------------------------------------------------------------- */
  body.abdd-messages .mx_LeftPanel_outerWrapper,
  body.abdd-messages .mx_MainSplit {
    margin-top: var(--abdd-header-height) !important;
    height: calc(100vh - var(--abdd-header-height)) !important;
    max-height: calc(100vh - var(--abdd-header-height)) !important;
  }

  body.abdd-messages .mx_LeftPanel_ResizeWrapper,
  body.abdd-messages .mx_LeftPanel_wrapper,
  body.abdd-messages .mx_LeftPanel,
  body.abdd-messages .mx_RoomView,
  body.abdd-messages .mx_HomePage,
  body.abdd-messages .mx_Welcome,
  body.abdd-messages .mx_RightPanel_ResizeWrapper,
  body.abdd-messages .mx_RightPanel_wrapper,
  body.abdd-messages .mx_RightPanel {
    margin-top: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
  }

  /* Stage 4 deliberately keeps the RightPanel at 360px. The wrapper lives
     inside MainSplit, so it must inherit MainSplit's vertical offset instead
     of receiving another one of its own. */
  body.abdd-messages[data-abdd-details-mode="persistent"] .mx_RightPanel_ResizeWrapper {
    margin-top: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
  }

  body.abdd-messages[data-abdd-details-mode="persistent"] .mx_RightPanel {
    margin-top: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
  }

  /* ----------------------------------------------------------------------
     DISCUSSIONS HORIZONTAL OVERFLOW

     The left rail is intentionally fixed-width and all interactive content is
     designed to fit inside it. Horizontal overflow therefore indicates nested
     Element sizing rather than intentional product behaviour.
     ---------------------------------------------------------------------- */
  body.abdd-messages .mx_LeftPanel_outerWrapper,
  body.abdd-messages .mx_LeftPanel_ResizeWrapper,
  body.abdd-messages .mx_LeftPanel_wrapper,
  body.abdd-messages .mx_LeftPanel,
  body.abdd-messages .mx_LeftPanel_roomListContainer,
  body.abdd-messages .mx_RoomListPanel,
  body.abdd-messages .abdd-room-list,
  body.abdd-messages .abdd-room-list-body {
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    max-width: 100% !important;
  }

  /* The center/right split must be allowed to shrink without pushing the
     fixed Discussions column wider than its contract. */
  body.abdd-messages .mx_MainSplit,
  body.abdd-messages .mx_MainSplit_body,
  body.abdd-messages .mx_RoomView,
  body.abdd-messages .mx_RoomView_body {
    min-width: 0 !important;
  }
}
