/* ============================================
   InfluenceHub – "Pažymėti visus matomus" a11y
   - Visible :focus-visible ring for the
     #select-all-visible checkbox label so keyboard
     users can see which control is focused when
     bulk-selecting visible creators.
   - 44px minimum touch target (WCAG 2.5.5) for
     mobile users on the label.
   - Dark mode, prefers-reduced-motion and
     forced-colors support.
   ============================================ */

/* ---------- Base: 44px minimum touch target ---------- */

label[for="select-all-visible"] {
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  border-radius: 0.75rem;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

/* ---------- Focus-visible ring (keyboard) ---------- */

/* The label wraps a native checkbox. When the checkbox receives focus
   via keyboard, :focus-visible matches on the input; we forward the
   ring to the label using :focus-within so the whole pill is outlined. */
label[for="select-all-visible"]:focus-within,
label[for="select-all-visible"]:has(#select-all-visible:focus-visible) {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 6px rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.06);
  border-color: #c4b5fd;
}

/* Direct focus on the checkbox itself – keep the native ring visible
   and high-contrast so it is never lost inside the label. */
#select-all-visible:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

/* ---------- Dark mode ---------- */

.dark label[for="select-all-visible"]:focus-within,
.dark label[for="select-all-visible"]:has(#select-all-visible:focus-visible) {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
  background: rgba(196, 181, 253, 0.1);
  border-color: #8b5cf6;
}

.dark #select-all-visible:focus-visible {
  outline-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
}

/* ---------- Fallback for browsers without :focus-visible ---------- */

@supports not selector(:focus-visible) {
  label[for="select-all-visible"]:focus-within {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35);
  }

  .dark label[for="select-all-visible"]:focus-within {
    outline-color: #c4b5fd;
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45);
  }
}

/* ---------- Small screens: keep the 44px target ---------- */

@media (max-width: 480px) {
  label[for="select-all-visible"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  label[for="select-all-visible"],
  #select-all-visible {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }

  /* Neutralise any hover/focus transform so no motion is perceived */
  label[for="select-all-visible"]:hover,
  label[for="select-all-visible"]:focus,
  label[for="select-all-visible"]:focus-within,
  label[for="select-all-visible"]:active {
    transform: none !important;
    transition: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  label[for="select-all-visible"]:focus-within,
  label[for="select-all-visible"]:has(#select-all-visible:focus-visible) {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark label[for="select-all-visible"]:focus-within,
  .dark label[for="select-all-visible"]:has(#select-all-visible:focus-visible) {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45) !important;
  }
}

/* ---------- Forced colors (Windows High Contrast) ---------- */

@media (forced-colors: active) {
  label[for="select-all-visible"] {
    border: 1px solid CanvasText;
    color: CanvasText;
    background: Canvas;
  }

  label[for="select-all-visible"]:hover {
    background: Highlight;
    color: HighlightText;
  }

  label[for="select-all-visible"]:focus-within,
  label[for="select-all-visible"]:has(#select-all-visible:focus-visible),
  #select-all-visible:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
    background: Highlight;
    color: HighlightText;
  }
}
