/* ─────────────────────────────────────────────
   HireSignal  |  Styles
   ───────────────────────────────────────────── */

:root {
  --navy:       #7c3aed;
  --navy-light: #6d28d9;
  --amber:      #f59e0b;
  --amber-light:#fcd34d;
  --bg:         #f0f4f8;
  --white:      #ffffff;
  --text:       #1e293b;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --error:      #dc2626;
  --success:    #16a34a;
  --radius:     10px;
  --radius-lg:  18px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
}

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

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Shared: Logo ─────────────────────────────── */
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-mark {
  width: 36px; height: 36px;
  background: var(--amber);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: var(--navy);
  flex-shrink: 0;
}
.logo-name { font-weight: 700; font-size: 18px; color: var(--navy); }

/* ── Shared: Buttons ──────────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 24px;
  background: var(--navy);
  color: var(--white);
  border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background .2s;
  margin-top: 8px;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; }

.hidden { display: none !important; }

/* ── Spinner ──────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════
   FORM PAGE
   ══════════════════════════════════════════════ */
.form-page { min-height: 100vh; }

.form-header {
  padding: 18px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.form-main {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-size: 28px; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.hero p  { font-size: 16px; color: var(--muted); line-height: 1.6; max-width: 480px; margin: 0 auto; }

.form-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px;
}

.form-group { margin-bottom: 22px; }
.form-group label {
  display: block;
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 7px;
}
.required { color: var(--amber); }
.optional { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.field-hint { font-size: 13px; color: var(--muted); margin-bottom: 7px; line-height: 1.5; }

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px; font-family: inherit; color: var(--text);
  background: var(--white);
  transition: border-color .2s;
  resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(124,58,237,.08);
}
.form-group input.invalid,
.form-group textarea.invalid { border-color: var(--error); }

.field-error { display: block; font-size: 13px; color: var(--error); margin-top: 5px; min-height: 18px; }

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 540px) {
  .form-row.two-col { grid-template-columns: 1fr; }
  .form-card { padding: 24px 20px; }
}

.radio-group { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.radio-option {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer; font-size: 14px;
  transition: border-color .2s, background .2s;
}
.radio-option:has(input:checked) {
  border-color: var(--navy);
  background: rgba(124,58,237,.06);
  color: var(--navy); font-weight: 600;
}
.radio-option input { display: none; }

.form-error {
  background: #fef2f2; border: 1px solid #fecaca;
  color: var(--error); font-size: 14px; padding: 12px 16px;
  border-radius: var(--radius); margin-bottom: 16px;
}

.privacy-note {
  text-align: center; font-size: 12px; color: var(--muted);
  margin-top: 20px; line-height: 1.5;
}

/* ══════════════════════════════════════════════
   CHAT PAGE
   ══════════════════════════════════════════════ */
.chat-page {
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.interview-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.label-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Messages area ──────────────────────────── */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}

.messages { display: flex; flex-direction: column; gap: 16px; }

.message-row {
  display: flex; align-items: flex-end; gap: 10px;
}
.message-row.user { flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  background: var(--amber); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--navy);
}

.message {
  max-width: min(480px, 78vw);
  padding: 13px 16px;
  font-size: 15px; line-height: 1.6;
  border-radius: 18px;
}
.message.ai {
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.message.user {
  background: var(--navy);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ───────────────────────── */
.typing-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  margin-top: 4px;
}
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 14px 18px !important;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(.8); opacity: .5; }
  40%            { transform: scale(1.2); opacity: 1; }
}

/* ── Input area ─────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 20px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}
.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 14px;
  transition: border-color .2s;
}
.chat-input-wrap:focus-within { border-color: var(--navy); }

#chatInput {
  flex: 1;
  border: none; background: transparent;
  font-size: 15px; font-family: inherit;
  resize: none; outline: none;
  line-height: 1.5; max-height: 150px; overflow-y: auto;
  color: var(--text);
}
#chatInput:disabled { color: var(--muted); cursor: not-allowed; }
#chatInput::placeholder { color: var(--muted); }

.send-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--navy); color: #fff;
  border: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
}
.send-btn:hover:not(:disabled) { background: var(--navy-light); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn:disabled svg { stroke: var(--muted); }

.input-hint {
  font-size: 12px; color: var(--muted);
  text-align: center; margin-top: 8px;
}

/* ── Overlays ───────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.65);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.overlay-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 400px; width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.overlay-card h3 { font-size: 18px; font-weight: 700; color: var(--navy); margin: 16px 0 8px; }
.overlay-card p  { font-size: 15px; color: var(--muted); line-height: 1.6; }

/* Report loading spinner */
.overlay-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}

/* Completion */
.check-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success); color: #fff;
  font-size: 30px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.overlay-card.completion h2 { font-size: 22px; color: var(--navy); margin-bottom: 10px; }
.completion-sub { font-size: 15px; color: var(--muted); line-height: 1.7; margin-top: 6px; }
.completion-detail {
  margin-top: 20px; padding: 12px 16px;
  background: var(--bg); border-radius: var(--radius);
  font-size: 13px; color: var(--muted);
}

/* ── CV file dropzone ─────────────────────────── */
.cv-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 26px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.cv-drop:hover, .cv-drop.dragging {
  border-color: var(--navy);
  background: rgba(124,58,237,.04);
}
.cv-drop.invalid { border-color: var(--error); }
.cv-drop.has-file {
  border-style: solid;
  border-color: var(--success);
  background: #f0fdf4;
}
.cv-drop-icon { color: var(--muted); }
.cv-drop.has-file .cv-drop-icon { color: var(--success); }
.cv-drop-text { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 6px; word-break: break-all; }
.cv-drop-sub  { font-size: 12px; color: var(--muted); }

/* ── JD acceptance gate ───────────────────────── */
.overlay-card.jd-card {
  max-width: 560px;
  text-align: left;
  padding: 36px 36px 30px;
}
.jd-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 4px;
}
.jd-title { font-size: 22px; font-weight: 700; color: var(--navy); margin-bottom: 14px; }
.jd-desc {
  max-height: 280px; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 13.5px; line-height: 1.65; color: var(--text);
  margin-bottom: 14px;
}
.jd-note { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; }
.jd-actions { display: flex; gap: 12px; }
.jd-actions .btn-primary.jd-accept { margin-top: 0; flex: 1.6; }
.btn-ghost {
  flex: 1;
  padding: 14px 18px;
  background: var(--white);
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-ghost:disabled, .jd-actions .btn-primary:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 540px) {
  .jd-actions { flex-direction: column-reverse; }
}
