/* The A4 sheet. Everything here prints exactly as previewed. */
.sheet {
  width: 297mm;
  height: 210mm;
  position: relative;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.25;
  transform-origin: 0 0;
  transform: scale(var(--scale, 1));
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sheet *, .sheet *::before { box-sizing: border-box; }
.sheet .ic { width: 1em; height: 1em; flex: none; }

.sheet-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--bg-fit, cover);
  object-position: var(--bg-pos, 50% 50%);
  transform: scale(var(--bg-zoom, 1));
  transform-origin: var(--bg-pos, 50% 50%);
  opacity: var(--bg-op, 1);
  filter: blur(var(--bg-blur, 0));
}

/* ---------- shared pieces ---------- */
.who-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(26px * var(--name-scale));
  font-weight: 700;
  letter-spacing: -0.01em;
}
.who-name .key { color: #eab308; font-size: 0.75em; }
.who-role {
  margin-top: 2px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.qr { width: 58px; height: 58px; flex: none; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr.boxed { background: #fff; padding: 4px; border-radius: 6px; }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--gap);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(var(--weeks), minmax(0, 150px));
  align-content: start;
  gap: var(--gap);
}

.cell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 5px;
  border: var(--bw) solid var(--c-bd);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c-bg) var(--card-op, 100%), transparent);
  color: var(--c-tx);
  overflow: hidden;
}
.cell.empty { visibility: hidden; }
.cell.past { opacity: var(--past-op); }
.cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.t-work { --c-bg: var(--work-bg); --c-bd: var(--work-bd); --c-date: var(--work-date); --c-datetx: var(--work-datetx); --c-tx: var(--work-tx); }
.t-off { --c-bg: var(--off-bg); --c-bd: var(--off-bd); --c-date: var(--off-date); --c-datetx: var(--off-datetx); --c-tx: var(--off-tx); }
.t-leave { --c-bg: var(--leave-bg); --c-bd: var(--leave-bd); --c-date: var(--leave-date); --c-datetx: var(--leave-datetx); --c-tx: var(--leave-tx); }
.t-vac { --c-bg: var(--vac-bg); --c-bd: var(--vac-bd); --c-date: var(--vac-date); --c-datetx: var(--vac-datetx); --c-tx: var(--vac-tx); }

.cell-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 4px;
  border-radius: var(--date-r);
  background: var(--c-date);
  color: var(--c-datetx);
  font-size: calc(11.5px * var(--ts));
  font-weight: 700;
  white-space: nowrap;
}
.cell-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: calc(14px * var(--ts));
  font-weight: 600;
}
.time { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.time .ic { font-size: 0.85em; opacity: 0.75; }
.cell-status { font-size: 1.05em; font-weight: 700; text-align: center; }

.legend { display: flex; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-item .ic { color: var(--accent); }
.foot { color: var(--muted); font-size: 10px; white-space: nowrap; }

/* ---------- Modelo Base ---------- */
.b-root {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 9mm 10mm 6mm;
}
.b-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}
.b-head.flip { flex-direction: row-reverse; }
.b-head.flip .who { text-align: right; }
.b-head.flip .who-name { justify-content: flex-end; }
.b-root .legend { justify-content: space-between; gap: 6px 14px; padding-top: 9px; border-top: 1px solid var(--line); }
.b-root .foot { text-align: center; }

/* ---------- Split com Imagem ---------- */
.s-root {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 16px;
  padding: 8mm;
}
.s-root.flip { flex-direction: row-reverse; }
.s-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.s-head { display: flex; align-items: center; gap: 14px; padding-bottom: 4px; }
.compact .weekdays { font-size: 10.5px; }
.compact .cell { padding: 4px; }
.compact .cell-date { font-size: calc(10px * var(--ts)); gap: 3px; padding: 3px 2px; }
.compact .cell-body { font-size: calc(12.5px * var(--ts)); }
.compact .time { gap: 4px; }
.s-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.s-foot .legend { gap: 4px 10px; font-size: 9.5px; }
.s-foot .legend-item { gap: 3px; }

.s-photo {
  flex: none;
  width: var(--photo-w);
  border-radius: var(--photo-r);
  overflow: hidden;
}
.s-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: var(--photo-fit);
  object-position: var(--photo-pos);
  transform: scale(var(--photo-zoom));
  transform-origin: var(--photo-pos);
}
.s-photo.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}
.s-photo.empty .ic { font-size: 40px; color: var(--accent); }
.s-photo.empty strong { color: var(--ink); font-size: 16px; }

/* ---------- Faixa com Imagem ---------- */
.n-root { position: absolute; inset: 0; display: flex; flex-direction: column; }
.n-hero { position: relative; flex: none; height: var(--hero-h); overflow: hidden; background: var(--accent); }
.n-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--photo-pos);
  transform: scale(var(--photo-zoom));
  transform-origin: var(--photo-pos);
}
.n-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, var(--hero-dim)), rgba(0, 0, 0, 0) 85%); }
.n-id {
  position: absolute;
  left: 10mm;
  right: 10mm;
  bottom: 5mm;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
}
.n-id .who-role { color: #fff; opacity: 0.9; }
.n-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1.5px dashed rgba(255, 255, 255, 0.7);
  border-radius: 99px;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}
.n-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 5mm 10mm 6mm; }
.n-body .legend { justify-content: space-between; gap: 6px 14px; padding-top: 9px; border-top: 1px solid var(--line); }
.n-body .foot { text-align: center; }

/* ---------- Agenda ---------- */
.a-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--weeks), minmax(0, 1fr)); gap: calc(var(--gap) * 2); }
.a-week { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.a-title {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.a-day {
  flex: 1;
  min-height: 0;
  max-height: var(--row-h);
  display: flex;
  border: var(--bw) solid var(--c-bd);
  border-radius: var(--radius);
  background: var(--c-bg);
  color: var(--c-tx);
  overflow: hidden;
}
.a-day.empty { visibility: hidden; }
.a-day.past { opacity: var(--past-op); }
.a-day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.a-date {
  flex: none;
  width: var(--date-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--c-date);
  color: var(--c-datetx);
  font-size: calc(15px * var(--ts));
  font-weight: 700;
  line-height: 1.1;
}
.a-date b { font-size: 0.62em; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.a-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 6px;
  font-size: calc(14px * var(--ts));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.a-body .ic { opacity: 0.6; }

/* ---------- Semana em Destaque ---------- */
.f-label { color: var(--accent); font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.f-big { flex: 0 0 var(--focus-h); grid-template-rows: minmax(0, 1fr); }
.f-big .cell { padding: 7px; }
.f-big .cell-date { padding: 5px 6px; font-size: calc(12.5px * var(--ts) * var(--focus-ts) / 1.25); }
.f-big .cell-body { gap: 4px; font-size: calc(14px * var(--ts) * var(--focus-ts)); }

/* ---------- images can be dragged into place ---------- */
.sheet img { -webkit-user-drag: none; user-select: none; }
@media screen {
  .sheet .can-drag { cursor: grab; touch-action: none; }
  .sheet .can-drag:active { cursor: grabbing; }
}

/* ---------- on screen only: hover highlight for click-to-edit ---------- */
@media screen {
  .sheet [data-edit] { cursor: pointer; }
  .sheet .hot { outline: 3px solid #2563eb !important; outline-offset: 2px; }
  .sheet.hot { cursor: pointer; outline: 4px solid #2563eb; outline-offset: -4px; }
}

/* ---------- print ---------- */
@page { size: A4 landscape; margin: 0; }

@media print {
  html, body { width: 297mm; height: 210mm; margin: 0 !important; padding: 0 !important; background: #fff !important; overflow: hidden !important; }
  .app { display: block !important; height: auto !important; min-height: 0 !important; }
  .app > :not(.stage), dialog, .pop { display: none !important; }
  .stage, .scaler { display: block !important; position: static !important; width: auto !important; height: auto !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; background: none !important; box-shadow: none !important; }
  .sheet { transform: none !important; height: 209.8mm; box-shadow: none !important; }
  .cell.today, .a-day.today { outline: none; }
  .screen-only { display: none !important; }
  /* No photo chosen: let the schedule use the whole sheet. */
  .s-photo.empty { display: none; }
}
