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

:root {
  --bg:        #0b0d14;
  --bg2:       #11141f;
  --surface:   rgba(255,255,255,0.045);
  --border:    rgba(255,255,255,0.08);
  --text:      #e8eaf0;
  --text-dim:  #7a8099;
  --accent:    #6c63ff;
  --accent2:   #00d4aa;
  --accent3:   #f59e0b;
  --accent4:   #ec4899;

  --sidebar-w: 220px;
  --radius:    14px;
  --radius-sm: 8px;
  --glow:      0 0 30px rgba(108,99,255,0.15);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Animated background blobs ─────────────────────────────────────────── */
.bg-blobs {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  animation: float 20s ease-in-out infinite alternate;
}
.blob-1 { width:500px; height:500px; background:#6c63ff; top:-150px; left:-100px; animation-delay:0s; }
.blob-2 { width:400px; height:400px; background:#00d4aa; bottom:-100px; right:100px; animation-delay:-7s; }
.blob-3 { width:350px; height:350px; background:#f59e0b; top:50%; left:50%; animation-delay:-14s; }

@keyframes float {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(40px,30px) scale(1.08); }
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(17,20,31,0.85);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  padding: 0 0 24px;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 28px 22px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.logo-icon { font-size: 22px; color: var(--accent); }
.logo-text  { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border: none; background: transparent;
  color: var(--text-dim);
  font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-item.active {
  background: rgba(108,99,255,0.18);
  color: #a89dff;
  font-weight: 600;
}
.nav-icon { font-size: 15px; }

.sidebar-footer { padding: 0 16px; }
.db-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-dim);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}
.status-dot.online  { background: #22c55e; }
.status-dot.offline { background: #ef4444; }
.status-dot.pulsing {
  background: #f59e0b;
  animation: pulse-dot 1.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.4; transform:scale(0.7); }
}

/* ── Main Layout ────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  padding: 32px 36px;
  position: relative; z-index: 1;
  min-height: 100vh;
}

/* ── Top Bar ────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 32px;
}
.top-bar-left { display: flex; flex-direction: column; gap: 3px; }
.page-title  { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.page-sub    { font-size: 13px; color: var(--text-dim); }
.top-bar-right { display: flex; align-items: center; gap: 14px; }

.refresh-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.35);
  border-radius: var(--radius-sm);
  color: #a89dff;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.refresh-btn:hover { background: rgba(108,99,255,0.28); transform: translateY(-1px); }
.refresh-btn.spinning #refresh-icon { display: inline-block; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tab-content { display: none; flex-direction: column; gap: 24px; }
.tab-content.active { display: flex; }

/* ── Stats Grid ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(12px);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--glow); }

.stat-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.stat-label  { font-size: 12px; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-badge  { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-blue   { background: rgba(108,99,255,0.2); color: #a89dff; }
.badge-purple { background: rgba(168,85,247,0.2); color: #c084fc; }
.badge-teal   { background: rgba(0,212,170,0.2);  color: #2dd4bf; }
.badge-orange { background: rgba(245,158,11,0.2); color: #fbbf24; }

.stat-value { font-size: 36px; font-weight: 800; letter-spacing: -1px; margin-bottom: 6px; }
.stat-meta  { font-size: 12px; color: var(--text-dim); }

/* ── Two Column Layout ──────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.full-card { width: 100%; }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 0;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; }

/* ── Department List ────────────────────────────────────────────────────── */
.dept-list { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.dept-row  { display: flex; flex-direction: column; gap: 6px; }
.dept-info { display: flex; justify-content: space-between; font-size: 13px; }
.dept-name { font-weight: 500; }
.dept-count { color: var(--text-dim); }
.dept-bar  { height: 6px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.dept-fill { height: 100%; border-radius: 999px; transition: width 0.8s cubic-bezier(.23,1,.32,1); }

/* ── Recent Orders ──────────────────────────────────────────────────────── */
.recent-orders { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.order-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background 0.2s;
}
.order-row:hover { background: rgba(255,255,255,0.06); }
.order-meta { display: flex; flex-direction: column; gap: 2px; }
.order-name { font-weight: 500; }
.order-product { font-size: 11px; color: var(--text-dim); }
.order-amount { font-weight: 700; color: var(--accent2); font-size: 14px; }

/* ── Search Box ─────────────────────────────────────────────────────────── */
.search-box {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  width: 240px;
}
.search-box:focus {
  border-color: rgba(108,99,255,0.5);
  background: rgba(108,99,255,0.06);
}
.search-box::placeholder { color: var(--text-dim); }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  padding: 12px 18px;
  text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.data-table tbody td {
  padding: 13px 18px;
  vertical-align: middle;
}
.data-table tbody tr:last-child { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.chip-active   { background: rgba(34,197,94,0.18);  color: #4ade80; }
.chip-inactive { background: rgba(239,68,68,0.18);  color: #f87171; }
.chip-dept {
  background: rgba(108,99,255,0.15);
  color: #a89dff;
}

/* ── Skeleton ───────────────────────────────────────────────────────────── */
.skeleton-row {
  height: 44px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.4s linear infinite;
  margin-bottom: 10px;
}
@keyframes shimmer { to { background-position: -400% 0; } }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
