/* =========================================================================
   OUR CLIENTS — hero stat chip, search/sort toolbar, client card grid.
   Loaded only on our_clients.php via theme_head()'s $extraCss param.
   Every rule here is prefixed .client(s)- to stay collision-free with the
   shared theme.css component set (same convention as city-page.css).
   ========================================================================= */

/* --- Hero stat chip (real client count via data-count, animated by the
       shared counter observer in theme.js — no page-specific JS needed) --- */
.clients-hero-stat {
  display: inline-flex; align-items: center; gap: .55rem;
  margin-top: 1.6rem; padding: .7rem 1.4rem;
  background: var(--wa-surface); border: 1px solid var(--wa-line);
  border-radius: 999px; box-shadow: var(--shadow-sm);
}
.clients-hero-stat .bi { color: var(--wa-action); font-size: 1.1rem; }
.clients-hero-stat .lbl { color: var(--wa-ink); font-weight: 600; font-size: .92rem; }

.clients-section-title { font-size: clamp(1.4rem, 2.4vw, 1.9rem); margin-bottom: 1.1rem; }

/* --- Toolbar: search + sort -------------------------------------------- */
.clients-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.clients-search { position: relative; flex: 1 1 320px; max-width: 420px; }
.clients-search input {
  width: 100%; border: 1px solid var(--wa-line); border-radius: var(--radius-btn);
  padding: .7rem 1rem .7rem 2.6rem; font-size: .95rem;
  background: var(--wa-surface); color: var(--wa-ink); box-shadow: var(--shadow-sm);
}
.clients-search input:focus {
  outline: none; border-color: var(--wa-green); background: #fff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}
.clients-search i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--wa-muted); font-size: .9rem; }

.clients-sort { display: flex; gap: .5rem; flex: 0 0 auto; }
.clients-sort-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--wa-line); background: var(--wa-surface); color: var(--wa-body);
  border-radius: var(--radius-btn); padding: .55rem 1.1rem; font-size: .86rem; font-weight: 600;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.clients-sort-btn:hover { border-color: var(--wa-action); color: var(--wa-teal-dark); }
.clients-sort-btn.active { background: var(--wa-teal); border-color: var(--wa-teal); color: #fff; }

.clients-count { color: var(--wa-muted); font-size: .88rem; margin: 0 0 1.6rem; }

/* --- Card grid ----------------------------------------------------------
   Bootstrap's .row defaults to align-items:stretch, so every .client-card
   (height:100% inside its column) naturally sits at equal row height —
   no JS equal-height hack needed, same approach as .card-wa/.audience-tile. */
.clients-hidden { display: none; }

.client-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .85rem;
  background: var(--wa-surface); border: 1px solid var(--wa-line);
  border-radius: var(--radius-card); padding: 1.6rem 1.2rem; height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
}
.client-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: rgba(34, 197, 94, .4); }

.client-logo-wrap {
  position: relative; width: 100%; height: 92px;
  display: flex; align-items: center; justify-content: center;
  background: var(--wa-page); border: 1px solid var(--wa-line); border-radius: 12px;
  padding: .7rem; overflow: hidden;
}
.client-logo-wrap img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  opacity: 0; transition: opacity .35s ease;
}
.client-logo-wrap img.loaded { opacity: 1; }
/* Fallback icon: hidden by default, shown only if the logo fails to load
   (or the CRM record has no logo at all) — never a broken-image glyph. */
.client-logo-fallback { display: none; font-size: 1.6rem; color: var(--wa-muted); }
.client-logo-wrap.logo-failed img { display: none; }
.client-logo-wrap.logo-failed .client-logo-fallback { display: block; }

.client-card h3 {
  font-size: .98rem; font-weight: 700; margin: 0; line-height: 1.35;
  /* Long company names shouldn't blow out card height / grid rhythm */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.client-address {
  display: flex; align-items: flex-start; gap: .4rem; margin: 0; width: 100%;
  color: var(--wa-muted); font-size: .82rem; line-height: 1.4;
}
.client-address i { color: var(--wa-teal); margin-top: .18rem; flex: 0 0 auto; }
.client-address span {
  text-align: left; min-width: 0;
  /* The masking helper fills most of the address with an unbroken run of
     bullet characters (no spaces) — without a forced break it overflows
     the card as one long "word" and bleeds into neighbouring rows/columns. */
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* --- Load more (default 50, reveals 50 more per click) ------------------ */
.clients-load-more-wrap { text-align: center; margin-top: 2.2rem; }

/* --- Empty / no-results states ------------------------------------------ */
.clients-empty-state, .clients-no-results {
  text-align: center; color: var(--wa-muted); padding: 3rem 1rem;
}
.clients-empty-state i, .clients-no-results i {
  font-size: 2.2rem; color: var(--wa-line); display: block; margin-bottom: 1rem;
}
.clients-empty-state h2 { margin-bottom: .5rem; }
.clients-no-results { display: none; }
.clients-no-results.show { display: block; }

@media (max-width: 575.98px) {
  .clients-toolbar { flex-direction: column; align-items: stretch; }
  .clients-search { max-width: none; }
  .clients-sort { justify-content: center; }
}
