/* Recurring page sort + filter toolbar. One row on desktop, two rows at 720px. */

/* `.recurring-row{display:grid}` in styles.css and the `display: grid` below
   both out-specify the UA `[hidden]{display:none}` rule, so a filtered-out row
   and a dismissed empty panel stayed on screen while the count said otherwise.
   These are the only two nodes this layer toggles, so scope the override to
   them rather than reaching for a global `[hidden]` rule. */
#recurringList .recurring-row[hidden],
.recurring-filter-empty[hidden] {
  display: none !important;
}

.recurring-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 12px;
}

.recurring-toolbar-field {
  display: grid;
  min-width: 0;
  /* The global label rule adds a 14px bottom margin that would knock the
     direction toggle out of line with the selects. */
  margin: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.recurring-toolbar-field select {
  min-height: 38px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card, #fff);
  color: var(--ink);
  font: 700 13px 'DM Sans', system-ui, sans-serif;
  text-transform: none;
}

/* A 40% green mix over the card fill lands at 1.80:1 (light) / 1.81:1
   (midnight) against the surface behind the ring, under the 3:1 WCAG 1.4.11
   floor. Solid --green is ~5:1 in both themes. */
.recurring-toolbar-field select:focus-visible,
.recurring-sort-direction:focus-visible,
.recurring-toolbar-clear:focus-visible,
.recurring-filter-empty .primary:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

.recurring-sort-direction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card, #fff);
  color: var(--ink);
  font: 800 15px 'DM Sans', system-ui, sans-serif;
  line-height: 1;
  cursor: pointer;
}

.recurring-sort-direction:hover {
  border-color: color-mix(in srgb, var(--green) 40%, var(--line));
}

.recurring-toolbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding-bottom: 8px;
}

.recurring-toolbar-clear {
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  font: 800 12px 'DM Sans', system-ui, sans-serif;
  text-decoration: underline;
  cursor: pointer;
}

.recurring-result-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.recurring-filter-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--card);
  text-align: center;
}

.recurring-filter-empty h3 { margin: 0; font: 800 18px Manrope, system-ui, sans-serif; }
.recurring-filter-empty p { max-width: 440px; margin: 0 0 4px; color: var(--muted); line-height: 1.55; }
.recurring-filter-empty .primary { width: auto; min-width: 180px; }

/* Selects already inherit the midnight input fill; the toggle is a button. */
body[data-theme="midnight"] .recurring-sort-direction {
  background: #171e34;
  border-color: var(--line);
  color: var(--ink);
}

/* Two rows under 720px: sort + direction + count first, the two filters second.
   `order` keeps the count on the first line without moving it ahead of the
   controls in the DOM. */
@media (max-width: 720px) {
  .recurring-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .recurring-toolbar-sort { order: 1; flex: 1 1 auto; }
  .recurring-sort-direction { order: 2; flex: 0 0 44px; width: 44px; min-height: 44px; }
  .recurring-toolbar-status { order: 3; flex: 0 0 auto; padding-bottom: 0; }
  .recurring-toolbar-person { order: 4; flex: 1 1 calc(50% - 4px); }
  .recurring-toolbar-category { order: 5; flex: 1 1 calc(50% - 4px); }

  .recurring-toolbar-field select { min-height: 44px; }
  /* "Clear" is only ~35px of text, so the tap target needs a floor on both axes. */
  .recurring-toolbar-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 4px;
  }
  .recurring-filter-empty { padding: 32px 18px; }
  .recurring-filter-empty .primary { width: 100%; min-height: 44px; }
}
