/* ==========================================================================
   ashish-chat-ui.css — تنسيقات نظام الشات الموحّد
   ========================================================================== */
.chat-wrap {
  display: flex;
  gap: 0;
  height: calc(100vh - 220px);
  min-height: 480px;
  background: #fff;
  border: 1px solid #e6e9f0;
  border-radius: 14px;
  overflow: hidden;
  direction: rtl;
  font-family: Tajawal, Cairo, sans-serif;
}
.chat-side {
  width: 300px;
  min-width: 260px;
  border-left: 1px solid #e6e9f0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}
.chat-side__head {
  padding: 12px 14px;
  border-bottom: 1px solid #e6e9f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-side__title { font-weight: 800; font-size: 15px; color: #0a1a3f; }
.chat-side__search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dfe4ec;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  box-sizing: border-box;
}
.chat-side__tabs { display: flex; gap: 6px; }
.chat-side__tabs button {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid #dfe4ec;
  background: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #55607a;
  cursor: pointer;
}
.chat-side__tabs button.active { background: #0a1a3f; color: #fff; border-color: #0a1a3f; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #eef1f6;
  align-items: center;
  transition: background .15s;
}
.chat-item:hover { background: #eef3fa; }
.chat-item.active { background: #e6edf9; }
.chat-item__avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #0a1a3f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-item__avatar.role-office { background: #1b5e20; }
.chat-item__avatar.role-client { background: #6a1b9a; }
.chat-item__meta { flex: 1; min-width: 0; }
.chat-item__name { font-weight: 700; font-size: 14px; color: #0a1a3f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__preview { font-size: 12px; color: #7a8398; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__badge {
  min-width: 20px; height: 20px;
  border-radius: 10px;
  background: #c62828;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}
.chat-item__role { font-size: 10px; color: #98a2b8; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-main__head {
  padding: 12px 16px;
  border-bottom: 1px solid #e6e9f0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}
.chat-main__head .name { font-weight: 800; font-size: 15px; color: #0a1a3f; }
.chat-main__head .role { font-size: 12px; color: #7a8398; }
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f2f5f9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(10,26,63,.08);
}
.chat-msg--me {
  align-self: flex-start;
  background: #0a1a3f;
  color: #fff;
  border-bottom-left-radius: 4px;
}
.chat-msg--other {
  align-self: flex-end;
  background: #fff;
  color: #1c2333;
  border-bottom-right-radius: 4px;
}
.chat-msg__sender { font-size: 11px; font-weight: 700; opacity: .75; margin-bottom: 3px; }
.chat-msg__time { font-size: 10px; opacity: .6; margin-top: 4px; text-align: left; }
.chat-msg img.chat-msg__img { max-width: 240px; border-radius: 10px; display: block; margin-top: 6px; }
.chat-msg__file {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 8px 10px;
  background: rgba(0,0,0,.06); border-radius: 8px;
  text-decoration: none; color: inherit; font-size: 12px; font-weight: 700;
}
.chat-msg--other .chat-msg__file { background: #eef3fa; color: #0a1a3f; }
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #98a2b8;
  gap: 8px;
  text-align: center;
  padding: 20px;
}
.chat-composer {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e6e9f0;
  background: #fff;
  align-items: center;
}
.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid #dfe4ec;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  max-height: 110px;
  box-sizing: border-box;
}
.chat-composer button {
  border: none;
  background: #0a1a3f;
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.chat-composer button:disabled { opacity: .5; cursor: default; }
.chat-composer .chat-attach-btn {
  background: #eef3fa;
  color: #0a1a3f;
  padding: 10px 12px;
  font-size: 17px;
}
.chat-fab {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  left: 18px;
  z-index: 2147482500;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: #0a1a3f;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(10,26,63,.35);
  display: flex; align-items: center; justify-content: center;
}
.chat-fab .chat-fab__badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 21px; height: 21px;
  border-radius: 11px;
  background: #c62828;
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
}
.chat-modal {
  position: fixed;
  inset: 0;
  z-index: 2147482600;
  background: rgba(7,17,38,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.chat-modal__card {
  width: 100%;
  max-width: 860px;
  height: min(640px, 92vh);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.chat-modal__card .chat-wrap { border: none; border-radius: 0; height: 100%; min-height: 0; flex: 1; }
.chat-modal__close {
  position: absolute;
  top: 14px; left: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #0a1a3f;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 2;
}
.chat-note { font-size: 12px; color: #98a2b8; text-align: center; padding: 6px; }

@media (max-width: 768px) {
  .chat-wrap { flex-direction: column; height: 100%; }
  .chat-side { width: 100%; min-width: 0; max-height: 40%; border-left: none; border-bottom: 1px solid #e6e9f0; }
  .chat-msg { max-width: 86%; }
  .chat-fab { bottom: calc(110px + env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; font-size: 23px; }
}
