.chat-fab {
  position: fixed;
  right: 18px;
  bottom: 90px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #f8fbff;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  z-index: 120;
}
.chat-fab .icon {
  width: 18px;
  height: 18px;
}
.chat-fab .badge {
  background: #facc15;
  color: #0f172a;
  margin-left: 4px;
}

.chat-card {
  display: grid;
  gap: 12px;
}

.chat-thread {
  height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--input-bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  display: flex;
}

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

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

.chat-bubble {
  max-width: min(78%, 560px);
  border-radius: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

.chat-msg.mine .chat-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border: none;
}

.chat-content {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-meta {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.72;
}

.chat-form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.chat-form-row input {
  min-height: 42px;
}

.admin-chat-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.chat-conv-list {
  max-height: 450px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  padding: 6px;
}

.chat-conv-list .conv-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent !important;
  border-radius: 10px;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text) !important;
  text-align: left;
  padding: 10px !important;
  min-height: 56px !important;
  transform: none !important;
  font-size: 13px !important;
}

.conv-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.conv-avatar {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #64748b, #475569);
  overflow: hidden;
}

.conv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-conv-list .conv-item:hover {
  background: #eef3ff;
  border-color: #d9e3ff;
  transform: none !important;
}

.chat-conv-list .conv-item.active {
  background: linear-gradient(135deg, #ecf2ff, #e2ecff);
  border-color: #9fb4f8 !important;
  box-shadow: 0 8px 18px rgba(30, 58, 138, 0.18) !important;
}

.chat-conv-list .conv-item.active .conv-avatar {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.conv-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.conv-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.conv-last {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}

.chat-conv-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.admin-chat-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.chat-active-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #dce4f6;
  background: #f6f9ff;
}

.chat-active-avatar {
  height: 34px;
  width: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  flex-shrink: 0;
  overflow: hidden;
}

.chat-active-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-active-meta {
  display: grid;
  min-width: 0;
}

.chat-active-meta strong {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-active-meta span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-thread {
  height: 380px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.admin-thread.thread-focus {
  border-color: rgba(30, 58, 138, 0.35);
  box-shadow: inset 0 0 0 1px rgba(30, 58, 138, 0.22);
}

@media (max-width: 900px) {
  .admin-chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-conv-list {
    max-height: 260px;
  }

  .admin-thread,
  .chat-thread {
    height: 320px;
  }
}
