/* ===== Base ===== */
:root {
  --bg: #f5f6f8; --card: #fff; --border: #e2e5ea;
  --text: #1c2733; --muted: #50555b;
  --primary: #e30613;
  --primary-dark: color-mix(in srgb, var(--primary) 80%, black);
  --danger: #dc2626;
  --radius: 10px;
  --font: system-ui, sans-serif;
  --topbar-height:62px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); line-height: 1.5; background: var(--bg); color: var(--text); overflow-x: clip ;}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); }

.btn { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff;touch-action: manipulation;font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: #eef1f5; }
.btn.danger { color: var(--danger); border-color: #f3c1c1; }
.btn.small { padding: 5px 9px; }

/* ===== Brand =====*/

.header-brand { display: flex; align-items: flex-end; justify-content: center; }
.header-brand img { width: 40px; height: auto;}
.header-brand h1 { font-size: 1.6rem; margin: 0; line-height: 1; font-weight: 400; }

/* ===== Auth ===== */
.auth-view { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: min(360px, 92vw); background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: 0 8px 30px rgba(20,40,80,.08); }
.auth-card-header {text-decoration: none; color: var(--text);}
.auth-card .muted { margin: 0 0 20px; }
.auth-card .header-brand { margin-bottom: 32px; }
.auth-card .header-brand img { width: 70px;}
.auth-card .header-brand h1 { font-size: 2.5rem; margin: 0 0 0 -3px; }
#login-form:has(#tab-login.active) > label:first-of-type {display: none;}
.form-error { background: #fdecec; color: #a11; border: 1px solid #f3c1c1; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }

/* ===== Layout ===== */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 15; }
.brand { font-weight: 700; color: var(--primary); font-size: 26px; margin-right: 78px;}
.topbar input { max-width: 320px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.layout { display: grid; min-height: calc(100vh - var(--topbar-height)); }

/* ===== Sidebar ===== */
.sidebar { background: var(--card); border-right: 1px solid var(--border); padding: 52px 10px 16px ;display: flex; gap: 18px; flex-direction: column; }
.sidebar nav {max-height: 203px; overflow: auto;}
.sidebar h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 24px 8px 6px; }
.sidebar h3:first-child { margin-top: 0px; }
.sidebar-taxonomies {background: var(--bg);padding-block: 12px;border-radius: 8px;}
.sidebar-taxonomies .gerer {margin-top:12px;}
.nav-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 8px; color: var(--text); }
.nav-item:hover { background: var(--border); }
.nav-item.active { background: #e8effd; color: var(--primary); font-weight: 600; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.filter-block label {display:flex;flex-wrap: wrap;gap: 0.2em;color: var(--text);}
.filter-block label input {width: 1em;}

/* ===== Liste ===== */
.main { padding: 16px 20px 60px; overflow-y: auto; }
#list-toolbar { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
#list-title { font-size: 17px; font-weight: 700; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item { display: flex; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; max-width: 1130px;}
.task-item:hover { border-color: #b9c6f2; }
.task-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px #dbe6fd; }
.task-left {display:flex; flex-direction: column; align-items: center;gap:4px;}
@media (min-width:600px) {.task-left {flex-direction: row; }}
.task-fav { background: none; border: none; cursor: pointer; font-size: 15px; color: #d99a00; opacity: .55; padding: 2px 4px; line-height: 1;display: flex;
  align-items: center; line-height: 1; justify-content: center; width: 32px; font-size: 24px; }
.task-item .task-fav { visibility: visible; }
.task-fav.fav { opacity: 1; }
.task-check { width: 20px; height: 20px; border: 2px solid #9aa6b5; border-radius: 50%; flex: none; margin-top: 2px; background: none; }
.task-check:hover { border-color: var(--primary); }
.task-item.done .task-check { background: #22a06b; border-color: #22a06b; }
.task-item.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-title { font-weight: 600;font-size: 17px; }
.task-main {flex: 1; min-width: 0;display: grid;gap: 8px;}
.task-meta { display: flex; flex-wrap: wrap; gap: 3px; }
.task-meta:empty {display:none}
.task-meta > div { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size:14px; color: var(--muted); align-items: center; }
.task-meta-textblocks {display:flex; flex-wrap:wrap; gap: 6px 8px; font-size: 14px;}
.task-meta-textblocks:empty {display:none}
.task-meta-textblocks > * + *:before {content:"•";padding-right: 8px;}
.followup {padding: 1px 10px; border-radius: 99px;background-color: var(--border);}
.followup-badge em { font-style: normal; color: #fff; }
.followup-color-select { margin-top: 6px; width: 100%; max-width: 220px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; background: #eef1f5; font-size: 12px; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; margin-right: -6px; border: 2px solid #fff; }
.avatars { display: inline-flex; padding-left: 6px; }
.due-late { color: var(--danger); font-weight: 600; }
.task-right {display: flex;flex-direction: column-reverse; justify-content: flex-end; gap: 8px; align-items: flex-end;}
@media (min-width:600px) {.task-right {flex-direction: row;align-items: center; }}
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* ===== Detail ===== */
.detail { background: var(--card); border-left: 1px solid var(--border); padding: 18px 22px 48px; overflow-y: auto; }
.detail { transition: opacity 200ms ease-out, transform 200ms ease-out, display 200ms allow-discrete; opacity: 1;  transform: translateY(0);}
.detail.hidden { opacity: 0; transform: translateX(40px); display: none;}
@starting-style {.detail:not(.hidden) {opacity: 0; transform: translateX(40px);}}
.detail h2 { margin: 20px 0; font-size: 22px; outline: none; cursor: text; }
.detail h2:focus { box-shadow: 0 0 0 2px var(--accent); border-radius: 4px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 4px;flex-wrap: wrap;}
.detail-head-buttons {width: 100%; display: flex; gap: 8px; flex-wrap: wrap; margin-block: 4px;}
.detail-head-buttons .btn {font-size: 14px;}
@media (max-width:739px) {.detail-head .btn {font-size: 16px;} .detail-head .btn-txt {display: none;}}
.field-grid { display: grid; gap: 10px 16px; margin: 14px 0; }
@media (min-width:560px) {.field-grid {grid-template-columns: 1fr 1fr;}}
.field-grid .full { grid-column: 1 / -1; }
.detail label { margin: 0; }
.section-title { display: flex; align-items: center;gap: 6px; flex-wrap: wrap; margin: 22px 0 8px;font-size: 0.9rem; font-weight: 700;text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* editor wysiwyg */
.editor-toolbar { border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: #f8f9fb; }
.editor-toolbar .ql-container.ql-snow {min-height: 140px;}
.editor-toolbar .ql-editor > * + * {margin-top: 0.7em !important;}
.editor-toolbar button { border: 0; background: none; border-radius: 6px; padding: 4px 9px; min-width: 30px; }
.editor-toolbar button:hover { background: #e6e9ee; }
.editor { min-height: 160px; border: 1px solid var(--border); border-radius: 0 0 8px 8px; padding: 12px; background: #fff; outline: none; }
.editor:focus { border-color: #9db6f5; }
.editor:empty:before { content: attr(data-placeholder); color: var(--muted); }
.editor p { margin: 0 0 8px; }
.editor ul, .editor ol { margin: 0 0 8px; padding-left: 22px; }

/* sous-taches */
.subtasks { list-style: none; padding: 0; margin: 8px 0; }
#st-add {display:flex;gap:8px;margin-top:6px}
@media (max-width:539px) {#st-add {flex-wrap: wrap;}}
#st-add input[type="date"] {width:44px;}
.st-add-assignee {width:52px}
.st-add-btn {color: var(--card);width: 48px;font-size: 18px;line-height: 1;font-weight: bold;}
.subtask { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; }
.subtask.dragging { opacity: .4; }
.subtask.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.subtask input[type=checkbox] { width: auto; }
.subtask .st-title { flex: 1; }
.subtask .st-title.done { text-decoration: line-through; color: var(--muted); }
.subtask input.st-edit { padding: 3px 6px; }
.subtask .st-due { width: 120px; font-size: 12px; }
.subtask .st-assignee { width: 130px; font-size: 12px; }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; }

/* commentaires */
.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.comment .c-body p { margin: 0 0 4px; }
.comment .c-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.comment .c-actions { font-size: 12px; }
.comment .c-actions button { border: 0; background: none; color: var(--muted); padding: 0 6px 0 0; }
.comment .c-actions button:hover { color: var(--danger); }
.comment-new textarea { min-height: 64px; resize: vertical; }

/* pieces jointes */
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.attach-item a { color: var(--primary); text-decoration: none; }
.attach-item .size { color: var(--muted); margin-left: auto; font-size: 12px; }

/* ===== Modales / toast ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,25,40,.45); display: grid; place-items: center; z-index: 50; }
.modal { width: min(520px, 94vw); max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: 14px; padding: 22px; box-shadow: 0 12px 40px rgba(10,25,60,.25); }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.chipbox { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbox.chipinput { align-items: center; }
.chip-input { border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px; font-size: 13px; min-width: 140px; background: var(--panel); color: var(--text);max-width: 24ch;width: fit-content; field-sizing: content; }
.chip-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chipbox.chipinput { position: relative; }
.chip-menu { position: absolute; z-index: 30; top: 100%; left: 0; min-width: 200px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 4px; max-height: 220px; overflow: auto; display: flex; flex-direction: column;max-height: 202px; }
.chip-opt { display: flex; align-items: center; gap: 6px; border: none; background: none; text-align: left; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.chip-opt:hover { background: var(--hover); }
.chip-create { color: var(--accent); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; background: #eef1f5; font-size: 0.8rem; text-transform: none; letter-spacing: 0; font-weight: 400;}
.chip .x { cursor: pointer; color: var(--muted); font-weight: 700; }
.chip .x:hover { color: var(--danger); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2733; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 99; }
#toast.error { background: var(--danger); }
.toast-action { margin-left: 10px; background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.toast-action:hover { background: rgba(255,255,255,.3); }

@media (max-width: 1239px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 10; }
  body.with-detail .layout { grid-template-columns: 1fr; }
  .detail { position: fixed; inset: 0; z-index: 20; }
}

@media (min-width: 1240px) {
  .topbar {position:fixed;top:0;left:0;width:100%;}
  .topbar .header-brand {margin-right: 60px;}
  .sidebar {padding: 92px 10px 16px; overflow-y: auto; max-height: 100vh; position: fixed; top: 0;
  left: 0;  z-index: 10;  max-width: 230px;  bottom: 0;}
  .sidebar nav {overflow: unset;}
  .nav-item {font-size: 13px;}
  .layout {grid-template-columns: 230px 1fr; overflow-y: auto;}
  .main {grid-column-start: 2; position: relative; width: 100%;margin-top: var(--topbar-height);}
  #detail-pane { overflow-y: auto; position: absolute; top: var(--topbar-height); right: 0; bottom:0; border-bottom: 1px solid var(--border);}
}

#d-save-html.dirty { background: var(--warning, #b45309); color: #fff; }
#d-save-html.dirty::after { content: " •"; }

/* ==== WYSIWYG etape 5b ==== */
.editor-toolbar button.dirty, button.dirty { }
#d-save-html.dirty { background: #b45309; color: #fff; }
#d-save-html.dirty::after { content: " •"; }
.editor:focus { outline: 2px solid var(--accent, #4f83d1); outline-offset: -1px; }
.editor blockquote { border-left: 3px solid var(--muted); margin: 6px 0; padding-left: 10px; opacity: .9; }
.editor code, .editor pre { background: rgba(255,255,255,.08); border-radius: 4px; padding: 1px 5px; font-family: monospace; }

.auth-link { display: block; margin-top: 14px; text-align: center; font-size: 13px; color: var(--accent, #3b82f6); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.form-ok { color: #16a34a; }

/* Onglets connexion / inscription */
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tabs .tab {
  flex: 1; padding: 8px 4px; border: 1px solid var(--border, #3a3f4b);
  background: transparent; color: var(--muted, #9aa3b2); border-radius: 8px;
  cursor: pointer; font-size: 13px;
}
.auth-tabs .tab.active { background: var(--primary, #4f8cff); color: #fff; border-color: var(--primary, #4f8cff); }

/* ===== Vue profil ===== */
.profile { max-width: 640px; }
.profile h2 { margin: 4px 0 8px; }
.profile h3 { margin: 22px 0 10px; font-size: 15px; }
.profile .muted { color: var(--muted, #777); font-size: 13px; }
.profile-opt { display: flex; align-items: center; gap: 8px; margin: 10px 0 12px; flex-wrap: wrap; }
.profile-opt select { padding: 4px 8px; }
.filter-line { display: flex; align-items: center; gap: 6px; font-weight: normal; }
#profile-form button { margin-top: 8px; }
#profile-msg { margin-top: 10px; }

/* ===== Theme sombre ===== */
body.theme-dark {
  --bg: #14181f; --card: #1e242d; --border: #333c49;
  --text: #e8ecf2; --muted: #8293a9;
  --primary: #3b82f6; --primary-dark: #2f6fdd; --danger: #ef4444;
}
body.theme-dark .task-item:hover { border-color: #4a5a78; }
body.theme-dark .task-item.active { box-shadow: 0 0 0 2px #274a80; }
body.theme-dark input, body.theme-dark select, body.theme-dark textarea { background: #171c24; border-color: #3a4452; color: var(--text); }
body.theme-dark .btn { background: #262e39; border-color: #3a4452; color: var(--text); }
body.theme-dark .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
body.theme-dark .btn.primary:hover { background: var(--primary-dark); }
body.theme-dark .btn.ghost:hover { background: #2a3340; color: var(--text); }
body.theme-dark .btn.danger { border-color: #5d2b2b; }
body.theme-dark .chip-menu { box-shadow: 0 8px 24px rgba(0,0,0,.5); }
body.theme-dark .chip-input { background: #171c24; border-color: #3a4452; color: var(--text); }
body.theme-dark .form-error { background: #3a1e1e; color: #f5b0b0; border-color: #5d2b2b; }
body.theme-dark .form-ok { background: #1d3327; color: #9be2b7; border-color: #2c5a41; }
body.theme-dark .avatar { border-color: var(--card); }
body.theme-dark .auth-card { box-shadow: 0 8px 30px rgba(0,0,0,.45); }
body.theme-dark .modal { box-shadow: 0 12px 40px rgba(0,0,0,.6); }
body.theme-dark .modal-backdrop { background: rgba(0,0,0,.6); }
body.theme-dark .task-check { border-color: #6b7889; }
body.theme-dark .due-late { color: #f87171; }
body.theme-dark .tag, body.theme-dark .chip { background: #2a3340; color: var(--text); }
body.theme-dark .filter-line input, body.theme-dark label input[type=checkbox], body.theme-dark label input[type=radio] { accent-color: var(--primary); }
body.theme-dark ::placeholder { color: #6b7889; }
body.theme-dark .theme-choice.active span { outline-color: var(--primary); }
body.theme-dark .ql-editor {color: var(--card);}

/* ===== Profil : identite, avatar, theme ===== */

.profile-avatar { width: 44px; height: 44px; font-size: 15px; margin: 0; border-width: 0; flex: none; }
.profile-avatar-wrapper {display: flex;flex-direction: column;gap: 6px;}
.identity-fields { display: flex; gap: 10px; flex: 1; }
.identity-fields label { flex: 1; margin-bottom: 0; }
.avatar-colors { display: none; }
.theme-choices { display: flex; gap: 10px; }
.theme-choice input { position: absolute; opacity: 0; width: 0; }
.theme-choice span { display: inline-block; padding: 7px 16px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--text); background: var(--card); }
.theme-choice input:checked + span { border-color: var(--primary); font-weight: 600; }
#profile-form :is(input, select) {width: auto;}

/* ==== Profil : avatar & theme ==== */
#p-avatar-preview {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 16px; margin: 20px; vertical-align: middle;
}
.p-color-label { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; }
#profile-pane input[type="color"] {
  width: 44px; height: 30px; padding: 2px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel); cursor: pointer;
}
.user-chip { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.user-chip:hover { background: var(--hover); }
.user-chip-name { font-size: 13px; color: var(--text-muted); }
.theme-row { display: flex; gap: 20px; margin: 8px 0 4px; }
.theme-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Zone de depot drag & drop des pieces jointes */
.dropzone {
  margin-top: 8px; padding: 18px 12px; text-align: center;
  border: 2px dashed var(--border); border-radius: 8px;
  color: var(--muted); font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover { border-color: var(--accent); color: var(--text); }
.dropzone.over {
  border-color: var(--accent); background: rgba(47, 128, 237, .08); color: var(--accent);
}


/* ===== Photo de profil ===== */
.p-photo-label { display:flex; flex-direction:column; gap:.3em; font-weight:600; font-size:.85em; }
.p-photo-label input[type=file] { font-weight:normal; }
#p-avatar-remove { align-self:flex-start; }
.avatar-img { width:100%; height:100%; border-radius:inherit; object-fit:cover; display:block; }
.profile-avatar .avatar-img { width:44px; height:44px; }
/* ===== Transitions ===== */
.task-enter { animation: taskIn .25s ease-out backwards; will-change: opacity; }
@keyframes taskIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Cross-fade entre vues (Chrome/Edge/Safari 18+; degrade gracieusement ailleurs) */
::view-transition-old(root) { animation: vtOut .18s ease both; }
::view-transition-new(root) { animation: vtIn .22s ease both; }
@keyframes vtOut { to { opacity: 0; } }
@keyframes vtIn  { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .task-enter { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ===== Administration des membres ===== */
.admin-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.admin-section h3 { margin-top: 0; }
.admin-add { display: grid; grid-template-columns: 1fr 1.4fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 16px; }
.admin-add input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.admin-user-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.admin-user-row:last-child { border-bottom: none; }
.admin-user-name { font-weight: 600; }
.admin-user-mail { font-size: 12px; }
.admin-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; vertical-align: middle; }
.admin-user-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) {
  .admin-add { grid-template-columns: 1fr; }
  .admin-user-actions { justify-content: flex-start; }
}
