/* ============ OppFinder - thème sombre ============ */
:root {
  --bg: #0e1117;
  --bg-soft: #151a23;
  --surface: #1a2130;
  --surface-hover: #202940;
  --border: #2a3347;
  --text: #e9edf4;
  --muted: #93a0b4;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, .12);
  --amber: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Avenir Next", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.45;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- boutons / champs ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06212e;
  font-weight: 600;
}
.btn-primary:hover { background: #5cc9f9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger:hover { color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }

input[type="text"], input[type="search"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: .95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .9rem; }
label small { color: var(--muted); font-weight: 400; }
.field-hint { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }
.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .4);
  color: var(--red);
  font-size: .9rem;
}

/* ---------- login ---------- */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(700px 400px at 20% 10%, rgba(56,189,248,.10), transparent),
    radial-gradient(700px 400px at 85% 90%, rgba(251,191,36,.07), transparent),
    var(--bg);
}
.login-card {
  width: min(380px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.login-brand { font-size: 1.5rem; font-weight: 700; text-align: center; }
.login-brand em { color: var(--accent); font-style: normal; }
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 10px; }
.login-card button { margin-top: 18px; }

/* ---------- layout app ---------- */
#view-app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 265px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
}
.brand { font-size: 1.25rem; font-weight: 700; padding: 0 4px 4px; }
.brand em { color: var(--accent); font-style: normal; }

.alert-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.alert-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.alert-item:hover { background: var(--surface); }
.alert-item.active { background: var(--accent-soft); border-color: var(--accent); }
.alert-item .alert-name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.alert-item .count { color: var(--muted); font-size: .85rem; }
.alert-item.inactive .alert-name { color: var(--muted); }
.alert-item .alert-kw { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px; color: var(--muted); font-size: .9rem;
}

.content { flex: 1; overflow-y: auto; padding: 26px 32px; }

/* ---------- entête alerte ---------- */
.alert-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.alert-header h1 { margin: 0 0 8px; font-size: 1.45rem; }
.alert-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: .82rem;
}
.chip.neutral { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.alert-meta { color: var(--muted); font-size: .85rem; margin-top: 8px; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 16px;
  margin: 20px 0 14px;
}
.toolbar input[type="search"] { max-width: 300px; }
.toggle { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--muted); cursor: pointer; white-space: nowrap; }
.job-count { margin-left: auto; color: var(--muted); font-size: .88rem; }

/* ---------- liste d'annonces ---------- */
.job-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; }
.job-card {
  display: flex; gap: 16px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color .15s;
}
.job-card:hover { border-color: #3b475f; }
.job-card.hidden-job { opacity: .5; }

.score {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  border: 3px solid var(--border);
  color: var(--muted);
}
.score.high { border-color: var(--green); color: var(--green); }
.score.mid  { border-color: var(--amber); color: var(--amber); }

.job-main { flex: 1; min-width: 0; }
.job-title { font-weight: 600; font-size: 1.02rem; }
.job-title a { color: var(--text); }
.job-title a:hover { color: var(--accent); text-decoration: none; }
.job-sub { color: var(--muted); font-size: .87rem; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tag {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: .75rem;
  color: var(--muted);
}
.tag.contract { color: var(--amber); border-color: rgba(251,191,36,.35); }

.job-actions { display: flex; gap: 4px; flex-shrink: 0; }
.icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--muted);
  padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn.fav-on { color: var(--amber); }
.icon-btn.ai { color: var(--accent); font-size: .85rem; border: 1px solid var(--border); }
.icon-btn.ai:hover { border-color: var(--accent); }

.empty-state { text-align: center; margin-top: 14vh; color: var(--muted); }
.empty-state .empty-icon { font-size: 3.2rem; }
.empty-state h2 { color: var(--text); }
.empty-state p { max-width: 440px; margin: 10px auto 22px; }

.list-empty { color: var(--muted); text-align: center; padding: 40px 0; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chat ---------- */
.chat-panel {
  width: 400px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-title { font-weight: 700; }
.chat-subtitle { color: var(--muted); font-size: .82rem; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: .93rem; white-space: pre-wrap; overflow-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgba(56,189,248,.3); }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.msg.assistant strong { color: var(--accent); }
.chat-hint { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 20px; padding: 0 10px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input textarea { resize: none; }
.chat-input button { flex-shrink: 0; align-self: flex-end; }

/* ---------- modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 8, 14, .7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  width: min(560px, 94vw);
  max-height: 90vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sources { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.source-opt { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.source-opt .unavailable { color: var(--muted); font-size: .8rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #view-app { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .alert-list { max-height: 180px; }
  .content { padding: 18px; }
  .chat-panel { position: fixed; inset: 0; width: 100%; z-index: 40; }
}
