@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg:       #f8fafc;
  --bg-2:     #ffffff;
  --bg-3:     #f1f5f9;
  --bg-4:     #e2e8f0;
  --border:   rgba(0,0,0,0.08);
  --border-2: rgba(0,0,0,0.15);
  --text:     #0f172a;
  --text-2:   #475569;
  --text-3:   #64748b;
  --accent:   #4f46e5;
  --accent-g: rgba(79,70,229,0.1);
  --green:    #16a34a;
  --green-g:  rgba(22,163,74,0.1);
  --red:      #dc2626;
  --red-g:    rgba(220,38,38,0.1);
  --yellow:   #d97706;
  --yellow-g: rgba(217,119,6,0.1);
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,0.04);
  --t:        all 0.15s cubic-bezier(0.4,0,0.2,1);
  --sidebar:  220px;
}

[data-theme="dark"] {
  --bg:       #09090d;
  --bg-2:     #0f0f15;
  --bg-3:     #161620;
  --bg-4:     #1c1c28;
  --border:   rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.12);
  --text:     #e2e2ef;
  --text-2:   #8888a8;
  --text-3:   #50506a;
  --accent:   #7c6af7;
  --accent-g: rgba(124,106,247,0.15);
  --green:    #22c55e;
  --green-g:  rgba(34,197,94,0.15);
  --red:      #ef4444;
  --red-g:    rgba(239,68,68,0.15);
  --yellow:   #f59e0b;
  --yellow-g: rgba(245,158,11,0.15);
}

[data-theme="dark"] .topbar {
  background: rgba(9,9,13,0.8);
}


*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

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

.sidebar {
  width: var(--sidebar);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}
.logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 8px 4px;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  transition: var(--t);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--accent-g); color: var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.content {
  flex: 1;
  margin-left: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-title { font-size: 14px; font-weight: 700; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.topbar-avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
}

.page { padding: 24px; max-width: 1200px; }

/* --- Stat Cards --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: var(--t);
}
.stat-card:hover { border-color: var(--border-2); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 6px; }
.stat-sub { font-size: 11px; color: var(--text-3); }
.stat-up { color: var(--green); }
.stat-down { color: var(--red); }

/* --- Cards / Panels --- */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-size: 13px; font-weight: 700; }
.panel-body { padding: 20px; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 14px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; transition: var(--t); font-family: inherit;
  white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6959e0; transform: translateY(-1px); }
.btn-ghost { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-4); color: var(--text); }
.btn-danger { background: var(--red-g); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-g); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover { background: var(--green); color: #fff; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: var(--t);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,106,247,0.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: var(--t); }
tbody tr:hover { background: var(--bg-3); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 100px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}
.badge-green  { background: var(--green-g);  color: var(--green);  border: 1px solid rgba(34,197,94,0.25);  }
.badge-red    { background: var(--red-g);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25);   }
.badge-yellow { background: var(--yellow-g); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.badge-gray   { background: var(--bg-4);     color: var(--text-2); border: 1px solid var(--border);         }
.badge-purple { background: var(--accent-g); color: var(--accent); border: 1px solid rgba(124,106,247,0.25);}

/* --- Toggle --- */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-4); border-radius: 20px;
  cursor: pointer; transition: var(--t);
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; bottom: 2px;
  background: var(--text-3);
  border-radius: 50%;
  transition: var(--t);
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* --- Health Dot --- */
.health-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.health-ok { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.health-err { background: var(--red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* --- Alert --- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--green-g); border: 1px solid rgba(34,197,94,0.2); color: var(--green); }
.alert-error   { background: var(--red-g);   border: 1px solid rgba(239,68,68,0.2);  color: var(--red);   }

/* --- Login Page --- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 20px; font-weight: 800; }
.login-logo p  { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .content { margin-left: 0; }
  .admin-layout { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
