/* ============================================================
   The Luxe — black & gold BLKFUSE theme.
   Telegram-style three-pane layout:
     left: chat list (300px) | center: conversation (1fr)
     right: room info (280px)
   Mobile (<900px): single column; body.room-open shows the
   conversation pane with a back button.
   ============================================================ */
:root {
  /* Sports-site palette: black + electric gold. Same tokens as
     BLKFUSE Sports so the two sites read as one brand. */
  --bg: #050505;
  --bg-soft: #0b0b0d;
  --bg-card: #101012;
  --bg-hover: #161618;
  --line: #26261c;
  --gold-line: #6b5312;
  --text: #ffffff;
  --muted: #b8b49a;
  --faint: #7a7660;
  --gold: #ffc61a;
  --gold-deep: #f5b301;
  --gold-dark: #8a6400;
  --gold-pale: #ffe27a;
  --gold-grad: linear-gradient(135deg, #ffe27a 0%, #f5b301 45%, #d99a00 100%);
  --gold-glow: 0 0 26px rgba(245, 179, 1, 0.38);
  --gold-soft: rgba(245, 179, 1, 0.12);
  --red: #e5484d;
  --green: #3fb96c;
  --blue: #4da3ff;
  --radius: 12px;
  --font-display: "Anton", "Oswald", "Arial Narrow", sans-serif;
  --font-head: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--gold); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 0.95rem; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.97);
  border-bottom: 2px solid var(--gold-dark);
  box-shadow: 0 4px 24px rgba(245, 179, 1, 0.12);
  flex-wrap: wrap;
}
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.wordmark .spark { color: var(--gold); font-size: 1.3rem; line-height: 1; }
.wordmark .name {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1.25rem;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark .credit { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.05em; }
.topbar .search-wrap { flex: 1; min-width: 180px; max-width: 420px; }
.topbar .search-wrap form { display: flex; gap: 6px; }
.topbar input[type="search"],
.topbar input[type="email"],
.topbar input[type="password"] {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  width: 100%;
}
.auth-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.auth-bar input { max-width: 200px; }
.auth-bar .who { font-size: 0.9rem; color: var(--muted); }
.form-hint { color: var(--muted); font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--gold-grad);
  color: #111;
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); box-shadow: var(--gold-glow); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold-dark);
}
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.btn.tiny { padding: 3px 8px; font-size: 0.8rem; border-radius: 6px; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }

/* ---------- App grid ---------- */
.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
  height: calc(100vh - 57px);
  min-height: 420px;
}
.pane { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane-left { border-right: 1px solid var(--line); background: var(--bg-soft); }
.pane-center { background: var(--bg); }
.pane-right { border-left: 1px solid var(--line); background: var(--bg-soft); overflow-y: auto; }

/* ---------- Left: chat list ---------- */
.folder-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 10px 6px;
  flex-wrap: wrap;
}
.folder-tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.82rem;
}
.folder-tab.active { background: var(--gold-grad); color: #000; border-color: var(--gold-deep); font-weight: 700; box-shadow: var(--gold-glow); }
.list-search { padding: 0 10px 8px; }
.list-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
}
.room-list { flex: 1; overflow-y: auto; padding: 0 6px 10px; }
.room-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.room-row:hover { background: var(--bg-hover); }
.room-row.active { background: var(--gold-soft); }
.room-row-main { flex: 1; min-width: 0; }
.room-row-top { display: flex; justify-content: space-between; gap: 8px; }
.room-row-name { font-family: var(--font-head); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row-time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.room-row-sub { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.room-row-last {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread-badge { color: var(--gold); font-size: 0.7rem; flex-shrink: 0; }
.search-results-head { padding: 10px; color: var(--muted); font-size: 0.85rem; }
.left-actions { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.left-actions .row { display: flex; gap: 6px; flex-wrap: wrap; }
.join-form { display: flex; gap: 6px; }
.join-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
}

/* ---------- Avatars ---------- */
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #111;
  flex-shrink: 0;
}
.avatar-room { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-dark); font-size: 1.05rem; }
.avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.68rem;
  color: #111;
  flex-shrink: 0;
}
.online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 4px;
  vertical-align: middle;
}

/* ---------- Center: conversation ---------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.back-btn { display: none; }
.chat-header-main { flex: 1; min-width: 0; }
.chat-header-main h1 { font-family: var(--font-head); font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-main .sub { color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-status { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.live-status.ok { color: var(--green); }
.pinned-bar {
  padding: 8px 14px;
  background: var(--gold-soft);
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; margin: auto; }
.empty-state h3 { font-family: var(--font-head); color: var(--text); margin: 0 0 6px; }

.message { display: flex; gap: 8px; align-items: flex-start; max-width: 78%; }
.message.mine { align-self: flex-end; flex-direction: row-reverse; }
.message.mine .bubble { background: rgba(245, 179, 1, 0.14); border-color: var(--gold-dark); }
.bubble {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg-author { font-weight: 700; color: var(--gold); font-size: 0.85rem; margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; }
.msg-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.msg-seen { color: var(--gold); }
.edited-mark { font-style: italic; }
.reply-quote {
  font-size: 0.82rem;
  color: var(--gold);
  border-left: 2px solid var(--gold);
  padding-left: 8px;
  margin-bottom: 4px;
  opacity: 0.9;
}
.pinned-flag { font-size: 0.78rem; color: var(--gold); margin-bottom: 2px; }
.msg-image { max-width: 320px; width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.msg-video { max-width: 320px; width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.msg-voice { margin-top: 6px; max-width: 280px; width: 100%; }
.msg-file { display: inline-block; margin-top: 6px; }
.reactions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.reaction-chip {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.82rem;
}
.reaction-chip.mine { border-color: var(--gold); background: var(--gold-soft); }
.msg-actions { display: none; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.message:hover .msg-actions { display: flex; }
.react-picker { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.react-pick {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.1rem;
  padding: 4px 8px;
}
.typing-indicator { min-height: 20px; padding: 2px 16px; color: var(--gold); font-size: 0.85rem; font-style: italic; }

/* ---------- Composer ---------- */
.composer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
}
.composer .attach-name { font-size: 0.8rem; color: var(--muted); align-self: center; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-mode { padding: 6px 14px 0; background: var(--bg-soft); font-size: 0.85rem; color: var(--gold); display: flex; gap: 8px; align-items: center; }
.composer-gate {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 14px;
  color: var(--muted);
  text-align: center;
}
.voice-btn.recording { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- Right: info panel ---------- */
.info-block { padding: 14px; border-bottom: 1px solid var(--line); }
.info-block h3 { font-family: var(--font-head); margin: 0 0 6px; font-size: 1.05rem; }
.info-block h4 { font-family: var(--font-head); margin: 0 0 8px; font-size: 0.9rem; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
.info-desc { color: var(--muted); margin: 0 0 6px; }
.info-meta { color: var(--muted); font-size: 0.85rem; margin: 0; }
.info-empty { padding: 16px; color: var(--muted); }
.invite-row { display: flex; gap: 6px; align-items: center; }
.invite-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.75rem;
  white-space: nowrap;
}
.member-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  border-radius: 999px;
  padding: 2px 7px;
}
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.media-video-thumb {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 6px; font-size: 0.8rem; color: var(--gold);
}
.pinned-item { font-size: 0.88rem; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.info-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { font-family: var(--font-head); margin: 0 0 4px; }
.modal-card .hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }
.modal-card .field { margin-bottom: 12px; }
.modal-card label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.modal-card input[type="text"],
.modal-card input[type="email"],
.modal-card textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal-error { color: var(--red); font-size: 0.88rem; min-height: 1.2em; }
.dm-result {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 8px; cursor: pointer;
}
.dm-result:hover { background: var(--bg-hover); }

/* ---------- Setup notice ---------- */
.setup-notice { max-width: 720px; margin: 40px auto; padding: 0 16px; }
.setup-card {
  background: var(--bg-soft);
  border: 1px solid var(--gold-dark);
  border-radius: 14px;
  padding: 24px;
}
.setup-card h1 { font-family: var(--font-head); margin: 0 0 4px; color: var(--gold); }
.setup-card ol { line-height: 1.9; }
.setup-card code { background: var(--bg-card); padding: 2px 6px; border-radius: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: calc(100vh - 57px); }
  .pane-left, .pane-center, .pane-right { grid-column: 1; grid-row: 1; }
  .pane-center, .pane-right { display: none; }
  body.room-open .pane-left { display: none; }
  body.room-open .pane-center { display: flex; }
  body.room-open .pane-right { display: none; }
  body.room-open.info-open .pane-right { display: flex; }
  body.room-open.info-open .pane-center { display: none; }
  .back-btn { display: inline-flex; }
  .message { max-width: 92%; }
  .message .msg-actions { display: flex; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .auth-bar input { max-width: 130px; }
}
