/* ── Room list ── */
.room-list {
  flex: 1;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.room-item:active {
  background: var(--bg-2);
}

.room-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--bg-3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  flex-shrink: 0;
  letter-spacing: -1px;
  overflow: hidden;
}


.room-body {
  flex: 1;
  min-width: 0;
}

.room-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.room-member-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 4px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.room-preview {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.room-time {
  font-size: 12px;
  color: var(--text-3);
}

.room-unread {
  background: var(--black);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ── Chat header ── */
.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 4px;
}

.chat-header-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.3px;
}

.btn-scroll-top {
  display: flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.5px;
  padding: 4px 6px;
  flex-shrink: 0;
}
.btn-scroll-top svg {
  width: 14px;
  height: 14px;
}

/* ── Chat search button ── */
.btn-chat-search {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
}

/* ── Chat search bar ── */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s, padding 0.25s;
  flex-shrink: 0;
}
.chat-search-bar.show {
  max-height: 52px;
  opacity: 1;
  padding: 8px 12px;
}

.chat-search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 6px 6px 10px;
}

.chat-search-icon {
  color: var(--text-3);
  flex-shrink: 0;
  font-size: 13px;
}

.chat-search-field input {
  flex: 1;
  background: none;
  border: none;
  font-size: 16px !important;
  outline: none;
  font-size: 13px;
  color: var(--text-1);
  min-width: 0;
}
.chat-search-field input::placeholder {
  color: var(--text-3);
}
.chat-search-field input::-webkit-search-cancel-button {
  display: none;
}

.chat-search-count {
  font-size: 11px;
  color: var(--text-3);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.chat-search-arrow {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 6px;
  transition: background 0.1s;
  flex-shrink: 0;
}
.chat-search-arrow:active {
  background: var(--bg-3);
}

.chat-search-close-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Search highlight ── */
mark.search-hit {
  background: rgba(255, 200, 0, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
mark.search-hit.current {
  background: rgba(255, 180, 0, 0.75);
  color: #111;
  border-radius: 2px;
}

/* ── Notice registered ── */
.notice-reg-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 16px;
  gap: 6px;
}

.notice-reg-label {
  font-size: 12px;
  color: var(--text-3);
}

.notice-reg-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  overflow: hidden;
}

.notice-reg-label-inner {
  font-size: 11px;
  color: var(--text-3);
  padding: 10px 14px 0;
  margin: 0;
}

.notice-reg-text {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 6px 14px 12px;
  margin: 0;
}

.notice-reg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.notice-reg-footer .fa {
  font-size: 10px;
  color: var(--text-3);
}

/* ── System message ── */
.system-msg {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin: 10px 16px;
  padding: 5px 12px;
  background: rgba(0,0,0,0.055);
  border-radius: 20px;
  display: inline-block;
  width: calc(100% - 32px);
}

/* ── Chat notice bar ── */
.chat-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-notice-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-3);
}

.chat-notice-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-notice-text {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-notice-chevron {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 12px;
  padding: 4px;
}

/* ── Chat messages ── */
.chat-bg {
  flex: 1;
  background: var(--bg-2);
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  -webkit-overflow-scrolling: touch;
}

.date-sep {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin: 16px auto 12px;
  padding: 5px 12px;
  background: rgba(0,0,0,0.055);
  border-radius: 20px;
  display: table;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-row.mine {
  flex-direction: row-reverse;
}

.msg-row.group-end {
  margin-bottom: 10px;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  align-self: flex-start;
  color: var(--text-1);
  overflow: hidden;
}


.msg-avatar.ghost {
  visibility: hidden;
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: calc(100% - 60px);
}

.msg-name {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 3px;
  padding-left: 2px;
}

.bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.msg-row.mine .bubble-wrap {
  flex-direction: row-reverse;
}

.bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

/* Other's bubble */
.msg-row:not(.mine) .bubble {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  color: var(--text-1);
}

/* Mine bubble */
.msg-row.mine .bubble {
  background: var(--black);
  color: var(--white);
  border-radius: 18px 4px 18px 18px;
}

.msg-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.msg-read {
  font-size: 11px;
  color: #888;
  line-height: 1;
}

.msg-time {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1;
  white-space: nowrap;
}

/* ── Call bubble ── */
.bubble.bubble-call {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  white-space: normal;
}

.call-call-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.msg-row:not(.mine) .bubble-call .call-call-icon { color: #27ae60; }
.msg-row:not(.mine) .bubble-call.missed .call-call-icon { color: #e74c3c; }
.msg-row.mine .bubble-call .call-call-icon { color: rgba(255,255,255,0.85); }
.msg-row.mine .bubble-call.missed .call-call-icon { color: rgba(255,120,120,0.9); }

.call-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.call-label {
  font-size: 14px;
  font-weight: 600;
}
.msg-row:not(.mine) .call-label { color: var(--text-1); }
.msg-row:not(.mine) .bubble-call.missed .call-label { color: #e74c3c; }
.msg-row.mine .call-label { color: var(--white); }

.call-duration {
  font-size: 12px;
}
.msg-row:not(.mine) .call-duration { color: var(--text-3); }
.msg-row.mine .call-duration { color: rgba(255,255,255,0.6); }

/* ── File bubble ── */
.bubble.bubble-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-width: 180px;
  max-width: 240px;
  white-space: normal;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  color: #fff;
}
.file-icon.pdf     { background: #e74c3c; }
.file-icon.doc,
.file-icon.docx    { background: #2b5dbf; }
.file-icon.xls,
.file-icon.xlsx    { background: #27ae60; }
.file-icon.ppt,
.file-icon.pptx    { background: #e67e22; }
.file-icon.zip     { background: #8e44ad; }
.file-icon.generic { background: #7f8c8d; }

.file-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.3;
}

.msg-row:not(.mine) .file-name { color: var(--text-1); }
.msg-row.mine .file-name       { color: var(--white); }

.file-size {
  display: none;
}

/* ── Chat image ── */
.bubble-img {
  max-width: 200px;
  width: 100%;
  border-radius: 12px;
  display: block;
  cursor: pointer;
}
.msg-row.mine .bubble-img {
  border-radius: 12px 4px 12px 12px;
}
.msg-row:not(.mine) .bubble-img {
  border-radius: 4px 12px 12px 12px;
}

/* ── Image popup ── */
.img-popup {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.img-popup.show {
  opacity: 1;
  pointer-events: auto;
}
.img-popup-img {
  max-width: 92%;
  max-height: 80vh;
  border-radius: 12px;
  object-fit: contain;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.img-popup.show .img-popup-img {
  transform: scale(1);
}
.img-popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

/* ── Reaction badges ── */
.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 2px;
}

.reaction-row.mine {
  justify-content: flex-end;
  padding-left: 0;
  padding-right: 2px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 8px 3px 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.reaction-badge i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 16px;
  text-align: center;
  color: #fff;
  flex-shrink: 0;
}

.reaction-badge.heart i { background: #ff6b6b; }
.reaction-badge.thumb  i { background: #339af0; }
.reaction-badge.check  i { background: #51cf66; }

.reaction-badge em {
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
