/* Circlo Iteration 5 - member search and discovery.
   ASCII-only source to avoid encoding regressions. */

#i5SearchPanel {
  position: fixed;
  z-index: 1400;
  width: min(520px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 96px));
  overflow: auto;
  border: 1px solid var(--border, rgba(127,127,127,.22));
  border-radius: 16px;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  box-shadow: 0 24px 70px rgba(15,23,42,.22);
}

body.dark #i5SearchPanel {
  background: #111827;
  color: #e5e7eb;
}

#i5SearchPanel.hidden {
  display: none !important;
}

.i5-search-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  background: inherit;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.i5-search-head strong {
  font-size: .94rem;
}

.i5-search-head span {
  color: var(--muted, #64748b);
  font-size: .8rem;
}

.i5-person-list {
  display: grid;
  gap: 2px;
  padding: 8px;
}

.i5-person {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 12px;
  padding: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.i5-person:hover,
.i5-person:focus-visible {
  background: var(--surface-2, #f1f5f9);
  outline: none;
}

.i5-person-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbeafe;
  border: 1px solid var(--border, #dbe3ef);
}

.i5-person-avatar.i5-avatar-fallback {
  display: grid;
  place-items: center;
  color: #1d4ed8;
  font-weight: 800;
  font-size: 1rem;
}

.i5-person-body {
  min-width: 0;
}

.i5-person-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.i5-person-user {
  display: block;
  margin-top: 2px;
  color: var(--muted, #64748b);
  font-size: .84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.i5-person-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 5px;
  color: var(--muted, #64748b);
  font-size: .78rem;
}

.i5-person-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.i5-person-go {
  color: var(--muted, #64748b);
  font-size: 1.15rem;
}

.i5-empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--muted, #64748b);
  line-height: 1.5;
}

.i5-search-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border, #e2e8f0);
  color: var(--muted, #64748b);
  font-size: .78rem;
  line-height: 1.4;
}

.i5-discover-view {
  width: min(900px, calc(100% - 24px));
  margin: 18px auto 40px;
}

.i5-discover-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.i5-discover-head h2 {
  margin: 0 0 5px;
}

.i5-discover-head p {
  margin: 0;
  color: var(--muted, #64748b);
  line-height: 1.45;
}

.i5-discover-search {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  margin: 14px 0 18px;
}

.i5-discover-search input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
}

body.dark .i5-discover-search input {
  background: #0f172a;
}

.i5-discover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.i5-discover-card {
  display: grid;
  grid-template-columns: 62px minmax(0,1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  background: var(--surface, #fff);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.i5-discover-card:hover,
.i5-discover-card:focus-visible {
  border-color: var(--brand, #2563eb);
  outline: none;
}

.i5-discover-card .i5-person-avatar {
  width: 62px;
  height: 62px;
}

.i5-discover-card h3 {
  margin: 0;
  font-size: 1rem;
}

.i5-discover-card p {
  margin: 3px 0 0;
  color: var(--muted, #64748b);
  font-size: .84rem;
}

.i5-discover-card .i5-person-meta {
  margin-top: 8px;
}

.i5-profile-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.i5-profile-controls button {
  white-space: nowrap;
}

.i5-manage-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100700;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15,23,42,.68);
  backdrop-filter: blur(8px);
}

.i5-manage-backdrop.hidden {
  display: none !important;
}

.i5-manage-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  background: var(--surface, #fff);
  color: var(--text, #0f172a);
  box-shadow: 0 28px 80px rgba(0,0,0,.28);
}

body.dark .i5-manage-card {
  background: #111827;
  color: #e5e7eb;
}

.i5-manage-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px;
  background: inherit;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.i5-manage-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.i5-manage-body {
  padding: 10px;
}

.i5-manage-row {
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border-radius: 12px;
}

.i5-manage-row:hover {
  background: var(--surface-2, #f8fafc);
}

.i5-manage-row .i5-person-avatar {
  width: 44px;
  height: 44px;
}

.i5-manage-row strong,
.i5-manage-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.i5-manage-row span {
  margin-top: 2px;
  color: var(--muted, #64748b);
  font-size: .82rem;
}

.i5-manage-empty {
  padding: 30px;
  text-align: center;
  color: var(--muted, #64748b);
}

.i5-search-loading {
  padding: 22px;
  text-align: center;
  color: var(--muted, #64748b);
}

@media (max-width: 720px) {
  .i5-discover-grid {
    grid-template-columns: 1fr;
  }

  .i5-discover-view {
    width: calc(100% - 14px);
    margin-top: 10px;
  }

  .i5-profile-controls {
    width: 100%;
    margin-left: 0;
  }

  .i5-profile-controls button {
    flex: 1;
  }

  .i5-manage-backdrop {
    padding: 0;
    align-items: end;
  }

  .i5-manage-card {
    width: 100%;
    max-height: 94vh;
    border-radius: 18px 18px 0 0;
  }
}
