/* Planning des projets et des pôles */
:root {
  /* Valeurs par défaut du thème pastel : remplacées par celles de la page Apparence (src/Theme.php). */
  --bg: #f8f5f0;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #2b3440;
  --muted: #6b7380;
  --border: #e4ddd3;
  --primary: #a8c8e8;
  --primary-ink: #1f2933;
  --primary-strong: #3f6f9f;
  --primary-soft: #dde9f5;
  --topbar: #cdb4db;
  --topbar-ink: #1f2933;
  --we: #f1ede7;
  --hol: #fbe1e1;
  --over: #a23b3b;
  --over-bg: #f6d3d3;
  --over-line: #eaa9a9;
  --under: #8a5a12;
  --under-bg: #fbe6c8;
  --under-line: #f2c58a;
  --ok: #2f6b45;
  --ok-bg: #d8efdf;
  --ok-line: #a9d8b7;
  --bg-image-opacity: .12;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 15px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; min-height: 100vh; }
/* Illustration de planning en fond, transparente (opacité réglable dans Apparence) */
body.has-bg-image::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url("../img/planning-fond.svg") no-repeat right -40px bottom -40px / min(760px, 90vw) auto;
  opacity: var(--bg-image-opacity);
}
.card, .month, .legend-item, .stat, .member-plan { box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent); }
a { color: var(--primary-strong); }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }

/* ------------------------------------------------------------ en-tête */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .6rem 1rem; background: var(--topbar); color: var(--topbar-ink);
  box-shadow: 0 1px 0 var(--border);
}
.brand { color: inherit; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; }
.mainnav a { color: inherit; opacity: .85; text-decoration: none; padding: .3rem .65rem; border-radius: 6px; }
.mainnav a:hover { background: color-mix(in srgb, currentColor 10%, transparent); opacity: 1; }
.mainnav a.active { background: color-mix(in srgb, currentColor 16%, transparent); opacity: 1; font-weight: 600; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.userbox form { margin: 0; }
.linklike { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.container { max-width: 1680px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }

/* ------------------------------------------------------------ composants */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; }
.toolbar form { margin: 0; }
.yearnav { display: flex; align-items: center; gap: .35rem; }
.yearnav strong { min-width: 3.2rem; text-align: center; font-size: 1.1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }

.btn {
  display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .9rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-strong); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--over-bg); border-color: var(--over-line); color: var(--over); }
.btn-danger:hover { border-color: var(--over); }
.btn.small { padding: .2rem .5rem; font-size: .85rem; }

input, select, textarea {
  font: inherit; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); max-width: 100%;
}
input[type=color] { padding: 0; width: 3rem; height: 2.2rem; }
input[type=checkbox] { width: 1rem; height: 1rem; }
input.days { width: 6rem; text-align: right; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .bar:focus-visible { outline: 2px solid var(--primary-strong); outline-offset: 1px; }

.form { display: flex; flex-direction: column; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: .45rem; }
.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.row .grow { flex: 1 1 260px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem; margin: 0; }
legend { font-size: .9rem; color: var(--muted); padding: 0 .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.actions { display: flex; align-items: center; gap: .6rem; }
.spacer { flex: 1; }
form.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.budget-grid { display: flex; flex-wrap: wrap; gap: .8rem; }
.danger-zone { display: flex; gap: .8rem; align-items: center; margin: 1rem 0; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .8rem; border: 1px solid; }
.flash-success { background: var(--ok-bg); border-color: var(--ok-line); }
.flash-error { background: var(--over-bg); border-color: var(--over-line); color: var(--over); }
.flash-warning { background: var(--under-bg); border-color: var(--under-line); }

.alert { border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: .8rem; border: 1px solid; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alert-over { background: var(--over-bg); border-color: var(--over-line); }
.alert-over strong:first-child { color: var(--over); }
.alert-under { background: var(--under-bg); border-color: var(--under-line); }
.alert-under summary { cursor: pointer; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-depasse { background: var(--over-bg); color: var(--over); }
.badge-non_atteint { background: var(--under-bg); color: var(--under); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.chip { display: inline-block; padding: .05rem .45rem; margin: .1rem; border-radius: 4px; font-size: .8rem; border: 1px solid var(--border); white-space: nowrap; }
.chip.st-depasse, .st-depasse { color: var(--over); }
.chip.st-depasse { border-color: var(--over-line); background: var(--over-bg); }
.chip.st-non_atteint, .st-non_atteint { color: var(--under); }
.chip.st-non_atteint { border-color: var(--under-line); background: var(--under-bg); }
.st-ok { color: var(--ok); }
.txt-over { color: var(--over); font-weight: 600; }

.swatch { display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; background: var(--c); margin-right: .4rem; vertical-align: -1px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot th { color: var(--text); }
.table.compact td, .table.compact th { padding: .3rem .5rem; }
.row-depasse { background: color-mix(in srgb, var(--over-bg) 35%, var(--surface)); }
.row-depasse td:first-child { box-shadow: inset 3px 0 0 var(--over); }
.row-non_atteint td:first-child { box-shadow: inset 3px 0 0 var(--under); }
tr.inactive { opacity: .6; }
.actions-cell { white-space: nowrap; }
.subtable { margin-top: .3rem; font-size: .85rem; border-collapse: collapse; }
.subtable td { padding: .15rem .4rem; }
.poles-detail summary { cursor: pointer; }

.progress { width: 120px; height: 8px; border-radius: 4px; background: var(--we); overflow: hidden; margin-top: .4rem; }
.progress span { display: block; height: 100%; background: var(--ok); }
.progress-depasse span { background: var(--over); }
.progress-non_atteint span { background: var(--under); }

.stats { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; color: var(--muted); font-size: .85rem; min-width: 130px; }
.stat span { display: block; font-size: 1.4rem; font-weight: 700; color: var(--text); }
.stat.st-depasse span { color: var(--over); }
.stat.st-non_atteint span { color: var(--under); }
.stat.st-ok span { color: var(--ok); }

/* ------------------------------------------------------------ légende */
.legend { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .6rem; }
.legend-group { display: flex; flex-wrap: wrap; gap: .3rem .5rem; }
.legend-item { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .55rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .85rem; color: var(--text); text-decoration: none; }
.legend-item .swatch { margin-right: .1rem; }
.legend-item.status-depasse { border-color: var(--over-line); background: var(--over-bg); }
.legend-item.status-non_atteint small { color: var(--under); }
.ico-over { color: var(--over); }
.legend-keys { font-size: .8rem; color: var(--muted); gap: .9rem; }
.key { display: inline-block; width: 1.1rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; border: 1px solid var(--border); }
.key-we { background: var(--we); }
.key-hol { background: var(--hol); }
.key-over { background: var(--primary) repeating-linear-gradient(45deg, transparent 0 3px, var(--over) 3px 5px); }
.key-under { background: var(--primary); box-shadow: inset 0 -3px 0 var(--under); }
.hint { font-size: .85rem; color: var(--muted); margin: .2rem 0 .8rem; }

/* ------------------------------------------------------------ calendrier */
.calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .6rem .7rem; }
.month h2 { font-size: .95rem; margin: 0 0 .4rem; text-transform: capitalize; }
.month-out { background: var(--surface-2); }
.month-out h2 { color: var(--muted); }
.month-out h2::after { content: " (hors année)"; font-weight: 400; font-size: .75rem; }
.mgrid { display: grid; grid-template-columns: 1.6rem repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.mgrid > div { background: var(--surface); }
.dh { text-align: center; font-size: .72rem; color: var(--muted); padding: .1rem 0; font-weight: 600; }
.dh.we { background: var(--we) !important; }
.wk { font-size: .66rem; color: var(--muted); text-align: center; padding-top: .15rem; background: var(--surface-2) !important; }
.day { min-height: 2.4rem; padding-bottom: 2px; position: relative; user-select: none; }
.day.empty { background: var(--surface-2) !important; }
.day.we { background: var(--we) !important; }
.day.hol { background: var(--hol) !important; }
.day .num { display: block; font-size: .72rem; padding: 0 .2rem; color: var(--muted); line-height: 1.3; }
.day.hol .num { color: var(--over); font-weight: 700; }
.day.today .num { background: var(--primary); color: var(--primary-ink); border-radius: 3px; display: inline-block; margin: 1px; }
.editable .day[data-date] { cursor: cell; }
.day.sel { background: var(--primary-soft) !important; }
.day.drop { box-shadow: inset 0 0 0 2px var(--primary-strong); }

.bar, .bar-empty { height: 13px; margin-top: 2px; }
.bar {
  position: relative; background: var(--c); margin-left: -1px; margin-right: -1px;
  font-size: 9px; line-height: 13px; color: var(--ci, var(--text)); white-space: nowrap; overflow: visible;
}
.bar.is-start { margin-left: 2px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.bar.is-end { margin-right: 2px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.bar.off { opacity: .4; }
.editable .bar { cursor: grab; }
.bar.dragging { opacity: .3; }
.bar .lbl {
  /* le libellé couvre les jours du bloc restant sur la ligne de semaine (--span) puis s'abrège */
  position: absolute; z-index: 2; left: 0; top: 0; height: 13px;
  width: calc(var(--span, 1) * 100% + (var(--span, 1) - 1) * 1px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 3px; font-weight: 600; letter-spacing: .02em;
}
.bar .lbl b { font-weight: 800; margin-right: 2px; }
.bar .lbl i { font-style: normal; opacity: .8; }
.bar .sg-over { background: var(--surface); color: var(--over); border-radius: 2px; padding: 0 2px; text-shadow: none; }
.bar.status-depasse {
  background-image: repeating-linear-gradient(45deg, transparent 0 4px, color-mix(in srgb, var(--over) 65%, transparent) 4px 6px);
  box-shadow: inset 0 -2px 0 var(--over);
}
.bar.status-non_atteint { box-shadow: inset 0 -3px 0 var(--under); }

/* ------------------------------------------------------------ code projet */
.code {
  display: inline-block; font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; font-size: .85em;
  padding: 0 .35rem; border-radius: 4px; background: var(--primary-soft); color: var(--text); white-space: nowrap; letter-spacing: .02em;
}
h1 .code { font-size: .8em; vertical-align: 2px; }
.code-row { align-items: flex-end; }
.code-sep { padding-bottom: .5rem; color: var(--muted); font-weight: 700; }
.code-input { width: 5.5rem; text-transform: uppercase; font-family: ui-monospace, "DejaVu Sans Mono", Consolas, monospace; }
.code-preview { font-size: 1.05rem; padding: .35rem .6rem; margin-left: .5rem; }

/* ------------------------------------------------------------ boîte de dialogue */
.dialog { border: 0; border-radius: 12px; padding: 1.2rem 1.4rem; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(15, 30, 50, .45); }
.dialog h2 { margin: 0; }
.impact ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .9rem; }
.impact p { margin: 0; }
.split { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .8rem; }
.split summary { cursor: pointer; font-weight: 600; color: var(--primary-strong); }
.split-body { display: flex; flex-direction: column; gap: .7rem; margin-top: .7rem; }
.split-body p { margin: 0; }
.split-field { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.split-inputs { display: flex; align-items: center; gap: .6rem; }
.split-inputs input[type=range] { flex: 1; accent-color: var(--primary-strong); }
.split-inputs input[type=number] { width: 5rem; }
.split-timeline { display: flex; gap: 2px; }
.tl-day {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px 0; border: 0; border-radius: 3px; background: var(--we); color: var(--text); font: inherit; cursor: pointer;
  position: relative;
}
.tl-day small { font-size: 9px; line-height: 1.1; color: inherit; opacity: .75; min-height: 10px; }
.tl-day span { font-size: 11px; font-weight: 600; line-height: 1.2; }
.tl-day.off { background: repeating-linear-gradient(45deg, var(--surface-2) 0 3px, var(--we) 3px 5px); color: var(--muted); cursor: default; }
.tl-day.a { background: var(--primary); color: var(--primary-ink); }
.tl-day.a.half { background: linear-gradient(90deg, var(--primary) 50%, var(--primary-soft) 50%); }
.tl-day.b { background: var(--under-line); color: var(--text); }
.tl-day.cut::after {
  content: ""; position: absolute; right: -2px; top: -4px; bottom: -4px; width: 2px; background: var(--over); border-radius: 1px;
}
.split-timeline.dense .tl-day span { font-size: 9px; }
.split-parts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.split-part { display: flex; flex-direction: column; gap: .1rem; padding: .4rem .6rem; border-radius: 6px; background: var(--surface); font-size: .85rem; border-left: 4px solid; }
.split-part.part-a { border-color: var(--primary); }
.split-part.part-b { border-color: var(--under-line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 480px) { .split-parts { grid-template-columns: 1fr; } }

.toast {
  position: fixed; right: 16px; bottom: 16px; max-width: min(460px, calc(100vw - 32px)); z-index: 50;
  background: var(--topbar); color: var(--topbar-ink); padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: .9rem; cursor: pointer;
}
.toast div + div { margin-top: .3rem; padding-top: .3rem; border-top: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
.toast-error { background: var(--over-bg); color: var(--over); }

@media (max-width: 640px) {
  .container { padding: .75rem 16px; }
  .userbox { margin-left: 0; }
  .calendar { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ membres */
.initials {
  display: inline-block; min-width: 1.9rem; text-align: center; padding: 0 .3rem; border-radius: 999px;
  background: var(--primary-soft); color: var(--text); font-size: .78rem; font-weight: 700; letter-spacing: .03em;
}
h2 .initials { font-size: .8rem; vertical-align: 2px; }
.member-plan { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: .8rem; }
.member-plan h2 { font-size: 1rem; margin-bottom: .4rem; }
#dlg-members-mode { margin-bottom: .4rem; }

/* ------------------------------------------------------------ apparence */
.presets { display: flex; flex-wrap: wrap; gap: .6rem; }
.preset {
  display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.preset:hover { border-color: var(--primary-strong); }
.preset-swatches { display: inline-flex; }
.preset-swatches i { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--surface); margin-left: -.3rem; }
.preset-swatches i:first-child { margin-left: 0; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem 1rem; }
.form label.color-field { flex-direction: row; align-items: center; gap: .6rem; }
.color-field span { display: flex; flex-direction: column; }
.color-field input[type=color] { width: 3rem; height: 2.4rem; border-radius: 8px; cursor: pointer; }
.bg-preview { display: block; max-width: 320px; width: 100%; margin-top: .6rem; opacity: var(--bg-image-opacity); border: 1px dashed var(--border); border-radius: var(--radius); }
.theme-sample { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .8rem; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); }
