/* Design System Tokens */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --secondary: #3B82F6;
  --cta: #F97316;
  --cta-hover: #EA580C;
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --bg-sidebar-hover: #334155;
  --bg-sidebar-active: rgba(37, 99, 235, 0.15);
  --text: #1E293B;
  --text-light: #64748B;
  --text-sidebar: #CBD5E1;
  --text-sidebar-active: #FFFFFF;
  --border: #E2E8F0;
  --success: #10B981;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 200ms ease;
}

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

body {
  font-family: 'Fira Sans', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Login Page ===== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  padding: 16px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  text-align: center;
}

.login-card .subtitle {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-cta {
  background: var(--cta);
  color: white;
}

.btn-cta:hover { background: var(--cta-hover); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover { background: var(--danger-hover); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--bg); border-color: var(--text-light); }

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-error {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h1 svg { width: 22px; height: 22px; color: var(--primary); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.sidebar-nav li a:hover {
  background: var(--bg-sidebar-hover);
  color: white;
}

.sidebar-nav li a.active {
  background: var(--bg-sidebar-active);
  color: var(--primary);
  border-left-color: var(--primary);
}

.sidebar-nav li a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text-sidebar);
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-sidebar);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  justify-content: center;
}

.btn-logout:hover { background: rgba(255,255,255,0.08); color: white; }

/* Main Content */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
}

.stat-card .stat-value.blue { color: var(--primary); }
.stat-card .stat-value.purple { color: #7C3AED; }
.stat-card .stat-value.green { color: var(--success); }

/* Content Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h2 svg { width: 18px; height: 18px; color: var(--primary); }

.card-body { padding: 24px; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.03);
}

.upload-zone svg {
  width: 40px;
  height: 40px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.upload-zone p {
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.upload-zone .hint {
  font-size: 12px;
  color: #94A3B8;
}

.upload-zone .btn { margin-top: 16px; }

#upload-file-input { display: none; }

.upload-progress {
  display: none;
  margin-top: 16px;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 300ms ease;
  width: 0%;
}

.upload-status {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

/* Table */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: #F1F5F9; }

.person-name {
  font-weight: 600;
  color: var(--text);
}

.theme-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}

.theme-tag:nth-child(odd) {
  background: #DBEAFE;
  color: var(--primary);
}

.theme-tag:nth-child(even) {
  background: #EDE9FE;
  color: #7C3AED;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-list a {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-family: 'Fira Code', monospace;
  transition: color var(--transition);
}

.link-list a:hover { color: var(--primary-hover); text-decoration: underline; }

.actions {
  display: flex;
  gap: 6px;
}

.meta-text {
  font-size: 13px;
  color: var(--text-light);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p { font-size: 15px; }

/* Users panel */
.users-section { display: none; }
.users-section.active { display: block; }
.resumes-section { display: none; }
.resumes-section.active { display: block; }

.add-user-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.add-user-form .form-group {
  margin-bottom: 0;
  flex: 1;
}

.add-user-form .form-group label {
  font-size: 13px;
  margin-bottom: 4px;
}

.add-user-form .form-group input {
  padding: 10px 14px;
  font-size: 14px;
}

.add-user-form .btn-primary {
  width: auto;
  flex-shrink: 0;
  min-width: 120px;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-badge.super { background: #FEF3C7; color: #D97706; }
.role-badge.admin { background: #DBEAFE; color: var(--primary); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 300ms ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.show { opacity: 1; visibility: visible; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition);
}

.modal-overlay.show .modal { transform: scale(1); }

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Mobile sidebar toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-sidebar);
  color: white;
  border: none;
  border-radius: var(--radius);
  width: 44px;
  height: 44px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .mobile-toggle { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
    padding-top: 64px;
  }

  .stats-grid { grid-template-columns: 1fr; }

  .add-user-form {
    flex-direction: column;
    align-items: stretch;
  }

  table { font-size: 13px; }
  thead th, tbody td { padding: 10px 12px; }
}

/* Focus visible for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Animations */
@media (prefers-reduced-motion: no-preference) {
  .stat-card { animation: fadeUp 400ms ease both; }
  .stat-card:nth-child(2) { animation-delay: 80ms; }
  .stat-card:nth-child(3) { animation-delay: 160ms; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
