/* ============================================================
   Feuille de service — mise en page de l'outil + aperçu A4
   ============================================================ */

html:not(.palo-authed) body { visibility: hidden; }

.topbar { flex-wrap: wrap; }

.topbar-select {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  max-width: 190px;
}

#save-status { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Menu d'auto-complétion (répertoire) ---------- */

#palo-combo {
  position: absolute;
  z-index: 100;
  min-width: 260px;
  max-width: 340px;
  max-height: 290px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(34, 31, 26, 0.12), 0 12px 32px rgba(34, 31, 26, 0.18);
  padding: 4px;
}

#palo-combo .combo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
}

#palo-combo .combo-item.selected { background: var(--accent-soft); }

#palo-combo .combo-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

#palo-combo .combo-main { min-width: 0; }

#palo-combo .combo-nom {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#palo-combo .combo-nom mark {
  background: none;
  color: var(--accent);
}

#palo-combo .combo-sub {
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#palo-combo .combo-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
}

body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Espace de travail ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(400px, 460px) 1fr;
  flex-grow: 1;
  min-height: 0;
}

.form-pane {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
}

.row.row-type-pat    { border-left: 3px solid var(--accent); }
.row.row-type-pause  { border-left: 3px solid #d9a13c; }
.row.row-type-fin    { border-left: 3px solid var(--ink); }

/* Liste technique : sections */

.tech-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--paper);
}

.tech-section .tech-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.tech-section .tech-head input {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tech-section .rows { margin-bottom: 8px; }

/* ---------- Aperçu ---------- */

.preview-pane {
  overflow: auto;
  padding: 24px;
  background: #dedad2;
}

.sheet-scale {
  transform-origin: top left;
}

.sheet {
  width: 794px; /* A4 @ 96dpi */
  min-height: 1123px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18), 0 12px 40px rgba(0,0,0,0.22);
  padding: 36px 40px;
  font-size: 13px;
  line-height: 1.45;
}

/* ---- contenu de la feuille ---- */

.sheet table {
  width: 100%;
  border-collapse: collapse;
}

.sheet th, .sheet td {
  border: 1px solid #444;
  padding: 5px 8px;
  text-align: center;
  vertical-align: middle;
}

.sheet th {
  background: #efece5;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fds-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 0;
  border: 1px solid #444;
  margin-bottom: 14px;
}

.fds-header > div {
  padding: 8px 10px;
  font-size: 11.5px;
}

.fds-header > div + div { border-left: 1px solid #444; }

.fds-header .head-prod strong { display: block; }

.fds-header .head-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.fds-header .head-center .prod-name {
  font-weight: 800;
  font-size: 14px;
  text-transform: uppercase;
}

.fds-header .head-center .prod-episode { color: #666; }

.fds-title {
  border: 2px solid #1a1a1a;
  text-align: center;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.fds-title .t1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.fds-title .t2 { font-size: 13px; margin-top: 2px; }

.fds-banner {
  border: 1px solid #444;
  background: #efece5;
  text-align: center;
  padding: 7px 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
}

.fds-banner strong { text-transform: uppercase; letter-spacing: 0.04em; }

.fds-section-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 18px 0 4px;
  text-align: center;
}

.fds-section-sub {
  text-align: center;
  font-size: 11px;
  font-style: italic;
  color: #555;
  margin-bottom: 8px;
}

.fds-lieux { margin-bottom: 0; text-align: left; }
.fds-lieux td { text-align: left; }
.fds-lieux .lieu-infos { font-size: 11px; color: #555; }

.calltimes-table { margin-bottom: 6px; }
.calltimes-table td.ct-time { font-weight: 800; font-size: 14px; }
.calltimes-table td.ct-lieu { font-size: 10.5px; color: #555; }

.planning-table td:nth-child(1),
.planning-table td:nth-child(4) { width: 70px; font-weight: 700; white-space: nowrap; }

.planning-table td:nth-child(2) { text-align: left; }
.planning-table td:nth-child(3) { font-size: 11.5px; }

.planning-table tr.p-pat td {
  background: #fbeae6;
  font-weight: 800;
}

.planning-table tr.p-pause td {
  background: #faf3e3;
  font-weight: 700;
}

.planning-table tr.p-fin td {
  background: #1a1a1a;
  color: #fff;
  font-weight: 800;
}

.tech-table td:nth-child(1) { text-align: left; width: 40%; }
.tech-table td:nth-child(2) { text-align: left; }
.tech-table td:nth-child(3) { width: 25%; }

.tech-table tr.tech-sec td {
  background: #1a1a1a;
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.fds-notes {
  border: 1px solid #444;
  padding: 8px 10px;
  margin-top: 14px;
  white-space: pre-line;
  font-size: 12px;
}

.fds-notes-title {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.sheet .empty-placeholder {
  color: #bbb;
  font-style: italic;
}

/* ---------- Impression ---------- */

@page {
  size: A4;
  margin: 10mm;
}

@media print {
  body { overflow: visible; height: auto; display: block; background: #fff; }
  .topbar, .form-pane { display: none !important; }
  .workspace { display: block; height: auto; }
  .preview-pane { overflow: visible; padding: 0; background: #fff; }
  .sheet-scale { transform: none !important; }
  .sheet {
    width: auto;
    min-height: 0;
    box-shadow: none;
    padding: 0;
  }
  .sheet table tr { break-inside: avoid; }
  .fds-header, .fds-title, .fds-banner { break-inside: avoid; }
  .tech-page-break { break-before: page; }
}
