@import url('/vendor/fonts/manrope/index.css');

/* Couleurs relevées sur le logo Mad'Trame : bleu « Mad' », rouge « Trame », jaune du remplaçant, gris des cases */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #10284a;
  --ink-2: #3d5170;
  --muted: #6b7a90;
  --line: #e1e6ed;
  --line-strong: #c9d1dc;
  --cell: #d6dde6;
  --blue: #0a6fc8;
  --blue-hover: #085ba5;
  --blue-soft: #e5f0fa;
  --red: #b0151e;
  --red-soft: #fbe9ea;
  --yellow: #f4cc14;
  --yellow-soft: #fdf6d6;
  --good: #1f7a4f;
  --warn: #8a5a00;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Manrope Variable', 'Manrope', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.4rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* Boutons et champs */
.btn { font: inherit; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); padding: 8px 14px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
input, select { font: inherit; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 10px; background: #fff; color: var(--ink); }
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(400px, 100%); display: grid; gap: 14px; }
.login-logo { width: 100%; height: auto; }
.login-card .muted { margin: -8px 0 4px; text-align: center; }

/* Bandeau */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 10px clamp(16px, 2.2vw, 36px);
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.25rem; letter-spacing: -.01em; }
.brand .mad { color: var(--blue); font-weight: 800; }
.brand .trame { color: var(--red); font-weight: 800; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs a { text-decoration: none; color: var(--ink-2); font-weight: 600; padding: 8px 12px; border-radius: var(--radius-sm); }
.tabs a:hover { background: var(--surface-2); }
.tabs a[aria-current="page"] { background: var(--blue-soft); color: var(--blue); }
.who { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .9rem; }

/* Contenu : occupe la largeur de l’écran (jusqu’à 1920 px). Les cartes « half » se mettent côte à côte sur grand écran */
.view { --gutter: clamp(16px, 2.2vw, 36px); padding: 20px var(--gutter); max-width: 1920px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(0, 1fr); grid-auto-flow: row dense; gap: 16px; }
@media (min-width: 1200px) {
  .view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view > * { grid-column: 1 / -1; }
  .view > .half { grid-column: auto; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.goto { display: flex; gap: 6px; align-items: center; }
.goto input { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.goto input[type="search"] { width: 15.5rem; max-width: 100%; }
@media (max-width: 640px) { .goto { width: 100%; } .goto input[type="search"] { flex: 1; width: auto; } }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.yellow { background: var(--yellow-soft); color: var(--warn); }
.notice { background: var(--yellow-soft); border: 1px solid #efdc8a; color: #5c4400; border-radius: var(--radius-sm); padding: 10px 14px; font-size: .9rem; }

/* Planning : une ligne par mission et site, une frise horaire de 8 h à 19 h 30 */
.day { padding: 0; overflow: hidden; }
.day-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.grid { display: grid; grid-template-columns: 190px 1fr; }
.scale, .lane { position: relative; min-height: 34px; border-bottom: 1px solid var(--line); }
.scale { min-height: 24px; font-size: .75rem; color: var(--muted); }
.scale span { position: absolute; top: 4px; transform: translateX(-50%); }
.row-label { padding: 7px 12px 7px 18px; border-bottom: 1px solid var(--line); font-size: .85rem; display: flex; gap: 6px; align-items: center; }
.row-label b { font-weight: 700; }
.row-label .site { color: var(--muted); }
.lane { background-image: repeating-linear-gradient(90deg, transparent 0 calc(100% / 23 - 1px), var(--line) calc(100% / 23 - 1px) calc(100% / 23)); }
.block { position: absolute; top: 4px; bottom: 4px; border-radius: 6px; padding: 0 8px; font-size: .8rem; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.block small { font-weight: 500; opacity: .9; }
.block .desc { font-weight: 500; font-style: italic; opacity: .95; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-right: .2em; }
.block .desc::before { content: "· "; font-style: normal; }
.block.unavailable { background: repeating-linear-gradient(135deg, var(--red-soft) 0 8px, #fff 8px 16px) !important; color: var(--red); border: 1px dashed var(--red); }
.block.pending { outline: 2px solid var(--yellow); outline-offset: -2px; }
/* Créneau à compléter : la case jaune du logo, en attente de quelqu'un */
.block.open { background: var(--yellow-soft); color: #5c4400; border: 2px dashed var(--yellow); }
/* Remplacement proposé par l'application */
.block.replacement { box-shadow: inset 0 0 0 2px var(--yellow); }
.block.pending-cause::after { content: ''; position: absolute; right: 4px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.block.locked { box-shadow: inset 0 0 0 2px var(--ink); }
.day-notes { list-style: none; margin: 0; padding: 10px 18px 14px; display: grid; gap: 6px; font-size: .85rem; border-top: 1px solid var(--line); }
.day-notes li { padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.day-notes .lvl-open { background: var(--yellow-soft); }
.day-notes .lvl-erreur { background: var(--red-soft); color: var(--red); }
.day-notes .lvl-alerte { background: #fff4e0; color: var(--warn); }
.open-notes { border-top: 1px solid var(--line); }
.open-notes > summary { cursor: pointer; padding: 10px 18px; display: flex; align-items: center; gap: 8px; list-style: none; font-size: .85rem; }
.open-notes > summary::-webkit-details-marker { display: none; }
.open-notes > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.open-notes[open] > summary::before { transform: rotate(90deg); }
.open-notes > summary:hover .muted { color: var(--blue); }
.open-notes .day-notes { border-top: 0; padding-top: 0; }
.stat b.warn { color: var(--warn); }
.stat b.bad { color: var(--red); }
/* Saisie des variations */
.var-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.var-form .wide { grid-column: 1 / -1; }
.var-form input, .var-form select { width: 100%; }
.var-form .hint { margin: 0; font-size: .85rem; }
.actions { white-space: nowrap; text-align: right; }
.actions small { white-space: normal; }
.recalc { display: grid; gap: 10px; border-color: var(--yellow); }
.recalc p { margin: 0; }
.changes { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; font-size: .85rem; }
.changes li { padding: 4px 8px; border-radius: 6px; }
.changes .del { background: var(--red-soft); }
.changes .add { background: #e7f5ee; }
.notice.revision { background: var(--red-soft); border-color: #f0b8bb; color: var(--red); }
/* Modification d'un créneau */
.block.editable { cursor: pointer; }
.block.editable:hover, .block.editable:focus-visible { filter: brightness(1.08); outline: 2px solid var(--ink); outline-offset: 1px; }
.block.pending { box-shadow: inset 0 0 0 3px var(--yellow); }
.edit-hint { margin: -4px 0 0; font-size: .85rem; }
.edit-dialog { border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(640px, calc(100vw - 32px)); color: var(--ink); }
.edit-dialog:focus { outline: none; }
.edit-dialog::backdrop { background: rgb(16 40 74 / .35); }
.edit-dialog .notice { margin: 0; }
.candidates { list-style: none; margin: -4px 0 0; padding: 0; font-size: .85rem; }
.btn.danger { color: var(--red); }
.day-head .btn { padding: 4px 10px; font-size: .85rem; }
.prepare { display: grid; gap: 10px; border-color: var(--blue); }
.prepare p { margin: 0; }
.unav-list { padding: 10px 18px; font-size: .85rem; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.closed { padding: 16px 18px; color: var(--muted); }

/* Tableaux */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* Compteur de congés */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat b { font-size: 1.5rem; font-weight: 800; }

@media (max-width: 760px) {
  .view { padding: 12px; }
  .grid { grid-template-columns: 110px 1fr; }
  .row-label { padding-left: 10px; flex-direction: column; align-items: flex-start; gap: 0; }
  .who span { display: none; }
}


/* Gestion de l'équipe */
.card-inset { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; margin: 12px 0; }
.var-form label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; align-self: end; }
.var-form .check input { width: auto; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.inline input[type=number] { width: 90px; }
.toolbar.wrap { flex-wrap: wrap; }
.pwd { font-size: 1.05rem; font-weight: 700; background: var(--surface); padding: 2px 8px; border-radius: 6px; user-select: all; }
.proposal { border-left: 4px solid var(--warn); }
.history details, .tpl-new { margin-top: 12px; }
.history summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.tpl-new > summary { display: inline-block; list-style: none; cursor: pointer; }
.tpl-new > summary::-webkit-details-marker { display: none; }
.tpl-new[open] > summary { margin-bottom: 8px; }
.tpl-variant { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px 12px; margin: 12px 0; min-width: 0; }
.tpl-variant legend { font-weight: 700; padding: 0 6px; }
.tpl-day { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start; }
.tpl-day:first-of-type { border-top: 0; }
.tpl-day > b { padding-top: 7px; }
.tpl-slot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.tpl-slot input[type=time] { width: 110px; }
.tpl-slot select { max-width: 190px; }
.tpl-day .btn.ghost { padding: 4px 10px; font-size: .85rem; }
tr.muted td { color: var(--ink-3, #888); }
@media (max-width: 640px) {
  .tpl-day { grid-template-columns: minmax(0, 1fr); }
  .tpl-slot select { max-width: none; flex: 1 1 140px; }
}
.nowrap { white-space: nowrap; }
table.needs th.need-cell, table.needs td.need-cell { text-align: center; width: 9%; }
.need-btn { font: inherit; font-weight: 700; min-width: 40px; padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--blue-soft);
  background: var(--blue-soft); color: var(--blue); cursor: pointer; }
.need-btn:hover { border-color: var(--blue); }
.need-btn.empty { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); font-weight: 600; }
.need-btn.empty:hover { color: var(--blue); border-color: var(--blue); }
.closure-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.closure { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 999px; font-size: .85rem;
  background: var(--red-soft); color: var(--red); }
.closure.fermeture { background: var(--surface-2); color: var(--ink-2); }
.closure.past { opacity: .55; }
.closure .btn { padding: 2px 8px; font-size: .8rem; color: inherit; }
.check-inline { font-weight: 500; font-size: .9rem; }
.check-inline input { width: auto; }
.pwd-form { display: grid; gap: 12px; }
.pwd-form .hint { margin: 0; font-size: .85rem; }
.pwd-title { font-size: 1.2rem; margin: 0; text-align: center; }
.pwd-intro { text-align: center; margin: 0 !important; }
.card .notice[data-ok] { margin: 10px 0 0; background: var(--blue-soft); border-color: #b9d6f0; color: var(--blue); }
@media print {
  .topbar, .toolbar .btn, .toolbar select, .toolbar .goto { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; border-color: #bbb; }
  .block { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
