/* ── Reset & Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #0b0812;
  --bg2:         #110d1a;
  --bg3:         #1a1428;
  --card:        #1e1730;
  --card2:       #241c38;
  --border:      #3a2e55;
  --purple:      #a855f7;
  --purple-dark: #7c3aed;
  --purple-glow: rgba(168,85,247,0.25);
  --purple-dim:  #6b21a8;
  --accent:      #e879f9;
  --text:        #f1eeff;
  --text-muted:  #9d8fc0;
  --text-dim:    #6b5f8a;
  --success:     #34d399;
  --warning:     #fbbf24;
  --danger:      #f87171;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(168,85,247,0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--purple-dim); border-radius: 3px; }

/* ── Noise texture overlay ─────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* ── Layout ────────────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - 240px);
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 8px 8px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.nav-link:hover, .nav-link.active {
  background: var(--purple-glow);
  color: var(--text);
  border: 1px solid var(--border);
}

.nav-link.active { color: var(--purple); border-color: var(--purple-dim); }
.nav-link svg { flex-shrink: 0; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-dim); }

.logout-btn {
  color: var(--text-dim);
  transition: color 0.2s;
  padding: 4px;
}
.logout-btn:hover { color: var(--danger); }

/* ── Page Header ───────────────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.page-title span { background: linear-gradient(135deg, var(--purple), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--purple), var(--accent));
}

.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; background: linear-gradient(135deg, var(--purple), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ── Upload Zone ───────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg2);
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--purple);
  background: var(--purple-glow);
  box-shadow: var(--shadow-glow);
}

.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.upload-sub { color: var(--text-muted); font-size: 14px; }
.upload-formats { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.format-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
}

/* ── Progress ──────────────────────────────────────────────────────── */
.progress-wrap { margin: 20px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.progress-bar { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-dark), var(--accent));
  border-radius: 4px;
  transition: width 0.4s ease;
  box-shadow: 0 0 12px var(--purple-glow);
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  color: white;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6); }
.btn-primary:disabled { opacity: 0.5; transform: none; cursor: not-allowed; }

.btn-success { background: var(--success); color: #0b2918; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 6px 12px; font-size: 12px; }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--purple); color: var(--purple); }

/* ── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 14px 16px; border-bottom: 1px solid rgba(58,46,85,0.4); vertical-align: middle; }
tbody tr:hover { background: rgba(168,85,247,0.04); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.badge-warning { background: rgba(251,191,36,0.15); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.badge-danger  { background: rgba(248,113,113,0.15); color: var(--danger);  border: 1px solid rgba(248,113,113,0.3); }
.badge-purple  { background: rgba(168,85,247,0.15); color: var(--purple);   border: 1px solid rgba(168,85,247,0.3); }
.badge-muted   { background: rgba(107,95,138,0.2);  color: var(--text-dim); border: 1px solid var(--border); }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-glow); }
.form-input::placeholder { color: var(--text-dim); }

.form-error {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.form-success {
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.3);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Auth Pages ────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-box {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow), var(--shadow-glow);
}

.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon { font-size: 40px; }
.auth-logo-text { font-size: 22px; font-weight: 700; background: linear-gradient(135deg, var(--purple), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-top: 8px; }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }

/* ── Landing Page ──────────────────────────────────────────────────── */
.landing { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; }

.landing-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(168,85,247,0.2) 0%, transparent 70%);
  pointer-events: none;
}

.landing-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(168,85,247,0.1);
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: 99px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--purple);
  margin-bottom: 32px;
}

.landing h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 800; letter-spacing: -2px; line-height: 1.1; margin-bottom: 20px; }
.landing h1 .gradient { background: linear-gradient(135deg, var(--purple), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.landing p { font-size: 18px; color: var(--text-muted); max-width: 560px; margin-bottom: 40px; }
.landing-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.landing-credit { margin-top: 64px; color: var(--text-dim); font-size: 12px; }
.landing-credit strong { color: var(--purple); }

/* ── Toasts ────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }

.toast {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Job List ──────────────────────────────────────────────────────── */
.job-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.job-icon { font-size: 24px; flex-shrink: 0; }
.job-info { flex: 1; min-width: 0; }
.job-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ── System Monitor ────────────────────────────────────────────────── */
.monitor-bar { height: 12px; background: var(--bg3); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.monitor-fill { height: 100%; border-radius: 6px; transition: width 1s ease; }
.monitor-cpu  { background: linear-gradient(90deg, #7c3aed, #a855f7); }
.monitor-ram  { background: linear-gradient(90deg, #0ea5e9, #06b6d4); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; max-width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utility ───────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
