/* Flatcast Chat V24 - desktop composer/sidebar alignment + cache-safe final override */
@media (min-width: 992px) {
  /* Composer top mode: use a real 2-column shell grid instead of negative offsets. */
  .fc-chat-shell.fc-chat-composer-top-desktop {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 260px !important;
    grid-template-rows: auto auto auto minmax(0, auto) auto auto !important;
    align-items: stretch !important;
  }

  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-topbar {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-toolbar {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-v8-style-panel {
    /* fixed popup; keep out of the layout flow */
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-body {
    display: contents !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-messages {
    grid-column: 1 !important;
    grid-row: 4 !important;
    min-width: 0 !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-sidebar {
    grid-column: 2 !important;
    grid-row: 3 / span 2 !important;
    position: relative !important;
    top: auto !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 100% !important;
    align-self: stretch !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-composer {
    grid-column: 1 !important;
    grid-row: 3 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    align-self: stretch !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    min-height: 58px !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-composer-row {
    width: 100% !important;
    min-width: 0 !important;
    padding-left: 48px !important;
    gap: 8px !important;
    align-items: center !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-composer-row textarea {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 40px !important;
    height: 40px !important;
    max-height: 80px !important;
    padding: 8px 12px !important;
    line-height: 1.3 !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-sendbtn {
    flex: 0 0 auto !important;
    min-width: 104px !important;
    width: auto !important;
    height: 40px !important;
    padding: 0 16px !important;
    margin-left: auto !important;
    margin-right: 30px !important; /* V24: visibly farther left than V23 */
    white-space: nowrap !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop .fc-chat-emoji-toolbar {
    margin: 0 !important;
    position: absolute !important;
    left: 10px !important;
    top: 8px !important;
    z-index: 3 !important;
  }

  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-desktop-eq-wrap {
    grid-column: 1 / -1 !important;
    grid-row: 5 !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-statusbar {
    grid-column: 1 / -1 !important;
    grid-row: 6 !important;
  }

  /* Native and CSS fullscreen: same exact two-column logic as normal desktop. */
  .fc-chat-shell.fc-chat-composer-top-desktop.is-fullscreen,
  .fc-chat-shell.fc-chat-composer-top-desktop:fullscreen,
  .fc-chat-shell.fc-chat-composer-top-desktop:-webkit-full-screen {
    grid-template-columns: minmax(0, 1fr) 260px !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop.is-fullscreen .fc-chat-messages,
  .fc-chat-shell.fc-chat-composer-top-desktop:fullscreen .fc-chat-messages,
  .fc-chat-shell.fc-chat-composer-top-desktop:-webkit-full-screen .fc-chat-messages {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop.is-fullscreen .fc-chat-sidebar,
  .fc-chat-shell.fc-chat-composer-top-desktop:fullscreen .fc-chat-sidebar,
  .fc-chat-shell.fc-chat-composer-top-desktop:-webkit-full-screen .fc-chat-sidebar {
    top: auto !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    align-self: stretch !important;
  }
}

/* Tablet/mobile keep the established drawer/full-width composer behavior. */
@media (max-width: 991px) {
  .fc-chat-shell.fc-chat-composer-top-desktop {
    display: flex !important;
  }
  .fc-chat-shell.fc-chat-composer-top-desktop > .fc-chat-body {
    display: grid !important;
  }
  .fc-chat-shell .fc-chat-composer {
    width: 100% !important;
    max-width: 100% !important;
  }
  .fc-chat-shell .fc-chat-sendbtn {
    margin-right: 0 !important;
  }
}
