/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #111214;
  --surface: #1e1f22;
  --surface-2: #2b2d31;
  --surface-3: #313338;
  --border: #3c3f45;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --danger-hover: #c03537;
  --warn: #f0a500;
  --warn-hover: #c98d00;
  --success: #57f287;
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-faint: #5c5f66;
  --radius: 8px;
  --radius-sm: 5px;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

h1,
h2,
h3,
h4 {
  color: var(--text);
  font-weight: 600;
}
h2 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
}
h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}
h4 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

small {
  font-size: 0.8rem;
  color: var(--text-muted);
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ─── Navbar ────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  margin-right: 0.5rem;
}

.navbar-brand img {
  height: 28px;
  border-radius: 6px;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  transition:
    color 0.15s,
    background 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav-link.active {
  color: var(--text);
  background: var(--surface-3);
}

.navbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-top: 52px;
  padding: 1.75rem 2rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.page {
  display: none;
}
.page.active {
  display: block;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ─── Grid Layouts ──────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 1rem;
  }
}

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-warn {
  background: var(--warn);
  color: #111;
}
.btn-warn:hover {
  background: var(--warn-hover);
}
.btn-success {
  background: var(--success);
  color: #111;
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-3);
}
.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
}

/* ─── Form Elements ──────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.form-row > * {
  flex: 1;
}
.form-row > .btn {
  flex: 0;
}

label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

select option {
  background: var(--surface-2);
}

/* ─── Tables ─────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--surface-2);
}

.table-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-warn {
  background: rgba(240, 165, 0, 0.15);
  color: var(--warn);
}
.badge-timeout {
  background: rgba(240, 165, 0, 0.1);
  color: #e09000;
}
.badge-ban {
  background: rgba(237, 66, 69, 0.15);
  color: var(--danger);
}
.badge-kick {
  background: rgba(237, 66, 69, 0.1);
  color: #c03537;
}
.badge-unban {
  background: rgba(87, 242, 135, 0.15);
  color: var(--success);
}
.badge-note {
  background: rgba(88, 101, 242, 0.15);
  color: var(--accent);
}

/* ─── Profile Header ─────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
}
.profile-tag {
  font-size: 1.1rem;
  font-weight: 700;
}
.profile-id {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.profile-dates {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 0.2rem;
}

.profile-stats {
  display: flex;
  gap: 1.5rem;
  text-align: center;
}

.profile-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}
.profile-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Action Panels ──────────────────────────────────────────── */
.action-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.action-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.action-panel h4 {
  margin-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 0.5rem;
}

/* ─── Activity Feed ──────────────────────────────────────────── */
.activity-feed {
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.activity-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.3s ease;
}

.activity-entry:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.activity-body {
  flex: 1;
}
.activity-title {
  font-size: 0.85rem;
  font-weight: 500;
}
.activity-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.activity-time {
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.activity-mod {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Leaderboard ────────────────────────────────────────────── */
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.leaderboard-row:hover {
  background: var(--surface-2);
}

.lb-rank {
  width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lb-rank.gold {
  color: #ffd700;
}
.lb-rank.silver {
  color: #c0c0c0;
}
.lb-rank.bronze {
  color: #cd7f32;
}

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--surface-3);
}

.lb-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}
.lb-rep {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
}

.lb-bar-wrap {
  width: 80px;
  height: 5px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.lb-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lb-tab-btn {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.lb-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── Settings Tabs ──────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.settings-tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
  margin-bottom: -1px;
}

.settings-tab-btn:hover {
  color: var(--text);
}
.settings-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.settings-section {
  display: none;
}
.settings-section.active {
  display: block;
}

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  margin: 1rem;
}

.modal-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.modal-message {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.modal-input-field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.modal-input-field:focus {
  border-color: var(--accent);
}
.modal-input-field.hidden {
  display: none;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ─── Toasts ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 220px;
  max-width: 340px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: all;
  animation: toastIn 0.25s ease forwards;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.removing {
  animation: toastOut 0.25s ease forwards;
}

.toast-success {
  background: #1a3a2a;
  border-left: 3px solid var(--success);
  color: var(--success);
}
.toast-error {
  background: #3a1a1a;
  border-left: 3px solid var(--danger);
  color: var(--danger);
}
.toast-warn {
  background: #3a2a00;
  border-left: 3px solid var(--warn);
  color: var(--warn);
}
.toast-info {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  color: var(--text);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ─── Add Form Row ───────────────────────────────────────────── */
.add-row {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}

.add-row-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ─── Utilities ──────────────────────────────────────────────── */
.text-muted {
  color: var(--text-muted);
}
.text-danger {
  color: var(--danger);
}
.text-success {
  color: var(--success);
}
.text-warn {
  color: var(--warn);
}
.text-accent {
  color: var(--accent);
}

.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
}
.gap-sm {
  gap: 0.5rem;
}
.gap-md {
  gap: 1rem;
}
.mb-sm {
  margin-bottom: 0.5rem;
}
.mb-md {
  margin-bottom: 1rem;
}
.ml-auto {
  margin-left: auto;
}
.hidden {
  display: none !important;
}
.overflow-x {
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* ─── Login Page ──────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo {
  width: 56px;
  height: 56px;
  display: block;
  margin: 0 auto 0.75rem;
}
.login-brand h2 {
  margin: 0;
  font-size: 1.3rem;
}
.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: rgba(237, 66, 69, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(237, 66, 69, 0.3);
}

/* ─── Navbar Username ──────────────────────────────────────────── */
.nav-username {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

/* ─── Permission Badges (user management) ─────────────────────── */
.perm-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  margin: 0.1rem;
}
.perm-badge.active {
  background: rgba(88, 101, 242, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.superadmin-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(240, 165, 0, 0.15);
  border: 1px solid var(--warn);
  color: var(--warn);
}

/* ─── Permissions Checklist ───────────────────────────────────── */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.perm-check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.perm-check-label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(88, 101, 242, 0.08);
}
