/* ========================================
   Community — live chat layout
   ======================================== */

.community-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 0;
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.community-header {
  flex-shrink: 0;
  margin-bottom: 16px;
}

.community-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.community-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 300;
  color: var(--soft-white);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.community-presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(94, 234, 212, 0.1);
  border: 1px solid rgba(94, 234, 212, 0.25);
  border-radius: 100px;
  font-size: 12px;
  color: var(--soft-white);
  letter-spacing: 0.3px;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
  animation: presencePulse 2s ease-in-out infinite;
}

@keyframes presencePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.presence-count {
  font-weight: 500;
}

.community-subtitle {
  font-size: 14px;
  color: var(--subtle-gray);
  line-height: 1.6;
  font-weight: 300;
}

.community-mod-note {
  font-size: 11px;
  color: var(--subtle-gray);
  margin-top: 4px;
  font-style: italic;
  letter-spacing: 0.2px;
}

/* ─── Room tabs ─── */
.community-rooms {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 8px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.room-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--subtle-gray);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
  flex-shrink: 0;
}

.room-tab:hover {
  background: rgba(94, 234, 212, 0.06);
  color: var(--soft-white);
}

.room-tab.active {
  background: linear-gradient(135deg, rgba(184, 164, 216, 0.25), rgba(94, 234, 212, 0.25));
  color: var(--soft-white);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(94, 234, 212, 0.15);
}

.room-tab-emoji {
  font-size: 16px;
  line-height: 1;
}

.room-tab-name {
  font-size: 12px;
}

/* ─── Chat area ─── */
.community-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  overflow: hidden;
  min-height: 400px;
  position: relative;
}

.community-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 234, 212, 0.2) transparent;
}

.community-messages::-webkit-scrollbar {
  width: 6px;
}

.community-messages::-webkit-scrollbar-thumb {
  background: rgba(94, 234, 212, 0.2);
  border-radius: 3px;
}

.community-loading-msgs,
.community-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--subtle-gray);
  font-size: 14px;
}

.community-empty-lotus {
  font-size: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 16px rgba(94, 234, 212, 0.4));
}

/* Date separator */
.community-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--subtle-gray);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 12px 0 4px;
  position: relative;
}

.community-date-sep::before,
.community-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
}

.community-date-sep::before { left: 0; }
.community-date-sep::after  { right: 0; }

/* Message row */
.community-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msgFadeIn 0.4s ease;
}

.community-msg-row.me {
  flex-direction: row-reverse;
}

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

.community-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--deep-navy);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--soft-purple), var(--teal-glow));
  box-shadow: 0 0 12px rgba(184, 164, 216, 0.3);
}

.community-avatar.tester {
  background: linear-gradient(135deg, #FFD700, var(--teal-glow));
  box-shadow: 0 0 16px rgba(255, 215, 100, 0.4);
}

.community-msg-content {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  gap: 4px;
}

.community-msg-row.me .community-msg-content {
  align-items: flex-end;
}

.community-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.community-msg-row.me .community-msg-header {
  flex-direction: row-reverse;
}

.community-msg-name {
  font-weight: 600;
  color: var(--soft-white);
  letter-spacing: 0.2px;
}

.tester-tag {
  font-size: 10px;
  padding: 1px 6px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(94, 234, 212, 0.2));
  border-radius: 100px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.community-msg-time {
  color: var(--subtle-gray);
  font-size: 10px;
  letter-spacing: 0.5px;
}

.community-msg-bubble {
  padding: 10px 14px;
  background: rgba(94, 234, 212, 0.10);
  border: 1px solid rgba(94, 234, 212, 0.20);
  border-radius: 14px;
  border-top-left-radius: 4px;
  color: var(--soft-white);
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.community-msg-row.me .community-msg-bubble {
  background: rgba(184, 164, 216, 0.18);
  border-color: rgba(184, 164, 216, 0.35);
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}

/* ─── Input bar ─── */
.community-input-wrap {
  flex-shrink: 0;
  padding: 14px 16px 8px;
  background: linear-gradient(180deg, transparent, rgba(11, 17, 24, 0.6));
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.community-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  padding: 6px 6px 6px 18px;
  transition: var(--transition-base);
}

.community-input-bar:focus-within {
  border-color: rgba(94, 234, 212, 0.4);
  box-shadow: 0 0 24px rgba(94, 234, 212, 0.12);
}

.community-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--soft-white);
  font-size: 14px;
  font-family: inherit;
  padding: 12px 0;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  line-height: 1.5;
}

.community-input::placeholder {
  color: var(--subtle-gray);
}

.community-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--soft-purple), var(--teal-glow));
  color: var(--deep-navy);
  cursor: pointer;
  transition: var(--transition-base);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(184, 164, 216, 0.3);
  border: none;
}

.community-send:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(184, 164, 216, 0.5),
              0 0 24px rgba(94, 234, 212, 0.3);
}

.community-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.community-send svg {
  transform: translateX(-1px);
}

.community-input-hint {
  font-size: 10px;
  color: var(--subtle-gray);
  text-align: right;
  margin-top: 6px;
  padding: 0 8px;
  letter-spacing: 0.3px;
}

/* Toast */
.community-toast {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
  z-index: 5;
  animation: toastSlideUp 0.3s ease;
  backdrop-filter: blur(20px);
}

@keyframes toastSlideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

.community-toast.error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #FCA5A5;
}

.community-toast.success {
  background: rgba(94, 234, 212, 0.15);
  border: 1px solid rgba(94, 234, 212, 0.4);
  color: var(--teal-glow);
}

@media (max-width: 640px) {
  .community-main {
    padding: 16px 12px 0;
    height: calc(100vh - 70px);
  }
  .community-msg-content { max-width: 85%; }
  .community-avatar { width: 32px; height: 32px; font-size: 13px; }
}
