/* ==========================================================================
   JobFinder — maquette minimaliste
   Tokens · Base · Layout · Composants · Vues · Responsive
   ========================================================================== */

/* ---------- Tokens (sombre adouci + violet, par défaut) ---------- */
:root {
  --bg: #24252D;
  --surface: #2C2D37;
  --surface-2: #353642;
  --border: #3E404D;
  --text: #ECECF1;
  --text-2: #ABACBC;
  --text-3: #7C7E8F;
  --accent: #A78BFA;
  --accent-ink: #1A1726;
  --accent-soft: rgba(167, 139, 250, .15);
  --warn: #E3B26B;
  --warn-soft: rgba(227, 178, 107, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .18);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .4);

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --nav-w: 232px;
  color-scheme: dark;
}

/* Variante claire (interrupteur dans Profil) */
:root[data-theme="light"] {
  --bg: #FAFAFC; --surface: #FFFFFF; --surface-2: #F1F0F6; --border: #E6E4EE;
  --text: #1D1B26; --text-2: #6A6878; --text-3: #9B99A8;
  --accent: #7C5CE0; --accent-ink: #FFFFFF; --accent-soft: #EFEAFD;
  --warn: #B07A35; --warn-soft: #F7EFE2;
  --shadow: 0 1px 2px rgba(20, 18, 30, .04), 0 4px 16px rgba(20, 18, 30, .04);
  --shadow-lg: 0 12px 48px rgba(20, 18, 30, .12);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
h1 { font-size: 2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: .95rem; font-weight: 600; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }
.grow { flex: 1; min-width: 0; }
.block-line { display: block; }
.center { display: block; margin: 0 auto; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.nav {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  gap: 32px;
  padding: 28px 16px;
  border-right: 1px solid var(--border);
}
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent);
  position: relative;
}
.brand-mark::after { /* petit point clair : sobre mais reconnaissable */
  content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg);
}
.brand-mark.lg { width: 40px; height: 40px; border-radius: 12px; }
.brand-mark.lg::after { inset: 13px; }
.brand-name { font-weight: 600; letter-spacing: -.01em; }

.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }

.nav-status { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: .8rem; color: var(--text-3); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--accent); }
.dot-warn { background: var(--warn); }

.main { padding: 56px 56px 80px; min-width: 0; }
.view { max-width: 880px; margin: 0 auto; animation: fade .35s var(--ease); }
.view-narrow { max-width: 640px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 32px; }
.eyebrow { font-size: .8rem; color: var(--text-3); margin-bottom: 6px; }
.eyebrow::first-letter { text-transform: uppercase; }
.lead { color: var(--text-2); margin-top: 8px; font-size: 1.02rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 40px 0 14px; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: .88rem; font-weight: 500; }
.link:hover { color: var(--accent); }

/* ---------- Composants ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 10px;
  font-weight: 500; font-size: .9rem;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.is-on { color: var(--accent); border-color: var(--accent); }
.btn-ghost.is-on .icon { fill: currentColor; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-3); margin-top: 8px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: .8rem; }
.btn-block { width: 100%; }
.icon-only { width: 40px; padding: 0; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.pill {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  font-size: .78rem; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.pill-score { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600; font-size: .85rem;
}
.avatar-img {
  object-fit: contain;
  background: #ffffff;
  padding: 3px;
  border: 1px solid var(--border);
}
.select-status {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.76rem;
  outline: none;
  cursor: pointer;
}
.select-status:focus { border-color: var(--accent); }

/* Objectif hebdo */
.week { padding: 18px 20px; }
.week-row { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 12px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s var(--ease); }

/* Cartes d'offres */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.job-card {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px;
  text-align: left;
  transition: border-color .15s, transform .2s var(--ease);
}
.job-card:hover { border-color: var(--text-3); transform: translateY(-2px); }
.job-card-title { font-weight: 500; line-height: 1.35; }
.job-card-co { color: var(--text-2); font-size: .88rem; margin-top: 2px; }
.job-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: .82rem; color: var(--text-3); }

/* Listes */
.list > li + li { border-top: 1px solid var(--border); }
.row {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  text-align: left;
  transition: background .15s;
}
button.row:hover { background: var(--surface-2); }
.list > li:first-child .row { border-radius: var(--radius) var(--radius) 0 0; }
.list > li:last-child .row { border-radius: 0 0 var(--radius) var(--radius); }
.list > li:only-child .row { border-radius: var(--radius); }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--text-2); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: .82rem; }

/* Barre d'outils Offres */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search {
  flex: 1 1 280px;
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-3);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); min-width: 0; }
.search input::placeholder { color: var(--text-3); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.segmented button {
  height: 36px; padding: 0 14px;
  border-radius: 8px;
  font-size: .86rem; font-weight: 500;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; color: var(--text-3); padding: 48px 0; }

/* Suivi (pipeline) */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 12px; font-size: .88rem; font-weight: 500; }
.col-head .count { color: var(--text-3); font-weight: 400; }
.col-body { display: flex; flex-direction: column; gap: 10px; min-height: 120px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.track-card { padding: 14px; text-align: left; transition: border-color .15s; }
.track-card:hover { border-color: var(--text-3); }
.track-card .t { font-weight: 500; font-size: .9rem; line-height: 1.35; }
.track-card .c { color: var(--text-2); font-size: .82rem; margin-top: 2px; }
.track-card .m { display: flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--text-3); font-size: .78rem; }
.col-empty { color: var(--text-3); font-size: .82rem; text-align: center; padding: 24px 8px; }

/* Profil */
.block { padding: 20px; margin-bottom: 16px; }
.block > h3, .block-head { margin-bottom: 16px; }
.block-head { display: flex; align-items: center; justify-content: space-between; }
.block-head h3 { margin: 0; }
.file-row { display: flex; align-items: center; gap: 14px; }
.file-icon { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; }
.kv dt { font-size: .8rem; color: var(--text-3); margin-bottom: 2px; }
.sources li { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.sources li + li { border-top: 1px solid var(--border); }
.toggle-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; cursor: pointer; }
.toggle-row + .toggle-row { border-top: 1px solid var(--border); }

.switch {
  appearance: none; -webkit-appearance: none;
  width: 40px; height: 24px; flex: none;
  border-radius: 99px;
  background: var(--border);
  position: relative; cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

.disclosure summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure .chev { color: var(--text-3); transition: transform .2s; }
.disclosure[open] .chev { transform: rotate(90deg); }
.disclosure[open] summary { margin-bottom: 12px; }
.log li { display: flex; gap: 16px; padding: 8px 0; font-size: .86rem; }
.log time { color: var(--text-3); width: 72px; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Panneau détail ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 15, 14, .28);
  backdrop-filter: blur(2px);
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(500px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .32s var(--ease), visibility 0s .32s;
}
.drawer:focus { outline: none; }
.drawer.open { transform: none; visibility: visible; transition: transform .32s var(--ease); }
.drawer-head { display: flex; justify-content: flex-end; padding: 16px 16px 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 32px 32px; }
.drawer-foot { display: flex; gap: 8px; padding: 16px 24px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

.d-co { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: .9rem; }
.d-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; margin: 16px 0 12px; }
.d-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.d-section { margin-top: 28px; }
.d-section > h3 { font-size: .8rem; font-weight: 500; color: var(--text-3); margin-bottom: 10px; }
.d-why li { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; }
.d-why .icon { color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }
.d-text { color: var(--text-2); }
.d-text p + p { margin-top: 10px; }
.msg-box {
  width: 100%; min-height: 150px; resize: vertical;
  padding: 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
  line-height: 1.55; font-size: .9rem;
  outline: 0;
}
.msg-box:focus { border-color: var(--accent); }
.msg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- Connexion ---------- */
.auth { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: center; animation: fade .4s var(--ease); }
.auth-card .brand-mark { margin: 0 auto 8px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card > p { margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: .85rem; color: var(--text-2); }
.field input {
  height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  outline: 0; font-size: .95rem;
}
.field input:focus { border-color: var(--accent); }
.auth-card .btn-primary { height: 44px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 70;
  transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg);
  font-size: .88rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablette : nav en icônes */
@media (max-width: 1024px) {
  :root { --nav-w: 76px; }
  .nav { padding: 28px 12px; align-items: center; }
  .nav-brand { padding: 0; }
  .brand-name, .nav-item span, .nav-status span:last-child { display: none; }
  .nav-item { justify-content: center; width: 48px; height: 44px; padding: 0; }
  .nav-status { padding: 0; }
  .main { padding: 48px 32px 72px; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Mobile : barre d'onglets en bas */
@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 1.65rem; }
  .app { display: block; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30;
    height: auto;
    flex-direction: row; justify-content: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(16px);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
  }
  .nav-brand, .nav-status { display: none; }
  .nav-list { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-list li { flex: 1; }
  .nav-item { flex-direction: column; gap: 3px; width: 100%; height: 54px; justify-content: center; background: none !important; }
  .nav-item span { display: block; font-size: .7rem; }
  .main { padding: 32px 20px calc(96px + env(safe-area-inset-bottom)); }
  .view-head { margin-bottom: 24px; }
  .section-head { margin-top: 32px; }

  .cards { grid-template-columns: 1fr; gap: 12px; }
  .job-card:hover { transform: none; }
  .job-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
  .job-card-foot { grid-column: auto; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex: none; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding: 0 8px; }
  .row { padding: 14px 16px; }
  .row .row-date { display: none; }

  /* Pipeline : colonnes défilantes horizontalement */
  .board {
    display: flex; gap: 12px;
    overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 -20px; padding: 0 20px 8px;
    scrollbar-width: none;
  }
  .board::-webkit-scrollbar { display: none; }
  .col { flex: 0 0 82%; scroll-snap-align: center; }

  .kv { grid-template-columns: 1fr; }

  /* Détail : feuille plein écran qui monte du bas */
  .drawer { width: 100%; border-left: 0; transform: translateY(100%); }
  .drawer-body { padding: 0 20px 24px; }
  .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .drawer-foot #d-dismiss { padding: 0 12px; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
}

/* Modal & Form elements */
.modal-dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 85; width: min(560px, 92vw); max-height: 85vh; overflow-y: auto;
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: block;
}
.modal-dialog[hidden] {
  display: none !important;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;
}
.form-group {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px;
}
.form-group label {
  font-size: .84rem; font-weight: 500; color: var(--text-2);
}
.form-control {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: .9rem; outline: 0;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control {
  height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; line-height: 1.4;
}
.checkbox-group {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px;
}
.checkbox-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); font-size: .84rem; cursor: pointer; user-select: none;
  transition: all .15s;
}
.checkbox-chip:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
}
.checkbox-chip input { cursor: pointer; }
.source-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.source-item:last-child { border-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
