@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {
  /* Light Theme Variables */
  --bg-main: #f5f6fa;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --text-primary: #202224;
  --text-secondary: #979797;
  --border-color: #e2e8f0;
  
  --primary: #4379EE;
  --primary-light: #e8f1fd;
  --primary-hover: #3264d1;
  --success: #00b69b;
  --success-light: #d9f3ea;
  --warning: #fec53d;
  --warning-light: #fff2d8;
  --danger: #fd5454;
  --danger-light: #ffdede;
  
  --sidebar-width: 250px;
  --header-height: 70px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

[data-theme="dark"] {
  --bg-main: #1b2431;
  --bg-surface: #273142;
  --bg-sidebar: #273142;
  --text-primary: #ffffff;
  --text-secondary: #8b9eb7;
  --border-color: #313d4f;
  
  --primary-light: rgba(67, 121, 238, 0.2);
  --success-light: rgba(0, 182, 155, 0.2);
  --warning-light: rgba(254, 197, 61, 0.2);
  --danger-light: rgba(253, 84, 84, 0.2);
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 { font-family: 'Outfit', sans-serif; font-weight: 700; color: var(--text-primary); }

a { text-decoration: none; color: inherit; }

/* LAYOUT */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-nav {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
  background-color: var(--primary);
  color: white;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 1.5rem; }

.search-bar {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 300px;
}
.search-bar input {
  border: none; background: transparent; outline: none; color: var(--text-primary); width: 100%;
}

.icon-btn {
  background: transparent; border: none; cursor: pointer; color: var(--text-secondary); font-size: 1.25rem; transition: color 0.2s; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--primary); }

.content { padding: 2rem; }

/* CARDS */
.card {
  background-color: var(--bg-surface);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  display: flex; justify-content: space-between; align-items: center;
}

.metric-icon {
  width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.icon-scraped { background-color: var(--primary-light); color: var(--primary); }
.icon-applied { background-color: var(--warning-light); color: var(--warning); }
.icon-interviews { background-color: var(--success-light); color: var(--success); }
.icon-rejected { background-color: var(--danger-light); color: var(--danger); }

.metric-value { font-size: 2rem; font-weight: 700; font-family: 'Outfit', sans-serif; margin: 0.25rem 0; }
.metric-label { color: var(--text-secondary); font-size: 0.875rem; font-weight: 500; }

/* UTILS */
.btn {
  padding: 0.5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; font-family: 'Inter', sans-serif; display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.2s;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: var(--bg-main); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--border-color); }

/* JOB LIST */
.job-item {
  display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border-color);
}
.job-item:last-child { border-bottom: none; }

.badge {
  padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-new { background-color: var(--primary-light); color: var(--primary); }
.badge-applied { background-color: var(--warning-light); color: var(--warning); }
.badge-interview { background-color: var(--success-light); color: var(--success); }
.badge-rejected { background-color: var(--danger-light); color: var(--danger); }

.form-control {
  width: 100%; padding: 0.75rem 1rem; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); }

/* ── Sidebar overlay backdrop ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Mobile / Tablet ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.active { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  #menu-toggle { display: flex !important; }

  .header { padding: 0 1rem; }
  .search-bar { display: none; }
  .header-right { gap: 0.75rem; }

  /* hide username text on small screens, keep avatar */
  .header-right > div > div { display: none; }
  .header-right > div > i { display: none; }

  .content { padding: 1rem; }

  /* metrics: 2 columns on tablet, 1 on phone */
  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }

  /* dashboard top bar */
  .page-header { flex-wrap: wrap; gap: 0.75rem; }
  .page-header > div { flex-wrap: wrap; }

  /* job item: stack on very small */
  .job-item { flex-wrap: wrap; gap: 0.5rem; }
  .job-item > div:last-child { flex-shrink: 0; }

  /* filter row */
  .filter-row { flex-direction: column; }
  .filter-row select { width: 100% !important; }

  /* settings grid */
  .settings-2col { grid-template-columns: 1fr !important; }
  .settings-tabs { gap: 0.4rem; }
  .settings-tab { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

  /* api key rows: stack */
  .api-key-row { flex-direction: column; align-items: stretch !important; }
  .api-key-row input { flex: unset !important; }
  .api-key-row button { width: 100%; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-value { font-size: 1.5rem; }

  h2 { font-size: 1.25rem; }

  .btn { font-size: 0.8rem; padding: 0.45rem 0.8rem; }

  /* recommendations/history page header */
  .page-header { flex-direction: column; align-items: flex-start !important; }
}

#menu-toggle { display: none; margin-right: 0.5rem; }

/* ── Utility: responsive 2-col form grid ──────────────────────────────── */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .grid-2col { grid-template-columns: 1fr; }
}

/* ── form-label default ───────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-group { margin-bottom: 1rem; }
