/* ── Base: Variables, reset, body, sidebar, topbar, layout, buttons, pills, scrollbar, spinner, toast, page-loading, mobile responsive ── */

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

:root {
  --bg:        #0C0D11;
  --sidebar:   #111318;
  --surface:   #1A1C24;
  --surface-2: #22242E;
  --border:    #2A2D38;
  --accent:    #D4681A;
  --accent-dim:#6A340D;
  --text:      #E4E4E7;
  --muted:     #52525B;
  --sub:       #A1A1AA;
  --pending:   #F59E0B;
  --to-apply:  #06B6D4;
  --applied:   #3B82F6;
  --skipped:   #6B7280;
  --maybe:     #F97316;
  --interview: #8B5CF6;
  --rejected:  #EF4444;
  --offer:     #10B981;
}

html, body { height: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.2s ease, min-width 0.2s ease;
}
#sidebar.collapsed {
  width: 48px;
  min-width: 48px;
}
#sidebar.collapsed .logo-sub,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-text,
#sidebar.collapsed .sidebar-version { display: none; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; }
#sidebar.collapsed .nav-icon { width: 18px; height: 18px; opacity: 0.7; }
#sidebar.collapsed .logo { padding: 16px 0; display: flex; justify-content: center; }
#sidebar.collapsed .logo-mark { gap: 0; }
#sidebar.collapsed .logo-mark .dot { width: 10px; height: 10px; }
#main.sidebar-collapsed { margin-left: 48px; }

.logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.logo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.06em;
}

nav {
  padding: 16px 12px;
  flex: 1;
}
.nav-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 6px;
  margin-top: 12px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

/* ── Main content ────────────────────────────────── */
#main {
  margin-left: 220px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  transition: margin-left 0.2s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, filter 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-blue   { background: #3B82F6; color: #fff; }
.btn-ghost  { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }

.content { padding: 28px 32px; flex: 1; overflow-x: hidden; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; }

.link-btn { color: var(--accent); text-decoration: none; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }

.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

/* ── Pages ───────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Page loading overlay ─────────────────────────── */
.page-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 12px;
}
.page-loading.active { display: flex; }
.page-loading .spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.page-loading .loading-text {
  font-size: 13px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Empty states ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-sub { font-size: 13px; }

/* ── Toast ───────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  font-family: 'DM Sans', sans-serif;
}
#toast.show { display: block; animation: fadeIn 0.2s; }

/* ── Animations ──────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress ────────────────────────────────────── */
.progress-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 20px;
}
.progress-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.step-list { display: flex; flex-direction: column; gap: 7px; }
.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.step-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.step-item.done .step-dot { background: var(--offer); }
.step-item.current .step-dot { background: var(--accent); animation: pulse 1s infinite; }
.step-item.error .step-dot  { background: var(--rejected); }

/* ── Result ──────────────────────────────────────── */
.result-panel {
  margin-top: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}
.result-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--offer);
  margin-bottom: 12px;
}
.result-links { display: flex; flex-direction: column; gap: 8px; }
.result-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}
.result-link:hover { border-color: var(--accent); }
.result-link-icon { color: var(--accent); font-size: 16px; }

/* ── Mobile hamburger button ──────────────────────────── */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 150;
  align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 7px;
  width: 34px; height: 34px;
  flex-shrink: 0;
}

/* ── Mobile sidebar overlay ───────────────────────────── */
#mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
#mobile-overlay.active { display: block; }

/* ── Mobile bottom nav ────────────────────────────────── */
#mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--sidebar);
  border-top: 1px solid var(--border);
  z-index: 90;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
}
.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
}
.mobile-nav-btn .nav-icon { width: 20px; height: 20px; opacity: 0.7; }
.mobile-nav-btn.active { color: var(--accent); }
.mobile-nav-btn.active .nav-icon { opacity: 1; }

/* ── Mobile responsive ────────────────────────────────── */
@media (max-width: 768px) {
  #mobile-menu-btn { display: none; }
  #mobile-bottom-nav { display: flex; }
  #sidebar { display: none !important; }
  #sidebar-toggle { display: none; }
  .sidebar-version { display: none; }
  #main, #main.sidebar-collapsed {
    margin-left: 0 !important;
    padding-bottom: 64px;
  }
  .topbar {
    padding: 10px 12px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 6px;
    position: relative;
  }
  .topbar > div {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
    max-width: calc(100vw - 24px);
  }
  .topbar > div::-webkit-scrollbar { display: none; }
  .topbar > div { flex-wrap: nowrap !important; }
  #main { overflow-x: hidden; max-width: 100vw; }
  .content { padding: 14px; }
  #toast { bottom: 74px; right: 12px; left: 12px; text-align: center; }
}

@media (max-width: 480px) {
  .content { padding: 12px; }
}
