/* app.css — ClearBid dashboard styles */

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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --sidebar-w: 240px;
  --header-h: 60px;
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

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

.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.auth-card p { color: var(--text-muted); margin-bottom: 24px; }

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  padding: 8px 16px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }

.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }

/* App Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.dashboard-nav {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}

.nav-logo { font-size: 1.3rem; }

.dashboard-nav nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.nav-icon { font-size: 1.1rem; }

.nav-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.user-info { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  transition: background 0.15s;
}
.btn-logout:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Page Header */
.page-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.2rem; padding: 4px; }
.page-title { font-size: 1.1rem; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }

/* Page Body */
.page-body { padding: 24px; flex: 1; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-new { background: var(--primary-light); color: var(--primary); }
.badge-parsed { background: var(--success-light); color: var(--success); }
.badge-draft { background: var(--warning-light); color: var(--warning); }
.badge-review { background: #f3e8ff; color: #7c3aed; }
.badge-final { background: var(--success-light); color: var(--success); }
.badge-proposal { background: #f3e8ff; color: #7c3aed; }
.badge-boilerplate { background: var(--primary-light); color: var(--primary); }
.badge-capability { background: #f0fdf4; color: #15803d; }

/* Fit Score Badges */
.fit-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  min-width: 36px;
  text-align: center;
}
.fit-green { background: #ecfdf5; color: #15803d; border: 1px solid #bbf7d0; }
.fit-yellow { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.fit-gray { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.table-link { font-weight: 500; }
.table-link:hover { color: var(--primary-hover); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.form-input-full { width: 100%; }
textarea.form-input { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Buttons */
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-parse {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-parse:hover { background: #6d28d9; }

.btn-generate {
  background: var(--success);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-generate:hover { background: #059669; }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* Loading */
.loading { text-align: center; padding: 48px; color: var(--text-muted); }
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Sections */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.req-list { list-style: none; }
.req-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.req-item:last-child { border-bottom: none; }
.req-priority {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 40px;
  text-align: center;
}
.priority-must { background: var(--danger-light); color: var(--danger); }
.priority-should { background: var(--warning-light); color: var(--warning); }
.priority-could { background: var(--primary-light); color: var(--primary); }

.criteria-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.criteria-weight { font-size: 12px; font-weight: 600; color: var(--primary); min-width: 60px; }

.compliance-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}
.compliance-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-top: 2px;
  flex-shrink: 0;
}
.compliance-check.done { background: var(--success); color: white; }
.compliance-check.missing { background: var(--border); color: var(--text-muted); }
.compliance-check.required { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }

/* Proposal Editor */
.proposal-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
}

.proposal-editor textarea {
  width: 100%;
  min-height: 500px;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}
.proposal-editor textarea:focus { outline: none; border-color: var(--primary); }

.proposal-sidebar { position: sticky; top: calc(var(--header-h) + 24px); }
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.sidebar-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* KB Page */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.kb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kb-card-title { font-weight: 600; margin-bottom: 4px; }
.kb-card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.kb-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-zone-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone-text { color: var(--text-muted); font-size: 13px; }
.upload-zone input[type="file"] { display: none; }

/* Opp Detail */
.opp-header { margin-bottom: 24px; }
.opp-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.opp-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-muted); }
.opp-meta-item { display: flex; align-items: center; gap: 4px; }

/* Markdown render */
.md-content h1 { font-size: 1.4rem; font-weight: 700; margin: 20px 0 12px; }
.md-content h2 { font-size: 1.1rem; font-weight: 600; margin: 16px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-content p { margin: 8px 0; line-height: 1.6; }
.md-content ul, .md-content ol { margin: 8px 0 8px 24px; }
.md-content li { margin: 4px 0; }
.md-content strong { font-weight: 600; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; margin-bottom: 8px; color: var(--text); }

/* ─── Onboarding ────────────────────────────────────────────────────────── */
.onboarding-wrap {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px 80px;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 32px;
}

.onboarding-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
}

.onboarding-logo { font-size: 1.5rem; }

.onboarding-tagline {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
}

/* Progress */
.onboarding-progress {
  width: 100%;
  max-width: 600px;
  margin-bottom: 28px;
}

.progress-track {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: #fbbf24;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
}

.step-label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  transition: color 0.3s;
}
.step-label.active { color: #fbbf24; }
.step-label.done { color: rgba(255,255,255,0.8); }

/* Card */
.onboarding-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.onboarding-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.step-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.required { color: var(--danger); }

/* Navigation */
.onboarding-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  width: 100%;
  max-width: 600px;
}

.onboarding-nav .btn-secondary {
  border-color: rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.8);
}
.onboarding-nav .btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* NAICS */
.naics-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
  z-index: 100;
  position: relative;
}

.naics-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.naics-option:hover { background: var(--primary-light); }

.naics-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.naics-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.naics-tag-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}
.naics-tag-remove:hover { opacity: 1; }

/* Cert Chips */
.cert-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cert-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.cert-chip input { display: none; }
.cert-chip:hover { border-color: var(--primary); }
.cert-chip.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.cert-label { font-weight: 500; }

/* Contract Range */
.contract-range { }
.range-label { font-weight: 600; font-size: 13px; margin-bottom: 8px; color: var(--text-muted); }
.range-inputs { display: flex; align-items: center; gap: 12px; }
.range-separator { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.range-hints { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.range-hint {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.range-hint:hover { border-color: var(--primary); background: var(--primary-light); }

/* Team Size */
.team-size-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.team-chip {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.team-chip input { display: none; }
.team-chip:hover { border-color: var(--primary); }
.team-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* Geo Chips */
.geo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.geo-chip {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.geo-chip input { display: none; }
.geo-chip:hover { border-color: var(--primary); }
.geo-chip.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* Review */
.review-summary {
  display: grid;
  gap: 12px;
}

.review-section {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.review-section:last-child { border-bottom: none; }

.review-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 140px;
  flex-shrink: 0;
}

.review-value {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
  .onboarding-wrap { padding: 24px 12px 60px; }
  .onboarding-card { padding: 24px 20px; }
  .cert-grid { grid-template-columns: 1fr; }
  .range-inputs { flex-direction: column; }
  .range-separator { display: none; }
  .step-label { font-size: 9px; }
  .review-section { flex-direction: column; gap: 4px; }
  .review-label { min-width: unset; }
}
@media (max-width: 768px) {
  .dashboard-nav {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .dashboard-nav.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
  .proposal-layout { grid-template-columns: 1fr; }
  .proposal-sidebar { position: static; }
  .kb-grid { grid-template-columns: 1fr; }
}