/* GroupChat — glassmorphism theme.
   Soft gradient canvas + frosted panels, messenger-style bubbles with avatars,
   indigo accent. Inspired by the reference designs. */

:root {
  --accent: #6d5efc;
  --accent-2: #9a86ff;
  --accent-grad: linear-gradient(135deg, #6d5efc 0%, #9a86ff 100%);
  --fg: #20243a;
  --fg-2: #565d78;
  --fg-muted: #898fa6;
  --danger: #e5484d;
  --green: #2ecd8f;
  --glass: rgba(255, 255, 255, 0.45);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --recv-bubble: rgba(255, 255, 255, 0.82);
  --field: rgba(255, 255, 255, 0.55);
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--fg);
  line-height: 1.5;
  background: linear-gradient(135deg, #aed2f4 0%, #c3ccf7 46%, #d9c6f2 100%) fixed;
}

.muted { color: var(--fg-muted); }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(60, 70, 130, 0.12);
}

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px rgba(60, 70, 130, 0.22);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
}
.login-title { margin: 0 0 0.25rem; font-size: 1.6rem; }

.login-card form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1.25rem; }
.login-card label { font-size: 0.78rem; font-weight: 600; color: var(--fg-2); margin-top: 0.5rem; }

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--field);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--fg);
  font-size: 1rem;
}
input::placeholder { color: var(--fg-muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.18); }

button {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-grad);
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: scale(0.98); }

.error {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.5);
  color: #a3262b;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ---------- App shell (chat) ---------- */
.chat-body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(60, 70, 130, 0.12);
}
.topbar-title { margin: 0; font-size: 1.15rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.me { font-weight: 600; color: var(--fg-2); }
form.inline { margin: 0; display: inline; }

.link-btn {
  background: var(--field);
  border: 1px solid var(--glass-border);
  color: var(--fg-2);
  margin: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.link-btn:hover { filter: none; background: #fff; }

.chat-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-radius: var(--radius-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(60, 70, 130, 0.12);
  padding: 1.1rem 1rem;
  overflow-y: auto;
}
.sidebar-title {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.online-list, .voice-participants { list-style: none; margin: 0; padding: 0; }
.online-item, .voice-participant {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

/* avatar circle */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.72rem; }

.online-name { position: relative; }
.online-dot, .speak-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); flex: none;
}
.speak-dot { background: rgba(0, 0, 0, 0.18); transition: background 0.1s ease, box-shadow 0.1s ease; }
.voice-participant.speaking .speak-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(46, 205, 143, 0.3); }

/* ---------- Voice panel ---------- */
.voice-bar { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--glass-border); }
.voice-btn {
  width: 100%; margin: 0 0 0.5rem;
  background: var(--field);
  border: 1px solid var(--glass-border);
  color: var(--fg); font-size: 0.9rem; padding: 0.6rem 0.7rem; font-weight: 600;
}
.voice-btn:hover { filter: none; background: #fff; }
.voice-btn.in-voice { background: var(--accent-grad); border-color: transparent; color: #fff; }
.voice-btn.muted { background: var(--danger); border-color: transparent; color: #fff; }

.mic-label { display: block; font-size: 0.72rem; color: var(--fg-muted); margin: 0.3rem 0 0.25rem; }
.mic-select {
  width: 100%; margin: 0 0 0.5rem;
  background: var(--field); color: var(--fg);
  border: 1px solid var(--glass-border); border-radius: 10px;
  padding: 0.5rem; font-size: 0.85rem;
}
.mic-select:focus { outline: none; border-color: var(--accent); }
.voice-status { display: block; font-size: 0.8rem; margin-bottom: 0.5rem; color: var(--fg-2); }

/* ---------- Chat main ---------- */
.chat-main {
  min-width: 0; min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(60, 70, 130, 0.12);
}

.messages {
  flex: 1; min-height: 0;
  overflow-y: scroll;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* bubbles */
.msg { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 78%; }
.msg-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg:not(.msg-mine) { align-self: flex-start; }

.bubble {
  background: var(--recv-bubble);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px 16px 16px 4px;
  padding: 0.5rem 0.75rem;
  min-width: 0;
  box-shadow: 0 4px 14px rgba(60, 70, 130, 0.08);
}
.msg-mine .bubble {
  background: var(--accent-grad);
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
  color: #fff;
}

.msg-head { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.1rem; }
.msg-author { font-weight: 700; font-size: 0.82rem; color: var(--accent); }
.msg-mine .msg-author { color: rgba(255, 255, 255, 0.9); }
.msg-time { font-size: 0.68rem; color: var(--fg-muted); }
.msg-mine .msg-time { color: rgba(255, 255, 255, 0.75); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem; }

.msg-image {
  max-width: min(300px, 100%); max-height: 300px;
  border-radius: 12px; display: block;
}

.msg-del {
  margin: 0 0 0 auto; padding: 0 0.2rem;
  background: none; border: none; color: inherit;
  font-size: 0.78rem; line-height: 1; cursor: pointer;
  opacity: 0.55; transition: opacity 0.12s ease;
}
.msg:hover .msg-del { opacity: 0.9; }
.msg-del:hover { opacity: 1; filter: none; }

/* states */
.placeholder-state { margin: auto; padding: 1rem; text-align: center; color: var(--fg-2); }
.conn-status { min-height: 1.2rem; padding: 0 1.1rem; font-size: 0.8rem; color: var(--fg-2); }
.conn-status.error { color: #a3262b; }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 0.9rem; margin: 0.4rem 0.9rem 0.9rem;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 6px 18px rgba(60, 70, 130, 0.1);
}
.composer input[type="text"] {
  flex: 1; margin: 0; border: none; background: transparent;
  padding: 0.3rem 0.4rem;
}
.composer input[type="text"]:focus { box-shadow: none; }
.composer button { margin: 0; flex: none; }

.icon-btn {
  background: transparent; border: none; color: var(--fg-2);
  font-size: 1.2rem; padding: 0.3rem 0.45rem; line-height: 1; border-radius: 50%;
}
.icon-btn:hover { filter: none; background: rgba(109, 94, 252, 0.12); }

#send-btn {
  border-radius: 999px; padding: 0.55rem 1.2rem; font-size: 0.9rem;
}

.composer input:disabled, .composer button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Scrollbars ---------- */
.messages, .sidebar { scrollbar-width: thin; scrollbar-color: rgba(109, 94, 252, 0.4) transparent; }
.messages::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: rgba(109, 94, 252, 0.35); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box;
}
.messages::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(109, 94, 252, 0.55); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; }
.brand-orb {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #c9b8ff, #6d5efc 70%);
  box-shadow: 0 2px 10px rgba(109, 94, 252, 0.5);
}
.brand-name { font-weight: 700; font-size: 1.05rem; }

.people-toggle { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .chat-body { padding: 8px; gap: 8px; }
  .topbar-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .people-toggle { display: inline-flex; align-items: center; background: var(--field); border: 1px solid var(--glass-border); }
  .chat-layout { grid-template-columns: 1fr; position: relative; }
  .sidebar {
    position: absolute; z-index: 20; top: 0; left: 0; bottom: 0;
    width: 78%; max-width: 270px;
    transform: translateX(-105%); transition: transform 0.2s ease;
  }
  body.show-people .sidebar { transform: translateX(0); }
  .msg { max-width: 90%; }
}
