/* chat.css */

/* ================================
   Main chat widget styles
================================ */
#rt-chat {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 10px;
  max-width: 420px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #fff;
  color: #111;
}

/* ================================
   Header
================================ */
.rtc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.rtc-title {
  font-weight: 700;
}
.rtc-room {
  font-size: 12px;
}

/* ================================
   Online bar (optional)
================================ */
.rtc-online {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin: 6px 0 8px;
  border: 1px solid #eee;
  border-radius: 10px;
  background: #fafafa;
  color: #1e293b;
  font-size: 13px;
}
.rtc-online .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .12);
}
.rtc-online .list {
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================================
   Messages viewport
================================ */
.rtc-body {
  border: 1px solid #eee;
  border-radius: 10px;
  height: 280px;
  overflow: auto;
  padding: 8px;
  background: #fafafa;
}

/* ================================
   Message rows
================================ */
.rtc-item {
  display: flex;
  gap: 8px;
  margin: 6px 0;
  align-items: flex-start;
}

/* Avatars / initials */
.rtc-av,
.rtc-initials {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  flex: 0 0 39px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: #ddd;
  color: #333;
  overflow: hidden;
}
.rtc-av {
  background: none;
}
.rtc-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Bubble + meta */
.rtc-bubble {
  flex: 1 1 auto;
  min-width: 0;
}
.rtc-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.rtc-meta {
  font-size: 11px;
  color: #666;
}

/* ================================
   Room selector (only for auto-room)
================================ */
.rt-room-select {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 12px;
}

/* ================================
   Input row
================================ */
#rt-chat .rtc-input {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px;
  border-top: 1px solid var(--border, #e6e6e6);
  background: var(--bg, #fff);
}

/* Controls row */
#rt-chat .rtc-controls {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

/* Textarea */
#rt-chat .rtc-text {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 88px;
  line-height: 22px;
  padding: 10px 12px;
  box-sizing: border-box;
  border: 1px solid var(--border, #e1e1e1);
  border-radius: 12px;
  font-size: 16px;
  resize: none;
  overflow: auto;
  background: #fff;
  color: #111;
  -webkit-appearance: none;
  appearance: none;
}

/* Send button */
#rt-chat .rtc-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #111;
  color: #fff;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
#rt-chat .rtc-send:disabled {
  opacity: .55;
  cursor: not-allowed;
}
#rt-chat .rtc-send:focus {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* ================================
   Launcher embedding
================================ */
#rt-rooms-chat #rt-chat {
  border: 0;
  padding: 0;
  max-width: none;
}
#rt-rooms-chat #rt-chat .rtc-body {
  border: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  padding: 0 0 8px 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
#rt-rooms-chat #rt-chat .rtc-input {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 10px 0;
  border-top: 1px solid #e6e6e6;
  background: #fff;
}

/* Room selection UI */
#rt-rooms-chat .rt-room-select {
  display: none !important;
}
#rt-rooms-chat .bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 0;
  background: #fff;
  border-bottom: 1px solid #e6e6e6;
}
#rt-rooms-chat .bar .back {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}
#rt-rooms-chat .bar .roomlabel {
  font-size: 18px;
  font-weight: 700;
}
#rt-rooms-chat .bar .online {
  margin-left: 8px;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 600;
}

/* ================================
   Views
================================ */
#rt-dm,
#rt-online,
#rt-rooms {
  display: none;
}

#rt-rooms-list {
  padding-top: 8px;
}
#rt-rooms-list .title {
  font-weight: 700;
  font-size: 18px;
  margin: 4px 0 10px;
}
#rt-rooms-ul {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-left: -12px;
  margin-right: -12px;
}
#rt-rooms-ul li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 6px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
#rt-rooms-ul .name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  color: #111;
}
#rt-rooms-ul .icon {
  display: none;
}
#rt-rooms-ul .meta {
  opacity: .7;
  font-size: 12px;
}

/* ================================
   Attachments
================================ */
#rt-chat .rt-attach-btn,
#rtc-attach-btn {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #111;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
#rt-chat .rt-attach-btn:hover,
#rtc-attach-btn:hover {
  background: #222;
}

/* Thumbnails */
#rt-chat .rt-attachments {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
#rt-chat img.rt-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
  display: block;
}

/* Pending row */
#rt-chat .rt-pending-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
#rt-chat .rt-thumb--pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  font-size: 12px;
  background: #fafafa;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 8px;
}
#rt-chat .rt-pending-note {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.2;
  font-weight: 500;
}

/* ================================
   Timestamp
================================ */
#rt-chat .rtc-bubble .rtc-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

/* ================================
   Welcome message
================================ */
.rtc-welcome {
  margin-top: 0;
  margin-bottom: 3px;
  padding: 6px 3px;
  border: 1px dashed var(--border, #ddd);
  border-radius: 10px;
  background: color-mix(in oklab, #fff 99%, #eee);
  font-weight: 500;
  font-size: 13px;
  color: #ff0000;
  text-align: center;
}

/* ================================
   Empty placeholder
================================ */
.rtc-empty-placeholder {
  text-align: center;
  padding: 20px;
  color: #888;
  font-style: italic;
}

/* ================================
   Action buttons (reply / delete / profile)
================================ */
/* Reply + Delete stay the same */
.rtc-reply,
.rtc-del {
  margin-left: 13px;
  background: none;
  border: none;
  font-size: 14px;
  color: #888;
  cursor: pointer;
}

.rtc-reply { margin-left: 6px; }
.rtc-del { color: #3b5998; }

/* Profile gets breathing room */
.rtc-profile {
  margin-left: 9px;
  margin-top: 3px;
  margin-right: 9px; /* 👈 space away from right edge */
  background: none;
  border: none;
  font-size: 14px;
  color: #555;
  cursor: pointer;
}

.rtc-bubble:hover .rtc-reply,
.rtc-bubble:hover .rtc-del,
.rtc-bubble:hover .rtc-profile {
  color: #333;
}
.rtc-bubble:hover .rtc-del {
  color: #900;
}

/* Line row wrapper */
.rtc-line-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rtc-line strong {
  white-space: nowrap;
}
