/* ===========================================================================
   Serenite Projets — feuille de style
   Charte alignée sur serenite.tech : Inter, orange #F07E33, slate #111827.
   =========================================================================== */
:root {
    --brand: #F07E33;
    --brand-dark: #d9661d;
    --brand-50: #FFF7ED;
    --brand-100: #FFEDD5;
    --ink: #111827;
    --bg: #FDFDFD;
    --surface: #ffffff;
    --muted: #6a7282;
    --muted-2: #9ca3af;
    --line: #e5e7eb;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --ok: #0f9d6e;
    --ok-bg: #ecfdf5;
    --danger: #e11d48;
    --danger-bg: #fef2f2;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(17,24,39,.06);
    --shadow: 0 6px 24px rgba(17,24,39,.08);
    --shadow-lg: 0 20px 60px rgba(17,24,39,.18);
    --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.accent { color: var(--brand); }
.ok { color: var(--ok); }
.danger, .text-danger { color: var(--danger); }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* --- Marque --------------------------------------------------------------- */
.brand { font-size: 19px; font-weight: 900; letter-spacing: -.03em; color: var(--ink); }
.brand span { color: var(--brand); }

/* --- Mise en page applicative --------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.nav-toggle { display: none; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--ink); color: #e5e7eb;
    display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; padding: 4px 8px 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
    color: #cbd5e1; font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s;
}
.nav-link .ico { font-size: 15px; opacity: .9; width: 18px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.user-chip:hover { background: rgba(255,255,255,.06); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 14px; color: #fff; }
.user-meta small { font-size: 12px; color: var(--muted-2); }
.logout { display: block; margin-top: 6px; padding: 8px; font-size: 13px; color: var(--muted-2); }
.logout:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 14px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.burger { font-size: 22px; cursor: pointer; }
.topbar-title { font-weight: 700; }
.content { padding: 30px 34px 60px; max-width: 1240px; width: 100%; }

/* --- En-tête de page ------------------------------------------------------ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a:hover { color: var(--brand); }

/* --- Boutons -------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    transition: transform .04s, background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(240,126,51,.3); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--slate-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.link { background: none; border: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer; font-weight: 600; }
.link:hover { text-decoration: underline; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 600; padding: 0; font-size: 15px; }
.inline { display: inline; }

/* --- Formulaires ---------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #374151; }
.field input, .field select, .field textarea {
    font-family: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; width: 100%; transition: border .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(240,126,51,.15);
}
.field input:disabled { background: var(--slate-100); color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-color input[type=color] { height: 44px; padding: 4px; cursor: pointer; }
input[type=range] { accent-color: var(--brand); }

/* --- Cartes & blocs ------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.card-narrow { max-width: 520px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.empty-lg { padding: 70px 30px; }
.empty.sm { padding: 22px; }

/* --- Statistiques --------------------------------------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 30px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat-num { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.stat-num.accent { color: var(--brand); } .stat-num.ok { color: var(--ok); } .stat-num.danger { color: var(--danger); }
.stat-label { font-size: 13px; color: var(--muted); }

/* --- Tableau de bord ------------------------------------------------------ */
.dash-cols { display: grid; grid-template-columns: 1fr 320px; gap: 26px; align-items: start; }
.task-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.task-feed a { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.task-feed a:hover { background: var(--slate-50); }
.task-feed-body { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.task-feed-body small { color: var(--muted); font-size: 12px; }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.due-late { color: var(--danger); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* --- Grille de projets ---------------------------------------------------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.project-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; display: flex; }
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.project-bar { width: 5px; flex-shrink: 0; }
.project-card-body { padding: 18px; flex: 1; min-width: 0; }
.project-card-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.project-card-head h3 { font-size: 16px; }
.project-card-foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 10px; }

/* --- Barres de progression ------------------------------------------------ */
.progress { background: var(--slate-100); border-radius: 99px; height: 8px; overflow: hidden; margin-top: 12px; position: relative; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.progress-xs { height: 5px; margin-top: 8px; }
.progress-lg { height: 12px; margin: 6px 0 24px; }
.progress-lg .progress-label { position: absolute; right: 8px; top: -22px; font-size: 12px; font-weight: 700; color: var(--muted); }

/* --- Badges --------------------------------------------------------------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-on_hold { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--brand-100); color: var(--brand-dark); }
.badge-archived { background: var(--slate-100); color: var(--muted); }
.badge-invited { background: var(--warn-bg); color: var(--warn); }
.badge-disabled { background: var(--slate-100); color: var(--muted); }
.badge-role-admin { background: var(--ink); color: #fff; }
.badge-role-user { background: var(--slate-100); color: #374151; }

/* --- Avatars -------------------------------------------------------------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-100); color: var(--brand-dark); font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }

/* --- Projet : disposition ------------------------------------------------- */
.project-head h1 { display: flex; align-items: center; gap: 10px; }
.project-desc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: #374151; margin: 0 0 18px; }
.project-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }

/* --- Kanban --------------------------------------------------------------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; min-width: 0; }
.kcol { background: var(--slate-50); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; }
.kcol-title { font-weight: 700; font-size: 14px; }
.kcol-count { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 99px; }
.kcol-body { display: flex; flex-direction: column; gap: 10px; min-height: 40px; flex: 1; padding: 2px; }
.kcol-body.drag-over { outline: 2px dashed var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); background: var(--brand-50); }
.kcol-add { margin-top: 10px; background: none; border: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px; border-radius: var(--radius-sm); text-align: left; }
.kcol-add:hover { background: var(--surface); color: var(--brand); }

.kard { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .12s, transform .12s; }
.kard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kard.dragging { opacity: .5; }
.kard.prio-high { border-left-color: var(--danger); }
.kard.prio-normal { border-left-color: var(--brand); }
.kard.prio-low { border-left-color: var(--muted-2); }
.kard-flag { font-size: 10.5px; font-weight: 700; color: var(--danger); text-transform: uppercase; letter-spacing: .04em; }
.kard-title { margin: 4px 0 0; font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.kard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.kard-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11.5px; color: var(--muted); background: var(--slate-100); padding: 2px 8px; border-radius: 99px; }
.chip-late { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

/* --- Rail projet ---------------------------------------------------------- */
.project-rail { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.panel-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; }
.member-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.member-list li { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.member-list small { display: block; color: var(--muted); font-size: 12px; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.activity li { display: flex; gap: 10px; font-size: 13px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex-shrink: 0; }
.activity small { display: block; color: var(--muted-2); font-size: 11.5px; margin-top: 2px; }

/* --- Tableaux ------------------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--slate-50); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 12px; align-items: center; }

/* --- Modales (dialog) ----------------------------------------------------- */
.modal { border: none; border-radius: 18px; padding: 0; width: min(560px, 94vw); box-shadow: var(--shadow-lg); color: var(--ink); }
.modal.modal-lg { width: min(880px, 95vw); }
.modal::backdrop { background: rgba(17,24,39,.5); backdrop-filter: blur(2px); }
.modal .form, .modal > .member-manage, .modal > .add-member { padding: 0 24px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-x { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-x:hover { color: var(--ink); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.modal-foot-split { justify-content: space-between; align-items: center; }
.modal-foot-split > div { display: flex; gap: 10px; }

/* --- Fiche tâche (modale large) ------------------------------------------- */
.task-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.task-form { padding: 22px 24px !important; border-right: 1px solid var(--line); }
.task-side { padding: 22px 24px; background: var(--slate-50); border-bottom-right-radius: 18px; max-height: 78vh; overflow-y: auto; }
.task-delete { margin-bottom: 18px; }
.side-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 10px; }
.attach-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attach-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.attach-link { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-link:hover { color: var(--brand); }
.attach-link small { color: var(--muted); }
.attach-form { display: flex; gap: 8px; align-items: center; }
.attach-form input[type=file] { font-size: 12px; flex: 1; min-width: 0; }
.comments { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.comment { display: flex; gap: 10px; }
.comment-body { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; flex: 1; }
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-head small { color: var(--muted-2); font-size: 12px; }
.comment-head .inline { margin-left: auto; }
.comment-body p { margin: 4px 0 0; font-size: 14px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { font-family: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
.member-manage { list-style: none; margin: 0; padding: 0 24px; display: flex; flex-direction: column; gap: 8px; }
.member-manage li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.member-manage small { color: var(--muted); }
.add-member { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 18px !important; }

/* --- Messages flash ------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

/* --- Authentification ----------------------------------------------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background:
    radial-gradient(900px 500px at 100% 0%, var(--brand-50), transparent),
    radial-gradient(700px 500px at 0% 100%, #f0f4ff, transparent), var(--bg); padding: 20px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 34px 32px; box-shadow: var(--shadow); }
.brand-auth { display: block; text-align: center; margin-bottom: 22px; font-size: 22px; }
.auth-title { font-size: 23px; text-align: center; }
.auth-sub { color: var(--muted); text-align: center; margin: 6px 0 24px; font-size: 14px; }
.auth-links { text-align: center; margin-top: 18px; font-size: 14px; }
.auth-links a { color: var(--brand); font-weight: 600; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.auth-foot a { color: var(--brand); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .dash-cols, .project-layout { grid-template-columns: 1fr; }
    .task-detail { grid-template-columns: 1fr; }
    .task-form { border-right: none; border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
    .app { flex-direction: column; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s; height: 100vh; }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .topbar { display: flex; }
    .content { padding: 20px 16px 50px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .kanban { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    h1 { font-size: 22px; }
}
