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

:root {
  --bg:        #080b10;
  --surface:   #0e1117;
  --surface2:  #141820;
  --border:    #1e2430;
  --border2:   #252d3d;
  --primary:   #5865f2;
  --primary-h: #4752c4;
  --accent:    #00d4aa;
  --accent-h:  #00b894;
  --danger:    #e84855;
  --danger-h:  #c0392b;
  --warn:      #f0a500;
  --text:      #cdd6f4;
  --text-muted:#6b7280;
  --text-dim:  #4b5563;
  --admin-col: #f0a500;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:      'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
  line-height: 1.6;
  min-height:  100vh;
}

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

input, textarea, select {
  font-family: var(--font);
  font-size: 0.95rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}
input::placeholder { color: var(--text-dim); }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-h); color: #fff; }
.btn-accent   { background: var(--accent);   color: #000; }
.btn-accent:hover   { background: var(--accent-h); color: #000; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover   { background: var(--danger-h); color: #fff; }
.btn-ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover    { border-color: var(--primary); }
.btn-warn     { background: var(--warn);     color: #000; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* ─── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(ellipse at 60% 20%, #0f1f40 0%, var(--bg) 70%);
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.auth-form .card {
  box-shadow: var(--shadow);
}

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

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-form .btn {
  width: 100%;
  justify-content: center;
  padding: 0.65rem;
  margin-top: 0.5rem;
  font-size: 1rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: rgba(232,72,85,.12); border: 1px solid rgba(232,72,85,.3); color: #f87171; }
.alert-success { background: rgba(0,212,170,.12); border: 1px solid rgba(0,212,170,.3); color: var(--accent); }

/* ─── App layout ─────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.topbar-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  flex: 0 0 auto;
}

.topbar-spacer { flex: 1; }

.topbar-user {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-admin { background: rgba(240,165,0,.2); color: var(--admin-col); }
.badge-user  { background: rgba(88,101,242,.2); color: var(--primary); }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--primary);
}

.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-sep {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 1rem;
}

.main-content {
  overflow-y: auto;
  padding: 1.5rem;
}

/* ─── Dashboard ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-active   { border-left: 3px solid var(--accent); }
.stat-expired  { border-left: 3px solid var(--danger); }
.stat-plan     { border-left: 3px solid var(--primary); }

/* ─── Chat ────────────────────────────────────────────────────────────────────── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px - 3rem);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  word-break: break-word;
  transition: background .1s;
}
.chat-msg:hover { background: var(--surface2); }

.chat-msg .meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
}

.chat-msg .username {
  font-weight: 700;
  color: var(--primary);
}
.chat-msg .username.admin { color: var(--admin-col); }

.chat-msg .time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.chat-msg .text { color: var(--text); }

.chat-input-wrap {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.chat-input-wrap input { flex: 1; }

/* ─── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead { background: var(--surface2); }

th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: var(--surface2); }

.status-banned { color: var(--danger); font-weight: 600; }
.status-active { color: var(--accent); }
.status-expired { color: var(--warn); }
.status-none { color: var(--text-dim); }

/* ─── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  transform: translateY(10px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

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

/* ─── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast-success { background: #0a2e1f; border: 1px solid var(--accent); color: var(--accent); }
.toast-error   { background: #2e0a0a; border: 1px solid var(--danger); color: #f87171; }

@keyframes slideIn { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: translateX(0); } }

/* ─── Admin tabs ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.4rem;
  margin-top: 1rem;
  justify-content: center;
}

/* ─── Misc ────────────────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input { max-width: 280px; }

.code-badge {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.online-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

@media (max-width: 700px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }
  .sidebar { display: none; }
}
