/* ===== Admin Panel ===== */
:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-sidebar: #0d0d14;
  --bg-hover: #1a1a28;
  --border: rgba(255,255,255,0.08);
  --text: #f0f0f5;
  --text-muted: #9ca3af;
  --purple: #8b5cf6;
  --indigo: #6366f1;
  --blue: #2e63b8;
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --teal: #14b8a6;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Login */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.15), transparent 60%);
}

.login-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 40px; display: block; margin-bottom: 8px; }
.login-brand h1 { font-size: 22px; font-weight: 800; }
.login-brand p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.form-field input, .form-field select {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.form-field input:focus, .form-field select:focus {
  outline: none;
  border-color: var(--purple);
}

.btn-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: 0.2s;
  text-decoration: none;
}
.btn-primary-admin {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
}
.btn-primary-admin:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-outline-admin {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline-admin:hover { border-color: var(--purple); }
.btn-sm-admin { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.back-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--purple); }

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

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand h2 {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-brand span { font-size: 11px; color: var(--text-muted); }

.sidebar-role {
  margin: 12px 16px;
  padding: 8px 12px;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 8px;
  font-size: 11px;
  color: #c4b5fd;
  font-weight: 600;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-group-label {
  padding: 12px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: rgba(99,102,241,0.1);
  color: #a5b4fc;
  border-left-color: var(--indigo);
}
.nav-item .icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
}
.sidebar-footer a:hover { background: var(--bg-hover); color: var(--text); }

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.admin-topbar {
  height: var(--topbar-h);
  background: rgba(10,10,15,0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-title h1 { font-size: 18px; font-weight: 700; }
.topbar-title p { font-size: 12px; color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-search {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  width: 220px;
  font-family: inherit;
}
.topbar-search:focus { outline: none; border-color: var(--purple); }

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.admin-content { padding: 24px; }

/* Panels */
.panel { display: none; animation: fadeIn 0.25s ease; }
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: 0.2s;
}
.stat-card:hover { border-color: rgba(139,92,246,0.3); transform: translateY(-2px); }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .change { font-size: 11px; margin-top: 4px; }
.stat-card .change.up { color: var(--green); }
.stat-card .change.down { color: var(--red); }
.stat-card .icon-top { font-size: 22px; margin-bottom: 8px; }

/* Cards & Tables */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-header h2 { font-size: 20px; font-weight: 800; }
.panel-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: rgba(34,197,94,0.15); color: #86efac; }
.badge-yellow { background: rgba(234,179,8,0.15); color: #fde047; }
.badge-red { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-blue { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-purple { background: rgba(139,92,246,0.15); color: #c4b5fd; }

/* AI Modules Grid */
.ai-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.ai-module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: 0.25s;
}
.ai-module-card:hover {
  border-color: rgba(139,92,246,0.4);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.ai-module-card .mod-icon { font-size: 28px; margin-bottom: 10px; }
.ai-module-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.ai-module-card > p { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.ai-module-card ul { list-style: none; }
.ai-module-card li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-module-card li::before { content: '▸'; color: var(--purple); }
.mod-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.mod-toggle {
  width: 40px;
  height: 22px;
  background: var(--green);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
}
.mod-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  right: 3px;
}
.mod-toggle.off { background: #4b5563; }
.mod-toggle.off::after { right: auto; left: 3px; }

/* Tech Stack */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.tech-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.tech-item h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.tech-item .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-item .tag {
  font-size: 11px;
  padding: 4px 8px;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 6px;
  color: #a5b4fc;
}

/* Flow diagram */
.flow-tree {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.8;
  color: #a5b4fc;
  overflow-x: auto;
  white-space: pre;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.chart-placeholder {
  height: 200px;
  background: linear-gradient(180deg, rgba(99,102,241,0.08), transparent);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .mobile-toggle { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}
