/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0f1a;
  --bg2:      #12152b;
  --card:     #181b2e;
  --card2:    #1e2235;
  --border:   #2a2d45;
  --accent:   #4e7cff;
  --accent2:  #7c5cff;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --text:     #e8eaf6;
  --text2:    #8b90a8;
  --text3:    #5a5f7a;
  --radius:   12px;
  --sidebar:  240px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.main {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.login-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  margin-bottom: 4px;
}

.logo-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 12px 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.nav-link:hover { background: var(--card2); color: var(--text); text-decoration: none; }
.nav-link.active { background: linear-gradient(135deg, rgba(78,124,255,.2), rgba(124,92,255,.2)); color: var(--accent); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-email {
  flex: 1;
  font-size: 12px;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  color: var(--danger);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}

.btn-logout:hover { background: rgba(239,68,68,.15); }
.btn-logout svg { width: 18px; height: 18px; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.topbar-sub { color: var(--text2); font-size: 13px; margin-left: 10px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  margin-left: auto;
}
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 180px;
}
.topbar-search input::placeholder { color: var(--text3); }

/* ── Content ───────────────────────────────────────────────────────────────── */
.content { padding: 20px 24px 40px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-icon { color: var(--accent); opacity: 0.7; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--card2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover { background: var(--card2); }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

/* ── User cell ─────────────────────────────────────────────────────────────── */
.user-cell { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card2);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--accent);
  border: 1px solid var(--border);
}

.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.user-name { font-weight: 600; color: var(--text); }
.user-sub  { font-size: 11px; color: var(--text2); }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-admin   { background: rgba(78,124,255,.2);  color: var(--accent);  border: 1px solid rgba(78,124,255,.3); }
.badge-staff   { background: rgba(245,158,11,.2);  color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.badge-user    { background: rgba(139,144,168,.15); color: var(--text2);  border: 1px solid var(--border); }
.badge-banned  { background: rgba(239,68,68,.2);   color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.badge-blocked { background: rgba(245,158,11,.2);  color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.badge-online  { background: rgba(34,197,94,.2);   color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.badge-offline { background: rgba(139,144,168,.1); color: var(--text3);   border: 1px solid var(--border); }
.badge-pending { background: rgba(245,158,11,.2);  color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.badge-resolved{ background: rgba(34,197,94,.2);   color: var(--success); border: 1px solid rgba(34,197,94,.3); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary  { background: var(--accent);   color: #fff; }
.btn-primary:hover { background: #3d6be0; text-decoration: none; }

.btn-danger   { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.3); text-decoration: none; }

.btn-success  { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover { background: rgba(34,197,94,.3); text-decoration: none; }

.btn-warning  { background: rgba(245,158,11,.15); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.btn-warning:hover { background: rgba(245,158,11,.3); text-decoration: none; }

.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card2); color: var(--text); text-decoration: none; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; border-radius: 6px; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 180px; }

.form-label { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], select, textarea {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

select { cursor: pointer; }

textarea { resize: vertical; min-height: 80px; }

/* ── Search bar ────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input { flex: 1; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 500;
}

.alert-success { background: rgba(34,197,94,.15);  color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.alert-error   { background: rgba(239,68,68,.15);  color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.alert-warning { background: rgba(245,158,11,.15); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }

.pagination a {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.1s;
}

.pagination a:hover { background: var(--card2); color: var(--text); text-decoration: none; }
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Chat messages ─────────────────────────────────────────────────────────── */
.chat-thread { display: flex; flex-direction: column; gap: 12px; }

.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.msg-bubble.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(78,124,255,.25), rgba(124,92,255,.25));
  border: 1px solid rgba(78,124,255,.3);
  color: var(--text);
}

.msg-bubble.recv {
  align-self: flex-start;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
}

.msg-meta { font-size: 10px; color: var(--text3); margin-top: 3px; }

.msg-img { max-width: 200px; max-height: 200px; border-radius: 10px; object-fit: cover; margin-top: 4px; cursor: pointer; }

.msg-deleted { color: var(--text3); font-style: italic; }

.msg-ephemeral {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 20px;
  color: var(--warning);
  font-size: 12px;
}

/* ── Media grid ────────────────────────────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

.media-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.media-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--card);
}

.media-card-info { padding: 8px 10px; }
.media-card-user { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-time { font-size: 10px; color: var(--text3); }

/* ── Banned words ──────────────────────────────────────────────────────────── */
.word-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.word-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.word-tag button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}

.word-tag button:hover { opacity: 1; }

/* ── Activity log ──────────────────────────────────────────────────────────── */
.log-entry {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.log-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}

.log-action { font-weight: 600; color: var(--text); }
.log-time   { font-size: 11px; color: var(--text3); }
.log-detail { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── Profile view ──────────────────────────────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card2);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: var(--accent);
  flex-shrink: 0;
}

.profile-name  { font-size: 22px; font-weight: 800; color: var(--text); }
.profile-uid   { font-size: 11px; color: var(--text3); font-family: monospace; }
.profile-bio   { font-size: 13px; color: var(--text2); margin-top: 4px; }
.profile-stats { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }
.profile-stat-val { font-size: 20px; font-weight: 800; color: var(--text); }
.profile-stat-lbl { font-size: 11px; color: var(--text2); }

/* ── Info table ────────────────────────────────────────────────────────────── */
.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.info-table td:first-child { color: var(--text2); width: 150px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.info-table tr:last-child td { border-bottom: none; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  justify-content: center;
}

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-muted { color: var(--text2); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 700; }
.w-full { width: 100%; }
.code  { font-family: monospace; font-size: 12px; background: var(--card2); padding: 2px 6px; border-radius: 4px; }

/* ── Lightbox ──────────────────────────────────────────────────────────────── */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

#lightbox.open { display: flex; }
#lightbox img  { max-width: 90vw; max-height: 90vh; border-radius: 10px; object-fit: contain; }
#lightbox-close {
  position: fixed; top: 20px; right: 24px;
  background: rgba(255,255,255,.1);
  border: none; border-radius: 50%;
  width: 40px; height: 40px;
  color: #fff; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar: 60px; }
  .nav-link span:last-child, .logo-badge, .admin-email { display: none; }
  .sidebar-logo { justify-content: center; }
  .sidebar-logo-img { height: 28px; }
  .nav-link { justify-content: center; padding: 12px; }
  .sidebar-footer { justify-content: center; }
  .topbar h1 { font-size: 18px; }
}
