


.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  direction: rtl;
}


.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  flex-shrink: 0;
  direction: rtl;
}

.chat-header__icon {
  color: var(--color-primary);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-header__title {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text);
  direction: rtl;
}

.chat-header__online {
  font-size: 0.65rem;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header__online::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
  display: block;
  animation: blink 1.5s infinite;
}

.chat-room-voice-strip {
  padding: 10px 6px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--surface-color);
  box-shadow: var(--shadow-sm);
}

.chat-room-voice-strip__seats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.chat-room-voice-seat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  width: 100%;
  max-width: 42px;
  justify-self: center;
}

.chat-room-voice-seat__avatar {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.chat-room-voice-seat:hover .chat-room-voice-seat__avatar {
  transform: translateY(-1px);
}

.chat-room-voice-seat.is-empty .chat-room-voice-seat__avatar {
  opacity: 1;
  background: var(--surface-elevated);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.chat-room-voice-seat__avatar-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

.chat-room-voice-seat__avatar-frame {
  position: absolute;
  inset: -4px;
  z-index: 2;
  pointer-events: none;
}

.chat-room-voice-seat__avatar-frame-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center center;
  will-change: transform;
}

.chat-room-voice-seat__mic-indicator {
  position: absolute;
  inset-inline-start: -2px;
  inset-block-end: -3px;
  z-index: 3;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.chat-room-voice-seat__mic-icon {
  width: 10px;
  height: 10px;
  display: block;
  filter: var(--icon-filter);
}

.chat-room-voice-seat.is-empty .chat-room-voice-seat__avatar-img,
.chat-room-voice-seat.is-empty .chat-room-voice-seat__avatar-frame,
.chat-room-voice-seat:not(.has-photo) .chat-room-voice-seat__avatar-img,
.chat-room-voice-seat:not(.has-frame) .chat-room-voice-seat__avatar-frame {
  display: none;
}

.chat-room-voice-seat.is-self .chat-room-voice-seat__avatar-img {
  box-shadow: 0 0 0 1px var(--link-color), var(--shadow-md);
}

.chat-room-voice-seat.is-speaking .chat-room-voice-seat__avatar-img {
  box-shadow: 0 0 0 2px var(--border-strong), var(--shadow-glow), var(--shadow-md);
}

.chat-room-voice-seat.is-muted .chat-room-voice-seat__mic-indicator {
  opacity: 0.78;
}

.chat-room-voice-seat.is-muted .chat-room-voice-seat__mic-indicator::after {
  position: absolute;
  content: '';
  width: 16px;
  height: 2px;
  background: var(--color-danger);
  border-radius: 999px;
  transform: rotate(-40deg);
}

.chat-room-voice-seat.is-empty .chat-room-voice-seat__mic-indicator {
  inset: 50% auto auto 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  border-color: var(--border-strong);
  background: var(--surface-color);
  box-shadow: var(--shadow-md);
}

.chat-room-voice-seat.is-empty .chat-room-voice-seat__mic-icon {
  width: 13px;
  height: 13px;
}

.chat-room-seat-menu {
  position: fixed;
  z-index: 950;
  min-width: 180px;
  padding: 8px;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface-color);
  box-shadow: var(--shadow-lg);
  direction: rtl;
}

.chat-room-seat-menu__action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  background: var(--surface-elevated);
  color: var(--text-main);
  font-family: 'Cairo', sans-serif;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
  text-align: right;
}

.chat-room-seat-menu__action + .chat-room-seat-menu__action {
  margin-top: 6px;
}

.chat-room-seat-menu__action:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.chat-room-seat-menu__action--danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.chat-collapse-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--border-radius-full);
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  font-size: 0.82rem;
}

.chat-collapse-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
  border-color: var(--color-border-light);
}

.chat-reopen-btn {
  position: fixed;
  top: calc(var(--total-header) + 12px);
  right: 8px;
  z-index: var(--z-overlay);
  padding: 7px 12px;
  border-radius: var(--border-radius-full);
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-size: 0.78rem;
}

.chat-leave-btn {
  padding: 6px 12px;
  border-radius: var(--border-radius-full);
  background: rgba(231,76,60,0.15);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  font-size: 0.78rem;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-leave-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}


.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border-light);
  border-radius: 4px;
}


.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--color-text-dim);
  direction: rtl;
}

.chat-placeholder i {
  font-size: 2.5rem;
  color: var(--color-border-light);
}

.chat-placeholder p {
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.6;
}


.chat-msg {
  display: flex;
  width: 100%;
  max-width: 100%;
  animation: msgIn 0.18s ease;
  min-width: 0;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg--others {
  justify-content: flex-start;
}

.chat-msg--self {
  justify-content: flex-end;
}

.chat-msg__card {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  width: min(100%, 330px);
  min-width: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-bg-card);
  direction: ltr;
}

.chat-msg--self .chat-msg__card {
  background: rgba(108,99,255,0.18);
  border-color: rgba(108,99,255,0.4);
  width: min(100%, 250px);
}

.chat-msg__avatar {
  width: 64px;
  height: 64px;
  align-self: flex-start;
  overflow: hidden;
  flex-shrink: 0;
  background: #4c3e7c;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}

.chat-msg__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-msg__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
  padding: 6px 10px 6px 0;
}

.chat-msg__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-bottom: 4px;
}

.chat-msg--self .chat-msg__meta {
  justify-content: flex-end;
}

.chat-msg__author {
  font-size: 0.72rem;
  color: var(--color-primary-light);
  font-weight: 600;
  direction: ltr;
  text-align: left;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg__author-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.chat-msg__bubble {
  width: 100%;
  padding: 0;
  border-radius: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  direction: rtl;
  color: var(--color-text);
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  flex: 1;
}

.chat-msg__uid-line {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
  direction: ltr;
}

.chat-msg--self .chat-msg__uid-line {
  justify-content: flex-end;
}

.chat-msg__uid-label {
  font-size: 0.58rem;
  color: var(--color-text-dim);
  flex-shrink: 0;
}

.chat-msg__uid-value {
  min-width: 0;
  font-size: 0.6rem;
  color: var(--color-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg__uid-copy {
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font-size: 0.58rem;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-msg__time {
  font-size: 0.6rem;
  color: var(--color-text-dim);
  direction: ltr;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-msg--others .chat-msg__time { text-align: right; }
.chat-msg--self   .chat-msg__time { text-align: right; }


.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-bg-card);
  flex-shrink: 0;
  direction: rtl;
}

.chat-input {
  flex: 1;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-full);
  padding: 7px 12px;
  font-size: 0.8rem;
  color: var(--color-text);
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  transition: border-color var(--transition-fast);
  min-width: 0;
}

.chat-input:focus {
  border-color: var(--color-primary);
}

.chat-input::placeholder {
  color: var(--color-text-dim);
}

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background-color: var(--color-primary-dark);
  transform: scale(1.08);
}
