@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f0e17;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.08);
  --bg-glass: rgba(255,255,255,0.06);
  --border-glass: rgba(255,255,255,0.1);
  --accent: #7f5af0;
  --accent-hover: #6b46e5;
  --accent-glow: rgba(127,90,240,0.3);
  --success: #2cb67d;
  --success-bg: rgba(44,182,125,0.12);
  --danger: #e53170;
  --danger-bg: rgba(229,49,112,0.12);
  --warning: #f0c040;
  --warning-bg: rgba(240,192,64,0.12);
  --text-primary: #fffffe;
  --text-secondary: rgba(255,255,255,0.6);
  --text-muted: rgba(255,255,255,0.35);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 30px var(--accent-glow);
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ===== Login Page ===== */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, rgba(127,90,240,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(44,182,125,0.1) 0%, transparent 50%),
              var(--bg-primary);
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: fadeUp 0.6s ease-out;
}

.login-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.login-card p { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }
.login-card .logo { font-size: 48px; margin-bottom: 16px; display: block; }
.login-form { text-align: left; }
.login-submit {
  width: 100%;
  justify-content: center;
  min-height: 42px;
}
.login-error {
  min-height: 20px;
  margin: -6px 0 14px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

/* ===== Layout ===== */
.app-layout {
  display: flex; min-height: 100vh;
}

.sidebar {
  width: 260px; min-width: 260px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-glass);
  display: flex; flex-direction: column;
  padding: 24px 0;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 8px;
}
.sidebar-header h2 { font-size: 18px; font-weight: 700; }
.sidebar-header span { font-size: 12px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 8px 12px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px; font-weight: 500;
  border: none; background: none; width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-item.active {
  background: rgba(127,90,240,0.15);
  color: var(--accent);
}
.nav-item .icon { font-size: 20px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
}
.current-user {
  padding: 0 0 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-glass);
}
.current-user span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.current-user strong {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  flex: 1; margin-left: 260px;
  padding: 32px;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(127,90,240,0.06) 0%, transparent 60%);
}

.page-header {
  margin-bottom: 32px;
}
.page-header h1 { font-size: 28px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ===== Cards ===== */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
}
.glass-card:hover {
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), 0 8px 32px rgba(0,0,0,0.2);
}

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 32px; }

.stat-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative; overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-glow); }
.stat-card .stat-icon { font-size: 32px; margin-bottom: 12px; }
.stat-card .stat-value { font-size: 36px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.stat-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 120px; height: 120px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  opacity: 0.3; border-radius: 50%;
  transform: translate(30%, -30%);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .spinner { animation: spin 0.8s linear infinite; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127,90,240,0.15);
}
.form-select option { background: var(--bg-secondary); }
.form-textarea {
  min-height: 96px;
  resize: vertical;
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}
table {
  width: 100%; border-collapse: collapse;
}
th, td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border-glass);
  font-size: 14px;
}
th {
  background: rgba(255,255,255,0.04);
  font-weight: 600; color: var(--text-secondary);
  font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover td { background: rgba(255,255,255,0.02); }
tr:last-child td { border-bottom: none; }
.detail-json {
  max-width: 360px;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-admin { background: var(--accent-glow); color: var(--accent); }
.badge-user { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ===== Progress ===== */
.progress-bar {
  width: 100%; height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.5s ease;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: fadeUp 0.3s ease;
}
.modal h3 { font-size: 20px; margin-bottom: 12px; }
.modal p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 24px; right: 24px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  min-width: 280px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }

/* ===== Section ===== */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 20px;
}
.pagination button {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer; font-size: 13px;
  transition: all var(--transition);
}
.pagination button:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination span { font-size: 13px; color: var(--text-muted); }

/* ===== Skeleton ===== */
.skeleton {
  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: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 14px; }

/* ===== Task Card ===== */
.task-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 16px;
}
.task-card .task-info { flex: 1; }
.task-card .task-id { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.task-card .task-status { font-size: 13px; margin-top: 4px; }

/* ===== Action Bar ===== */
.action-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 24px;
}

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-cards { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
