/* --------------Couleurs (maquette Figma : violet + neutres façon Notion)-------------- */
:root {
  --primary: #6E5DC6; --vtext: #6E5DC6; --tint: #EEEBFA;
  --bg: #FFFFFF; --side: #F7F7F5; --colbg: #F1F1EF; --card: #FFFFFF;
  --border: #E9E9E7; --text: #37352F; --text2: #787774; --avbg: #E3E2E0;
  --hover: #EBEBE9; --danger: #E03E3E; --danger-bg: #FDEBEC;
  --overlay: rgba(15, 15, 15, .35);
}

/* --------------Mode sombre (classe posée sur <html> par theme.js)-------------- */
:root.dark {
  --vtext: #A797F2; --tint: #2E2847;
  --bg: #191919; --side: #202020; --colbg: #252525; --card: #2F2F2F;
  --border: #373737; --text: #E9E9E7; --text2: #9B9A97; --avbg: #3F3F3F;
  --hover: #2C2C2C; --danger: #FF7B72; --danger-bg: #3B2426;
  --overlay: rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 14px/1.4 Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* --------------Composants communs-------------- */
.btn { height: 34px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.full { width: 100%; }
.icon-btn { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn:hover { background: var(--hover); }
.ghost-btn { border: 0; background: none; color: var(--text2); display: inline-flex; padding: 4px; border-radius: 4px; flex: none; }
.ghost-btn:hover { background: var(--hover); color: var(--text); }
.link { border: 0; background: none; color: var(--vtext); font-weight: 600; text-align: left; padding: 0; }
.link:hover { text-decoration: underline; }
.input { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: var(--bg); width: 100%; }
.input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.av { border-radius: 50%; background: var(--avbg); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid var(--bg); flex: none; }
.av.me { background: var(--primary); color: #fff; }
.stack { display: flex; }
.stack .av + .av { margin-left: -5px; }
.muted { color: var(--text2); font-size: 13px; }
.grow { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #37352F; color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 60; }

/* --------------Logo-------------- */
.logo { background: #6E5DC6; position: relative; flex: none; }
.logo i { position: absolute; background: #fff; border-radius: 99px; }

/* --------------Connexion-------------- */
.login { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--side); position: relative; }
.login-card { width: 420px; max-width: calc(100% - 32px); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 44px 40px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { font-size: 24px; margin-top: 8px; }
.login-card p { color: var(--text2); }
.login-card .btn { width: 100%; height: 42px; margin-top: 12px; }
.login-card small { color: var(--text2); font-size: 12px; }
.corner { position: absolute; right: 32px; top: 28px; }

/* --------------Mise en page : barre latérale + contenu-------------- */
.app { display: flex; height: 100%; }
.sidebar { width: 240px; flex: none; background: var(--side); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 10px 16px; }
.sb-top { display: flex; align-items: center; gap: 10px; padding: 4px 10px; border-radius: 6px; }
.sb-top:hover { background: var(--hover); }
.brand { font-weight: 700; font-size: 16px; }
.sb-label { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: .04em; padding: 24px 10px 8px; }
.sb-list { display: flex; flex-direction: column; gap: 2px; }
.sb-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 6px 0 14px; border-radius: 6px; position: relative; }
.sb-item:hover { background: var(--hover); }
.sb-item .dot { width: 10px; height: 10px; border-radius: 3px; background: #B4B4B0; flex: none; }
.sb-item.active { background: var(--tint); font-weight: 600; }
.sb-item.active .dot { background: var(--primary); }
.sb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item .ghost-btn { visibility: hidden; }
.sb-item:hover .ghost-btn, .sb-item.menu-open .ghost-btn { visibility: visible; }
.sb-new { padding: 10px 14px; }
.sb-form { padding: 6px 8px; }
.sb-spacer { flex: 1; }
.sb-user { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); margin: 0 -10px; padding: 14px 20px 0; }
.sb-user b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { height: 84px; flex: none; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 40px; }
.top h1 { font-size: 28px; font-weight: 700; flex: 1; min-width: 0; }
.top h1 input { font: inherit; border: 0; background: none; width: 100%; text-overflow: ellipsis; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.top h1 input:not(:disabled):hover { background: var(--hover); }
.top h1 input:focus { background: var(--bg); outline: 2px solid var(--primary); }
.top h1 input:disabled { opacity: 1; cursor: default; }

/* --------------Menu « ⋯ »-------------- */
.ctx { position: absolute; z-index: 30; width: 190px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; font-weight: 400; }
.ctx > button { width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 5px; display: flex; align-items: center; gap: 8px; }
.ctx > button:hover { background: var(--hover); }
.ctx > button.danger { color: var(--danger); }
.ctx > button.danger:hover { background: var(--danger-bg); }

/* --------------Mes boards-------------- */
.tiles { display: flex; flex-wrap: wrap; gap: 24px; padding: 32px 40px; align-content: flex-start; overflow-y: auto; }
.tile { width: 248px; height: 132px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: transform .12s, box-shadow .12s; display: block; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.tile-bar { height: 6px; background: var(--primary); }
.tile-body { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.tile-name { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-role { color: var(--text2); font-size: 13px; margin-bottom: 12px; }
.tile.new { border: 2px dashed var(--border); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.tile.new:hover { border-color: var(--primary); }
.tile.new b { color: var(--vtext); font-size: 15px; }
.tile.form { padding: 18px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.tile.form:hover { transform: none; box-shadow: none; }
.empty { color: var(--text2); padding: 0 40px; }

/* --------------Board : colonnes et cartes-------------- */
.board { flex: 1; display: flex; gap: 16px; align-items: flex-start; padding: 24px 40px; overflow: auto; }
.col { width: 272px; flex: none; background: var(--colbg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.col.over-limit { box-shadow: inset 0 0 0 2px var(--danger); }
.col-head { display: flex; align-items: center; gap: 6px; padding: 2px 2px 10px 4px; position: relative; }
.col-name { font-weight: 600; flex: 1; text-overflow: ellipsis; border: 0; background: none; padding: 2px 4px; border-radius: 4px; min-width: 0; }
.col-name:not(:disabled):hover { background: var(--hover); }
.col-name:focus { background: var(--bg); outline: 2px solid var(--primary); }
.col-name:disabled { opacity: 1; cursor: default; }
.count { color: var(--text2); font-size: 12px; white-space: nowrap; }
.count.full { color: var(--danger); font-weight: 600; }
.col-cards { display: flex; flex-direction: column; gap: 8px; min-height: 8px; padding: 2px; }
.add-card { padding: 10px 4px 2px; }
.add-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.add-form .row { display: flex; gap: 8px; align-items: center; }
.add-col { width: 272px; flex: none; background: var(--colbg); border-radius: 10px; padding: 14px; }
.card { background: var(--card); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.14); overflow: hidden; cursor: pointer; user-select: none; }
.card[draggable="true"] { cursor: grab; }
.card:hover { box-shadow: 0 0 0 2px var(--primary); }
.card.dragging { opacity: .35; }
.cover { height: 30px; }
.cbody { padding: 9px 11px; display: flex; flex-direction: column; gap: 7px; }
.ctitle { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.lbls { display: flex; gap: 5px; flex-wrap: wrap; }
.lbl { width: 40px; height: 7px; border-radius: 4px; }
.cfoot { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 12px; color: var(--text2); padding: 1px 4px; border-radius: 4px; }
.badge.done { background: #1F845A; color: #fff; font-weight: 600; padding: 1px 6px; }
.drop-ph { height: 52px; border: 2px dashed var(--primary); border-radius: 8px; background: var(--tint); flex: none; }

/* --------------Fenêtres (modales)-------------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto; z-index: 40; }
.modal { background: var(--bg); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 26px; width: 100%; position: relative; }
.modal.sm { max-width: 460px; margin-top: 120px; }
.modal.md { max-width: 560px; }
.modal.lg { max-width: 1100px; padding: 0; overflow: hidden; }
.m-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.m-head h2 { font-size: 20px; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.m-text { color: var(--text2); line-height: 1.5; overflow-wrap: anywhere; }
.m-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.m-cover { height: 72px; }
.m-close { position: absolute; right: 14px; top: 14px; }
.m-close.on-cover { color: #fff; }
.m-grid { display: flex; padding: 18px 30px 30px; gap: 26px; }
.m-grid.no-cover { padding-top: 34px; }
.m-left { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-right { width: 220px; flex: none; border-left: 1px solid var(--border); padding-left: 20px; display: flex; flex-direction: column; }
.m-title { font-size: 22px; font-weight: 700; text-overflow: ellipsis; border: 0; background: none; padding: 2px 6px; margin-left: -6px; border-radius: 6px; width: calc(100% - 30px); }
.m-title:not(:disabled):hover { background: var(--hover); }
.m-title:disabled { opacity: 1; cursor: default; }
.m-sub { color: var(--text2); font-size: 13px; margin: 2px 0 18px; overflow-wrap: anywhere; }
.sec { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; margin: 16px 0 8px; }
.m-left .sec:first-of-type, .m-right .sec:first-of-type { margin-top: 0; }
.m-right .hint + .sec { margin-top: 16px; }
h4 { font-size: 16px; font-weight: 600; margin: 18px 0 10px; }
textarea.desc { width: 100%; min-height: 100px; max-height: 320px; overflow-y: auto; resize: vertical; background: var(--side); border: 1px solid var(--border); border-radius: 6px; padding: 12px; line-height: 1.6; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.chip { padding: 4px 14px; border-radius: 4px; font-weight: 600; font-size: 12px; color: #172B4D; max-width: 100%; overflow-wrap: anywhere; }
.cl { margin-top: 6px; }
.cl-head { display: flex; align-items: center; gap: 8px; }
.cl-head h4 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.progress { height: 6px; background: var(--border); border-radius: 4px; margin-bottom: 8px; overflow: hidden; }
.progress div { height: 100%; background: var(--primary); transition: width .2s; }
.ci { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.ci > span:not(.cb) { min-width: 0; overflow-wrap: anywhere; line-height: 18px; }
.ci.done span:not(.cb) { color: var(--text2); text-decoration: line-through; }
.ci .ghost-btn { margin-left: auto; visibility: hidden; }
.ci:hover .ghost-btn { visibility: visible; }
.cb { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid #B4B4B0; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.cb.on { background: var(--primary); border-color: var(--primary); }
select.select { height: 34px; width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--bg); }
.hint { font-size: 12px; color: var(--text2); margin-top: 6px; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; }
.cs { width: 40px; height: 28px; border-radius: 5px; border: 0; }
.cs.none { border: 1.5px dashed #B4B4B0; background: linear-gradient(to top right, transparent 47%, #9B9A97 48%, #9B9A97 52%, transparent 53%); }
.cs.sel { outline: 2px solid var(--text); outline-offset: 2px; }
.lrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.lbar { flex: 1; height: 26px; border-radius: 4px; font-weight: 600; font-size: 12px; color: #172B4D; display: flex; align-items: center; padding: 0 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lrow .lname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .ghost-btn { visibility: hidden; }
.lrow:hover .ghost-btn { visibility: visible; }
.new-label { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.mrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mrow .mtxt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.mrow select.select { width: 120px; }
.inv { display: flex; gap: 10px; }
.inv select.select { width: 120px; }

/* --------------Petits écrans (téléphone, tablette en portrait)-------------- */
.menu-btn { display: none; }
.sb-backdrop { display: none; }

@media (max-width: 760px) {
  /* La barre latérale devient un tiroir ouvert par le bouton ☰ */
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: var(--overlay); }

  .top { height: auto; min-height: 64px; padding: 12px 16px; gap: 10px; }
  .top h1 { font-size: 22px; }
  .top .btn { padding: 0 12px; }
  .board, .tiles { padding: 16px; }
  .board { scroll-snap-type: x mandatory; }
  .col, .add-col { width: min(272px, 82vw); scroll-snap-align: start; }
  .tile { width: 100%; }
  .empty { padding: 0 16px; }

  .overlay { padding: 16px 10px; }
  .modal { padding: 20px; }
  .modal.sm { margin-top: 40px; }
  .m-grid { flex-direction: column; padding: 16px 18px 22px; gap: 18px; }
  .m-grid.no-cover { padding-top: 40px; }
  .m-right { width: auto; border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
  .mrow { flex-wrap: wrap; }
  .mrow .mtxt { min-width: 150px; }
  .inv { flex-wrap: wrap; }
  .inv .input { flex: 1 1 100%; }
  .inv select.select, .inv .btn { flex: 1; }
}

/* Écrans tactiles : pas de survol, donc les boutons « ⋯ » et corbeille restent visibles */
@media (hover: none) {
  .sb-item .ghost-btn, .ci .ghost-btn, .lrow .ghost-btn { visibility: visible; }
}

@media (max-width: 480px) {
  /* Pas la place pour les avatars dans l'en-tête : ils restent visibles dans « Membres » */
  .top .stack { display: none; }
  .login-card { padding: 32px 22px; }
  .corner { right: 16px; top: 16px; }
}
