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

/* ── Base ── */
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
.container { max-width: 860px; margin: 0 auto; padding: 0 1.25rem; }

header {
  background: #18181b;
  color: #fff;
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}
header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
header p  { color: #a1a1aa; font-size: 0.875rem; margin-top: 0.2rem; }

.card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #52525b;
  margin-bottom: 1rem;
}
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: #a1a1aa; font-size: 0.8rem; }

/* ── JD textarea ── */
#jd-text {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.15s;
}
#jd-text:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

.upload-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: #6366f1;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#jd-file { display: none; }

/* ── Drop zone ── */
#drop-zone {
  border: 2px dashed #d4d4d8;
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  color: #a1a1aa;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
#drop-zone:hover, #drop-zone:focus { background: #f5f3ff; border-color: #a5b4fc; outline: none; }
#drop-zone.drag-over { background: #eef2ff; border-color: #6366f1; }
#drop-zone svg { display: block; margin: 0 auto 0.6rem; color: #c4b5fd; }
#drop-zone p    { font-size: 0.9rem; color: #71717a; }
#drop-zone small { font-size: 0.8rem; margin-top: 0.2rem; display: block; }
#cv-file-input { display: none; }

/* ── File list ── */
#file-list { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.7rem;
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-radius: 5px;
  font-size: 0.85rem;
}
.file-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item button {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #a1a1aa;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  margin-left: 0.5rem;
  transition: color 0.1s;
}
.file-item button:hover { color: #ef4444; }

/* ── Inline error ── */
.inline-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* ── Evaluate button ── */
#evaluate-btn {
  margin-top: 1.1rem;
  padding: 0.6rem 1.5rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
#evaluate-btn:not(:disabled):hover { background: #4f46e5; }
#evaluate-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 1.1rem; height: 1.1rem;
  border: 2px solid #c7d2fe;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap { padding: 0.5rem 0; }
.progress-outer { position: relative; margin-bottom: 0.55rem; }
#progress-rocket {
  position: absolute;
  top: 50%;
  left: 0%;
  margin-left: -0.7rem;
  transform: translateY(-50%);
  transition: left 0.45s ease;
  user-select: none;
  line-height: 1;
}
.rocket-inner {
  display: block;
  font-size: 1.3rem;
  transform: rotate(90deg);
  animation: rocket-glow 0.65s ease-in-out infinite;
}
@keyframes rocket-glow {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(251,146,60,.7)); }
  50%       { filter: drop-shadow(0 0 8px rgba(251,146,60,1)) drop-shadow(0 0 16px rgba(253,186,116,.55)); }
}
.progress-track {
  width: 100%;
  height: 6px;
  background: #e4e4e7;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #818cf8 0%, #6366f1 55%, #f97316 82%, #fde68a 100%);
  border-radius: 3px;
  width: 0%;
  transition: width 0.45s ease;
}
.progress-msg { font-size: 0.84rem; color: #6366f1; }

/* ── Typing dots ── */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing-dots span {
  width: 6px; height: 6px;
  background: #a1a1aa;
  border-radius: 50%;
  animation: dot-bounce 1.1s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #18181b;
  color: #f4f4f5;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.83rem;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Results table ── */
#results-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
#results-table thead th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 2px solid #e4e4e7;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
  white-space: nowrap;
}
#results-table tbody tr.data-row {
  cursor: pointer;
  transition: background 0.1s;
}
#results-table tbody tr.data-row:hover { background: #f9f9fb; }
#results-table tbody tr.data-row.expanded { background: #f5f3ff; }
#results-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f4f4f5;
  vertical-align: middle;
}
.rank-cell { color: #a1a1aa; font-size: 0.8rem; width: 2rem; }
.name-cell strong { font-weight: 600; }
.score-val { font-weight: 700; font-size: 1.05rem; color: #18181b; }

/* ── Recommendation badge ── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-strong_match { background: #d1fae5; color: #065f46; }
.badge-match        { background: #dbeafe; color: #1e40af; }
.badge-maybe        { background: #fef3c7; color: #92400e; }
.badge-no_match     { background: #fee2e2; color: #991b1b; }

/* ── Detail panel ── */
.detail-row td { padding: 0 !important; border-bottom: 2px solid #e0e0f0; }
.detail-panel {
  padding: 1.25rem 1.5rem;
  background: #fafaff;
  border-top: 1px solid #e4e4e7;
}

/* Dimension bars */
.dimensions { margin-bottom: 1.1rem; }
.dim-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.83rem;
}
.dim-label    { width: 130px; flex-shrink: 0; color: #52525b; }
.dim-track    { flex: 1; height: 7px; background: #e4e4e7; border-radius: 4px; overflow: hidden; }
.dim-fill     { height: 100%; border-radius: 4px; background: #6366f1; transition: width 0.45s ease; }
.dim-score    { width: 2.2rem; text-align: right; font-weight: 600; font-size: 0.82rem; color: #3f3f46; flex-shrink: 0; }
.dim-rationale { font-size: 0.78rem; color: #71717a; margin: 0.1rem 0 0.45rem 130px; line-height: 1.4; }
.dim-evidence { margin: 0.1rem 0 0.45rem 130px; display: flex; flex-direction: column; gap: 0.2rem; }
.dim-evidence blockquote {
  font-size: 0.78rem;
  font-style: italic;
  color: #52525b;
  background: #eef2ff;
  border-left: 3px solid #818cf8;
  padding: 0.2rem 0.5rem;
  border-radius: 0 4px 4px 0;
  margin: 0;
}

/* Strengths / gaps grid */
.sg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.sg-col h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
  margin-bottom: 0.4rem;
}
.sg-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.sg-col ul li { font-size: 0.85rem; padding-left: 1rem; position: relative; }
.sg-col ul li::before { content: "•"; position: absolute; left: 0; color: #6366f1; }

/* Summary */
.detail-summary {
  font-size: 0.875rem;
  color: #52525b;
  line-height: 1.55;
  border-top: 1px solid #e4e4e7;
  padding-top: 0.85rem;
}

/* ── Chat ── */
#chat-messages {
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #e4e4e7;
  border-radius: 7px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg.user     { align-self: flex-end; }
.chat-msg.assistant{ align-self: flex-start; }
.chat-bubble {
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: #6366f1;
  color: #fff;
  border-radius: 14px 14px 3px 14px;
}
.chat-msg.assistant .chat-bubble {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 14px 14px 14px 3px;
}
/* markdown inside assistant bubble */
.chat-bubble p   { margin-bottom: 0.35rem; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { padding-left: 1.2rem; margin-bottom: 0.35rem; }
.chat-bubble code { font-size: 0.8rem; background: #f4f4f5; padding: 0.1rem 0.3rem; border-radius: 3px; }

.chat-input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
#chat-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  transition: border-color 0.15s;
}
#chat-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
#chat-send {
  padding: 0.6rem 1.2rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  align-self: flex-end;
}
#chat-send:not(:disabled):hover { background: #4f46e5; }
#chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Utilities ── */
.hidden { display: none !important; }
