.chat-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  border-bottom: 1px solid rgba(34, 43, 82, 0.1);
  box-shadow: none;
}
.chat-topbar .inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-topbar .back-home {
  color: #222B52;
  text-decoration: none;
  font-weight: 600;
  transition: color .2s ease;
}
.chat-topbar .back-home:hover {
  color: #B25640;
}
.chat-topbar .lang-toggle {
  border: none;
  background: transparent;
  color: #7F858D;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color .2s ease;
}
.chat-topbar .lang-toggle.active {
  color: #B25640;
}
.chat-page {
  min-height: 100vh;
  padding: 92px 0 34px;
  background: #F8F7F0;
}
.chat-shell {
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(34, 43, 82, 0.12);
  box-shadow: none;
  display: grid;
  grid-template-columns: 330px 1fr;
  min-height: 78vh;
}
.chat-sidebar {
  background: #F8F7F0;
  border-right: 1px solid rgba(34, 43, 82, 0.1);
  padding: 18px;
}
.chat-sidebar.compact {
  padding-top: 22px;
}
.chat-sidebar h3 {
  margin-bottom: 10px;
  font-size: 22px;
  color: #222B52;
  font-weight: 800;
}
.chat-sidebar-note {
  color: #7F858D;
  font-size: 13px;
  margin-bottom: 14px;
}
.chat-sidebar .form-control {
  border-radius: 11px;
  border: 1px solid rgba(34, 43, 82, 0.15);
  background: #fff;
  font-size: 13px;
  color: #222B52;
  min-height: 42px;
}
.chat-sidebar .form-control:focus {
  border-color: #B25640;
  box-shadow: none;
  outline: 0;
}
.chat-create-form .form-control {
  margin-bottom: 10px;
}
.chat-search-wrap {
  margin-top: 10px;
  margin-bottom: 12px;
}
.chat-list {
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 3px;
}
.chat-list-pagination {
  margin-top: 8px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-page-btn {
  border: 1px solid rgba(34, 43, 82, 0.15);
  background: #fff;
  color: #222B52;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  padding: 6px 10px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.chat-page-btn:hover,
.chat-page-btn:focus {
  border-color: #B25640;
  background: #fff;
  color: #B25640;
}
.chat-page-btn.disabled,
.chat-page-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.chat-page-state {
  font-size: 11px;
  color: #7F858D;
  font-weight: 700;
}
.chat-list-item {
  position: relative;
  background: #fff;
  border: 1px solid rgba(34, 43, 82, 0.12);
  border-radius: 13px;
  padding: 11px 12px;
  margin-bottom: 9px;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease;
}
.chat-list-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: transparent;
  transition: background .2s ease;
}
.chat-list-item:hover {
  border-color: rgba(178, 86, 64, 0.45);
  box-shadow: none;
  transform: none;
}
.chat-list-item.active {
  border-color: #B25640;
  background: #F8F7F0;
  box-shadow: none;
}
.chat-list-item:hover::before,
.chat-list-item.active::before {
  background: #B25640;
}
.chat-list-item .title {
  font-weight: 800;
  color: #222B52;
  margin-bottom: 4px;
  font-size: 13px;
}
.chat-list-item .meta {
  color: #7F858D;
  font-size: 12px;
  line-height: 1.5;
}
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}
.chat-main .btn,
.chat-file-pick-btn {
  border-radius: 11px;
  font-weight: 700;
}
.chat-main .btn:hover,
.chat-main .btn:focus,
.chat-main .btn:active {
  color: #fff;
}
.chat-main .btn-light {
  background: #F8F7F0;
  border: 1px solid rgba(34, 43, 82, 0.15);
  color: #222B52;
}
.chat-main .btn-light:hover,
.chat-main .btn-light:focus {
  color: #222B52;
  border-color: #B25640;
  background: #fff;
}
.chat-main .btn-light:hover span,
.chat-main .btn-light:focus span {
  color: #222B52;
}
.chat-main .btn:not(.btn-light) {
  background: #B25640;
  border: 1px solid #984a36;
  color: #fff;
  box-shadow: none;
}
.chat-main .btn:not(.btn-light):hover,
.chat-main .btn:not(.btn-light):focus {
  background: #984a36;
  border-color: #843e2f;
}
.chat-main-placeholder {
  margin: auto;
  text-align: center;
  color: #7F858D;
}
.chat-main-placeholder h4 {
  color: #222B52;
}
.chat-header {
  padding: 15px 20px;
  border-bottom: 1px solid rgba(34, 43, 82, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
}
.chat-header h4 {
  margin: 0;
  color: #222B52;
  font-weight: 800;
}
.chat-participants {
  font-size: 12px;
  color: #7F858D;
  margin-top: 4px;
}
.chat-typing-indicator {
  font-size: 11px;
  color: #B25640;
  min-height: 16px;
  margin-top: 4px;
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  background: #F8F7F0;
}
.chat-bubble {
  max-width: min(80%, 700px);
  margin-bottom: 13px;
  border-radius: 16px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid rgba(34, 43, 82, 0.12);
  box-shadow: none;
}
.chat-bubble.mine {
  margin-left: auto;
  background: #B25640;
  color: #fff;
  border-color: #984a36;
  box-shadow: none;
}
.chat-bubble .sender {
  font-size: 11px;
  margin-bottom: 6px;
  opacity: .82;
  font-weight: 700;
}
.chat-bubble .content {
  font-size: 13px;
  line-height: 1.72;
  word-break: break-word;
}
.chat-bubble.mine .content,
.chat-bubble.mine .content p,
.chat-bubble.mine .content li,
.chat-bubble.mine .content span,
.chat-bubble.mine .content strong,
.chat-bubble.mine .content em,
.chat-bubble.mine .content b,
.chat-bubble.mine .content i,
.chat-bubble.mine .content u,
.chat-bubble.mine .content code,
.chat-bubble.mine .content blockquote,
.chat-bubble.mine .content h1,
.chat-bubble.mine .content h2,
.chat-bubble.mine .content h3,
.chat-bubble.mine .content h4,
.chat-bubble.mine .content h5,
.chat-bubble.mine .content h6,
.chat-bubble.mine .content a {
  color: #fff !important;
}
.chat-bubble .content p {
  margin-bottom: .5rem;
}
.chat-bubble .content p:last-child {
  margin-bottom: 0;
}
.chat-bubble .content a {
  color: inherit;
  text-decoration: underline;
}
.chat-bubble .time {
  font-size: 10px;
  margin-top: 9px;
  opacity: .75;
}
.chat-bubble .read-receipt {
  font-size: 10px;
  margin-top: 6px;
  opacity: .78;
}
.chat-attachments {
  margin-top: 9px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(34, 43, 82, 0.06);
  border: 1px solid rgba(34, 43, 82, 0.12);
  color: inherit;
  transition: border-color .2s ease, background-color .2s ease;
}
.chat-attachment-link:hover {
  transform: none;
  border-color: #B25640;
  background: rgba(178, 86, 64, 0.08);
}
.chat-image-thumb {
  width: 108px;
  height: 108px;
  border-radius: 11px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.chat-compose {
  border-top: 1px solid rgba(34, 43, 82, 0.1);
  background: #fff;
  padding: 14px;
}
.chat-editor-source {
  display: none;
}
.chat-compose .ck.ck-editor__main > .ck-editor__editable {
  border-radius: 12px !important;
  border-color: rgba(34, 43, 82, 0.15) !important;
  background: #fff !important;
  color: #222B52;
}
.chat-compose .ck.ck-toolbar {
  border-radius: 12px 12px 0 0 !important;
  border-color: rgba(34, 43, 82, 0.15) !important;
  background: #F8F7F0 !important;
}
.chat-compose .ck.ck-editor__main > .ck-editor__editable:focus {
  border-color: #B25640 !important;
  box-shadow: none !important;
  outline: 0;
}
.chat-compose .ck-editor__editable {
  min-height: 120px;
  max-height: 240px;
}
.chat-compose-tools {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr auto;
  gap: 10px;
  margin-top: 10px;
  align-items: start;
}
.chat-file-tools {
  border: 1px solid rgba(34, 43, 82, 0.12);
  border-radius: 12px;
  background: #F8F7F0;
  padding: 10px;
}
.chat-file-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.chat-file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.chat-file-pick-btn {
  border: 1px solid #B25640;
  background: #B25640;
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}
.chat-file-pick-btn:hover,
.chat-file-pick-btn:focus {
  background: #984a36;
  border-color: #843e2f;
  color: #fff;
}
.chat-file-selected {
  font-size: 12px;
  color: #222B52;
}
.chat-file-note {
  margin-top: 6px;
  font-size: 11px;
  color: #7F858D;
}
.chat-emoji-wrap {
  min-width: 0;
}
.emoji-search {
  margin-bottom: 8px;
}
.emoji-grid {
  border: 1px solid rgba(34, 43, 82, 0.12);
  border-radius: 12px;
  padding: 8px;
  max-height: 100px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 6px;
  background: #F8F7F0;
}
.emoji-btn {
  border: 1px solid rgba(34, 43, 82, 0.12);
  background: #fff;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  padding: 5px 0;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease;
}
.emoji-btn:hover {
  transform: none;
  border-color: #B25640;
  box-shadow: none;
}
.chat-message {
  display: none;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.chat-message.below {
  margin-top: 8px;
}
.chat-message.success {
  display: block;
  background: #ebf7ee;
  color: #205e2d;
  border-color: #cde9d4;
}
.chat-message.error {
  display: block;
  background: #fdecec;
  color: #8a1f1f;
  border-color: #f4c9c9;
}

.chat-list::-webkit-scrollbar,
.chat-thread::-webkit-scrollbar,
.emoji-grid::-webkit-scrollbar {
  width: 8px;
}
.chat-list::-webkit-scrollbar-thumb,
.chat-thread::-webkit-scrollbar-thumb,
.emoji-grid::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(34, 43, 82, 0.2);
}
.chat-list::-webkit-scrollbar-track,
.chat-thread::-webkit-scrollbar-track,
.emoji-grid::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 991px) {
  .chat-shell {
    grid-template-columns: 1fr;
    min-height: 84vh;
    border-radius: 16px;
  }
  .chat-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(34, 43, 82, 0.1);
    padding: 14px;
  }
  .chat-list {
    max-height: 250px;
  }
  .chat-compose-tools {
    grid-template-columns: 1fr;
  }
  .chat-bubble {
    max-width: 100%;
  }
  .chat-thread {
    padding: 14px 12px;
  }
  .chat-header {
    padding: 12px 14px;
  }
  .chat-compose {
    padding: 11px;
  }
}

html[dir="rtl"] .chat-sidebar {
  border-right: 0;
  border-left: 1px solid rgba(34, 43, 82, 0.1);
}
html[dir="rtl"] .chat-list-item::before {
  left: auto;
  right: 0;
}
html[dir="rtl"] .chat-bubble.mine {
  margin-left: 0;
  margin-right: auto;
}
html[dir="rtl"] .chat-sidebar,
html[dir="rtl"] .chat-main,
html[dir="rtl"] .chat-message {
  text-align: right;
}
html[dir="rtl"] .chat-file-picker {
  justify-content: flex-start;
}
html[dir="rtl"] .chat-list-pagination {
  flex-direction: row-reverse;
}
