/* ═══════════════════════════════════════════════════════════
   HR Analytics & CSI Platform — Styles
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-alt: #16162b;
  --border: #2a2a4a;
  --primary: #6366f1;
  --primary-hover: #7c7ff5;
  --accent-green: #22c55e;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ─── Login ─── */
#app { height: 100vh; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

#login-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a3e 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 400px;
  max-width: 90vw;
}

.logo { text-align: center; margin-bottom: 8px; }
.logo svg { margin-bottom: 12px; }
.logo h1 { font-size: 1.5rem; font-weight: 600; }
.subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 0.85rem; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-muted); }
.form-group input, .select-input, .search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .select-input:focus, .search-input:focus {
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.5rem; cursor: pointer; padding: 4px 8px;
}
.btn-close:hover { color: var(--text); }

.hint { margin-top: 20px; font-size: 0.75rem; color: var(--text-muted); }
.hint code { background: var(--surface-alt); padding: 2px 6px; border-radius: 4px; }
.error-msg { color: var(--accent-red); margin-top: 12px; font-size: 0.85rem; text-align: center; }

/* ─── Main Layout ─── */
#main-screen { flex-direction: row; }

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--primary); }

.nav-list { list-style: none; padding: 12px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { color: var(--text); background: rgba(99, 102, 241, 0.08); }
.nav-item.active { color: var(--primary); background: rgba(99, 102, 241, 0.12); border-right: 2px solid var(--primary); }
.nav-item.logout { margin-top: auto; color: var(--accent-red); }
.nav-spacer { flex: 1; }
.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-name { font-size: 0.85rem; font-weight: 500; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }

/* ─── Content Area ─── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header h2 { font-size: 1.3rem; font-weight: 600; }
.view-controls { display: flex; gap: 10px; align-items: center; }
.search-input { width: 240px; }
.select-input { width: auto; min-width: 140px; padding: 8px 12px; }

/* ─── Cards / Grid ─── */
.candidates-grid, .companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.card:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 8px; }
.card-name { font-size: 1.05rem; font-weight: 600; }
.card-role { font-size: 0.75rem; color: var(--primary); background: rgba(99,102,241,0.12); padding: 2px 8px; border-radius: 12px; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tag { font-size: 0.7rem; background: var(--surface-alt); padding: 2px 8px; border-radius: 12px; color: var(--text-muted); }
.card-score { display: flex; align-items: center; gap: 8px; }
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.score-high { background: rgba(34,197,94,0.15); color: var(--accent-green); }
.score-med { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
.score-low { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.score-info { background: rgba(59,130,246,0.15); color: var(--accent-blue); }

/* ─── Modals ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 700px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 101;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 24px;
}
.modal-header h2 { font-size: 1.3rem; }
.modal-subtitle { color: var(--text-muted); font-size: 0.85rem; }

/* ─── Score Bars ─── */
.score-section { margin-bottom: 24px; }
.score-section h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text-muted); }

.score-bar-item { margin-bottom: 12px; }
.score-bar-label { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 4px; }
.score-bar-track {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ─── Profile Detail ─── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.detail-field { }
.detail-field label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.detail-field span { font-size: 0.9rem; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }

/* ─── CSI Specific ─── */
.csi-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.metric-value { font-size: 1.8rem; font-weight: 700; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.rec-card {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--primary);
}
.rec-high { border-left-color: var(--accent-red); }
.rec-medium { border-left-color: var(--accent-yellow); }
.rec-low { border-left-color: var(--accent-green); }
.rec-label { font-weight: 600; font-size: 0.9rem; }
.rec-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Admin ─── */
.admin-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.admin-panel h3 { font-size: 1rem; margin-bottom: 16px; }
.stats-row { display: flex; gap: 20px; flex-wrap: wrap; }
.stat-item { text-align: center; padding: 12px; min-width: 80px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--text-muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; }

/* ─── Stage Badges ─── */
.stage-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
}
.stage-ideation { background: rgba(239,68,68,0.15); color: #ef4444; }
.stage-startup { background: rgba(245,158,11,0.15); color: #f59e0b; }
.stage-early_growth { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stage-expansion { background: rgba(99,102,241,0.15); color: #6366f1; }
.stage-mature { background: rgba(34,197,94,0.15); color: #22c55e; }
.stage-enterprise { background: rgba(139,92,246,0.15); color: #8b5cf6; }

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

/* ─── Mobile Top Bar ─── */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(99,102,241,0.1); }
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ─── Sidebar Overlay (mobile) ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ─── Sidebar Close Button (mobile) ─── */
.sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.sidebar-close:hover { color: var(--text); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  /* Mobile top bar */
  .mobile-topbar { display: flex; }

  /* Sidebar transforms into slide-out drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    min-width: 260px;
    z-index: 99;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.active { display: block; }

  .sidebar-close { display: block; }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-header h3 { font-size: 0.95rem; }

  .nav-item { padding: 12px 20px; }
  .nav-label { display: inline; }

  /* Content fills full width */
  .content { padding: 16px; }

  /* View header stacks on mobile */
  .view-header { flex-direction: column; align-items: stretch; }
  .view-controls { flex-direction: column; width: 100%; }
  .search-input, .select-input { width: 100%; }

  /* Grids to single column */
  .candidates-grid, .companies-grid { grid-template-columns: 1fr; }
  .admin-panels { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .csi-metrics { grid-template-columns: 1fr; }

  /* Modal padding reduced on mobile */
  .modal-content { padding: 20px; }

  /* Login card tighter on small screens */
  .login-card { padding: 24px; }
  .login-card .logo h1 { font-size: 1.25rem; }

  /* View header title smaller */
  .view-header h2 { font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .login-card { padding: 20px; }
  .login-card .logo h1 { font-size: 1.1rem; }
  .modal-content { padding: 16px; }
  .content { padding: 12px; }
}
