@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Familjen+Grotesk:wght@400;500;600;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --primary: #506EF2;
  --primary-hover: #3a55d4;
  --primary-glow: rgba(80,110,242,0.25);
  --green: #3DD68C;
  --pink: #F24E8F;
  --amber: #F59E0B;
  --red: #EF4444;
  --purple: #8B5CF6;

  --bg:     #16171D;
  --bg2:    #111218;
  --bg3:    #0C0D11;
  --surface: #1E2028;
  --surface2: #252731;
  --surface3: #2E3040;
  --hover: rgba(255,255,255,0.04);

  --text:   #E2E4EE;
  --text-2: #9FA3B8;
  --text-3: #5C6080;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

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

  --font: 'DM Sans', sans-serif;
  --font-display: 'Familjen Grotesk', sans-serif;

  --sidebar-w: 72px;
  --ch-sidebar-w: 248px;
  --mem-sidebar-w: 236px;
  --header-h: 52px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg3);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeInScale { from { opacity:0; transform:scale(0.96); } to { opacity:1; transform:scale(1); } }
@keyframes slideLeft { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow-pulse { 0%,100% { box-shadow: 0 0 0 0 var(--primary-glow); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  border: none; transition: all 0.18s ease;
  line-height: 1;
}
.btn-primary {
  background: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--glow); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: var(--border2); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  background: transparent; border: none; color: var(--text-3);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all 0.15s;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon.active { color: var(--primary); }

/* ===== FORM ELEMENTS ===== */
.input {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 14px; color: var(--text);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.input::placeholder { color: var(--text-3); }
.input-sm { padding: 8px 12px; font-size: 13px; }

.form-label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2); margin-bottom: 6px;
}
.form-group { margin-bottom: 18px; }
.form-error {
  font-size: 12px; color: var(--red);
  margin-top: 5px; display: none;
}
.form-group.error .input { border-color: var(--red); }
.form-group.error .form-error { display: block; }

/* ===== AVATAR ===== */
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
  position: relative;
  user-select: none;
}
.avatar-40 { width: 40px; height: 40px; font-size: 16px; }
.avatar-36 { width: 36px; height: 36px; font-size: 14px; }
.avatar-32 { width: 32px; height: 32px; font-size: 13px; }
.avatar-28 { width: 28px; height: 28px; font-size: 11px; }
.avatar-48 { width: 48px; height: 48px; font-size: 18px; }
.avatar-72 { width: 72px; height: 72px; font-size: 28px; }

.status-indicator {
  position: absolute; bottom: -1px; right: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2.5px solid var(--bg2);
}
.status-indicator.sm { width: 10px; height: 10px; border-width: 2px; }
.status-online { background: var(--green); }
.status-idle { background: var(--amber); }
.status-dnd { background: var(--red); }
.status-offline { background: var(--text-3); }

/* ===== BADGE ===== */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 7px; border-radius: 100px;
  font-size: 10px; font-weight: 800; line-height: 1;
}
.badge-notif { background: var(--red); color: #fff; }
.badge-green { background: rgba(61,214,140,0.15); color: var(--green); }
.badge-blue { background: rgba(80,110,242,0.15); color: var(--primary); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--purple); }

/* ===== TOOLTIP ===== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%);
  background: var(--surface3); color: var(--text);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--radius-sm);
  pointer-events: none; opacity: 0;
  transition: opacity 0.15s; z-index: 100;
  box-shadow: var(--shadow);
}
[data-tip]:hover::after { opacity: 1; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999; pointer-events: none;
}
.toast {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideLeft 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 360px;
  pointer-events: all;
}
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--primary); }
.toast-warning { border-left: 3px solid var(--amber); }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: fadeInScale 0.25s ease;
  position: relative;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  margin-bottom: 6px;
}
.modal-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 28px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--surface2); border: none; color: var(--text-3);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.modal-close:hover { background: var(--surface3); color: var(--text); }

/* ===== CONTEXT MENU ===== */
.ctx-menu {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 180px;
  z-index: 800;
  box-shadow: var(--shadow-lg);
  animation: fadeInScale 0.15s ease;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.12s;
}
.ctx-item:hover { background: var(--surface3); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: rgba(239,68,68,0.1); }
.ctx-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== SPINNER ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px; background: var(--border);
  margin: 12px 0;
}
.divider-labeled {
  display: flex; align-items: center; gap: 12px;
  font-size: 11px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.divider-labeled::before, .divider-labeled::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ===== PING DOT ===== */
.ping-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: glow-pulse 2s infinite;
}

/* ===== USER CARD POPUP ===== */
.user-card {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 280px;
  box-shadow: var(--shadow-lg);
  z-index: 400;
  overflow: hidden;
  animation: fadeInScale 0.2s ease;
}
.user-card-banner {
  height: 70px;
}
.user-card-body {
  padding: 0 16px 16px;
  position: relative;
}
.user-card-avatar-wrap {
  margin-top: -28px; margin-bottom: 10px;
}
.user-card-name { font-size: 18px; font-weight: 700; }
.user-card-tag { font-size: 13px; color: var(--text-2); }
.user-card-divider { height: 1px; background: var(--border); margin: 12px 0; }
.user-card-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 6px; }
.user-card-status-text { font-size: 13px; color: var(--text-2); }
