/*
 * Member directory (people.php) + its popups (people_sendmail.php, people_addfriend.php) - 2026-09-27.
 * Prefix kp-. Uses the km-theme.css tokens (--km-*). Keep this file ASCII.
 */
.kp-page { max-width: 1240px; margin: 0 auto; }

/* ---------- hero ---------- */
.kp-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  padding: 22px 24px; margin-bottom: 16px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--km-primary, #2563eb) 0%, color-mix(in srgb, var(--km-primary, #2563eb) 55%, #0f172a) 100%);
  background-color: var(--km-primary, #2563eb);
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--km-primary, #2563eb) 60%, transparent);
  position: relative; overflow: hidden;
}
.kp-hero::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, .08); pointer-events: none;
}
.kp-hero-txt { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 320px; position: relative; z-index: 1; }
.kp-hero-ico {
  width: 52px; height: 52px; border-radius: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .18); font-size: 24px;
}
.kp-hero h2 { margin: 0 0 4px; font-size: 24px; font-weight: 600; color: #fff; line-height: 1.25; }
.kp-hero p { margin: 0; opacity: .88; font-size: 14px; }
.kp-stats { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.kp-stat {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 92px; padding: 10px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, .14); color: #fff !important; text-decoration: none !important; line-height: 1.2;
  border: 1px solid rgba(255, 255, 255, .18);
}
a.kp-stat:hover { background: rgba(255, 255, 255, .24); }
.kp-stat b { font-size: 20px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.kp-stat span { font-size: 12px; opacity: .85; }
.kp-stat .kp-dot { position: static; border-color: rgba(255, 255, 255, .6); }

/* ---------- online dot ---------- */
.kp-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--km-success, #12b76a);
  border: 2px solid var(--km-surface, #fff); flex: none; vertical-align: middle;
}
i.kp-dot { font-style: normal; }

/* ---------- layout ---------- */
.kp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.kp-main { min-width: 0; }
.kp-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 70px; }

/* ---------- search / filter bar ---------- */
.kp-bar {
  background: var(--km-surface, #fff); border: 1px solid var(--km-border, #e4e7ec); border-radius: 16px;
  box-shadow: var(--km-shadow-sm); padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px;
}
.kp-bar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kp-q { position: relative; flex: 1 1 260px; min-width: 0; }
.kp-q > .fa-search { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--km-muted, #667085); pointer-events: none; }
.kp-q input {
  width: 100%; height: 44px; border: 1px solid var(--km-border-strong, #cfd4dc); border-radius: 12px; padding: 0 40px;
  font-size: 15px; background: var(--km-surface-2, #f8fafc); outline: 0; transition: border-color .15s, box-shadow .15s, background .15s;
}
.kp-q input:focus { border-color: var(--km-primary); background: var(--km-surface, #fff); box-shadow: 0 0 0 4px var(--km-primary-ring); }
.kp-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 12px/1 inherit; padding: 4px 7px; border-radius: 6px;
  background: var(--km-surface, #fff); border: 1px solid var(--km-border-strong, #cfd4dc); color: var(--km-muted, #667085); box-shadow: none;
}
.kp-q input:focus ~ .kp-kbd, .kp-q input:not(:placeholder-shown) ~ .kp-kbd { display: none; }
.kp-go { height: 44px; border-radius: 12px !important; padding: 0 20px; font-weight: 500; }
.kp-filters { gap: 8px; }
.kp-sel { margin: 0; flex: 1 1 150px; min-width: 0; font-weight: normal; }
.kp-sel select {
  width: 100%; height: 38px; border: 1px solid var(--km-border, #e4e7ec); border-radius: 10px; padding: 0 10px;
  background: var(--km-surface-2, #f8fafc); font-size: 13.5px; color: var(--km-text, #1d2433); cursor: pointer;
}
.kp-sel select:focus { outline: 0; border-color: var(--km-primary); box-shadow: 0 0 0 3px var(--km-primary-ring); }
.kp-toggle { margin: 0; font-weight: normal; cursor: pointer; flex: none; }
.kp-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.kp-toggle span {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--km-border, #e4e7ec); background: var(--km-surface-2, #f8fafc); font-size: 13.5px; white-space: nowrap;
}
.kp-toggle input:checked + span { background: rgba(18, 183, 106, .12); border-color: rgba(18, 183, 106, .45); color: #067647; font-weight: 500; }
.kp-toggle input:focus-visible + span { outline: 2px solid var(--km-primary); outline-offset: 2px; }

/* ---------- result line ---------- */
.kp-result { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; flex-wrap: wrap; }
.kp-result-txt { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--km-muted, #667085); min-width: 0; }
.kp-result-txt b { color: var(--km-text, #1d2433); }
.kp-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 11px; border-radius: 999px;
  background: var(--km-primary-soft); color: var(--km-primary); font-size: 13px;
}
.kp-chip a { color: inherit; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none !important; opacity: .75; }
.kp-chip a:hover { opacity: 1; background: var(--km-primary-ring); }
.kp-clear { font-size: 13px; margin-left: 4px; }
.kp-view { display: inline-flex; background: var(--km-surface, #fff); border: 1px solid var(--km-border, #e4e7ec); border-radius: 10px; padding: 3px; }
.kp-view-btn { border: 0; background: transparent; width: 34px; height: 30px; border-radius: 7px; color: var(--km-muted, #667085); }
.kp-view-btn.is-on { background: var(--km-primary-soft); color: var(--km-primary); }

/* ---------- cards ---------- */
.kp-grid {
  list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
}
.kp-card {
  background: var(--km-surface, #fff); border: 1px solid var(--km-border, #e4e7ec); border-radius: 16px; padding: 20px 14px 14px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; min-width: 0;
  box-shadow: var(--km-shadow-sm); transition: transform .2s var(--km-ease), box-shadow .2s var(--km-ease), border-color .2s;
  content-visibility: auto; contain-intrinsic-size: 280px;
}
.kp-card:hover { transform: translateY(-2px); box-shadow: var(--km-shadow); border-color: var(--km-border-strong, #cfd4dc); }
.kp-pic { position: relative; display: block; width: 88px; height: 88px; flex: none; }
.kp-av {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: var(--km-surface-2, #f1f5f9);
  box-shadow: 0 0 0 3px var(--km-surface, #fff), 0 0 0 4px var(--km-border, #e4e7ec);
}
.kp-card.is-online .kp-av { box-shadow: 0 0 0 3px var(--km-surface, #fff), 0 0 0 5px rgba(18, 183, 106, .55); }
.kp-pic .kp-dot { position: absolute; right: 4px; bottom: 4px; width: 16px; height: 16px; border-width: 3px; }
.kp-body { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; width: 100%; }
.kp-name {
  font-weight: 600; font-size: 15.5px; color: var(--km-text, #1d2433) !important; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kp-name:hover { color: var(--km-primary) !important; }
.kp-full { font-size: 13px; color: var(--km-muted, #667085); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-meta { font-size: 12.5px; color: var(--km-muted, #667085); max-width: 100%; }
.kp-meta span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kp-meta .fa { opacity: .7; }
.kp-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 4px; }
.kp-tag {
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--km-primary-soft); color: var(--km-primary);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.kp-tag.is-soft { background: var(--km-surface-2, #f1f5f9); color: var(--km-muted, #667085); border: 1px solid var(--km-border, #e4e7ec); }
.kp-tag.is-public { background: rgba(18, 183, 106, .1); color: #067647; }
.kp-actions { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; width: 100%; }
.kp-add { margin: 0; }
.kp-add .btn { border-radius: 999px !important; padding: 5px 14px; font-weight: 500; }
.kp-ic {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--km-muted, #667085) !important; background: var(--km-surface-2, #f1f5f9); border: 1px solid var(--km-border, #e4e7ec);
  text-decoration: none !important;
}
.kp-ic:hover { color: var(--km-primary) !important; background: var(--km-primary-soft); border-color: transparent; }
.kp-state {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.kp-state.is-friend { background: rgba(18, 183, 106, .12); color: #067647; }
.kp-state.is-wait { background: rgba(247, 144, 9, .12); color: #b54708; }
.kp-visit { border-radius: 999px !important; }

/* list view (toggle, remembered per browser) */
.kp-page.is-list .kp-grid { grid-template-columns: 1fr; gap: 8px; }
.kp-page.is-list .kp-card { flex-direction: row; text-align: left; padding: 12px 14px; gap: 14px; contain-intrinsic-size: 90px; }
.kp-page.is-list .kp-pic { width: 56px; height: 56px; }
.kp-page.is-list .kp-pic .kp-dot { width: 13px; height: 13px; right: 1px; bottom: 1px; border-width: 2px; }
.kp-page.is-list .kp-body { align-items: flex-start; flex: 1 1 auto; }
.kp-page.is-list .kp-tags { justify-content: flex-start; }
.kp-page.is-list .kp-actions { width: auto; margin: 0; padding: 0; flex: none; justify-content: flex-end; }

/* ---------- empty ---------- */
.kp-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 48px 20px; margin-bottom: 16px;
  background: var(--km-surface, #fff); border: 1px dashed var(--km-border-strong, #cfd4dc); border-radius: 16px; color: var(--km-muted, #667085);
}
.kp-empty .fa { font-size: 40px; opacity: .45; margin-bottom: 6px; }
.kp-empty b { color: var(--km-text, #1d2433); font-size: 16px; font-weight: 500; }

/* ---------- side boxes ---------- */
.kp-box { background: var(--km-surface, #fff); border: 1px solid var(--km-border, #e4e7ec); border-radius: 16px; box-shadow: var(--km-shadow-sm); padding: 16px; }
.kp-box h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kp-box h3 .fa { color: var(--km-primary); }
.kp-depts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.kp-depts a {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; overflow: hidden;
  color: var(--km-text, #1d2433) !important; text-decoration: none !important; font-size: 13.5px; z-index: 0;
}
.kp-depts a:hover { background: var(--km-surface-2, #f1f5f9); }
.kp-depts li[aria-current] a { background: var(--km-primary-soft); color: var(--km-primary) !important; font-weight: 500; }
.kp-dn { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-dc { flex: none; font-weight: 600; font-size: 12.5px; color: var(--km-muted, #667085); }
.kp-bar-fill { position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--km-primary); opacity: .35; z-index: -1; }
.kp-more-btn { margin-top: 8px; width: 100%; border: 0; background: var(--km-surface-2, #f1f5f9); border-radius: 10px; padding: 8px; font-size: 13px; color: var(--km-primary); }
.kp-more-btn:hover { background: var(--km-primary-soft); }
.kp-legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--km-muted, #667085); }
.kp-legend li { display: flex; align-items: flex-start; gap: 8px; }
.kp-legend li > .fa, .kp-legend li > .kp-dot { margin-top: 3px; flex: none; width: 14px; text-align: center; }
.kp-legend li > .kp-dot { width: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 991px) {
  .kp-layout { grid-template-columns: minmax(0, 1fr); }
  .kp-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 600px) {
  .kp-hero { padding: 18px 16px; border-radius: 16px; }
  .kp-hero h2 { font-size: 20px; }
  .kp-hero-ico { width: 44px; height: 44px; font-size: 20px; }
  .kp-stats { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kp-stat { min-width: 0; }
  .kp-bar { padding: 12px; }
  .kp-kbd { display: none; }
  .kp-go span { display: none; }
  .kp-go { padding: 0 16px; }
  .kp-sel { flex: 1 1 calc(50% - 4px); }
  .kp-toggle { flex: 1 1 100%; }
  .kp-toggle span { width: 100%; justify-content: center; }
  .kp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kp-card { padding: 16px 10px 12px; }
  .kp-pic { width: 72px; height: 72px; }
  .kp-add .btn { padding: 5px 10px; font-size: 12.5px; }
  .kp-page.is-list .kp-card { flex-wrap: wrap; }
  .kp-page.is-list .kp-body { flex: 1 1 calc(100% - 80px); }
  .kp-page.is-list .kp-actions { width: 100%; justify-content: flex-start; padding-left: 70px; }
}
@media (max-width: 360px) {
  .kp-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .kp-card, .kp-card:hover { transition: none; transform: none; }
}

/* ---------- popups (people_sendmail.php / people_addfriend.php) ---------- */
body.kp-popup { background: var(--km-bg, #f3f5f9); margin: 0; }
html.km-embed body.kp-popup { background: var(--km-surface, #fff) !important; padding: 0 !important; }
.kp-pop {
  max-width: 460px; margin: 32px auto; padding: 22px; background: var(--km-surface, #fff);
  border: 1px solid var(--km-border, #e4e7ec); border-radius: 18px; box-shadow: var(--km-shadow);
}
.kp-pop.kp-pop-wide { max-width: 640px; }
html.km-embed .kp-pop { max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 18px 20px; }
.kp-pop-title { margin: 0 0 16px; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kp-pop-title .fa { color: var(--km-primary); }
html.km-embed .kp-pop-title { display: none; } /* the lightwindow already shows the title */
.kp-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.kp-who-pic { position: relative; width: 56px; height: 56px; flex: none; }
.kp-who-pic .kp-av { box-shadow: 0 0 0 2px var(--km-surface, #fff), 0 0 0 3px var(--km-border, #e4e7ec); }
.kp-who-pic .kp-dot { position: absolute; right: 0; bottom: 0; }
.kp-who-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.kp-who-txt b { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-who-txt small { color: var(--km-muted, #667085); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-pop-q { margin: 16px 0 0; font-size: 15px; }
.kp-pop-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.kp-pop-actions .btn { min-width: 96px; }
.kp-note { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-top: 16px; font-size: 14px; }
.kp-note .fa { font-size: 18px; margin-top: 1px; flex: none; }
.kp-note.is-ok { background: rgba(18, 183, 106, .1); color: #067647; }
.kp-note.is-info { background: var(--km-primary-soft); color: var(--km-primary); }
.kp-note.is-err { background: rgba(240, 68, 56, .1); color: #b42318; }
.kp-mail .kp-note { margin: 0 0 14px; }
.kp-to { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--km-surface-2, #f8fafc); border: 1px solid var(--km-border, #e4e7ec); margin-bottom: 16px; min-width: 0; }
.kp-to-lbl { font-size: 13px; color: var(--km-muted, #667085); flex: none; }
.kp-to .kp-who-pic { width: 44px; height: 44px; }
.kp-field { display: block; margin: 0 0 14px; font-weight: normal; position: relative; }
.kp-field > span { display: block; font-size: 13px; font-weight: 500; color: var(--km-muted, #667085); margin-bottom: 6px; }
.kp-field textarea { resize: vertical; min-height: 150px; }
.kp-count { position: absolute; right: 10px; bottom: 6px; font-size: 11.5px; color: var(--km-muted, #667085); pointer-events: none; }
@media (max-width: 480px) {
  .kp-pop { margin: 0; border-radius: 0; border: 0; min-height: 100vh; }
  .kp-pop-actions .btn { flex: 1 1 0; }
}
