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

:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3e;
  --surface: #222536;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --text: #e2e8f0;
  --muted: #8892a4;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --sidebar-w: 220px;
  --sidebar-collapsed: 60px;
  --topbar-h: 56px;
  --radius: 8px;
  --transition: 0.2s ease;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 12px; text-align: left; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(99,102,241,0.04); }

/* ===== Layout ===== */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}

.logo-icon { font-size: 22px; flex-shrink: 0; }
.logo-text { font-weight: 700; font-size: 16px; color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: rgba(99,102,241,0.15); color: var(--accent); border-right: 3px solid var(--accent); }

.nav-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.nav-label { font-size: 14px; }

.sidebar-toggle {
  border: none;
  background: none;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 16px;
  border-top: 1px solid var(--border);
  transition: color var(--transition);
  text-align: left;
}
.sidebar-toggle:hover { color: var(--text); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* ===== Main Wrapper ===== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-wrapper.expanded { margin-left: var(--sidebar-collapsed); }

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  padding: 4px;
  display: none;
}

.page-title { font-size: 18px; font-weight: 600; flex: 1; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.admin-badge {
  background: rgba(99,102,241,0.2);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ===== Stat Cards ===== */
.stat-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;
}

.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }
.btn-warning { background: var(--warning); color: #000; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Status */
.badge-active { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-banned { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-temp-banned { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-blocked { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-inactive { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* Role */
.badge-admin { background: rgba(168,85,247,0.15); color: #c084fc; }
.badge-moderator { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-user { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* Plan */
.badge-elite { background: rgba(234,179,8,0.15); color: #facc15; }
.badge-premium { background: rgba(168,85,247,0.15); color: #c084fc; }
.badge-freemium { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-free { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* Store / misc */
.badge-yes { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-no { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ===== Filters / Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.input-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  outline: none;
  transition: border-color var(--transition);
}
.input-field:focus { border-color: var(--accent); }
.input-field::placeholder { color: var(--muted); }

select.input-field { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }

textarea.input-field { resize: vertical; min-height: 80px; }

.search-input { min-width: 220px; }

/* ===== Table Wrapper ===== */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagination .btn { min-width: 36px; justify-content: center; }
.pagination .page-info { color: var(--muted); font-size: 13px; margin: 0 6px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 18px;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

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

/* ===== Form Groups ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.checkbox-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ===== Actions Dropdown ===== */
.actions-wrap { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 170px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--border); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

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

/* ===== Detail View ===== */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.detail-avatar {
  width: 56px; height: 56px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.detail-info h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.detail-info .meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.info-item { }
.info-item .label { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.info-item .value { font-size: 14px; font-weight: 500; word-break: break-all; }

.two-col { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.actions-panel { }
.actions-panel .card-title { font-size: 13px; }

.action-item {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.action-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.action-item .action-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ===== Bot Detail Drawer ===== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 600px;
  max-width: 95vw;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 510;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition);
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h2 { font-size: 16px; font-weight: 600; }
.drawer-close { background: none; border: none; color: var(--muted); font-size: 20px; }
.drawer-close:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ===== Store Image ===== */
.store-img {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}
.store-img-placeholder {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ===== Section Headers ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }

/* ===== System Page ===== */
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.job-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.job-info p { font-size: 12px; color: var(--muted); }
.job-result { margin-top: 8px; font-size: 12px; padding: 6px 10px; border-radius: 4px; }
.job-result.ok { background: rgba(34,197,94,0.1); color: #4ade80; }
.job-result.err { background: rgba(239,68,68,0.1); color: #f87171; }

/* ===== Loading / Empty states ===== */
.loading-state, .empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
  flex-direction: column;
  gap: 10px;
}
.empty-icon { font-size: 36px; }

/* ===== Misc ===== */
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.back-btn { margin-bottom: 16px; }
.w100 { width: 100%; }

code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: var(--accent-hover);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .menu-btn { display: block; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
