/* ============================================================
   PLANNING PRINT DÉDIÉ (Nouveau système V4 indépendant écran)
   Unité : millimètres (mm) + points (pt). A4 PAYSAGE.
   ============================================================ */

@page {
  size: A4 landscape;
  margin: 0;
}

html, body {
  background: #fff !important;
  margin: 0 !important;
  padding: 0 !important;
  color: #0f172a;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

/* ---------- Buffers / Masquage écran (uniquement pendant impression) ---------- */
#npBuffer {
  display: none;
  width: 0; height: 0; overflow: hidden;
}
body.np-printing {
  background: #fff !important;
  height: auto;
  overflow: visible;
}
body.np-printing > :not(#npBuffer) {
  display: none !important;
}
body.np-printing #npBuffer {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

/* ---------- Page semaine (format A4 paysage réel : 297×210mm) ---------- */
.np-page {
  width: 297mm;
  height: 210mm;
  padding: 7mm 9mm 5mm 9mm;
  box-sizing: border-box;
  page-break-after: always;
  break-after: page;
  display: flex;
  flex-direction: column;
  gap: 3mm;
  overflow: hidden;
  background: #fff;
}
.np-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

/* ============================ HEADER ============================ */
.np-header {
  display: grid;
  grid-template-columns: 72mm 1fr 56mm;
  align-items: center;
  gap: 4mm;
  padding-bottom: 2mm;
  border-bottom: 2px solid #0b2547;
}
.np-h-left {
  display: flex;
  align-items: center;
  gap: 3mm;
  min-width: 0;
}
.np-logo {
  width: 16mm;
  height: 16mm;
  flex-shrink: 0;
  border-radius: 50%;
  background: #1e5aa8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 9pt;
  line-height: 1;
  text-align: center;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.np-logo img {
  width: 100%; height: 100%; object-fit: contain;
  border-radius: 50%;
}
.np-h-brand {
  display: flex;
  flex-direction: column;
  gap: 0.4mm;
  min-width: 0;
}
.np-h-brand b {
  font-size: 12pt;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
  letter-spacing: .01em;
}
.np-h-brand span {
  font-size: 10pt;
  color: #334155;
  font-weight: 600;
}
.np-h-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8mm;
}
.np-h-week {
  font-size: 22pt;
  font-weight: 900;
  color: #0b2547;
  line-height: 1;
  letter-spacing: .02em;
}
.np-h-range {
  font-size: 11pt;
  font-weight: 700;
  color: #0b2547;
}
.np-h-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.2mm;
}
.np-h-right .np-quote {
  font-size: 9.5pt;
  font-style: italic;
  color: #0f172a;
  font-weight: 600;
}
.np-h-right hr {
  width: 36mm;
  border: none;
  border-top: 1px solid #94a3b8;
  margin: 0;
}

/* ============================ GRILLE TABLEAU ============================ */
.np-grid-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1.2px solid #94a3b8;
  border-radius: 2.5mm;
  overflow: hidden;
  box-sizing: border-box;
}
.np-grid {
  display: grid;
  grid-template-columns: 28mm repeat(5, minmax(0, 1fr)) minmax(0, 1.1fr);
  grid-template-rows: 15mm repeat(6, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  background: #fff;
}
.np-cell {
  box-sizing: border-box;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  padding: 0;
  overflow: hidden;
  position: relative;
}
/* Bordures extérieures déjà portées par wrap, donc 1ère colonne + 1ère ligne pas de bordure top/left en double */
.np-col-head {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2mm;
  color: #0b2547;
  border-bottom: 1.2px solid #94a3b8;
  font-weight: 700;
  padding: 0.8mm 0.6mm;
}
.np-col-head.fri {
  background: linear-gradient(180deg, #fecaca 0%, #fca5a5 100%);
  color: #7f1d1d;
  border-bottom-color: #b91c1c;
}
.np-col-head .np-dow {
  font-size: 9.5pt;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1;
}
.np-col-head .np-date {
  font-size: 8.5pt;
  font-weight: 700;
  opacity: .95;
}
.np-col-head .np-col-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1mm;
  font-size: 7.5pt;
  font-weight: 800;
  line-height: 1;
  margin-top: 0.6mm;
  opacity: .95;
}
.np-col-head .np-stat-pres { font-weight: 900; letter-spacing: -.01em; }
.np-col-head .np-stat-sep { opacity: .6; font-weight: 900; }
.np-col-head .np-stat-abs { font-weight: 900; letter-spacing: -.01em; }
.np-col-head.fri .np-col-stats { color: #7f1d1d; }
/* Colonne Horaires en-tête */
.np-cell.np-hour-head {
  background: linear-gradient(180deg, #0b2547 0%, #0b3370 100%);
  color: rgba(255,255,255,.95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10pt;
  font-weight: 900;
  letter-spacing: .06em;
  border-right: 1.2px solid #94a3b8;
  border-bottom: 1.2px solid #94a3b8;
  padding: 0 1mm;
}

/* Cellule Horaire (gauche, HEURE + HEURE FIN) */
.np-cell.np-hour {
  background: linear-gradient(180deg, #f1f5fb 0%, #e2e8f0 100%);
  color: #0b2547;
  padding: 1.2mm 1.6mm;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.6mm;
  border-right: 1.2px solid #94a3b8;
  font-weight: 800;
}
.np-hour .np-hh-start {
  font-size: 10.5pt;
  font-weight: 900;
  line-height: 1;
}
.np-hour .np-hh-arrow {
  font-size: 9pt;
  color: #475569;
  font-weight: 700;
  line-height: 1;
  margin-left: 0.2mm;
}
.np-hour .np-hh-end {
  font-size: 8.5pt;
  color: #334155;
  font-weight: 700;
  line-height: 1;
}

/* Cellule Journée classique (droite) */
.np-cell.np-day {
  background: #fff;
  padding: 1.5mm 2mm;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1mm;
}
.np-cell.np-day.fri {
  background: #fff5f5;
}
/* Dernière colonne (SAM) no border right */
.np-cell.np-lastcol { border-right: none; }

/* Dernière ligne slot no border bottom (la section absences en a une nouvelle) */
.np-cell.np-lastslot { border-bottom: none; }

/* ============================ BADGES ASSIGNATIONS ============================ */
.np-badge {
  --pc: #1e5aa8;
  display: flex;
  align-items: center;
  gap: 1.4mm;
  padding: 1mm 1.6mm 1mm 1mm;
  border-radius: 2.2mm;
  min-height: 7.2mm;
  box-sizing: border-box;
  color: #0f172a;
  font-weight: 700;
  font-size: 9pt;
  line-height: 1.05;
  background: color-mix(in srgb, var(--pc) 18%, #fff 82%);
  border: 1px solid color-mix(in srgb, var(--pc) 55%, #fff 45%);
  flex: 0 0 auto;
  overflow: hidden;
}
.np-avatar {
  width: 5.2mm;
  height: 5.2mm;
  flex-shrink: 0;
  border-radius: 1.8mm;
  background: var(--pc);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8pt;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .01em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.np-avatar.light {
  color: #0b2547;
  background: color-mix(in srgb, var(--pc) 60%, #fff 40%);
}
.np-badge-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Tags Télétravail / Matin / Après-midi / Personnalisé ---------- */
.np-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 6.5pt;
  font-weight: 900;
  line-height: 1;
  padding: 0.3mm 0.8mm;
  border-radius: 1mm;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.np-tag-tt {
  background: #1e40af;
  color: #fff;
}
.np-tag-pres {
  color: #0b2547;
  background: rgba(15, 23, 42, .08);
  border: 1px solid rgba(15, 23, 42, .12);
}
.np-tag-pres.np-tag-am {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}
.np-tag-pres.np-tag-pm {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}
.np-tag-pres.np-tag-pers {
  background: #faf5ff;
  border-color: #d8b4fe;
  color: #6b21a8;
}

/* ============================ SECTION ABSENCES ============================ */
.np-abs-wrap {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 28mm repeat(6, minmax(0, 1fr));
  background: #fff;
  border-top: 1.2px solid #b91c1c;
  min-height: 0;
}
.np-abs-title {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  color: #7f1d1d;
  padding: 1.2mm 1.6mm;
  display: flex;
  flex-direction: column;
  gap: 0.8mm;
  align-items: flex-start;
  justify-content: flex-start;
  border-right: 1.2px solid #b91c1c;
  box-sizing: border-box;
  overflow: hidden;
}
.np-abs-title b {
  font-size: 10pt;
  font-weight: 900;
  line-height: 1;
}
.np-abs-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5mm;
  margin-top: 0.4mm;
}
.np-abs-legend span {
  font-size: 7.8pt;
  color: #7f1d1d;
  font-weight: 600;
  line-height: 1.05;
}
.np-abs-cell {
  background: #fff5f5;
  padding: 1mm 1.4mm;
  border-right: 1px solid #fca5a5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.9mm;
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}
.np-abs-cell.np-lastcol { border-right: none; }
.np-apill {
  --pc: #1e5aa8;
  display: flex;
  align-items: center;
  gap: 1mm;
  padding: 0.7mm 1mm 0.7mm 0.7mm;
  border-radius: 1.6mm;
  font-size: 7.8pt;
  font-weight: 700;
  line-height: 1.05;
  background: color-mix(in srgb, var(--pc) 18%, #fff 82%);
  border: 1px solid color-mix(in srgb, var(--pc) 55%, #fff 45%);
  color: #0f172a;
  overflow: hidden;
  flex: 0 0 auto;
  min-height: 5.8mm;
  box-sizing: border-box;
}
.np-apill .np-avatar {
  width: 4.4mm; height: 4.4mm;
  font-size: 7pt;
  border-radius: 1.2mm;
}
.np-apill-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.np-apill-type {
  flex-shrink: 0;
  font-size: 7pt;
  font-weight: 800;
  padding: 0.2mm 0.7mm;
  border-radius: 1mm;
  background: rgba(15,23,42,.07);
  color: #334155;
}

/* ============================ FOOTER ============================ */
.np-footer {
  padding-top: 1.5mm;
  border-top: 1px solid #cbd5e1;
  display: grid;
  grid-template-columns: 70mm 1fr 82mm;
  align-items: start;
  gap: 3mm;
  font-size: 8pt;
  color: #334155;
}
.np-f-left {
  display: flex;
  flex-direction: column;
  gap: 0.4mm;
}
.np-f-left b {
  color: #0b2547;
  font-weight: 900;
  font-size: 8.5pt;
}
.np-f-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6mm;
  font-style: italic;
  font-size: 8.5pt;
  color: #0f172a;
  font-weight: 600;
}
.np-f-center .np-f-line {
  width: 40mm;
  border-top: 1px solid #94a3b8;
  height: 0;
}
.np-f-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4mm;
}
.np-f-right .np-f-page {
  font-weight: 800;
  color: #0b2547;
}

/* ============================ MODALE UI écran (avant impression) ============================ */
.np-modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 9998;
}
.np-modal-mask.open { display: flex; }
.np-modal {
  width: 680px;
  max-width: 95vw;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15,23,42,.2);
  padding: 22px 24px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}
.np-modal h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: #0b2547;
}
.np-modal .sub {
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  margin-top: -4px;
}
.np-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  background: #f1f5fb;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
}
.np-picker label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e3a60;
}
.np-picker select {
  padding: 9px 11px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  font: inherit;
  color: #0b2547;
  background: #fff;
  font-weight: 600;
}
.np-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}
.np-actions button {
  padding: 9px 16px;
  border-radius: 9px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}
.np-btn-ghost {
  background: #f8fafc;
  color: #334155;
  border-color: #e2e8f0;
}
.np-btn-primary {
  background: linear-gradient(180deg, #0b4493, #0b3370);
  color: #fff;
  box-shadow: 0 4px 10px rgba(11,68,147,.2);
}
.np-btn-primary:hover { filter: brightness(1.05); }
