/* Dedert production planner — styling.
 * Look and feel borrows from the customer's Excel workbook (coloured grid,
 * sheet-like day tabs) with the Dedert brand fonts from the site PoC. */

@font-face {
  font-family: "Fredoka"; font-weight: 600; font-display: swap;
  src: url("../fonts/fredoka-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-weight: 600; font-display: swap;
  src: url("../fonts/nunito-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-weight: 700; font-display: swap;
  src: url("../fonts/nunito-700.woff2") format("woff2");
}

:root {
  --brand: #0c7ac2;
  --brand-dark: #085a91;
  --paper: #f4f7fa;
  --ink: #1c2733;
  --line: #d5dee6;
  --ok: #c6efce; --ok-ink: #1e6b34;
  --warn: #ffeb9c; --warn-ink: #7a5c00;
  --bad: #ffc7ce; --bad-ink: #9c0006;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 600 15px/1.45 "Nunito", system-ui, sans-serif;
  background: var(--paper); color: var(--ink);
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: #fff; border-bottom: 2px solid var(--line);
}
.logo { height: 44px; width: auto; }
.title h1 { font: 600 22px/1.1 "Fredoka", "Nunito", sans-serif; margin: 0; color: var(--brand-dark); }
.subtitle { margin: 0; font-size: 12px; color: #64748b; }
.weeknav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.weeknav span { font-family: "Fredoka", sans-serif; font-size: 17px; min-width: 120px; text-align: center; }
button {
  font: 600 14px "Nunito", sans-serif; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--bad-ink); }
.viewtoggle button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- day tabs, like Excel sheet tabs ---------- */
.daytabs { display: flex; gap: 2px; padding: 10px 16px 0; overflow-x: auto; }
.daytabs button {
  border-radius: 8px 8px 0 0; border-bottom: none; padding: 8px 14px;
  background: #e4ebf1; white-space: nowrap;
}
.daytabs button .d { display: block; font-size: 11px; color: #64748b; font-weight: 600; }
.daytabs button.active { background: #fff; border-color: var(--line); font-weight: 700; color: var(--brand-dark); }
.daytabs button.saved::after { content: " ●"; color: var(--brand); font-size: 9px; vertical-align: super; }

main { padding: 0 16px 24px; }

/* ---------- panels ---------- */
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 0 8px 8px 8px;
  margin-bottom: 12px; padding: 12px;
}
details.panel summary { cursor: pointer; font-family: "Fredoka", sans-serif; color: var(--brand-dark); }
.savestate { font: 600 12px "Nunito", sans-serif; color: #64748b; margin-left: 8px; }
.setup { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; align-items: flex-start; }
fieldset.lines { border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
fieldset.lines legend { font-family: "Fredoka", sans-serif; color: var(--brand-dark); padding: 0 4px; }
fieldset.lines label { display: flex; flex-direction: column; font-size: 12px; gap: 4px; }
input[type="time"], input[type="number"] {
  font: 600 14px "Nunito", sans-serif; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: 6px; width: 90px;
}
/* typeable time entry (round 3: typing beats picking from a wheel) */
input.tijd {
  font: 600 14px "Nunito", sans-serif; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: 6px;
  width: 62px; text-align: center;
}
input.tijd.bad { border-color: var(--bad-ink); background: var(--bad); }
input.tijd:disabled { opacity: .45; background: #f1f5f8; }
fieldset.lines label.lineon {
  flex-direction: row; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; padding-bottom: 9px; color: var(--brand-dark);
}
.copyday { display: inline-flex; gap: 6px; align-items: center; }
.copyday select {
  font: 600 13px "Nunito", sans-serif; padding: 6px;
  border: 1px solid var(--line); border-radius: 6px;
}
.linehours { font-size: 13px; color: #64748b; padding-bottom: 9px; min-width: 52px; }
fieldset.breaks { border: 1px solid var(--line); border-radius: 8px; max-width: 210px; }
fieldset.breaks legend { font-family: "Fredoka", sans-serif; color: var(--brand-dark); padding: 0 4px; }
fieldset.breaks .brk { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
fieldset.breaks select {
  font: 600 13px "Nunito", sans-serif; padding: 4px;
  border: 1px solid var(--line); border-radius: 6px;
}
fieldset.breaks .delbrk { padding: 3px 8px; color: var(--bad-ink); }
#addBreak { font-size: 13px; padding: 4px 10px; }
.presence-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.presence { border-collapse: collapse; font-size: 13px; }
table.presence th, table.presence td { padding: 3px 10px; border-bottom: 1px solid #eef2f6; text-align: left; white-space: nowrap; }
table.presence thead th { position: sticky; top: 0; background: #fff; }
table.presence label { display: flex; align-items: center; gap: 6px; }
table.presence input[type="time"] { width: 84px; padding: 2px 4px; }
table.presence input.tijd { width: 56px; padding: 2px 4px; }
table.presence input[type="number"] { width: 58px; padding: 2px 4px; }
table.presence tr.absent td { opacity: 0.45; }
.actions { display: flex; flex-direction: column; gap: 8px; justify-content: flex-start; }

/* Intermediate widths (tablets like iPad Pro, small laptops): the button
 * column no longer fits beside the presence table and would wrap into a
 * tall stack that pushes the grid down — flow the buttons horizontally in
 * whatever space remains (beside the table when possible, else one row). */
@media (max-width: 1459px) {
  .actions { flex-direction: row; flex-wrap: wrap; flex: 1 1 320px; align-content: flex-start; }
}

/* ---------- the grid ---------- */
.gridwrap {
  overflow: auto; max-height: 74vh; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px;
  position: relative;
}
#grid { border-collapse: separate; border-spacing: 0; }
#grid th, #grid td {
  border-right: 1px solid #e3e9ef; border-bottom: 1px solid #e3e9ef;
  padding: 0 4px; white-space: nowrap; font-size: 11px; height: 19px;
}
#grid thead th {
  position: sticky; top: 0; z-index: 3; background: #fff;
  font: 600 12px "Fredoka", sans-serif; color: var(--brand-dark);
  text-align: left; padding: 6px; border-bottom: 2px solid var(--line);
}
#grid td.time, #grid th.time {
  position: sticky; left: 0; z-index: 2; background: #fff;
  font-weight: 700; color: #64748b; min-width: 52px; text-align: right;
}
#grid thead th.time { z-index: 4; }
#grid tr.hour td { border-bottom-color: #b9c6d2; }
#grid td.slot { cursor: pointer; min-width: 104px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; user-select: none; }
#grid td.slot:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
/* drag-fill range selection (mouse): the cells the menu will fill */
#grid td.slot.selrange {
  outline: 2px dashed var(--brand); outline-offset: -2px;
  box-shadow: inset 0 0 0 99px rgba(12, 122, 194, .14);
}
#grid td.conflict { background: #fff !important; color: #d40000 !important; font-weight: 800; }
#grid td.gap { background: repeating-linear-gradient(45deg, #fff, #fff 4px, #ffe6e6 4px, #ffe6e6 8px); }

/* thick line on the day's break moments: the "pauze tot pauze" blocks */
#grid tr.breakline td, #grid tr.breakline th { border-top: 2px solid #16202b; }

/* station columns ("wie staat waar"), like the right-hand side of the
 * customer's own printout: one column per station, gaps pop out as red.
 * Sticky on the right edge so the coverage check is always in view;
 * fixed widths make the per-column right offsets work (9 x 62px + divider).
 * app.js sets the inline right offsets when it renders the grid. */
#grid th.sep, #grid td.sep {
  position: sticky; z-index: 2;
  min-width: 8px; max-width: 8px; width: 8px; padding: 0;
  background: #dfe7ee; border-left: 2px solid #7e8ea0;
}
#grid .stcol {
  position: sticky; z-index: 2;
  width: 62px; min-width: 62px; max-width: 62px;
}
#grid thead th.stcol {
  writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 4px 2px; font-size: 10px; text-align: right; z-index: 3;
  height: 92px;   /* room for the rotated station names */
}
#grid thead th.sep { z-index: 3; }
#grid td.stcol {
  font-size: 10px; color: #33414f; background: #fbfcfe;
  overflow: hidden; text-overflow: ellipsis;
}
#grid td.stcol.gap {
  background: var(--bad); color: var(--bad-ink);
  text-align: center; font-weight: 800;
}

/* compact colour view: the workbook's colours-only display mode */
#grid.colors td.slot { min-width: 18px; max-width: 22px; color: transparent; padding: 0; }
#grid.colors thead th { writing-mode: vertical-rl; transform: rotate(180deg); padding: 4px 2px; font-size: 11px; }
#grid.colors thead th.time { writing-mode: horizontal-tb; transform: none; }

/* ---------- checks ---------- */
.checks h3, .legend h3 { font-family: "Fredoka", sans-serif; color: var(--brand-dark); margin: 4px 0 8px; }
.checks .cols { display: flex; gap: 24px; flex-wrap: wrap; }
table.check { border-collapse: collapse; font-size: 13px; }
table.check th, table.check td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; }
table.check thead th { background: #eef3f7; }
.ok   { background: var(--ok);   color: var(--ok-ink); }
.warn { background: var(--warn); color: var(--warn-ink); }
.bad  { background: var(--bad);  color: var(--bad-ink); }
.checks ul { margin: 6px 0; padding-left: 20px; font-size: 13px; }

/* ---------- legend ---------- */
.legend .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.legend .chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; background: #fff;
}
.legend .chip i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }

/* ---------- task menu (cell editor) ---------- */
.taskmenu {
  position: absolute; z-index: 50; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px;
  display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow: auto;
}
/* the display:flex above would override the UA's [hidden] rule — make the
 * hidden attribute win again (the menu genuinely closes after a choice) */
.taskmenu[hidden] { display: none; }
.taskmenu button { display: flex; align-items: center; gap: 8px; border: none; text-align: left; padding: 5px 8px; }
.taskmenu button i { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.taskmenu button:hover { background: #eef3f7; }
.taskmenu .who { font-size: 11px; color: #64748b; padding: 2px 8px 4px; border-bottom: 1px solid var(--line); }
.taskmenu .range {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: #64748b;
  padding: 4px 8px; border-bottom: 1px solid var(--line);
}
.taskmenu .range select {
  font: 600 13px "Nunito", sans-serif; padding: 3px;
  border: 1px solid var(--line); border-radius: 6px;
}

/* ---------- capability matrix ---------- */
.capmatrix-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-height: 70vh; }
#capMatrix { border-collapse: collapse; font-size: 12px; }
#capMatrix th, #capMatrix td { border: 1px solid #e3e9ef; padding: 4px 6px; text-align: center; }
#capMatrix thead th { position: sticky; top: 0; background: #eef3f7; z-index: 2; }
#capMatrix td:first-child, #capMatrix th:first-child { position: sticky; left: 0; background: #fff; text-align: left; z-index: 1; }
#capMatrix .off { color: #cbd5e1; }
#capMatrix .flagcol { border-left: 2px solid #b9c6d2; background: #f6f9fc; }
#capMatrix thead th.flagcol { background: #e6edf3; }
#capMatrix .delemp { border: none; background: none; color: var(--bad-ink); padding: 0 6px; font-size: 13px; }
#capMatrix .delemp:hover { font-weight: 800; }
.addemp { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.addemp input[type="text"] {
  font: 600 14px "Nunito", sans-serif; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; width: 210px;
}
#settingsView h3 { font-family: "Fredoka", sans-serif; color: var(--brand-dark); margin: 22px 0 4px; }
.softrules { max-width: 760px; padding-left: 20px; }
.softrules li { margin-bottom: 7px; }

footer { padding: 12px 16px 28px; font-size: 12px; color: #64748b; }
footer a { color: var(--brand); }

/* ---------- small viewports ---------- */
@media (max-width: 800px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .logo { height: 34px; }
  .title h1 { font-size: 17px; }
  .subtitle { display: none; }
  .weeknav { margin-left: 0; }
  main { padding: 0 8px 16px; }
  .daytabs { padding: 8px 8px 0; }
  .daytabs button { padding: 6px 9px; }
  .setup { gap: 12px; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .gridwrap { max-height: 66vh; }
  #grid td.slot { min-width: 84px; font-size: 10px; }
  #grid.colors td.slot { min-width: 13px; max-width: 15px; }
  /* small screens: station columns scroll with the grid instead of
   * sticking — a 566px sticky block would swallow the viewport */
  #grid .stcol, #grid .sep { position: static; }
}

.printheader { display: none; }

/* ---------- print: a logical paper layout ----------
 * A4 landscape: a title line, the day grid (absent employees' columns
 * dropped), and the colour legend. Setup, checks and navigation stay off
 * paper. Cell colours are forced (print-color-adjust). */
@media print {
  @page { size: A4 landscape; margin: 7mm; }
  .topbar, .daytabs, #setupPanel, .panel.checks, footer, .taskmenu { display: none !important; }
  body { background: #fff; font-size: 10px; }
  .printheader {
    display: block; font: 600 13px "Fredoka", "Nunito", sans-serif;
    color: #000; margin: 0 0 4px;
  }
  .gridwrap { max-height: none; overflow: visible; border: none; border-radius: 0; margin-bottom: 4px; }
  #grid { width: 100%; }
  #grid th, #grid td {
    font-size: 6.2px; height: 7.6px; line-height: 1.05; padding: 0 2px;
    border-color: #999; color: #000;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  #grid thead th { position: static; font-size: 7.2px; border-bottom: 1.5px solid #000; }
  #grid td.time, #grid th.time { position: static; min-width: 30px; }
  #grid td.slot { min-width: 0; max-width: none; }
  #grid .absent-col { display: none; }
  #grid .stcol, #grid .sep { display: none; }   /* station columns are a screen aid */
  #grid tr.printtrim { display: none; }         /* rows outside the planned range */
  #grid tr.breakline td { border-top: 1.5px solid #000; }
  #grid td.conflict { outline: 1px solid #d40000; }
  .panel.legend { border: none; padding: 0; }
  .legend h3 { display: none; }
  .legend .chip { padding: 0 4px; font-size: 6.6px; border-color: #999; }
  .legend .chip i { width: 8px; height: 8px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
