/* Checklove — styles on top of Bootstrap 5.3 */

:root,
[data-bs-theme="light"] {
  --cl-bg: #f8f9fa;
  --cl-card: #ffffff;
  --cl-border: #e5e7eb;
  --cl-text: #1f2328;
  --cl-muted: #5f6670;
  --cl-faint: #6b7280;
  --cl-accent: #f59e0b;        /* buttons, checkboxes */
  --cl-on-accent: #1f1300;     /* text on amber */
  --cl-accent-text: #c2410c;   /* links / text accents (readable on white) */
  --cl-accent-soft: #fff4e0;
  --cl-accent-soft-text: #9a3412;
  --cl-high: #dc2626;
  --cl-low: #9ca3af;
  --cl-overdue: #b91c1c;
  --cl-overdue-bg: #fde8e8;
  --cl-chip: #eef0f3;
  --cl-tag-bg: #f1f2f4;
  --bs-body-bg: var(--cl-bg);
  --bs-body-color: var(--cl-text);
  --bs-link-color-rgb: 194, 65, 12;
  --bs-link-hover-color-rgb: 154, 52, 18;
  --bs-border-color: #d0d5dc;
}

[data-bs-theme="dark"] {
  --cl-bg: #16181c;
  --cl-card: #1f2226;
  --cl-border: #2e3238;
  --cl-text: #e8eaed;
  --cl-muted: #a0a6af;
  --cl-faint: #8a9099;
  --cl-accent-text: #fbbf24;
  --cl-accent-soft: #3a2a12;
  --cl-accent-soft-text: #fcd34d;
  --cl-high: #f87171;
  --cl-low: #6b7280;
  --cl-overdue: #f87171;
  --cl-overdue-bg: #3a1f22;
  --cl-chip: #2a2e34;
  --cl-tag-bg: #2a2e34;
  --bs-body-bg: var(--cl-bg);
  --bs-body-color: var(--cl-text);
  --bs-link-color-rgb: 251, 191, 36;
  --bs-link-hover-color-rgb: 252, 211, 77;
  --bs-border-color: #3a3f46;
}

body {
  background: var(--cl-bg);
  color: var(--cl-text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Buttons & form bits ---------- */
.btn-amber {
  --bs-btn-bg: var(--cl-accent);
  --bs-btn-border-color: var(--cl-accent);
  --bs-btn-color: var(--cl-on-accent);
  --bs-btn-hover-bg: #e8900a;
  --bs-btn-hover-border-color: #e8900a;
  --bs-btn-hover-color: var(--cl-on-accent);
  --bs-btn-active-bg: #d97706;
  --bs-btn-active-border-color: #d97706;
  --bs-btn-active-color: var(--cl-on-accent);
  --bs-btn-disabled-bg: var(--cl-accent);
  --bs-btn-disabled-border-color: var(--cl-accent);
  --bs-btn-disabled-color: var(--cl-on-accent);
  font-weight: 600;
}
.btn, .form-control, .form-select { min-height: 44px; }
.form-control, .form-select { font-size: 16px; } /* stops iOS zooming into inputs */
.form-control:focus, .form-select:focus {
  border-color: var(--cl-accent);
  box-shadow: 0 0 0 .2rem rgba(245, 158, 11, .25);
}
.form-check-input:checked { background-color: var(--cl-accent); border-color: var(--cl-accent); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(245, 158, 11, .25); border-color: var(--cl-accent); }
.btn-check:checked + .btn-outline-seg {
  background: var(--cl-accent-soft);
  color: var(--cl-accent-soft-text);
  border-color: var(--bs-border-color);
  font-weight: 700;
}
.btn-outline-seg { border-color: var(--bs-border-color); color: var(--cl-text); }
.btn-check:checked + .btn-outline-seg.seg-high { background: var(--cl-overdue-bg); color: var(--cl-overdue); }
.seg-mark { display: inline-block; width: 4px; height: 14px; border-radius: 2px; margin-right: 6px; vertical-align: -2px; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--cl-text);
  border-radius: 8px; padding: 0;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--cl-chip); }
.icon-btn.muted { color: var(--cl-muted); }

.visually-hidden-focusable:not(:focus) { position: absolute !important; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1020;
  height: 56px; padding: 0 8px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--cl-card); border-bottom: 1px solid var(--cl-border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--cl-text); font-weight: 700; font-size: 19px; }
.brand:hover { color: var(--cl-text); }

.page { max-width: 640px; margin: 0 auto; padding: 20px 16px 96px; }
.section-label {
  font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--cl-muted); margin: 0 0 10px;
}
.card-cl { background: var(--cl-card); border: 1px solid var(--cl-border); border-radius: 12px; }

/* ---------- Home: list cards ---------- */
.list-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin-bottom: 12px;
  text-decoration: none; color: var(--cl-text);
}
.list-card:hover { color: var(--cl-text); border-color: var(--cl-accent); }
.list-card .name { font-size: 17px; font-weight: 600; }
.list-card .meta { font-size: 14px; color: var(--cl-muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill-overdue { background: var(--cl-overdue-bg); color: var(--cl-overdue); }
.pill-edit { background: var(--cl-accent-soft); color: var(--cl-accent-soft-text); }
.pill-view { background: var(--cl-chip); color: var(--cl-muted); }
.empty { color: var(--cl-muted); text-align: center; padding: 28px 12px; }

.fab {
  position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1030;
  width: 60px; height: 60px; border-radius: 30px; border: 0;
  background: var(--cl-accent); color: var(--cl-on-accent);
  box-shadow: 0 4px 14px rgba(180, 83, 9, .35);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- List page ---------- */
.list-header {
  position: sticky; top: 56px; z-index: 1010;
  display: flex; align-items: center; gap: 4px;
  min-height: 60px; padding: 0 4px;
  background: var(--cl-card); border-bottom: 1px solid var(--cl-border);
}
.list-header .title-block { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-header .title { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counts { font-size: 13px; color: var(--cl-muted); }
.count-hidden { color: var(--cl-faint); }
/* "Show done" switch in the list header */
.hide-btn {
  min-height: 44px; padding: 0 8px; margin: 0; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--cl-muted);
}
.hide-btn.form-switch { padding-left: 8px; }
.hide-btn.form-switch .form-check-input { float: none; margin: 0; width: 36px; height: 20px; cursor: pointer; }
.board-inner { max-width: 640px; margin: 0 auto; padding: 12px 16px 48px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--cl-chip); background: var(--cl-chip); color: var(--cl-text);
  font-size: 14px; font-weight: 600;
}
.chip.active { background: var(--cl-accent); border-color: var(--cl-accent); color: var(--cl-on-accent); }
.view-note { font-size: 14px; color: var(--cl-muted); background: var(--cl-chip); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }

.group { margin-bottom: 14px; overflow: hidden; }
.item-list { min-height: 8px; }
.item-list:empty { min-height: 44px; }
.item-list:empty::after {
  content: "Drop items here"; display: block; text-align: center;
  font-size: 13px; color: var(--cl-faint); padding: 12px;
}
.root-list:empty::after { content: none; }
.root-list:empty { min-height: 0; }
.group.root-group:has(.root-list:empty) { display: none; }
body.dragging .group.root-group { display: block !important; }
body.dragging .root-list:empty { min-height: 44px; }

.item-row {
  display: flex; align-items: center; min-height: 56px;
  border-left: 4px solid transparent; border-bottom: 1px solid var(--cl-border);
  background: var(--cl-card);
}
.item-list > .item-row:last-child { border-bottom: 0; }
.item-row.prio-high { border-left-color: var(--cl-high); }
.item-row.prio-low  { border-left-color: var(--cl-low); }
.drag-handle {
  width: 26px; align-self: stretch; padding-left: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cl-faint); cursor: grab; touch-action: none; flex-shrink: 0;
}
.check-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; padding: 0;
}
.box {
  width: 22px; height: 22px; border-radius: 6px; box-sizing: border-box;
  border: 2px solid var(--cl-faint);
  display: flex; align-items: center; justify-content: center; color: var(--cl-on-accent);
}
.done .box { background: var(--cl-accent); border-color: var(--cl-accent); }
.item-body {
  flex: 1; min-width: 0; padding: 10px 12px 10px 0;
  display: flex; flex-direction: column; gap: 4px;
  border: 0; background: transparent; text-align: left; color: var(--cl-text);
}
.item-row:not(.can-edit) .item-body { padding-left: 12px; }
.item-text { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.done .item-text { text-decoration: line-through; color: var(--cl-faint); }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.due, .tag { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--cl-tag-bg); color: var(--cl-muted); }
.due { font-weight: 600; }
.due.overdue { background: var(--cl-overdue-bg); color: var(--cl-overdue); }
.due.soon { background: var(--cl-accent-soft); color: var(--cl-accent-soft-text); }

.section-header { display: flex; align-items: center; border-bottom: 1px solid var(--cl-border); }
.group.collapsed .section-header { border-bottom: 0; }
.section-handle { width: 26px; align-self: stretch; display: flex; align-items: center; justify-content: center; color: var(--cl-faint); cursor: grab; touch-action: none; }
.section-toggle {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 0 0 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 0; background: transparent; color: var(--cl-text); text-align: left;
}
.section-toggle .chev { color: var(--cl-muted); transition: transform .15s; }
.group.collapsed .chev { transform: rotate(-90deg); }
.section-name { font-size: 16px; font-weight: 700; }
/* Add-item field inside a section: same look as the one at the top of the list */
.add-row { padding: 10px 12px; border-top: 1px solid var(--cl-border); }
.add-row .form-control { height: 44px; border-radius: 10px; }

.quick-add { margin-bottom: 14px; }
.quick-add .form-control { height: 48px; border-radius: 10px; }

/* Sortable states */
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }

/* ---------- Modal as a bottom sheet on phones ---------- */
.modal-content { background: var(--cl-card); border: 0; border-radius: 16px; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--bs-border-color); margin: 10px auto 0; }
@media (max-width: 575.98px) {
  .modal-dialog.modal-sheet {
    margin: 0; max-width: none; width: 100%;
    min-height: 100%; align-items: flex-end;
  }
  .modal.fade .modal-dialog.modal-sheet { transform: translateY(40px); }
  .modal.show .modal-dialog.modal-sheet { transform: none; }
  .modal-sheet .modal-content { border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.modal-header, .modal-footer { border: 0; }
.modal-title { font-weight: 700; font-size: 19px; }

/* ---------- Share & admin rows ---------- */
.person-row { display: flex; align-items: center; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--cl-border); }
.person-row:last-child { border-bottom: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  background: var(--cl-chip); color: var(--cl-muted);
}
.avatar.me { background: var(--cl-accent-soft); color: var(--cl-accent-soft-text); }
.user-row { display: flex; align-items: center; gap: 4px; padding: 8px 4px 8px 16px; min-height: 60px; border-bottom: 1px solid var(--cl-border); }
.user-row:last-child { border-bottom: 0; }
.text-danger-cl { color: var(--cl-overdue) !important; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; max-width: 420px; margin: 0 auto; gap: 28px; }
.auth-logo { width: 72px; height: 72px; border-radius: 18px; background: var(--cl-card); box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }

/* Modal header: close button on the right */
.modal-header .icon-btn { margin-left: auto; flex-shrink: 0; }
.modal-body { padding-top: 4px; }

/* Readable secondary buttons */
.btn-outline-secondary {
  --bs-btn-color: var(--cl-text);
  --bs-btn-border-color: var(--bs-border-color);
  --bs-btn-hover-bg: var(--cl-chip);
  --bs-btn-hover-color: var(--cl-text);
  --bs-btn-hover-border-color: var(--bs-border-color);
  --bs-btn-active-bg: var(--cl-chip);
  --bs-btn-active-color: var(--cl-text);
}

/* ---------- Waiting for the server ---------- */
/* .on: blocks taps and shows the top bar at once. .slow (added after 300 ms): dims the page and shows the box. */
.busy { position: fixed; inset: 0; z-index: 2000; display: none; }
.busy.on { display: flex; align-items: center; justify-content: center; }
.busy.slow { background: rgba(15, 17, 20, .38); }
.busy-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; overflow: hidden; background: rgba(245, 158, 11, .25); }
.busy-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%;
  background: var(--cl-accent); animation: busy-slide 1.1s ease-in-out infinite;
}
@keyframes busy-slide { from { left: -40%; } to { left: 100%; } }
.busy-box {
  display: none; align-items: center; gap: 12px; padding: 14px 20px;
  border-radius: 14px; background: var(--cl-card); color: var(--cl-text);
  border: 1px solid var(--cl-border); box-shadow: 0 8px 28px rgba(0, 0, 0, .25); font-weight: 600;
}
.busy.slow .busy-box { display: flex; }
.busy-box .spinner-border { width: 22px; height: 22px; border-width: 3px; color: var(--cl-accent); }
@media (prefers-reduced-motion: reduce) { .busy-bar::after { animation-duration: 3s; } }

/* Message when a request fails */
.net-toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 2001;
  max-width: 420px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: var(--cl-overdue-bg); color: var(--cl-overdue); border: 1px solid var(--cl-overdue);
  font-weight: 600; text-align: center; display: none;
}
.net-toast.show { display: block; }

/* ---------- Tag suggestions in the edit dialog ---------- */
.tag-group-label { font-size: 12px; font-weight: 600; color: var(--cl-muted); margin-top: 12px; }
.tag-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tag-pick {
  height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--bs-border-color); background: transparent; color: var(--cl-text);
  font-size: 14px;
}
.tag-pick.active {
  background: var(--cl-accent-soft); color: var(--cl-accent-soft-text);
  border-color: var(--cl-accent); font-weight: 600;
}

/* Home: items due within the next few days */
.pill-soon { background: var(--cl-accent-soft); color: var(--cl-accent-soft-text); }
