/* WGroups V13 UI Fix: V7-style UI + stable dark/light + safe refresh + elevated Join */
:root {
  --wg-green: #25d366;
  --wg-green-2: #10b964;
  --wg-green-dark: #075e54;
  --wg-mint: #e9fff3;
  --wg-light-bg: #f3fbf6;
  --wg-light-card: rgba(255, 255, 255, 0.96);
  --wg-dark-bg: #07130f;
  --wg-dark-card: rgba(13, 30, 24, 0.96);
  --wg-card-shadow: 0 12px 30px rgba(4, 120, 62, 0.10), 0 3px 10px rgba(15, 23, 42, 0.06);
}

html {
  background: var(--bg);
}

html:not(.dark) body.wg-v7-ui,
html:not(.dark) body {
  background:
    radial-gradient(circle at top left, rgba(37, 211, 102, .18), transparent 32%),
    radial-gradient(circle at top right, rgba(7, 94, 84, .12), transparent 35%),
    linear-gradient(180deg, #f6fff9 0%, #eefaf3 48%, #f7faf6 100%) !important;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

html.dark body.wg-v7-ui,
html.dark body {
  background:
    radial-gradient(circle at top left, rgba(37, 211, 102, .13), transparent 30%),
    radial-gradient(circle at top right, rgba(7, 94, 84, .28), transparent 38%),
    linear-gradient(180deg, #06100d 0%, #081813 52%, #050b09 100%) !important;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body.wg-v7-ui header.sticky,
body header.sticky {
  border-bottom: 0 !important;
  background: linear-gradient(135deg, #087b5f, #0aae5d 55%, #23d366) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 28px rgba(6, 95, 70, 0.24) !important;
}

body.wg-v7-ui header.sticky h1,
body header.sticky h1,
body.wg-v7-ui header.sticky span,
body header.sticky span {
  color: #ffffff !important;
}

body.wg-v7-ui header.sticky button,
body header.sticky button {
  color: #ffffff !important;
  background: rgba(255, 255, 255, .14) !important;
  backdrop-filter: blur(8px);
}

html.dark body.wg-v7-ui header.sticky,
html.dark body header.sticky {
  background: linear-gradient(135deg, #064e3b, #087b5f 55%, #10b964) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .38) !important;
}

body.wg-v7-ui main {
  background: var(--card) !important;
}

.wg-group-card,
.wg-v7-card,
body.wg-v7-ui article,
body.wg-v7-ui [class*="rounded-3xl"][class*="bg-[var(--card)]"],
body.wg-v7-ui [class*="rounded-2xl"][class*="bg-[var(--card)]"] {
  border: 1px solid var(--border) !important;
  background: var(--card) !important;
  box-shadow: var(--wg-card-shadow) !important;
  backdrop-filter: blur(10px);
}

html.dark .wg-group-card,
html.dark .wg-v7-card,
html.dark body.wg-v7-ui article {
  box-shadow: 0 12px 30px rgba(0, 0, 0, .34), 0 2px 8px rgba(37, 211, 102, .08) !important;
}

body.wg-v7-ui input,
body.wg-v7-ui select,
body.wg-v7-ui textarea {
  border-radius: 18px !important;
  border-color: var(--border) !important;
  background: var(--card) !important;
  color: var(--text) !important;
  box-shadow: 0 8px 24px rgba(6, 95, 70, .07) !important;
}

html.dark body.wg-v7-ui input,
html.dark body.wg-v7-ui select,
html.dark body.wg-v7-ui textarea {
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22) !important;
}

body.wg-v7-ui nav.fixed.bottom-0 > div,
body nav.fixed.bottom-0 > div {
  border: 1px solid var(--border) !important;
  border-bottom: 0 !important;
  background: color-mix(in srgb, var(--card) 94%, transparent) !important;
  box-shadow: 0 -12px 30px rgba(6, 95, 70, .11) !important;
  backdrop-filter: blur(16px);
}

html.dark body.wg-v7-ui nav.fixed.bottom-0 > div,
html.dark body nav.fixed.bottom-0 > div {
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .38) !important;
}

body.wg-v7-ui nav.fixed.bottom-0 a[href*="add-group"] div,
body nav.fixed.bottom-0 a[href*="add-group"] div {
  background: linear-gradient(135deg, #17dd75, #00a856) !important;
  box-shadow: 0 14px 28px rgba(0, 168, 86, .32), 0 4px 12px rgba(0, 80, 40, .18) !important;
}

/* Join button stable: visible in small cards, no text clipping */
.wag-join-button,
.wag-join-elevated,
button.wag-join-button,
button.wag-join-elevated,
a.wag-join-elevated {
  display: inline-flex !important;
  min-width: 86px !important;
  height: 40px !important;
  align-items: center !important;
  justify-content: center !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 0 18px !important;
  background: linear-gradient(135deg, #00d96b, #009846) !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  letter-spacing: .2px !important;
  white-space: nowrap !important;
  box-shadow: 0 12px 22px rgba(0, 160, 82, .32), 0 3px 8px rgba(0, 80, 40, .18) !important;
  transform: translateZ(0);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease !important;
}

.wag-join-button:active,
.wag-join-elevated:active {
  transform: translateY(1px) scale(.985) !important;
  box-shadow: 0 6px 14px rgba(0, 130, 65, .26) !important;
  filter: brightness(.98);
}

/* Hard-coded old dist classes still become dark-safe */
html.dark .bg-white {
  background-color: var(--card) !important;
}
html.dark .border-gray-100 {
  border-color: var(--border) !important;
}
html.dark .text-gray-500 {
  color: var(--muted) !important;
}

/* React pull-to-refresh indicator: below sticky header, no overlap with status bar/header */
.wg-pull-indicator {
  pointer-events: none;
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  z-index: 45;
  display: inline-flex;
  min-width: 168px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(37, 211, 102, .18);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0, 120, 60, .20), 0 2px 8px rgba(15, 23, 42, .10);
  backdrop-filter: blur(14px);
  will-change: transform, opacity;
}

html.dark .wg-pull-indicator {
  border-color: rgba(37, 211, 102, .22);
  background: rgba(9, 24, 19, .96);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .34);
}

/* External dist-only pull refresh uses this id. It is intentionally below header. */
#wg-pull-refresh {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 50%;
  transform: translate3d(-50%, -70px, 0);
  z-index: 45;
  min-width: 168px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(37, 211, 102, .18);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: Poppins, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 900;
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(0, 120, 60, .20), 0 2px 8px rgba(15, 23, 42, .10);
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms ease, opacity 160ms ease;
  backdrop-filter: blur(14px);
  will-change: transform, opacity;
}
#wg-pull-refresh.wg-visible {
  opacity: 1;
}
#wg-pull-refresh.wg-ready,
#wg-pull-refresh.wg-refreshing {
  color: #ffffff;
  background: linear-gradient(135deg, #00d66b, #009846);
}
#wg-pull-refresh .wg-spinner {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2.4px solid currentColor;
  border-top-color: transparent;
  box-sizing: border-box;
}
#wg-pull-refresh.wg-refreshing .wg-spinner {
  animation: wg-spin .75s linear infinite;
}
@keyframes wg-spin {
  to { transform: rotate(360deg); }
}

body.wg-v7-ui .overflow-x-auto {
  scrollbar-width: none;
}
body.wg-v7-ui .overflow-x-auto::-webkit-scrollbar {
  display: none;
}



/* V13.2 original-safe mini patch: join button, long names, image fallback layout */
.line-clamp-2 {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wg-group-card {
  overflow: hidden !important;
}

.wg-group-card h3 {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.22 !important;
}

.wg-group-card .wag-join-button,
button.wag-join-button {
  width: auto !important;
  min-width: 76px !important;
  max-width: 86px !important;
  height: 38px !important;
  padding: 0 15px !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: linear-gradient(135deg, #00d96b, #009846) !important;
  color: #ffffff !important;
  font-size: 12.5px !important;
  font-weight: 900 !important;
  text-align: center !important;
  box-shadow:
    0 10px 20px rgba(0, 160, 82, .30),
    inset 0 1px 0 rgba(255, 255, 255, .28) !important;
}

.wg-group-card .wag-join-button:active {
  transform: scale(.97);
}

.wg-group-card button:not(.wag-join-button) {
  min-width: 0;
}

.wg-group-card [class*="Views"] {
  white-space: nowrap;
}
