/* ─── Design System: White-Label Dark Theme ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-sidebar: #0d1321;
  --bg-input: #1e293b;
  --border-color: rgba(148, 163, 184, 0.1);
  --border-active: rgba(99, 102, 241, 0.5);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

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

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

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  box-shadow: var(--shadow-glow);
}

.sidebar-brand .brand-name {
  font-size: 18px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

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

.nav-section { margin-bottom: 24px; }
.nav-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted);
  padding: 0 12px; margin-bottom: 8px;
}

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: var(--transition); position: relative;
  margin-bottom: 2px;
}
.nav-link:hover { color: var(--text-primary); background: var(--accent-glow); }
.nav-link.active {
  color: #fff; background: var(--accent-gradient);
  box-shadow: var(--shadow-glow);
}
.nav-link i { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Main Content ─── */
.main-content {
  flex: 1; margin-left: var(--sidebar-width);
  padding: 32px; min-height: 100vh;
}

.page-header { margin-bottom: 32px; }
.page-title {
  font-size: 28px; font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  transition: var(--transition);
  overflow: hidden;
}
.card:hover { border-color: var(--border-active); box-shadow: var(--shadow-glow); }
.card-body { padding: 24px; }

/* ─── Stat Cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-gradient);
  opacity: 0; transition: var(--transition);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-glow); }
.stat-card:hover::before { opacity: 1; }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 16px;
}
.stat-icon.purple { background: rgba(99,102,241,0.15); color: var(--accent-primary); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--info); }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── Tables ─── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}
.table-title { font-size: 16px; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 12px 24px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.2);
}
td {
  padding: 16px 24px; border-bottom: 1px solid var(--border-color);
  font-size: 14px; vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 100px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%;
}
.badge-active { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-active::before { background: var(--success); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-pending::before { background: var(--warning); }
.badge-disabled { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-disabled::before { background: var(--danger); }
.badge-unknown { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.badge-unknown::before { background: var(--text-muted); }
.badge-role {
  padding: 3px 10px; border-radius: 6px; font-size: 11px;
}
.badge-superadmin { background: rgba(99,102,241,0.15); color: var(--accent-primary); }
.badge-admin { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-user { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none;
  transition: var(--transition); text-decoration: none;
}
.btn-primary {
  background: var(--accent-gradient); color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(99,102,241,0.4); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--border-active); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--accent-glow); }
.btn-success { background: rgba(16,185,129,0.15); color: var(--success); }
.btn-success:hover { background: rgba(16,185,129,0.25); }

/* ─── Forms ─── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }

/* ─── Template Grid ─── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 12px; }
.template-card {
  border: 2px solid var(--border-color); border-radius: var(--radius-md);
  padding: 16px; cursor: pointer; transition: var(--transition);
  text-align: center; position: relative;
}
.template-card:hover { border-color: var(--border-active); background: var(--accent-glow); }
.template-card.selected { border-color: var(--accent-primary); background: var(--accent-glow); }
.template-card.selected::after {
  content: '✓'; position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; background: var(--accent-primary);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: #fff;
}
.template-icon { font-size: 36px; margin-bottom: 8px; }
.template-name { font-size: 14px; font-weight: 600; }
.template-files { font-size: 12px; color: var(--text-muted); }

/* ─── Site Detail ─── */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.detail-section { margin-bottom: 24px; }
.detail-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.detail-value { font-size: 15px; font-weight: 500; }

.onboarding-steps { list-style: none; padding: 0; }
.onboarding-steps li {
  padding: 12px 16px; border-left: 3px solid var(--border-color);
  margin-bottom: 8px; font-size: 14px; color: var(--text-secondary);
}
.onboarding-steps li.completed { border-left-color: var(--success); color: var(--text-primary); }
.onboarding-steps li .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-input); font-size: 12px; font-weight: 700;
  margin-right: 8px;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed; top: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  animation: slideIn 0.3s ease; min-width: 280px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
}
.toast-success { background: #065f46; color: #d1fae5; border: 1px solid rgba(16,185,129,0.3); }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid rgba(239,68,68,0.3); }
.toast-info { background: #1e3a5f; color: #bfdbfe; border: 1px solid rgba(59,130,246,0.3); }

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

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(0.9); transition: var(--transition);
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; }

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  top: -200px; right: -200px; pointer-events: none;
}
.login-page::after {
  content: ''; position: absolute; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, transparent 70%);
  bottom: -100px; left: -100px; pointer-events: none;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); padding: 48px; width: 100%; max-width: 440px;
  backdrop-filter: blur(20px); position: relative; z-index: 1;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 36px; }
.login-brand .brand-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: var(--accent-gradient); border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  box-shadow: var(--shadow-glow);
}
.login-brand h1 {
  font-size: 24px; font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-brand p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.login-form .btn-primary { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px; display: none;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state i { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* ─── Actions Row ─── */
.actions { display: flex; gap: 8px; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
