/* ============================================================
   DuoCord — tema escuro estilo Discord
   ============================================================ */
:root {
  --bg-deepest: #1e1f22;   /* barra mais escura */
  --bg-sidebar: #2b2d31;   /* sidebar / painéis   */
  --bg-chat: #313338;      /* área do chat        */
  --bg-hover: #3a3c41;
  --bg-active: #404249;
  --bg-input: #383a40;
  --border: #26272b;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --text-muted: #949ba4;
  --text-faint: #6d6f78;
  --accent: #5865f2;       /* blurple */
  --accent-hover: #4752c4;
  --green: #23a559;
  --yellow: #f0b232;
  --red: #f23f43;
  --gray: #80848e;
  --radius: 8px;
  --sidebar-w: 240px;
  --members-w: 232px;
  --font: "gg sans", "Noto Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-deepest);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea {
  font-family: inherit; font-size: 15px; color: var(--text-strong);
  background: var(--bg-deepest); border: 1px solid var(--border);
  border-radius: 4px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: none; }
[hidden] { display: none !important; }

.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 15px; height: 15px; }
.icon.muted { color: var(--text-muted); }
.icon.accent { color: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 6px; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-strong); }
.icon-btn.accent { color: var(--accent); }
.icon-btn.danger:hover { background: var(--red); color: #fff; }

/* ---------- Tela de login ---------- */
.auth-screen {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #23244d 0%, var(--bg-deepest) 55%);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--bg-sidebar);
  border-radius: 10px; padding: 32px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.auth-logo .icon { width: 28px; height: 28px; color: #fff; }
.auth-card h1 { text-align: center; color: var(--text-strong); font-size: 24px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 6px 0 24px; }
.auth-card label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--text-muted); margin: 14px 0 6px; }
.auth-error, .modal-error {
  background: rgba(242,63,67,.12); border: 1px solid rgba(242,63,67,.4);
  color: #fca5a7; font-size: 13.5px; border-radius: 6px; padding: 8px 12px; margin-top: 14px;
}
.btn-primary {
  width: 100%; margin-top: 18px; background: var(--accent); color: #fff;
  font-weight: 600; font-size: 15px; padding: 11px; border-radius: 6px;
  transition: background .12s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary {
  background: var(--bg-input); color: var(--text-strong); font-weight: 600;
  font-size: 14px; padding: 8px 14px; border-radius: 6px;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-link {
  display: block; margin: 14px auto 0; color: #00a8fc; font-size: 13.5px;
}
.btn-link:hover { text-decoration: underline; }

/* ---------- Layout principal ---------- */
.app {
  display: grid; height: 100dvh;
  grid-template-columns: var(--sidebar-w) 1fr var(--members-w);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar); display: flex; flex-direction: column; min-height: 0;
}
.server-header {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 48px;
  font-weight: 700; color: var(--text-strong);
  box-shadow: 0 1px 0 var(--border); flex: none;
}
.channel-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); padding: 0 8px 4px;
}
.section-title.pad { padding: 16px 16px 8px; }
.channel-list { list-style: none; }
.channel-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 5px; color: var(--text-muted); cursor: pointer; margin-bottom: 1px;
  font-weight: 500;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text); }
.channel-item.active { background: var(--bg-active); color: var(--text-strong); }
.channel-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-item .icon-btn { width: 24px; height: 24px; opacity: 0; }
.channel-item:hover .icon-btn { opacity: 1; }
.channel-item .icon-btn:hover { color: var(--red); }

/* Painel de voz na sidebar */
.voice-panel {
  flex: none; border-top: 1px solid var(--border); padding: 10px 12px;
  background: var(--bg-sidebar);
}
.voice-panel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.voice-status { color: var(--green); font-weight: 700; font-size: 13.5px; }
.voice-quality {
  display: flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 12px;
  margin-top: 2px;
}
.voice-quality.good #latency-text, .voice-quality.good .icon { color: var(--green); }
.voice-quality.ok #latency-text, .voice-quality.ok .icon { color: var(--yellow); }
.voice-quality.bad #latency-text, .voice-quality.bad .icon { color: var(--red); }

/* Painel do usuário */
.user-panel {
  flex: none; height: 56px; background: var(--bg-deepest);
  display: flex; align-items: center; gap: 4px; padding: 0 8px;
}
.user-panel-info {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 4px 6px; border-radius: 5px; cursor: pointer;
}
.user-panel-info:hover { background: var(--bg-hover); }
.user-panel-names { min-width: 0; }
.user-panel-name {
  font-size: 14px; font-weight: 600; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-panel-sub { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Avatares e status ---------- */
.avatar-wrap { position: relative; flex: none; }
.avatar-wrap img, .avatar-fallback {
  border-radius: 50%; object-fit: cover; display: block;
  background: var(--bg-active);
}
.avatar-wrap.sm img { width: 32px; height: 32px; }
.avatar-wrap.md img { width: 40px; height: 40px; }
.avatar-wrap.lg img { width: 80px; height: 80px; }
.status-dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px;
  border-radius: 50%; border: 3px solid var(--bg-deepest); background: var(--gray);
}
.status-dot.online { background: var(--green); }
.status-dot.away { background: var(--yellow); }
.status-dot.dnd { background: var(--red); }
.status-dot.offline { background: var(--gray); }

/* ---------- Coluna central ---------- */
.main { display: flex; flex-direction: column; background: var(--bg-chat); min-width: 0; min-height: 0; }
.topbar {
  flex: none; height: 48px; display: flex; align-items: center; gap: 8px;
  padding: 0 16px; box-shadow: 0 1px 0 var(--border);
}
.topbar h2 { font-size: 16px; color: var(--text-strong); }
.topbar-call {
  display: flex; align-items: center; gap: 6px; margin-left: 14px;
  color: var(--text-muted); font-size: 13.5px;
  background: var(--bg-sidebar); border-radius: 20px; padding: 4px 12px;
}
.topbar-spacer { flex: 1; }

/* ---------- Área de vídeo ---------- */
.video-stage {
  flex: none; display: flex; gap: 10px; padding: 12px 16px;
  background: var(--bg-deepest); max-height: 42vh;
}
.video-tile {
  position: relative; flex: 1; min-width: 0; border-radius: 10px; overflow: hidden;
  background: #000; aspect-ratio: 16/9; max-height: 38vh;
  display: flex; align-items: center; justify-content: center;
}
.video-tile video { width: 100%; height: 100%; object-fit: contain; }
.video-tile.no-video video { display: none; }
.tile-avatar { display: none; }
.video-tile.no-video { background: var(--bg-sidebar); }
.video-tile.no-video .tile-avatar { display: block; }
.tile-avatar img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.tile-label {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 7px;
  background: rgba(0,0,0,.65); padding: 4px 10px; border-radius: 14px;
  font-size: 13px; font-weight: 600; color: #fff;
}
.tile-muted { color: var(--red); }
.speaking-ring {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint);
  transition: background .1s, box-shadow .1s;
}
.speaking-ring.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.video-tile.speaking { outline: 2px solid var(--green); outline-offset: -2px; }

/* ---------- Aviso de retenção ---------- */
.retention-banner {
  flex: none; display: flex; align-items: center; gap: 8px;
  margin: 8px 16px 0; padding: 8px 12px; border-radius: 6px;
  background: rgba(240,178,50,.1); border: 1px solid rgba(240,178,50,.35);
  color: #f5cd6f; font-size: 13.5px;
}

/* ---------- Mensagens ---------- */
.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; min-height: 0; }
.date-divider {
  display: flex; align-items: center; gap: 10px; color: var(--text-faint);
  font-size: 12px; font-weight: 700; margin: 18px 0 8px;
}
.date-divider::before, .date-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--bg-hover);
}
.msg { display: flex; gap: 14px; padding: 3px 8px; border-radius: 6px; }
.msg:hover { background: rgba(0,0,0,.12); }
.msg.head { margin-top: 14px; }
.msg .gutter { width: 40px; flex: none; }
.msg .body { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-author { font-weight: 600; color: var(--text-strong); font-size: 15px; }
.msg-time {
  font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.msg-time b { color: var(--text-muted); font-weight: 600; }
.msg-text { color: var(--text); line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }
.msg-image {
  display: block; max-width: min(420px, 100%); max-height: 320px; border-radius: 8px;
  margin-top: 4px; cursor: pointer; object-fit: cover;
}
.messages-empty {
  color: var(--text-muted); text-align: center; padding: 48px 20px; font-size: 14px;
}
.messages-empty strong { color: var(--text-strong); display: block; font-size: 17px; margin-bottom: 6px; }

/* ---------- Composer ---------- */
.composer {
  flex: none; display: flex; align-items: flex-end; gap: 6px;
  margin: 8px 16px 0; padding: 6px 8px; background: var(--bg-input); border-radius: 10px;
}
.composer textarea {
  flex: 1; background: transparent; border: none; padding: 8px 4px;
  max-height: 140px; line-height: 1.4;
}
.composer textarea:focus { border: none; }

/* ---------- Barra de chamada ---------- */
.call-bar {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px 12px;
}
.call-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-input); color: var(--text-strong);
  padding: 10px 14px; border-radius: 24px; font-weight: 600; font-size: 14px;
  transition: background .12s, color .12s;
}
.call-btn:hover { background: var(--bg-hover); }
.call-btn.join { background: var(--green); color: #fff; }
.call-btn.join:hover { background: #1e8e4d; }
.call-btn.danger { background: var(--red); color: #fff; }
.call-btn.danger:hover { background: #d33236; }
.call-btn.active-red { background: var(--red); color: #fff; }
.call-btn.active-green { background: var(--green); color: #fff; }
.call-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.volume-control {
  display: flex; align-items: center; gap: 8px; background: var(--bg-input);
  padding: 8px 14px; border-radius: 24px; color: var(--text-muted);
}
.volume-control input[type=range] { width: 90px; accent-color: var(--accent); padding: 0; border: none; background: transparent; }

/* ---------- Painel de membros ---------- */
.members { background: var(--bg-sidebar); overflow-y: auto; }
.member-list { list-style: none; padding: 0 8px; }
.member-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 5px; margin-bottom: 2px;
}
.member-item:hover { background: var(--bg-hover); }
.member-item.is-offline { opacity: .45; }
.member-name { font-weight: 600; color: var(--text); font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-info { min-width: 0; }

/* ---------- Modais ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 440px; background: var(--bg-sidebar); border-radius: 10px;
  overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  max-height: 90dvh; display: flex; flex-direction: column;
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 0;
}
.modal h3 { color: var(--text-strong); font-size: 18px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-body label {
  display: block; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em; color: var(--text-muted); margin: 14px 0 6px;
}
.modal-body label:first-child { margin-top: 0; }
.modal footer { padding: 14px 18px; background: var(--bg-deepest); }
.modal footer .btn-primary { margin-top: 0; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.profile-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.status-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-picker button {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--bg-deepest); border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text);
}
.status-picker button .status-dot { position: static; border: none; width: 10px; height: 10px; }
.status-picker button.selected { border-color: var(--accent); background: rgba(88,101,242,.12); }

.channel-input-wrap {
  display: flex; align-items: center; gap: 8px; background: var(--bg-deepest);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 10px;
}
.channel-input-wrap input { border: none; background: transparent; padding: 10px 0; }

.image-lightbox { position: relative; max-width: 90vw; max-height: 90dvh; }
.image-lightbox img { max-width: 90vw; max-height: 85dvh; border-radius: 8px; display: block; }
.lightbox-close { position: absolute; top: -40px; right: 0; color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-deepest); border: 1px solid var(--border); color: var(--text-strong);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 90vw; text-align: center;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-deepest); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsivo (tablet) ---------- */
@media (max-width: 1024px) {
  :root { --members-w: 200px; --sidebar-w: 220px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
  .members {
    position: fixed; right: 0; top: 0; bottom: 0; width: 240px; z-index: 40;
    box-shadow: -8px 0 24px rgba(0,0,0,.4);
    transform: translateX(100%); transition: transform .18s ease;
  }
  .members.open { transform: translateX(0); }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 190px; }
  .call-btn span { display: none; }
  .call-btn.join span { display: inline; }
  .video-stage { flex-direction: column; max-height: 50vh; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
