/* TrackSOS v1.1.214 — member-facing WhatsApp Communities.
   Separate from Control Room incident-sharing WhatsApp functions. */

.home-community-tab {
  position: absolute;
  z-index: 515;
  top: 50%;
  right: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 72px;
  padding: 11px 7px 10px;
  border: 1px solid rgba(255,255,255,.38);
  border-right: 0;
  border-radius: 18px 0 0 18px;
  background: linear-gradient(145deg, #07111b, #111d29);
  color: #fff;
  box-shadow: 0 12px 34px rgba(5,12,20,.28);
  transform: translateY(-50%);
  cursor: pointer;
}
.home-community-tab span {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border-radius: 50%;
  background: #19a84b;
  color: #fff;
  box-shadow: 0 7px 18px rgba(25,168,75,.32);
}
.home-community-tab b { font-size: .66rem; letter-spacing: .01em; }
.home-community-tab:active { transform: translateY(-50%) scale(.97); }

.community-drawer-backdrop {
  position: fixed;
  z-index: 1200;
  inset: 0;
  background: rgba(3,9,16,.48);
  opacity: 0;
  transition: opacity .22s ease;
  backdrop-filter: blur(3px);
}
.community-drawer-backdrop.open { opacity: 1; }
.community-drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0,1fr) auto auto;
  width: min(92vw, 430px);
  height: 100%;
  padding-top: env(safe-area-inset-top);
  background: #fff;
  box-shadow: -20px 0 56px rgba(3,10,18,.26);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.22,.75,.25,1);
}
.community-drawer.open { transform: translateX(0); }
.community-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.community-drawer-header h2 { margin: 2px 0 4px; color: var(--ink); font-size: 1.35rem; }
.community-drawer-header p { margin: 0; color: var(--muted); font-size: .8rem; }
.community-drawer-header > button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.6rem;
}
.community-drawer-search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  margin: 14px 18px 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--muted);
}
.community-drawer-search input {
  width: 100%;
  min-height: 45px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}
.community-drawer-list {
  min-height: 0;
  padding: 5px 14px 14px;
  overflow: auto;
  overscroll-behavior: contain;
}
.community-drawer-card {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 11px;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(15,29,46,.06);
}
.community-drawer-card-icon,
.community-directory-icon {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e8ebef;
  border-radius: 15px;
  background: #f4f6f8;
  color: var(--red);
}
.community-drawer-card-icon { width: 52px; height: 52px; }
.community-drawer-card-icon img,
.community-directory-icon img { width: 100%; height: 100%; object-fit: cover; }
.community-drawer-card-copy { min-width: 0; }
.community-drawer-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.community-drawer-card-title strong { color: var(--ink); font-size: .86rem; }
.community-drawer-card-title span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #eaf8ef;
  color: #11753a;
  font-size: .58rem;
  font-weight: 800;
}
.community-drawer-card-copy p {
  display: -webkit-box;
  margin: 4px 0 3px;
  overflow: hidden;
  color: #5f6b7c;
  font-size: .69rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.community-drawer-card-copy small { color: #7d8794; font-size: .61rem; }
.community-drawer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 72px;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: #19a84b;
  color: #fff;
  font-size: .69rem;
  font-weight: 750;
}
.community-drawer-action.joined { background: #122033; }
.community-drawer-loading,
.community-drawer-empty {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 40px 22px;
  border: 1px dashed #d7dce3;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.community-drawer-empty strong { color: var(--ink); }
.community-drawer-empty span { max-width: 260px; font-size: .76rem; line-height: 1.45; }
.community-drawer-empty.error { color: var(--red-dark); }
.community-join-confirm {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  margin: 0 14px 12px;
  padding: 13px;
  border: 1px solid #bce7ca;
  border-radius: 15px;
  background: #eefaf2;
}
.community-join-confirm-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: #19a84b;
  color: #fff;
}
.community-join-confirm strong { color: var(--ink); font-size: .82rem; }
.community-join-confirm p { margin: 3px 0 0; color: #526659; font-size: .67rem; line-height: 1.42; }
.community-join-confirm-actions { grid-column: 1/-1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.community-join-confirm-actions button { min-height: 39px; padding: 8px 10px; }
.community-drawer-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}
.community-drawer-footer button { min-height: 46px; justify-content: center; }

.community-directory-page { max-width: 900px; padding-bottom: 30px; }
.community-directory-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 24px;
  border-radius: 23px;
  background: linear-gradient(135deg, #08121d, #172638);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.community-directory-hero::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -72px;
  width: 190px;
  height: 190px;
  border: 22px solid rgba(239,27,36,.17);
  border-radius: 50%;
}
.community-directory-hero-copy { position: relative; z-index: 1; }
.community-directory-hero .page-kicker { color: #ff8c91; }
.community-directory-hero h1 { margin: 3px 0 7px; font-size: clamp(1.65rem,5vw,2.25rem); }
.community-directory-hero p { max-width: 610px; margin: 0; color: #d2d9e1; font-size: .88rem; line-height: 1.55; }
.community-directory-hero-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 24px;
  background: #19a84b;
  color: #fff;
  box-shadow: 0 14px 34px rgba(25,168,75,.28);
}
.community-directory-toolbar {
  display: grid;
  gap: 11px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.community-directory-search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--muted);
}
.community-directory-search input {
  width: 100%;
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}
.community-category-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.community-category-chips::-webkit-scrollbar { display: none; }
.community-category-chips button {
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4e5b6e;
  font-size: .72rem;
  font-weight: 700;
}
.community-category-chips button.active { border-color: var(--red); background: var(--red); color: #fff; }
.community-directory-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid #f3c8cb;
  border-radius: 16px;
  background: var(--red-soft);
  color: var(--red-dark);
}
.community-directory-notice strong { font-size: .81rem; }
.community-directory-notice p { margin: 3px 0 0; color: #6f4c50; font-size: .69rem; line-height: 1.45; }
.community-directory-list { display: grid; gap: 12px; }
.community-directory-card {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 9px 27px rgba(16,31,49,.07);
}
.community-directory-leading { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 13px; min-width: 0; }
.community-directory-icon { width: 68px; height: 68px; border-radius: 18px; }
.community-directory-copy { min-width: 0; }
.community-directory-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.community-directory-title h3 { margin: 0; color: var(--ink); font-size: 1rem; }
.community-verified-badge,
.community-featured-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: .58rem;
  font-weight: 800;
}
.community-verified-badge { background: #eaf8ef; color: #11753a; }
.community-featured-badge { background: #fff4d8; color: #8c6100; }
.community-directory-copy > p { margin: 5px 0 7px; color: #5e6a7c; font-size: .76rem; line-height: 1.47; }
.community-directory-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: #7b8594; font-size: .65rem; }
.community-directory-meta span { display: inline-flex; align-items: center; gap: 4px; }
.community-directory-actions { display: grid; justify-items: stretch; gap: 6px; min-width: 170px; }
.community-whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  border-radius: 13px;
  background: #19a84b;
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(25,168,75,.20);
}
.community-whatsapp-button.joined { background: #122033; box-shadow: none; }
.community-remove-joined { border: 0; background: transparent; color: #7a8493; font-size: .64rem; text-decoration: underline; }
.community-directory-loading,
.community-directory-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 190px;
  padding: 36px;
  border: 1px dashed #d6dbe2;
  border-radius: 19px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}
.community-directory-empty strong { color: var(--ink); font-size: .95rem; }
.community-directory-empty span { max-width: 400px; font-size: .75rem; line-height: 1.5; }
.community-directory-empty.error { color: var(--red-dark); }
.community-confirm-backdrop {
  position: fixed;
  z-index: 1300;
  inset: 0;
  display: grid;
  align-items: end;
  background: rgba(3,10,18,.52);
  backdrop-filter: blur(4px);
}
.community-confirm-sheet {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: #fff;
  text-align: center;
  box-shadow: 0 -18px 52px rgba(3,10,18,.24);
}
.community-confirm-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  font-size: 1.5rem;
}
.community-confirm-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #19a84b;
  color: #fff;
}
.community-confirm-sheet h2 { max-width: 520px; margin: 2px 40px 0; font-size: 1.2rem; }
.community-confirm-sheet p { max-width: 560px; margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.52; }
.community-confirm-sheet > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; width: min(100%,520px); margin-top: 6px; }
.community-confirm-sheet > div button { min-height: 48px; justify-content: center; }

@media (max-width: 720px) {
  .home-community-tab { top: 46%; width: 64px; padding: 9px 5px; }
  .home-community-tab span { width: 36px; height: 36px; }
  .community-directory-page { padding-left: 12px; padding-right: 12px; }
  .community-directory-hero { padding: 19px; }
  .community-directory-hero-icon { width: 66px; height: 66px; border-radius: 20px; }
  .community-directory-card { grid-template-columns: 1fr; gap: 12px; }
  .community-directory-actions { grid-template-columns: 1fr; min-width: 0; }
  .community-directory-icon { width: 58px; height: 58px; }
}

@media (max-width: 430px) {
  .community-drawer-card { grid-template-columns: auto minmax(0,1fr); }
  .community-drawer-action { grid-column: 1/-1; width: 100%; }
  .community-directory-hero-icon { display: none; }
  .community-directory-hero { grid-template-columns: 1fr; }
  .community-directory-leading { align-items: start; }
  .community-directory-title h3 { width: 100%; }
}
