/* 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; }
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;
}
.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[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; }

/* ---------- 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; }
#grid td.slot:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
#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); }

/* 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;
}
.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); }

/* ---------- 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; }

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; }
}

.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 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; }
}
