/* ============================================================
   NEXUS — Main Stylesheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand */
  --nexus-1: #6C63FF;
  --nexus-2: #A855F7;
  --nexus-grad: linear-gradient(135deg, #6C63FF 0%, #A855F7 50%, #EB459E 100%);

  /* Status */
  --green:   #57F287;
  --yellow:  #FEE75C;
  --red:     #ED4245;
  --orange:  #FF9B3F;

  /* Plan colors */
  --spark:   #57F287;
  --nova:    #6C63FF;
  --ultra:   #EB459E;

  /* Dark theme */
  --bg:      #0b0c10;
  --bg2:     #111318;
  --bg3:     #181921;
  --sidebar: #0f1015;
  --card:    #16171e;
  --card2:   #1c1d26;
  --input:   #12131a;
  --border:  rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);

  --text:    #e8e9f2;
  --text2:   #b0b3c8;
  --muted:   #6b6f8a;

  --font:    'Outfit', sans-serif;
  --mono:    'JetBrains Mono', monospace;

  --radius:  12px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --shadow:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

[data-theme="light"] {
  --bg:      #f4f5fa;
  --bg2:     #ecedf5;
  --bg3:     #e4e5f0;
  --sidebar: #dfe0ec;
  --card:    #ffffff;
  --card2:   #f8f9fe;
  --input:   #ecedf5;
  --border:  rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text:    #1a1b26;
  --text2:   #4a4d6b;
  --muted:   #8b8fa8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--nexus-1); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); font-size: 0.85em; background: var(--card2); padding: 2px 6px; border-radius: 4px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.2s; text-decoration: none;
  white-space: nowrap; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--nexus-1); color: #fff; }
.btn-primary:hover { background: #5a52e0; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--card2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c93b3e; }
.btn-success { background: var(--green); color: #000; }
.btn-success:hover { background: #43d470; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }
.btn-grad { background: var(--nexus-grad); color: #fff; }
.btn-grad:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px;
  background: var(--input); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--nexus-1);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-error { font-size: 13px; color: var(--red); margin-top: 5px; }

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.card-sm { padding: 16px; }
.card-lg { padding: 32px; }

/* ── Badge pills ── */
.badge-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
}
.badge-free    { background: rgba(153,170,181,0.15); color: #99AAB5; }
.badge-spark   { background: rgba(87,242,135,0.15);  color: var(--spark); }
.badge-nova    { background: rgba(108,99,255,0.15);  color: var(--nova); }
.badge-ultra   { background: rgba(235,69,158,0.15);  color: var(--ultra); }
.badge-staff   { background: rgba(108,99,255,0.15);  color: var(--nexus-1); }
.badge-mod     { background: rgba(87,242,135,0.15);  color: var(--green); }
.badge-online  { background: rgba(87,242,135,0.15);  color: var(--green); }
.badge-idle    { background: rgba(254,231,92,0.15);  color: var(--yellow); }
.badge-dnd     { background: rgba(237,66,69,0.15);   color: var(--red); }
.badge-offline { background: rgba(153,153,153,0.15); color: #999; }

/* ── Status dot ── */
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.status-online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-idle    { background: var(--yellow); }
.status-dnd     { background: var(--red); }
.status-offline { background: var(--muted); }

/* ── Avatar ── */
.avatar {
  border-radius: 50%; object-fit: cover;
  display: inline-block; flex-shrink: 0;
}
.avatar-sm  { width: 32px;  height: 32px; }
.avatar-md  { width: 40px;  height: 40px; }
.avatar-lg  { width: 64px;  height: 64px; }
.avatar-xl  { width: 96px;  height: 96px; }
.avatar-2xl { width: 128px; height: 128px; }
.avatar-wrap { position: relative; display: inline-block; }
.avatar-wrap .status-dot { position: absolute; bottom: 2px; right: 2px; border: 2px solid var(--bg); width: 12px; height: 12px; }

/* ── User badge icons ── */
.user-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.user-badge-icon {
  width: 22px; height: 22px; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; cursor: help; position: relative;
  transition: transform 0.15s;
}
.user-badge-icon:hover { transform: scale(1.2); }
.user-badge-icon[data-rarity="legendary"] { background: rgba(254,231,92,0.15); }
.user-badge-icon[data-rarity="epic"]      { background: rgba(168,85,247,0.15); }
.user-badge-icon[data-rarity="rare"]      { background: rgba(108,99,255,0.15); }
.user-badge-icon[data-rarity="common"]    { background: rgba(255,255,255,0.07); }

/* ── Alert ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(237,66,69,0.15);   border-left: 3px solid var(--red);    color: #ff8c8e; }
.alert-success { background: rgba(87,242,135,0.15);  border-left: 3px solid var(--green);  color: #57F287; }
.alert-info    { background: rgba(108,99,255,0.15);  border-left: 3px solid var(--nexus-1); color: #a5aaff; }
.alert-warning { background: rgba(255,155,63,0.15);  border-left: 3px solid var(--orange); color: #ffb84d; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--card2); }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Tooltips ── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--border2);
  color: var(--text); font-size: 12px; padding: 5px 10px;
  border-radius: 6px; white-space: nowrap; z-index: 1000;
  pointer-events: none; box-shadow: var(--shadow);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity 0.2s; padding: 20px;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 32px;
  width: 100%; max-width: 480px;
  transform: scale(0.95); transition: transform 0.2s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.modal-desc { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; padding: 4px; }

/* ── Chat layout ── */
.app-layout {
  display: flex; height: 100vh; overflow: hidden;
}
.server-rail {
  width: 72px; background: var(--sidebar); flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 2px; overflow-y: auto;
}
.channel-sidebar {
  width: 240px; background: var(--bg2); flex-shrink: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.member-sidebar { width: 240px; background: var(--bg2); flex-shrink: 0; overflow-y: auto; }

/* Server icon */
.server-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--card2); display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer; transition: all 0.2s; position: relative;
  overflow: hidden; flex-shrink: 0;
}
.server-icon:hover, .server-icon.active { border-radius: 16px; }
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-icon-pip {
  position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
  width: 4px; background: var(--text); border-radius: 0 4px 4px 0;
  transition: height 0.2s;
}
.server-icon:hover .server-icon-pip { height: 20px; }
.server-icon.active .server-icon-pip { height: 40px; }

/* Channel list */
.channel-header {
  padding: 16px; font-size: 15px; font-weight: 700;
  border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; flex-shrink: 0;
}
.category-name {
  padding: 16px 8px 4px 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.channel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin: 0 4px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 15px; color: var(--muted); transition: all 0.15s;
}
.channel-item:hover { background: rgba(255,255,255,0.05); color: var(--text2); }
.channel-item.active { background: rgba(108,99,255,0.15); color: var(--text); }
.channel-icon { font-size: 17px; flex-shrink: 0; }

/* Chat messages */
.chat-header {
  padding: 0 16px; height: 48px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  background: var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.messages-area {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.message-group { display: flex; gap: 16px; padding: 6px 8px; border-radius: 8px; transition: background 0.1s; }
.message-group:hover { background: rgba(255,255,255,0.02); }
.message-avatar { flex-shrink: 0; margin-top: 2px; }
.message-body {}
.message-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.message-author { font-weight: 700; font-size: 15px; cursor: pointer; }
.message-author:hover { text-decoration: underline; }
.message-time { font-size: 11px; color: var(--muted); }
.message-content { font-size: 15px; line-height: 1.5; color: var(--text); word-break: break-word; }
.message-content code { font-size: 0.85em; }
.message-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 100px; font-size: 13px;
  background: var(--card2); border: 1px solid var(--border2);
  cursor: pointer; transition: all 0.15s;
}
.reaction-btn:hover, .reaction-btn.active { border-color: var(--nexus-1); background: rgba(108,99,255,0.1); }

/* Chat input */
.chat-input-area {
  padding: 0 16px 16px; flex-shrink: 0;
}
.chat-input-wrap {
  background: var(--card2); border-radius: var(--radius);
  border: 1px solid var(--border2); display: flex; align-items: flex-end;
  gap: 8px; padding: 8px 12px;
  transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: var(--nexus-1); }
.chat-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font); font-size: 15px;
  max-height: 200px; resize: none; line-height: 1.5;
}
.chat-input::placeholder { color: var(--muted); }
.chat-input-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px; border-radius: 6px;
  font-size: 20px; transition: color 0.15s; display: flex;
}
.chat-input-btn:hover { color: var(--text); }

/* ── Profile popup ── */
.profile-popup {
  position: fixed; z-index: 5000; width: 300px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.profile-popup-banner { height: 80px; position: relative; }
.profile-popup-avatar { position: absolute; bottom: -24px; left: 16px; }
.profile-popup-body { padding: 32px 16px 16px; }
.profile-popup-name { font-size: 18px; font-weight: 700; }
.profile-popup-tag  { font-size: 13px; color: var(--muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .member-sidebar { display: none; }
  .channel-sidebar { width: 200px; }
}
@media (max-width: 500px) {
  .channel-sidebar { position: fixed; left: -240px; z-index: 100; transition: left 0.25s; top: 0; bottom: 0; }
  .channel-sidebar.open { left: 72px; }
}

/* ── Animations ── */
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
@keyframes spin { to{transform:rotate(360deg)} }

.fade-in { animation: fadeIn 0.3s ease both; }
.loading { animation: pulse 1.5s ease infinite; }
.spin { animation: spin 1s linear infinite; }

/* ── Notification dot ── */
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); position: absolute;
  top: 2px; right: 2px; border: 2px solid var(--sidebar);
}
.notif-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--sidebar);
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Typography helpers ── */
.text-muted   { color: var(--muted); }
.text-small   { font-size: 13px; }
.text-center  { text-align: center; }
.font-bold    { font-weight: 700; }
.grad-text    { background: var(--nexus-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ── Misc helpers ── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.w-full       { width: 100%; }
.hidden       { display: none !important; }
