/* =========================================================
   Job App — Global Styles
   Design: flat, minimal, white cards, 1px light borders
   ========================================================= */

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

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.10);
  --border-hover: rgba(0,0,0,0.20);
  --text: #212529;
  --muted: #6c757d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --danger: #dc3545;
  --success: #198754;
  --warning: #ffc107;
  --info: #0dcaf0;
  --radius: 10px;
  --gap: 20px;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Inputs & Buttons ── */
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 60px; }

label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e9ecef; color: var(--text); }
.btn-secondary:hover { background: #dee2e6; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled  { opacity: .5; cursor: default; }

/* ── Auth Page ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.auth-logo {
  font-size: 22px; font-weight: 700; color: var(--primary);
  margin-bottom: 4px;
}
.auth-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active { color: var(--primary); border-color: var(--primary); }

.auth-form .field { margin-bottom: 16px; }
.auth-form .btn { width: 100%; justify-content: center; }

.auth-links { text-align: center; margin-top: 16px; font-size: 12px; color: var(--muted); }
.auth-links a { color: var(--primary); }

.form-hidden { display: none !important; }

.msg { margin-top: 12px; font-size: 12px; padding: 8px 12px; border-radius: 6px; }
.msg-error   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.msg-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ── Dashboard Layout ── */
.layout { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 100;
  height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-logo { font-size: 16px; font-weight: 700; color: var(--primary); }
.header-logo span { color: var(--text); font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-user { font-size: 13px; color: var(--muted); }
.header-user strong { color: var(--text); }

/* Stats bar */
.stats-bar {
  display: flex; gap: var(--gap);
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.stat-item {
  display: flex; flex-direction: column; align-items: center;
  flex: 1;
}
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Main grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: var(--gap) 24px;
  flex: 1;
}
@media (max-width: 900px) { .main-grid { grid-template-columns: 1fr; } }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  position: relative;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-header-right { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 12px 16px; flex: 1; overflow: hidden; }
.card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* Gear / settings button */
.gear-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--muted);
  padding: 2px 4px; border-radius: 4px;
  transition: color .15s;
  line-height: 1;
}
.gear-btn:hover { color: var(--text); }

/* ── Settings Popup ── */
.settings-popup {
  position: absolute; right: 12px; top: 48px;
  z-index: 99;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: none;
}
.settings-popup.open { display: block; }
.settings-popup .popup-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 12px;
}
.settings-popup .field { margin-bottom: 12px; }
.settings-popup .popup-footer { margin-top: 14px; display: flex; justify-content: flex-end; }

/* ── Job List ── */
.job-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.job-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.job-item:hover { border-color: var(--primary); }
.job-item-title { font-weight: 500; font-size: 13px; color: var(--text); }
.job-item-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 8px; }
.job-item-meta span::before { content: "· "; }
.job-item-meta span:first-child::before { content: ""; }
.job-item-actions { display: flex; gap: 6px; margin-top: 8px; }

.job-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 24px; }
.job-loading { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; }

/* ── Status Badges ── */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 500;
}
.badge-saved     { background: #e7f1ff; color: #0d6efd; }
.badge-applied   { background: #fff3cd; color: #856404; }
.badge-interview { background: #d1e7dd; color: #0f5132; }
.badge-offer     { background: #f8d7da; color: #842029; }

/* ── AI Chat ── */
.chat-messages {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 280px; overflow-y: auto;
  padding: 4px;
}
.chat-bubble {
  max-width: 85%; padding: 10px 12px;
  border-radius: 12px; font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.bubble-user {
  align-self: flex-end;
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble-ai {
  align-self: flex-start;
  background: #f0f4ff; color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid #dde6ff;
}
.bubble-typing { opacity: .6; font-style: italic; }

.chat-input-row {
  display: flex; gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.chat-input-row input { flex: 1; }

/* ── Skills Checklist ── */
.skills-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.skill-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s;
}
.skill-item:hover { border-color: var(--primary); }
.skill-item.completed { opacity: .55; }
.skill-item input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; accent-color: var(--primary); }
.skill-item label { margin: 0; font-size: 13px; color: var(--text); font-weight: 400; cursor: pointer; }
.skill-item.completed label { text-decoration: line-through; color: var(--muted); }

/* ── Saved Jobs ── */
.saved-job-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.saved-job-info { flex: 1; min-width: 0; }
.saved-job-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-job-meta { font-size: 11px; color: var(--muted); }
.saved-job-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.status-select {
  width: auto; font-size: 11px; padding: 3px 6px;
  border-radius: 12px;
}

.trash-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 2px;
  transition: color .15s;
}
.trash-btn:hover { color: var(--danger); }

/* ── Toggle ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.toggle {
  position: relative; width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #ced4da; border-radius: 20px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: ""; position: absolute;
  height: 14px; width: 14px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ── Utility ── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.align-center { align-items: center; }
