/*
 * HENDAR v0.94.7 — semantic project-chat message alignment.
 *
 * Message position is bound to the sender relationship (.mine/.theirs), not
 * inherited page direction. Bubble content remains RTL for Arabic text.
 */

.project-chat-messages .project-chat-message {
  width: 100%;
  flex-direction: row;
  justify-content: flex-start;
  direction: ltr;
}

.project-chat-messages .project-chat-message.theirs {
  justify-content: flex-start;
}

.project-chat-messages .project-chat-message.mine {
  flex-direction: row;
  justify-content: flex-end;
}

.project-chat-messages .project-chat-message.mine .project-chat-sender-avatar {
  order: 2;
}

.project-chat-messages .project-chat-message.mine .project-chat-bubble {
  order: 1;
}

.project-chat-messages .project-chat-bubble {
  direction: rtl;
  text-align: start;
}

.project-chat-back {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  padding: 0;
  border: 1px solid #c8d9d4;
  border-radius: 50%;
  background: #fff;
  color: #176e60;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}

.project-chat-back.hidden,
.project-chat-back[hidden] {
  display: none;
}

.project-chat-header-actions .project-chat-search {
  display: block;
  width: min(190px, 24vw);
}

.project-chat-header-actions .project-chat-search input {
  width: 100%;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #cbdad6;
  border-radius: 999px;
  background: #fff;
  color: #173e37;
  font: inherit;
  font-size: 11px;
  outline: 0;
}

.project-chat-header-actions .project-chat-search input:focus {
  border-color: #087f6d;
  box-shadow: 0 0 0 3px rgb(8 127 109 / 12%);
}

.project-chat-roster [data-chat-member][data-direct-user],
.project-chat-roster [data-chat-member="project-team"] {
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.project-chat-roster [data-chat-member][data-direct-user]:hover,
.project-chat-roster [data-chat-member][data-direct-user]:focus-visible,
.project-chat-roster [data-chat-member="project-team"]:hover,
.project-chat-roster [data-chat-member="project-team"]:focus-visible {
  border-color: #79bcae;
  background: #f0faf7;
  outline: 0;
  box-shadow: inset 0 0 0 2px rgb(8 127 109 / 14%);
}

.project-chat-roster [data-chat-member].selected {
  border-color: #55a996;
  background: #e2f5ef;
  box-shadow: inset -4px 0 0 #087f6d;
}

@media (max-width: 600px) {
  .project-chat-messages .project-chat-message {
    width: 100%;
  }

  .project-chat-header .project-chat-back {
    display: grid;
  }

  .project-chat-header .project-chat-back.hidden,
  .project-chat-header .project-chat-back[hidden] {
    display: none;
  }

  .project-chat-header-actions .project-chat-search {
    width: min(100%, 240px);
    flex: 1 1 150px;
  }
}

/* UALL-AF recovery: pane ownership, direct reply, and a safe mobile drawer. */
.project-chat-shell.project-chat-shell {
  display: grid !important;
  height: min(820px, calc(100dvh - 142px)) !important;
  min-height: min(620px, calc(100dvh - 142px)) !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  overflow: hidden !important;
}

.project-chat-shell .project-chat-header {
  min-width: 0 !important;
  grid-template-columns: auto minmax(150px, 1fr) minmax(360px, auto) !important;
}

.project-chat-shell .project-chat-header > *,
.project-chat-shell .project-chat-header-actions,
.project-chat-shell .project-chat-header-actions > * {
  min-width: 0 !important;
}

.project-chat-shell .project-chat-header-actions {
  max-width: 100% !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
}

.project-chat-shell .project-chat-header-actions .project-chat-search {
  width: auto !important;
  min-width: 150px !important;
  max-width: 420px !important;
  flex: 1 1 210px !important;
}

.project-chat-shell .project-chat-layout,
.project-chat-shell .project-chat-main {
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
}

.project-chat-shell .project-chat-messages {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  overflow-anchor: none !important;
  scrollbar-gutter: stable !important;
  touch-action: pan-y !important;
}

.project-chat-shell .project-chat-composer {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: visible !important;
  isolation: isolate !important;
}

.project-chat-shell .project-chat-composer > * { min-width: 0 !important; }

.project-chat-shell .project-chat-roster {
  display: grid !important;
  min-width: 0 !important;
  min-height: 0 !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  overflow: hidden !important;
  overscroll-behavior: contain !important;
}

.project-chat-shell .project-chat-roster-rows {
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
}

.project-chat-shell .project-chat-roster > header {
  display: grid !important;
  grid-template-columns:minmax(0, 1fr) auto auto !important;
  gap: 8px !important;
}

.project-chat-shell .project-chat-roster-close {
  display: grid !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  place-items: center !important;
  padding: 0 !important;
  border: 1px solid #cbdad6 !important;
  border-radius: 11px !important;
  background: #fff !important;
  color: #315f57 !important;
  font: inherit !important;
  font-size: 23px !important;
  line-height: 1 !important;
  cursor: pointer !important;
}

.project-chat-shell .project-chat-direct-reply {
  display: inline-flex !important;
  min-width: 0 !important;
  min-height: 30px !important;
  align-items: center !important;
  justify-self: start !important;
  gap: 5px !important;
  margin: 1px 0 !important;
  padding: 4px 8px !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: #087f6d !important;
  font: inherit !important;
  font-size: 10px !important;
  font-weight: 850 !important;
  cursor: pointer !important;
}

.project-chat-shell .project-chat-direct-reply:hover,
.project-chat-shell .project-chat-direct-reply:focus-visible {
  background: rgb(8 127 109 / 10%) !important;
  outline: 2px solid rgb(8 127 109 / 30%) !important;
  outline-offset: 1px !important;
}

.project-chat-shell .project-chat-message-menu > div > :not([data-chat-edit]):not([data-chat-delete]) {
  display: none !important;
}

@media (max-width: 1100px) {
  .project-chat-shell .project-chat-header {
    grid-template-columns: auto minmax(0, 1fr) !important;
  }

  .project-chat-shell .project-chat-header-actions {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    display: flex !important;
  }
}

@media (max-width: 900px) {
  .project-chat-shell .project-chat-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .project-chat-shell .project-chat-roster {
    position: absolute !important;
    z-index: 40 !important;
    inset: 0 0 0 auto !important;
    display: none !important;
    width: min(350px, 92%) !important;
    max-width: 100% !important;
    border: 0 !important;
    border-inline-start: 1px solid #d8e4e7 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: -18px 0 48px rgb(18 55 69 / 22%) !important;
  }
  .project-chat-shell .project-chat-roster.show { display: grid !important; }
}

@media (max-width: 390px) {
  .project-chat-shell.project-chat-shell {
    width: 100% !important;
    height: calc(100dvh - 104px) !important;
    min-height: 0 !important;
    max-height: none !important;
    border-radius: 0 !important;
  }

  .project-chat-shell .project-chat-header {
    grid-template-columns: 42px minmax(0, 1fr) !important;
    gap: 6px !important;
    padding: 8px 7px !important;
  }

  .project-chat-shell .project-chat-header-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) repeat(4, 42px) !important;
    gap: 4px !important;
  }

  .project-chat-shell .project-chat-header-actions .project-chat-search {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .project-chat-shell .project-chat-header-actions button {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
  }

  .project-chat-shell .project-chat-header-actions button > span:not(:first-child) { display: none !important; }
  .project-chat-shell .project-chat-messages { padding: 7px 6px 9px !important; }
  .project-chat-shell .project-chat-bubble { max-width: 92% !important; }
  .project-chat-shell .project-chat-composer { gap: 4px !important; padding: 7px 6px calc(7px + env(safe-area-inset-bottom, 0px)) !important; }
  .project-chat-shell .project-chat-composer textarea { min-height: 42px !important; padding: 9px 10px !important; }
  .project-chat-shell .project-chat-roster { width: 100% !important; }
}
