/* ================================================================
   chat.css — SG OverGearGaming Chat System
   ================================================================ */

/* ── Floating Chat Button ── */
.chat-fab {
  position: fixed;
  bottom: 90px;
  right: 22px;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, #00f5d4, #00b4d8);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 22px rgba(0,245,212,.4);
  z-index: 900;
  transition: transform .2s, box-shadow .2s;
}
.chat-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 30px rgba(0,245,212,.5);
}
.chat-fab svg { color: #000; }
.chat-fab-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 20px; height: 20px;
  background: #ff3e6c;
  border-radius: 10px;
  font-size: .62rem; font-weight: 800;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border: 2px solid #05060f;
  display: none;
}
.chat-fab-badge.show { display: flex; }

/* ── Chat Panel ── */
.chat-panel {
  position: fixed;
  bottom: 154px;
  right: 22px;
  width: 380px;
  height: 560px;
  background: #0e1122;
  border: 1px solid rgba(0,245,212,.14);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.04);
  z-index: 901;
  transform: scale(.92) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  transform-origin: bottom right;
}
.chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #0a0d1a;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.chat-header-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(0,245,212,.2), rgba(0,180,216,.1));
  border: 1px solid rgba(0,245,212,.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-header-icon svg { color: #00f5d4; }
.chat-header-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem; font-weight: 700;
  color: #eef0ff; line-height: 1;
}
.chat-header-sub { font-size: .68rem; color: #7b82a8; margin-top: 2px; }
.chat-header-close {
  margin-left: auto;
  background: none; border: none;
  color: #7b82a8; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
}
.chat-header-close:hover { background: rgba(255,255,255,.07); color: #eef0ff; }

/* ── Views ── */
.chat-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-view.hidden { display: none; }

/* ── Conversation List ── */
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.conv-list::-webkit-scrollbar { width: 3px; }
.conv-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

.conv-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%;
  gap: 12px; color: #2e3354;
  text-align: center; padding: 2rem;
}
.conv-empty svg { color: #2e3354; }
.conv-empty-title { font-size: .88rem; font-weight: 700; color: #3d4570; }
.conv-empty-sub { font-size: .72rem; color: #2e3354; line-height: 1.5; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background .18s;
  border-bottom: 1px solid rgba(255,255,255,.03);
  position: relative;
}
.conv-item:hover { background: rgba(255,255,255,.04); }
.conv-item.active { background: rgba(0,245,212,.05); }

.conv-av {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #1a2040, #0e1530);
  border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800;
  color: #00f5d4; flex-shrink: 0;
  font-family: 'Rajdhani', sans-serif; letter-spacing: .5px;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name {
  font-size: .82rem; font-weight: 700;
  color: #eef0ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-preview {
  font-size: .7rem; color: #7b82a8; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-listing-tag {
  font-size: .62rem;
  background: rgba(0,245,212,.08);
  color: #00f5d4;
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.conv-meta {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.conv-time { font-size: .62rem; color: #2e3354; }
.conv-unread {
  min-width: 18px; height: 18px; border-radius: 9px;
  background: #ff3e6c; color: #fff;
  font-size: .6rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── New Chat Row ── */
.new-chat-row {
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.new-chat-btn {
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  background: rgba(0,245,212,.08);
  border: 1px solid rgba(0,245,212,.18);
  color: #00f5d4;
  font-size: .78rem; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .2s;
  font-family: 'Outfit', sans-serif;
}
.new-chat-btn:hover { background: rgba(0,245,212,.14); }

/* ── Messages View ── */
.msg-view-header {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: #0a0d1a;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.msg-back-btn {
  background: none; border: none;
  color: #7b82a8; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s; flex-shrink: 0;
}
.msg-back-btn:hover { background: rgba(255,255,255,.07); color: #eef0ff; }
.msg-other-av {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, #1a2040, #0e1530);
  border: 1px solid rgba(0,245,212,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 800; color: #00f5d4;
  font-family: 'Rajdhani', sans-serif; flex-shrink: 0;
}
.msg-other-info { flex: 1; min-width: 0; }
.msg-other-name {
  font-size: .82rem; font-weight: 700; color: #eef0ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-listing-ref {
  font-size: .62rem; color: #7b82a8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #00f5d4; box-shadow: 0 0 6px #00f5d4;
  flex-shrink: 0;
}

/* ── Messages Area ── */
.messages-area {
  flex: 1; overflow-y: auto;
  padding: 14px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.messages-area::-webkit-scrollbar { width: 3px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* Date divider */
.msg-date-divider {
  text-align: center; font-size: .62rem; color: #2e3354;
  margin: 8px 0; position: relative;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: ''; position: absolute; top: 50%;
  width: calc(50% - 40px); height: 1px;
  background: rgba(255,255,255,.04);
}
.msg-date-divider::before { left: 0; }
.msg-date-divider::after  { right: 0; }

/* Bubble */
.msg-row {
  display: flex; align-items: flex-end; gap: 7px;
  max-width: 85%;
}
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.theirs { align-self: flex-start; }

.msg-av-small {
  width: 24px; height: 24px; border-radius: 7px;
  background: #121629;
  border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; justify-content: center;
  font-size: .52rem; font-weight: 800; color: #7b82a8;
  font-family: 'Rajdhani', sans-serif;
  flex-shrink: 0; margin-bottom: 2px;
}
.msg-row.mine .msg-av-small { display: none; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .8rem;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, #00f5d4, #00d4b8);
  color: #020810;
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .msg-bubble {
  background: #121629;
  color: #eef0ff;
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: .58rem;
  margin-top: 3px;
  text-align: right;
  opacity: .55;
}
.msg-row.mine .msg-time { color: #020810; }
.msg-row.theirs .msg-time { color: #7b82a8; }

/* Typing indicator */
.msg-typing {
  display: none;
  align-self: flex-start;
  padding: 8px 13px;
  background: #121629;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 16px; border-bottom-left-radius: 4px;
}
.msg-typing.show { display: flex; gap: 4px; align-items: center; }
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #7b82a8;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* Loading spinner */
.msg-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: #2e3354; gap: 8px; font-size: .78rem;
}
.msg-loading svg { animation: spin 1s linear infinite; color: #2e3354; }

/* ── Input Area ── */
.msg-input-area {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: #0a0d1a;
  flex-shrink: 0;
}
.msg-input-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.msg-textarea {
  flex: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 9px 12px;
  color: #eef0ff;
  font-size: .82rem;
  font-family: 'Outfit', sans-serif;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.4;
  transition: border-color .2s;
  overflow-y: auto;
}
.msg-textarea:focus { border-color: rgba(0,245,212,.3); }
.msg-textarea::placeholder { color: #2e3354; }
.msg-send-btn {
  width: 38px; height: 38px; border-radius: 11px;
  background: #00f5d4; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
.msg-send-btn:hover { background: #00dfc0; transform: scale(1.05); }
.msg-send-btn:disabled { opacity: .4; pointer-events: none; }
.msg-send-btn svg { color: #000; }

/* ── New Chat Form (inside panel) ── */
.new-chat-form {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 1;
}
.new-chat-form-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem; font-weight: 700; color: #eef0ff;
}
.new-chat-label {
  font-size: .68rem; font-weight: 700;
  color: #7b82a8; text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 5px;
}
.new-chat-input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  padding: 9px 12px;
  color: #eef0ff; font-size: .84rem;
  font-family: 'Outfit', sans-serif;
  outline: none; transition: border-color .2s;
}
.new-chat-input:focus { border-color: rgba(0,245,212,.3); }
.new-chat-input::placeholder { color: #2e3354; }
.new-chat-start-btn {
  padding: 10px;
  border-radius: 10px;
  background: #00f5d4; color: #000;
  font-size: .84rem; font-weight: 800;
  border: none; cursor: pointer;
  font-family: 'Outfit', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .2s, transform .15s;
}
.new-chat-start-btn:hover { background: #00dfc0; transform: translateY(-1px); }
.new-chat-back { 
  font-size: .75rem; color: #7b82a8; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  background: none; border: none; font-family: 'Outfit', sans-serif;
  padding: 0; transition: color .2s;
}
.new-chat-back:hover { color: #eef0ff; }

/* ── Scrollbar general ── */
.chat-panel * { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.08) transparent; }

/* ── Responsive ── */
@media (max-width: 520px) {
  .chat-panel {
    right: 0; bottom: 0;
    width: 100vw; height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .chat-fab {
    bottom: 78px;
    right: 16px;
  }
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }