* { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #0a0b0f;
  --bg-elevated: #101218;
  --panel: #14161e;
  --panel-alt: #1b1e29;
  --panel-hover: #22263380;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef0f6;
  --muted: #8d92a3;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --accent-pink: #ff6bb3;
  --danger: #ff5c72;
  --success: #34d399;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --gradient-accent: linear-gradient(135deg, var(--accent), var(--accent-pink));
}

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  isolation: isolate;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px circle at 12% -5%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(600px circle at 100% 10%, rgba(255, 107, 179, 0.12), transparent 55%),
    radial-gradient(800px circle at 50% 120%, rgba(34, 211, 238, 0.08), transparent 60%);
  pointer-events: none;
}

* { scrollbar-color: rgba(255, 255, 255, 0.18) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }
*::-webkit-scrollbar-track { background: transparent; }

h1 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 26px 0 12px; letter-spacing: -0.01em; }
h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }

.muted { color: var(--muted); font-size: 0.9rem; }
.small { font-size: 0.8rem; }

button {
  background: var(--gradient-accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(124, 92, 255, 0.28); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.ghost-btn, .decline-btn {
  background: var(--panel-alt);
  color: var(--text);
  box-shadow: none;
}
.ghost-btn:hover, .decline-btn:hover { background: var(--panel-hover); filter: none; box-shadow: none; }

.danger-btn { background: linear-gradient(135deg, var(--danger), #ff8a5c); }

input[type='text'],
input[type='password'],
textarea {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type='text']:focus,
input[type='password']:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ---- Centered card pages (login) ---- */

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: min(440px, 92vw);
  padding: 32px;
  background: linear-gradient(180deg, var(--panel), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-ring {
  width: 20px;
  height: 20px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--gradient-accent);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}

.auth-tagline { margin: 6px 0 0; }
.auth-card { margin-top: 0; }
.auth-tabs { display: flex; gap: 6px; margin: 22px 0 18px; background: var(--panel-alt); padding: 4px; border-radius: var(--radius-sm); }
.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.auth-tab:hover { filter: none; transform: none; box-shadow: none; background: rgba(255, 255, 255, 0.04); }
.auth-tab.active { background: var(--gradient-accent); color: white; }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.83rem; color: var(--muted); font-weight: 500; }
.error-text { color: var(--danger); margin-top: 14px; font-size: 0.88rem; }

.divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 16px; color: var(--muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: white;
  color: #3c4043;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.google-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ---- App shell: rail + main ---- */

.app-shell { display: flex; height: 100vh; overflow: hidden; }

.community-rail {
  width: 76px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  overflow-y: auto;
}

.rail-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  margin-bottom: 4px;
}
.rail-logo:hover { filter: none; transform: none; box-shadow: none; background: var(--panel-hover); }

.rail-list { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1; overflow-y: auto; width: 100%; }

.rail-icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  padding: 0;
  box-shadow: none;
  position: relative;
  transition: border-radius 0.18s ease, transform 0.15s ease;
}
.rail-icon:hover { border-radius: var(--radius-md); filter: none; transform: none; box-shadow: none; }
.rail-icon.active { border-radius: var(--radius-md); box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--accent); }
.rail-add { background: var(--panel-alt); color: var(--muted); font-size: 1.2rem; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---- Top bar / nav ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 18, 24, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.top-nav { display: flex; gap: 26px; }
.nav-link {
  background: none;
  color: var(--muted);
  padding: 6px 2px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: none;
  position: relative;
  border-radius: 0;
}
.nav-link:hover { background: none; color: var(--text); filter: none; transform: none; box-shadow: none; }
.nav-link.active { color: var(--text); }
.nav-link.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: 2px;
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--gradient-accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  vertical-align: middle;
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.icon-btn:hover { background: var(--panel-alt); color: var(--text); filter: none; transform: none; box-shadow: none; }

.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  position: relative;
}
.avatar-xs { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-more { background: var(--panel-alt) !important; color: var(--muted) !important; font-size: 0.65rem; }
.avatar-sm { width: 36px; height: 36px; font-size: 0.8rem; }
.avatar-lg { width: 76px; height: 76px; font-size: 1.5rem; }

.status-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  bottom: -1px;
  right: -1px;
  background: var(--muted);
}
.status-dot.online { background: var(--success); }

main#views { flex: 1; padding: 28px 36px 60px; max-width: 1240px; margin: 0 auto; width: 100%; overflow-y: auto; }

.view { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--radius-md);
}
.inline-form input { flex: 1; min-width: 160px; }

.checkbox-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.85rem; }
.checkbox-label input { width: auto; accent-color: var(--accent); }

/* ---- Comunidades ---- */

.communities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 8px;
}

.community-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.community-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.community-banner { height: 96px; }
.community-body { padding: 18px; display: flex; flex-direction: column; gap: 7px; }
.community-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.enter-btn { margin-top: 8px; width: 100%; }

.invite-panel { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.invite-panel .link-row { display: flex; gap: 6px; }
.invite-panel .link-row input { flex: 1; min-width: 0; font-size: 0.78rem; }
.invite-panel form { display: flex; gap: 6px; }
.invite-panel form input { flex: 1; min-width: 0; }

.invites-section { margin-bottom: 24px; }
.invites-list { display: flex; flex-direction: column; gap: 10px; }
.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}
.invite-row p { margin: 0; }
.invite-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ---- Conversas (channels) ---- */

.conversas-layout { display: flex; flex-direction: column; height: calc(100vh - 170px); }

.channel-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.channel-tab {
  background: var(--panel-alt);
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: none;
  position: relative;
}
.channel-tab:hover { filter: none; transform: none; box-shadow: none; background: var(--panel-hover); }
.channel-tab.active { background: var(--gradient-accent); color: white; }
.unread-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-pink);
  margin-left: 7px;
  vertical-align: middle;
}

.channel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.channel-header h2 { margin: 0; }
.member-bubbles { display: flex; align-items: center; }
.member-bubbles .avatar { margin-left: -8px; border: 2px solid var(--bg); }
.member-bubbles .avatar:first-child { margin-left: 0; }

.text-channel-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.voice-channel-panel { flex: 1; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }

.messages-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 6px;
}

.chat-message { display: flex; gap: 12px; }
.chat-message-body { flex: 1; min-width: 0; }
.chat-message .message-meta { margin: 0 0 4px; font-size: 0.85rem; }
.chat-message .message-meta strong { font-weight: 700; }

.message-row { position: relative; display: flex; flex-direction: column; align-items: flex-start; padding: 2px 0; border-radius: var(--radius-sm); }
.message-row:hover { background: rgba(255, 255, 255, 0.02); }
.message-row:hover .message-actions { opacity: 1; pointer-events: auto; }
.message-text { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.message-deleted { font-style: italic; color: var(--muted); }
.edited-tag { font-size: 0.72rem; }

.message-actions {
  position: absolute;
  top: -14px;
  right: 4px;
  display: flex;
  gap: 2px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  box-shadow: var(--shadow-sm);
}
.msg-action-btn {
  background: none;
  box-shadow: none;
  padding: 4px 7px;
  font-size: 0.85rem;
  line-height: 1;
}
.msg-action-btn:hover { background: var(--panel-hover); filter: none; transform: none; box-shadow: none; }

.reaction-picker {
  position: absolute;
  top: -48px;
  right: 4px;
  display: flex;
  gap: 3px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.reaction-picker button { background: none; box-shadow: none; padding: 4px 6px; font-size: 1rem; }
.reaction-picker button:hover { background: var(--panel-hover); filter: none; transform: none; box-shadow: none; }

.reactions-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.reaction-chip {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  box-shadow: none;
}
.reaction-chip:hover { filter: none; transform: none; box-shadow: none; background: var(--panel-hover); }
.reaction-chip.mine { background: rgba(124, 92, 255, 0.18); border-color: var(--accent); color: var(--accent-2); }

.message-edit-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 6px 10px;
}

.typing-indicator {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.message-form { display: flex; gap: 8px; margin-top: 14px; }
.message-form input { flex: 1; }
.send-btn { width: 44px; padding: 10px; display: flex; align-items: center; justify-content: center; }

/* ---- Voice channel ---- */

.voice-controls { display: flex; gap: 8px; flex-wrap: wrap; }

.voice-participants {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-participants li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.video-tile {
  position: relative;
  background: black;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  cursor: pointer;
  border: 1px solid var(--border);
}
.video-tile:fullscreen { aspect-ratio: unset; }
.video-tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
}
.unmute-btn { position: absolute; top: 8px; right: 8px; padding: 4px 10px; font-size: 0.8rem; }

/* ---- Mensagens (DMs) ---- */

.dm-strip { display: flex; gap: 18px; overflow-x: auto; padding: 4px 0 20px; }
.dm-strip-item {
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
  width: 72px;
  box-shadow: none;
}
.dm-strip-item:hover { background: none; color: var(--text); filter: none; transform: none; box-shadow: none; }
.dm-strip-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px; }

.dm-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  height: calc(100vh - 300px);
  min-height: 420px;
}

.dm-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.dm-list-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s ease;
}
.dm-list-item:hover { background: var(--panel-hover); }
.dm-list-item.active { background: var(--panel-alt); }
.dm-list-text { flex: 1; min-width: 0; }
.dm-list-text p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dm-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  padding: 18px;
  min-height: 0;
}
.dm-panel-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.dm-panel-header p { margin: 0; }
#dm-messages { flex: 1; }

/* ---- Perfil ---- */

.profile-banner {
  height: 130px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 20% 20%, rgba(124, 92, 255, 0.45), transparent 55%),
    radial-gradient(circle at 80% 60%, rgba(255, 107, 179, 0.3), transparent 55%),
    var(--panel);
  margin-bottom: -44px;
}

.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.profile-header { display: flex; align-items: center; gap: 18px; }
.profile-identity { flex: 1; }
.profile-header .avatar-lg { border: 3px solid var(--panel); }
.status-badge { background: var(--gradient-accent); color: white; }
.profile-bio { white-space: pre-wrap; margin: 16px 0 10px; line-height: 1.5; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }

.stats-row { display: flex; gap: 14px; margin: 20px 0; }
.stat-box {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-value { font-size: 1.5rem; font-weight: 800; background: var(--gradient-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }

.settings-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 480px;
}
.settings-panel label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.settings-label { display: block; margin-bottom: 6px; }
.status-options { display: flex; gap: 8px; flex-wrap: wrap; }
.status-option { background: var(--panel-alt); color: var(--muted); box-shadow: none; }
.status-option:hover { filter: none; transform: none; box-shadow: none; background: var(--panel-hover); }
.status-option.active { background: var(--gradient-accent); color: white; }
