/* =========================================================
   beredskapstid — minimal responsive stylesheet
   ========================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #dee2e6;
  --color-primary: #0d6efd;
  --color-primary-hover: #0b5ed7;
  --color-danger: #dc3545;
  --color-text: #212529;
  --color-muted: #6c757d;
  --color-red-day-bg: #fff5f5;
  --color-red-day-text: #c0392b;
  --color-total-row: #e9ecef;

  /* Badge colours */
  --badge-b1: #6ea8fe;
  --badge-b2a: #a3cfbb;
  --badge-b2b: #75b798;
  --badge-b3a: #ffda6a;
  --badge-b3b: #ffc107;
  --badge-b4: #f1aeb5;
  --badge-ot1: #6ea8fe;
  --badge-ot2: #f1aeb5;

  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-bg);
}

body {
  padding: 1rem;
  max-width: 960px;
  margin: 0 auto;
}

h1 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.25rem;
}

/* -------------------------
   Week navigation header
   ------------------------- */
#week-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

#week-label {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
  min-width: 200px;
}

#week-header button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 0.3rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 1rem;
}

#week-header button:hover {
  background: var(--color-primary-hover);
}

input[type="week"] {
  border: 1px solid var(--color-border);
  border-radius: 0.3rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

.name-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.name-field label {
  font-weight: 500;
  white-space: nowrap;
}

.name-field input {
  border: 1px solid var(--color-border);
  border-radius: 0.3rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
  width: 160px;
}

/* -------------------------
   Tables
   ------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  overflow: hidden;
}

thead th {
  background: var(--color-primary);
  color: #fff;
  padding: 0.45rem 0.6rem;
  text-align: left;
  font-weight: 600;
}

tbody td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f1f3f5;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Red days (holidays + Sundays) */
tr.red-day td {
  background: var(--color-red-day-bg);
}

tr.red-day .day-label {
  color: var(--color-red-day-text);
  font-weight: 600;
}

.date-small {
  font-size: 0.75rem;
  color: var(--color-muted);
  display: block;
}

.holiday-name {
  font-size: 0.72rem;
  color: var(--color-red-day-text);
  font-style: italic;
  display: block;
}

/* Jour table inputs */
.jour-start,
.jour-end {
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  padding: 0.2rem 0.35rem;
  width: 72px;
  font-family: inherit;
}


/* Summary table total rows */
tr.total td {
  font-weight: 700;
  background: var(--color-total-row);
}

/* -------------------------
   Emergency entries
   ------------------------- */
#entries-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
  padding: 0.45rem 0.6rem;
}

.entry-row select,
.entry-row input[type="number"],
.entry-row input[type="text"] {
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.88rem;
}

.entry-row select           { width: 60px; }
.entry-row .entry-start     { width: 72px; }
.entry-row input[type="number"] { width: 70px; }
.entry-row .entry-desc      { flex: 1; min-width: 120px; }

.remove-entry-btn {
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.remove-entry-btn:disabled {
  background: #adb5bd;
  cursor: not-allowed;
}

#add-entry-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 0.3rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  align-self: flex-start;
}

#add-entry-btn:hover {
  background: var(--color-primary-hover);
}

/* -------------------------
   Badges
   ------------------------- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 52px;
  text-align: center;
  background: #e9ecef;
  color: #333;
}

.badge-b1  { background: var(--badge-b1);  color: #000; }
.badge-b2a { background: var(--badge-b2a); color: #000; }
.badge-b2b { background: var(--badge-b2b); color: #000; }
.badge-b3a { background: var(--badge-b3a); color: #000; }
.badge-b3b { background: var(--badge-b3b); color: #000; }
.badge-b4  { background: var(--badge-b4);  color: #000; }

/* -------------------------
   Utility
   ------------------------- */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* -------------------------
   Category legend
   ------------------------- */
details.legend {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  overflow: hidden;
}

details.legend summary {
  cursor: pointer;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}

details.legend summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.15s;
}

details[open].legend summary::before {
  transform: rotate(90deg);
}

details.legend summary:hover {
  background: #f1f3f5;
}

.legend-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.75rem;
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
}

.legend-grid .lg-cat {
  font-weight: 700;
  white-space: nowrap;
  padding: 0.2rem 0;
}

.legend-grid .lg-desc {
  color: var(--color-muted);
  padding: 0.2rem 0;
  border-bottom: 1px solid #f1f3f5;
}

.legend-grid .lg-desc:last-child {
  border-bottom: none;
}

/* Summary table: show cursor hint that tooltip is available */
#summary-table td[title] {
  cursor: help;
  text-decoration: underline dotted var(--color-muted);
  text-underline-offset: 2px;
}

/* -------------------------
   Responsive
   ------------------------- */
@media (max-width: 640px) {
  body { padding: 0.5rem; }

  #week-header { gap: 0.5rem; }

  .entry-row select        { width: 55px; }
  .entry-row .entry-start { width: 65px; }
  .entry-row input[type="number"] { width: 60px; }

  thead th, tbody td { padding: 0.3rem 0.4rem; }
}
