/* shadcn-vue design tokens, hand-ported: no build step, no Tailwind.
   Values are the stock "slate" theme from ui.shadcn.com, converted to
   plain custom properties so a CDN Vue page can use them directly. */
:root {
  --background: hsl(0 0% 100%);
  --foreground: hsl(222.2 84% 4.9%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(222.2 84% 4.9%);
  --primary: hsl(222.2 47.4% 11.2%);
  --primary-foreground: hsl(210 40% 98%);
  --secondary: hsl(210 40% 96.1%);
  --secondary-foreground: hsl(222.2 47.4% 11.2%);
  --muted: hsl(210 40% 96.1%);
  --muted-foreground: hsl(215.4 16.3% 46.9%);
  --accent: hsl(210 40% 96.1%);
  --accent-foreground: hsl(222.2 47.4% 11.2%);
  --destructive: hsl(0 72.2% 50.6%);
  --destructive-foreground: hsl(210 40% 98%);
  --success: hsl(142.1 70.6% 35.3%);
  --warning: hsl(32.1 94.6% 43.7%);
  --progress: hsl(280 65% 52%);
  --border: hsl(214.3 31.8% 91.4%);
  --input: hsl(214.3 31.8% 91.4%);
  --ring: hsl(222.2 84% 4.9%);
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: hsl(222.2 84% 4.9%);
    --foreground: hsl(210 40% 98%);
    --card: hsl(222.2 84% 4.9%);
    --card-foreground: hsl(210 40% 98%);
    --primary: hsl(210 40% 98%);
    --primary-foreground: hsl(222.2 47.4% 11.2%);
    --secondary: hsl(217.2 32.6% 17.5%);
    --secondary-foreground: hsl(210 40% 98%);
    --muted: hsl(217.2 32.6% 17.5%);
    --muted-foreground: hsl(215 20.2% 65.1%);
    --accent: hsl(217.2 32.6% 17.5%);
    --accent-foreground: hsl(210 40% 98%);
    --destructive: hsl(0 62.8% 55%);
    --destructive-foreground: hsl(210 40% 98%);
    --success: hsl(142.1 70.6% 45.3%);
    --warning: hsl(32.1 94.6% 55%);
    --progress: hsl(280 75% 70%);
    --border: hsl(217.2 32.6% 17.5%);
    --input: hsl(217.2 32.6% 17.5%);
    --ring: hsl(212.7 26.8% 83.9%);
  }
}

:root[data-theme="dark"] {
  --background: hsl(222.2 84% 4.9%);
  --foreground: hsl(210 40% 98%);
  --card: hsl(222.2 84% 4.9%);
  --card-foreground: hsl(210 40% 98%);
  --primary: hsl(210 40% 98%);
  --primary-foreground: hsl(222.2 47.4% 11.2%);
  --secondary: hsl(217.2 32.6% 17.5%);
  --secondary-foreground: hsl(210 40% 98%);
  --muted: hsl(217.2 32.6% 17.5%);
  --muted-foreground: hsl(215 20.2% 65.1%);
  --accent: hsl(217.2 32.6% 17.5%);
  --accent-foreground: hsl(210 40% 98%);
  --destructive: hsl(0 62.8% 55%);
  --destructive-foreground: hsl(210 40% 98%);
  --success: hsl(142.1 70.6% 45.3%);
  --warning: hsl(32.1 94.6% 55%);
  --progress: hsl(280 75% 70%);
  --border: hsl(217.2 32.6% 17.5%);
  --input: hsl(217.2 32.6% 17.5%);
  --ring: hsl(212.7 26.8% 83.9%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Hide the app until Vue has mounted, so the raw template never flashes */
[v-cloak] { display: none; }

/* --- typography --- */
.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

.page-subtitle {
  color: var(--muted-foreground);
  margin: 0.25rem 0 0;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* --- card --- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card + .card { margin-top: 1rem; }

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-content { padding: 1.25rem; }
.card-content.flush { padding: 0; }

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

/* --- filter groups --- */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Checkbox styled as a shadcn "toggle" pill */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.toggle:hover { background: var(--accent); }

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle.is-on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.toggle input:focus-visible + .toggle-box {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* The little check square inside the pill */
.toggle-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.6;
  flex: none;
}

.toggle.is-on .toggle-box { opacity: 1; }
.toggle-box svg { width: 10px; height: 10px; }

/* --- input --- */
.input {
  display: block;
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  font-family: inherit;
}

.input::placeholder { color: var(--muted-foreground); }

.input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -1px;
  border-color: var(--ring);
}

.search-wrap { position: relative; }

.search-wrap .input { padding-left: 2.1rem; }

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted-foreground);
  pointer-events: none;
}

/* --- buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn:hover:not(:disabled) { background: var(--accent); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-icon {
  width: 2.25rem;
  padding: 0;
}

.btn svg { width: 14px; height: 14px; }

/* --- badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-outline {
  border-color: var(--border);
  color: var(--muted-foreground);
}

/* Urgent Meldungen: the one badge that should pull the eye */
.badge-priority {
  background: color-mix(in srgb, var(--destructive) 15%, transparent);
  color: var(--destructive);
  border-color: color-mix(in srgb, var(--destructive) 35%, transparent);
}

.badge-done {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.badge-open {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 35%, transparent);
}

.badge-progress {
  background: color-mix(in srgb, var(--progress) 15%, transparent);
  color: var(--progress);
  border-color: color-mix(in srgb, var(--progress) 35%, transparent);
}

/* --- table --- */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 0;
  border-bottom: 1px solid var(--border);
}

/* Header is a button so sorting is keyboard reachable */
.th-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.th-btn:hover { color: var(--foreground); }

.th-btn .sort-icon {
  width: 12px;
  height: 12px;
  opacity: 0.35;
  flex: none;
}

.th-btn.is-sorted { color: var(--foreground); }
.th-btn.is-sorted .sort-icon { opacity: 1; }

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--muted); }

td.center { text-align: center; }

td.wrap {
  white-space: normal;
  min-width: 16rem;
  max-width: 28rem;
}

.check {
  color: var(--success);
  width: 16px;
  height: 16px;
}

/* Map link styled as a small ghost button */
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  color: var(--foreground);
  text-decoration: none;
  font-size: 0.8rem;
}

.map-link:hover { background: var(--accent); }
.map-link svg { width: 12px; height: 12px; }

/* --- editable status --- */
.status-cell { position: relative; display: inline-flex; align-items: center; gap: 0.35rem; }

/* The badge doubles as the control, so it keeps its colour meaning */
.badge-button {
  border-width: 1px;
  border-style: solid;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  gap: 0.25rem;
}

.badge-button:hover:not(:disabled) { filter: brightness(0.95); }
.badge-button:disabled { opacity: 0.6; cursor: progress; }
.badge-button svg { width: 10px; height: 10px; opacity: 0.7; }

.badge-button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.status-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.status-menu-item {
  display: block;
  padding: 0.2rem 0.3rem;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: none;
  cursor: pointer;
  text-align: left;
}

.status-menu-item:hover { background: var(--accent); }

/* Marks a change that is recorded but not yet in QFieldCloud */
.pending-note {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-style: italic;
  white-space: nowrap;
}

.pending-note.saved { color: var(--success); font-style: normal; }

.status-error {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  color: var(--destructive);
  font-size: 0.85rem;
}

/* --- empty state --- */
.empty {
  padding: 3rem 1.25rem;
  text-align: center;
  color: var(--muted-foreground);
}

.empty svg {
  width: 32px;
  height: 32px;
  opacity: 0.4;
  margin-bottom: 0.75rem;
}

.empty p { margin: 0.25rem 0; }

/* --- footer / pagination --- */
.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- sync line --- */
.sync {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.sync.stale {
  color: var(--destructive);
  font-weight: 500;
}

.sync svg { width: 13px; height: 13px; }

/* --- card list (phones) --- */
/* Two renderings of the same rows; only one is ever displayed. */
.card-list { display: none; }

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row-card {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.row-card:last-child { border-bottom: 0; }

.row-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.row-id {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.row-date {
  margin-left: auto;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  white-space: nowrap;
}

.row-comment {
  margin: 0 0 0.6rem;
  /* Long comments are the reason cards beat a table here - let them wrap */
  overflow-wrap: anywhere;
}

.empty-comment {
  color: var(--muted-foreground);
  font-style: italic;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.row-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.row-assignees {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* --- sort control, only needed where there are no clickable headers --- */
.sort-control {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.sort-control-label {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.select-native {
  width: auto;
  height: 2rem;
  padding: 0 0.5rem;
}



/* --- select / dropdown (shadcn popover + checkbox items) --- */
.select-wrap { position: relative; }

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-width: 14rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
}

.select-trigger:hover { background: var(--accent); }

.select-trigger:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-caret {
  width: 14px;
  height: 14px;
  flex: none;
  opacity: 0.5;
}

.select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  padding: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
}

.select-option:hover { background: var(--accent); }

.select-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.select-option .toggle-box { opacity: 1; }
.select-option-label { flex: 1; }
.muted-label { color: var(--muted-foreground); font-style: italic; }

.select-abbr {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.assignee-list {
  display: inline-flex;
  gap: 0.25rem;
}

td.center { width: 1%; }

.select-count {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.select-action {
  display: block;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: none;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.select-action:hover {
  background: var(--accent);
  color: var(--foreground);
}

.select-sep {
  height: 1px;
  margin: 0.25rem 0;
  background: var(--border);
}

@media (max-width: 768px) {
  body { padding: 1rem 0.75rem 3rem; }
  .card-content { padding: 1rem; }

  /* The table cannot be made readable this narrow, so swap it out */
  .table-scroll { display: none; }
  .card-list { display: block; }
  .sort-control { display: flex; }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .select-trigger { min-width: 0; }

  .table-footer {
    justify-content: space-between;
    row-gap: 0.5rem;
  }

  .header { gap: 0.5rem; }
  .page-title { font-size: 1.25rem; }
}
