/* ---------------------------------------------------------
   Familieplan — layout og tema
   --------------------------------------------------------- */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #dcdfe6;
  --accent: #3b6ea5;
  --accent-text: #ffffff;
  --danger: #b3453f;
  --today: #fff6e3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .06);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #232830;
    --text: #e7e9ee;
    --muted: #9aa2b1;
    --border: #2f3540;
    --accent: #6ea8e0;
    --accent-text: #10151b;
    --danger: #e0857f;
    --today: #2a2618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body.is-modal { overflow: hidden; }

h2, h3 { margin: 0; font-weight: 650; }

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar__logo { font-size: 20px; }
.topbar__title { letter-spacing: .2px; }
.topbar__add { margin-left: 4px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; }

/* Status for synkronisering — en lille prik med tekst. */
.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.sync[hidden] { display: none; }
.sync::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.sync.is-ok::before { background: #4f9a71; }
.sync.is-syncing::before { background: var(--accent); }
.sync.is-offline, .sync.is-auth { color: var(--danger); }
.sync.is-offline::before, .sync.is-auth::before { background: var(--danger); }

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--accent); color: var(--accent-text); }

/* ---------- Knapper ---------- */

.btn {
  font: inherit;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn--ghost { background: transparent; }

.icon-btn {
  font: inherit;
  font-size: 18px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- Hovedområde og værktøjslinje ---------- */

.main { padding: 16px; max-width: 1500px; margin: 0 auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar__right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.toolbar__title { font-size: 19px; }
.toolbar__nav { display: flex; gap: 6px; align-items: center; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }

.filter {
  font: inherit;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.filter:hover { color: var(--text); }
.filter.is-active {
  border-color: var(--person);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--person);
  background: var(--surface-2);
}

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- Ugestatistik ---------- */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--person);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat__name { font-weight: 600; font-size: 13px; }
.stat__value { font-size: 17px; font-weight: 650; }
.stat__sub { font-size: 12px; color: var(--muted); }

/* ---------- Ugevisning ---------- */

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }

.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
}
.day.is-weekend { background: var(--surface-2); }
.day.is-today { border-color: var(--accent); box-shadow: var(--shadow); }
.day.is-dropzone { outline: 2px dashed var(--accent); outline-offset: 2px; }

.day__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.day__name { font-weight: 650; font-size: 13px; }
.day__date { display: block; font-size: 12px; color: var(--muted); }
.day__count {
  font-size: 11px;
  font-weight: 650;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}
.day.is-weekend .day__count { background: var(--surface); }
.day__list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.day__empty { margin: 0; font-size: 12px; color: var(--muted); }

.day__add {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text);
  width: 100%;
}
.day__add:focus { border-style: solid; border-color: var(--accent); outline: none; }

/* ---------- Kort ---------- */

.card {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--person);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  cursor: grab;
}
.day.is-weekend .card { background: var(--surface); }
.card:hover { box-shadow: var(--shadow); }
.card.is-dragging { opacity: .45; }
.card.is-high { border-left-width: 5px; }
.card--event { background: color-mix(in srgb, var(--person) 9%, var(--surface)); }

.card__check {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.card__check:hover { border-color: var(--person); }
.card.is-done .card__check { background: var(--person); border-color: var(--person); }
.card.is-done .card__check::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.card__body { flex: 1; min-width: 0; cursor: pointer; }
.card__body:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.card__title { font-size: 13.5px; overflow-wrap: anywhere; }
.card.is-done .card__title { text-decoration: line-through; color: var(--muted); }
.card.is-high .card__title { font-weight: 600; }

.card__meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.card__time { font-weight: 650; color: var(--text); }
.card.is-done .card__time { color: var(--muted); font-weight: 550; }
.card__repeat, .card__note-flag { font-size: 12px; }

.chip {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--person);
  border: 1px solid color-mix(in srgb, var(--person) 45%, transparent);
  background: color-mix(in srgb, var(--person) 12%, transparent);
  white-space: nowrap;
}

/* ---------- Månedsvisning ---------- */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.mhead { font-size: 12px; font-weight: 650; color: var(--muted); padding: 2px 4px; }

.mcell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mcell.is-outside { opacity: .5; }
.mcell.is-weekend { background: var(--surface-2); }
.mcell.is-today { border-color: var(--accent); background: var(--today); }
.mcell.is-dropzone { outline: 2px dashed var(--accent); outline-offset: 2px; }

.mcell__head { display: flex; align-items: center; justify-content: space-between; }
.mcell__num { font-size: 12px; font-weight: 650; color: var(--muted); }
.mcell.is-today .mcell__num { color: var(--accent); }

.mcell__add {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  padding: 0 2px;
}
.mcell:hover .mcell__add, .mcell__add:focus { opacity: 1; }

.mcell__list { display: flex; flex-direction: column; gap: 4px; overflow: auto; max-height: 190px; }
.mcell .card { padding: 4px 6px; }
.mcell .card__title { font-size: 12.5px; }

.month-agenda { display: none; }
.agenda__day { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.agenda__title { font-size: 14px; color: var(--muted); }
.agenda__day.is-today .agenda__title { color: var(--accent); }

/* ---------- To-do ---------- */

.quickadd { margin-bottom: 14px; }
.quickadd .input { max-width: 520px; }

.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.group__title { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.group__count {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
}
.group__list { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Indkøb ---------- */

.slist {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.srow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.srow:last-child { border-bottom: 0; }
.srow__label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.srow input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.srow.is-done span { text-decoration: line-through; color: var(--muted); }

/* ---------- Indstillinger ---------- */

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel__title { font-size: 15px; }
.panel__hint, .panel__stats { margin: 0; font-size: 13px; color: var(--muted); }
.panel__list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }

kbd {
  font: inherit;
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- Formularfelter ---------- */

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field--color { flex: 0 0 92px; }

.input {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input--color { padding: 2px; height: 38px; }
textarea.input { resize: vertical; }

.form__actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* ---------- Dialog ---------- */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(10, 14, 20, .5); }

.modal__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal__head h2 { font-size: 17px; }

/* ---------- Diverse ---------- */

.empty {
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* ---------- Responsivt ---------- */

@media (max-width: 1100px) {
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day { min-height: 0; }
}

@media (max-width: 820px) {
  .main { padding: 12px; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .topbar__add { order: 3; }
  .tabs { order: 4; width: 100%; overflow-x: auto; }
  .week { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .month-grid, .mhead { display: none; }
  .month-agenda { display: block; }
  .toolbar__right { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .card, .btn, .tab, .filter { transition: background-color .12s ease, box-shadow .12s ease, opacity .12s ease; }
}
