/* ============================================================
   CHAT — macOS-style community chat window
   ============================================================ */

.chat-window {
  margin-top: 18px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.03) inset;
  background: var(--bg2);
}

/* ---- Title bar ---- */
.chat-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #2A2350, #211B43);
  border-bottom: 1px solid var(--line-soft);
}

.chat-lights { display: flex; gap: 8px; }
.chat-lights__dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  display: block;
}
.chat-lights__dot--red    { background: #FF5F57; }
.chat-lights__dot--yellow { background: #FEBC2E; }
.chat-lights__dot--green  { background: #28C840; }

.chat-titlebar__title {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.chat-titlebar__expand { color: var(--faint); }

/* ---- Chat body (3 columns) ---- */
.chat-body {
  display: grid;
  grid-template-columns: 200px 1fr 188px;
  height: 540px;
}

/* ---- Rooms sidebar ---- */
.chat-rooms {
  border-right: 1px solid var(--line-soft);
  padding: 14px 10px;
  background: rgba(0,0,0,.12);
  overflow-y: auto;
}

.chat-rooms__group {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 10px 10px 6px;
}

.room {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--ease), color var(--ease);
}
.room:hover { background: var(--surface); color: var(--ink); }
.room.is-active { background: linear-gradient(90deg, rgba(255,92,138,.16), transparent); color: var(--ink); }

.room__hash { color: var(--faint); }
.room.is-active .room__hash { color: var(--pink); }

.room__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-left: auto;
  flex-shrink: 0;
}

/* ---- Main chat area ---- */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-main__head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-main__room-name { font-weight: 700; font-size: 15px; }
.chat-main__online    { color: var(--faint); font-size: 12px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* ---- Message types ---- */
.chat-msg { display: flex; gap: 11px; }

.chat-msg__av {
  width: 36px; height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #06121A;
}

.chat-msg__head { display: flex; align-items: baseline; gap: 8px; }
.chat-msg__name { font-weight: 700; font-size: 13.5px; }
.chat-msg__time { color: var(--faint); font-size: 11px; }
.chat-msg__body { color: #D9D4F5; font-size: 13.5px; line-height: 1.5; margin-top: 2px; }

/* System message */
.chat-msg--system { justify-content: center; }
.chat-msg--system .chat-msg__sys {
  color: var(--faint);
  font-size: 12px;
  background: var(--surface);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--line-soft);
}

/* Gift message */
.chat-gift-msg {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  margin-top: 2px;
  background: linear-gradient(120deg, rgba(255,200,87,.16), rgba(255,92,138,.1));
  border: 1px solid rgba(255,200,87,.35);
}
.chat-gift-msg__icon {
  font-size: 30px;
  animation: wobble 1.6s ease-in-out infinite;
}
.chat-gift-msg__text b { color: var(--gold); }

/* ---- Chat input ---- */
.chat-input {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chat-input__gift {
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  display: grid; place-items: center;
  transition: border-color var(--ease);
  flex-shrink: 0;
}
.chat-input__gift:hover { border-color: var(--pink); }

.chat-input__field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
}
.chat-input__emoji { color: var(--faint); }
.chat-input__field input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}
.chat-input__field input::placeholder { color: var(--faint); }

.chat-input__send {
  width: 40px; height: 40px;
  border-radius: 11px;
  border: 0;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: #fff;
  font-size: 15px;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: filter var(--ease);
}
.chat-input__send:hover { filter: brightness(1.1); }

/* ---- Members sidebar ---- */
.chat-members {
  border-left: 1px solid var(--line-soft);
  padding: 14px 12px;
  background: rgba(0,0,0,.12);
  overflow-y: auto;
}

.chat-members__group {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 8px 8px;
}

.chat-member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--ease);
  white-space: nowrap;
}
.chat-member:hover { background: var(--surface); color: var(--ink); }

.chat-member__av {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 12px;
  color: #06121A;
  font-weight: 700;
  position: relative;
  flex-shrink: 0;
}
.chat-member__dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg2);
}

/* ---- Message bubble (used by dynamic chat.js) ---- */
.chat-msg__bubble {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-msg__text {
  color: #D9D4F5;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---- System message inline text ---- */
.chat-msg--system {
  display: flex;
  justify-content: center;
}
.chat-msg--system::before { display: none; }

/* ---- Gift picker popup ---- */
.chat-gift-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 20;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.7);
  animation: fade-in .15s ease;
}

.chat-gift-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line-soft);
  background: var(--bg2);
  font-size: 22px;
  transition: border-color var(--ease), transform var(--ease);
}
.chat-gift-opt small { font-size: 10px; color: var(--gold); font-weight: 700; }
.chat-gift-opt:hover { border-color: var(--pink); transform: scale(1.05); }

/* chat-input needs position:relative for picker to anchor */
.chat-input { position: relative; }

/* ---- Responsive ---- */
@media (max-width: 920px) {
  .chat-body { grid-template-columns: 1fr; height: auto; }
  .chat-rooms,
  .chat-members { display: none; }
  .chat-messages { height: 400px; }
}
