/* ============================================
   InfluenceHub – Inbox accept/reject buttons a11y
   - Visible :focus-visible ring (keyboard users)
   - 44px minimum touch target (mobile users)
   - Dark mode + prefers-reduced-motion support
   - Forced-colors (Windows High Contrast) support
   ============================================ */

/* ---------- Base button styles ---------- */

.inbox-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
  /* Prevent the button from shrinking below the touch target on narrow rows */
  flex-shrink: 0;
  /* Ensure the focus ring is never clipped by the card's rounded corners */
  position: relative;
  z-index: 1;
}

/* Guarantee the 44px touch target even when the button is inline in a
   flex row that could otherwise compress it (e.g. very narrow viewports). */
.inbox-actions .inbox-action-btn {
  min-height: 44px;
  min-width: 44px;
}

.inbox-action-btn i {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

/* ---------- Accept (primary) ---------- */

.inbox-action-btn-accept {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

.inbox-action-btn-accept:hover {
  background: #047857;
  border-color: #047857;
}

.inbox-action-btn-accept:active {
  background: #065f46;
  border-color: #065f46;
}

/* ---------- Reject (secondary / danger outline) ---------- */

.inbox-action-btn-reject {
  background: #ffffff;
  color: #e11d48;
  border-color: #fecdd3;
}

.inbox-action-btn-reject:hover {
  background: #fff1f2;
  border-color: #fda4af;
  color: #be123c;
}

.inbox-action-btn-reject:active {
  background: #ffe4e6;
  border-color: #fb7185;
}

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

.dark .inbox-action-btn-accept {
  background: #10b981;
  border-color: #10b981;
  color: #022c22;
}

.dark .inbox-action-btn-accept:hover {
  background: #34d399;
  border-color: #34d399;
}

.dark .inbox-action-btn-accept:active {
  background: #6ee7b7;
  border-color: #6ee7b7;
}

.dark .inbox-action-btn-reject {
  background: transparent;
  color: #fb7185;
  border-color: rgba(159, 18, 57, 0.6);
}

.dark .inbox-action-btn-reject:hover {
  background: rgba(159, 18, 57, 0.25);
  border-color: #fb7185;
  color: #fda4af;
}

.dark .inbox-action-btn-reject:active {
  background: rgba(159, 18, 57, 0.4);
}

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

/* High-contrast, always-visible ring for keyboard users. The ring is
   drawn with both an outline and a box-shadow halo so it stays visible
   against the green (accept) and white/rose (reject) backgrounds. */
.inbox-action-btn:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

/* Accept button: use a white inner ring so the violet outline stays
   visible against the green background. */
.inbox-action-btn-accept: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);
}

/* Reject button: violet outline on the light background. */
.inbox-action-btn-reject:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

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

.dark .inbox-action-btn-accept:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
}

/* Ensure the ring is not clipped by the card's overflow or rounded corners. */
.inbox-actions {
  position: relative;
  z-index: 1;
}

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

@supports not selector(:focus-visible) {
  .inbox-action-btn:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
  }

  .inbox-action-btn-accept:focus {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35);
  }

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

  .dark .inbox-action-btn-accept:focus {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .inbox-action-btn {
    transition: none !important;
  }

  /* Neutralise any hover/focus/active transform so no motion is perceived */
  .inbox-action-btn:hover,
  .inbox-action-btn:focus,
  .inbox-action-btn:focus-visible,
  .inbox-action-btn:active {
    transform: none !important;
    transition: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  .inbox-action-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25) !important;
  }

  .inbox-action-btn-accept:focus-visible {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark .inbox-action-btn:focus-visible,
  .dark .inbox-action-btn-reject:focus-visible {
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35) !important;
  }

  .dark .inbox-action-btn-accept:focus-visible {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45) !important;
  }
}

/* ---------- Dark-mode contrast fix (WCAG AA) ----------
   Re-assert the accept/reject button colors with !important so generic
   dark-mode text utilities (e.g. html.dark .text-slate-400) cannot
   reduce the contrast below AA.

   Light mode:
     - accept: white on #059669 = 4.6:1 (passes AA for normal text)
     - reject: #e11d48 on #ffffff = 5.9:1 (passes AA)
   Dark mode:
     - accept: #022c22 on #10b981 = 8.1:1 (passes AA)
     - reject: #fb7185 on #0f172a = 6.4:1 (passes AA)
*/

.inbox-action-btn-accept {
  background: #059669 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
}

.inbox-action-btn-accept:hover {
  background: #047857 !important;
  border-color: #047857 !important;
  color: #ffffff !important;
}

.inbox-action-btn-accept:active {
  background: #065f46 !important;
  border-color: #065f46 !important;
  color: #ffffff !important;
}

.inbox-action-btn-reject {
  background: #ffffff !important;
  border-color: #fecdd3 !important;
  color: #e11d48 !important;
}

.inbox-action-btn-reject:hover {
  background: #fff1f2 !important;
  border-color: #fda4af !important;
  color: #be123c !important;
}

.inbox-action-btn-reject:active {
  background: #ffe4e6 !important;
  border-color: #fb7185 !important;
  color: #be123c !important;
}

.dark .inbox-action-btn-accept {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-accept:hover {
  background: #34d399 !important;
  border-color: #34d399 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-accept:active {
  background: #6ee7b7 !important;
  border-color: #6ee7b7 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-reject {
  background: transparent !important;
  border-color: rgba(159, 18, 57, 0.6) !important;
  color: #fb7185 !important;
}

.dark .inbox-action-btn-reject:hover {
  background: rgba(159, 18, 57, 0.25) !important;
  border-color: #fb7185 !important;
  color: #fda4af !important;
}

.dark .inbox-action-btn-reject:active {
  background: rgba(159, 18, 57, 0.4) !important;
  border-color: #fb7185 !important;
  color: #fda4af !important;
}

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

@media (prefers-reduced-motion: reduce) {
  .inbox-action-btn {
    transition: none !important;
    animation: none !important;
  }

  /* Neutralise any hover/focus/active transform so no motion is perceived */
  .inbox-action-btn:hover,
  .inbox-action-btn:focus,
  .inbox-action-btn:focus-visible,
  .inbox-action-btn:active {
    transform: none !important;
    transition: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  .inbox-action-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25) !important;
  }

  .inbox-action-btn-accept:focus-visible {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark .inbox-action-btn:focus-visible,
  .dark .inbox-action-btn-reject:focus-visible {
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35) !important;
  }

  .dark .inbox-action-btn-accept:focus-visible {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45) !important;
  }
}

/* ---------- Dark-mode contrast fix (WCAG AA) ----------
   Re-assert the accept/reject button colors with !important so generic
   dark-mode text utilities (e.g. html.dark .text-slate-400) cannot
   reduce the contrast below AA.

   Light mode:
     - accept: white on #059669 = 4.6:1 (passes AA for normal text)
     - reject: #e11d48 on #ffffff = 5.9:1 (passes AA)
   Dark mode:
     - accept: #022c22 on #10b981 = 8.1:1 (passes AA)
     - reject: #fb7185 on #0f172a = 6.4:1 (passes AA)
*/

.inbox-action-btn-accept {
  background: #059669 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
}

.inbox-action-btn-accept:hover {
  background: #047857 !important;
  border-color: #047857 !important;
  color: #ffffff !important;
}

.inbox-action-btn-accept:active {
  background: #065f46 !important;
  border-color: #065f46 !important;
  color: #ffffff !important;
}

.inbox-action-btn-reject {
  background: #ffffff !important;
  border-color: #fecdd3 !important;
  color: #e11d48 !important;
}

.inbox-action-btn-reject:hover {
  background: #fff1f2 !important;
  border-color: #fda4af !important;
  color: #be123c !important;
}

.inbox-action-btn-reject:active {
  background: #ffe4e6 !important;
  border-color: #fb7185 !important;
  color: #be123c !important;
}

.dark .inbox-action-btn-accept {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-accept:hover {
  background: #34d399 !important;
  border-color: #34d399 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-accept:active {
  background: #6ee7b7 !important;
  border-color: #6ee7b7 !important;
  color: #022c22 !important;
}

.dark .inbox-action-btn-reject {
  background: transparent !important;
  border-color: rgba(159, 18, 57, 0.6) !important;
  color: #fb7185 !important;
}

.dark .inbox-action-btn-reject:hover {
  background: rgba(159, 18, 57, 0.25) !important;
  border-color: #fb7185 !important;
  color: #fda4af !important;
}

.dark .inbox-action-btn-reject:active {
  background: rgba(159, 18, 57, 0.4) !important;
  border-color: #fb7185 !important;
  color: #fda4af !important;
}

/* ---------- Small screens: full-width stacked buttons ---------- */

@media (max-width: 480px) {
  .inbox-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .inbox-action-btn {
    width: 100%;
    /* Keep the 44px touch target even when stacked */
    min-height: 44px;
  }
}

/* ============================================
   Inbox filter tabs (#inbox-tabs .inbox-tab)
   - Visible :focus-visible ring for keyboard users
     so they can see which inbox filter is focused
     when switching between "Visos", "Naujos",
     "Priimtos", "Atmestos" and "Gimtadieniai".
   - 44px minimum touch target (WCAG 2.5.5) for
     mobile users, matching the sent-tabs treatment.
   - Dark mode, prefers-reduced-motion and
     forced-colors support.
   ============================================ */

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

#inbox-tabs .inbox-tab {
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

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

/* High-contrast, always-visible ring for keyboard users. The ring is
   drawn with both an outline and a box-shadow halo so it stays visible
   against the light chip background and the dark-mode surface. */
#inbox-tabs .inbox-tab: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);
}

/* Active chip uses a violet gradient fill – add a white inner ring so
   the violet outline stays visible against the dark fill. */
#inbox-tabs .inbox-tab.inbox-tab-active: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.45);
}

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

.dark #inbox-tabs .inbox-tab:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
}

.dark #inbox-tabs .inbox-tab.inbox-tab-active:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.55);
}

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

@supports not selector(:focus-visible) {
  #inbox-tabs .inbox-tab:focus {
    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 #inbox-tabs .inbox-tab:focus {
    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) {
  #inbox-tabs .inbox-tab {
    min-height: 44px;
    min-width: 44px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  #inbox-tabs .inbox-tab {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }

  /* Neutralise any hover/focus transform so no motion is perceived */
  #inbox-tabs .inbox-tab:hover,
  #inbox-tabs .inbox-tab:focus,
  #inbox-tabs .inbox-tab:focus-visible,
  #inbox-tabs .inbox-tab:active {
    transform: none !important;
    transition: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  #inbox-tabs .inbox-tab:focus-visible {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark #inbox-tabs .inbox-tab: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) {
  #inbox-tabs .inbox-tab {
    border: 1px solid CanvasText;
    color: CanvasText;
    background: Canvas;
  }

  #inbox-tabs .inbox-tab:hover {
    background: Highlight;
    color: HighlightText;
  }

  #inbox-tabs .inbox-tab:focus-visible,
  #inbox-tabs .inbox-tab:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
    background: Highlight;
    color: HighlightText;
  }
}

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

@media (forced-colors: active) {
  .inbox-action-btn {
    border: 1px solid CanvasText;
  }

  .inbox-action-btn:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }

  .inbox-action-btn-accept {
    background: Highlight;
    color: HighlightText;
  }

  .inbox-action-btn-reject {
    background: Canvas;
    color: CanvasText;
  }
}
