/* ── App shell ──────────────────────────────────────────────────── */
#wpcc-app {
  display: flex; height: 75vh;
  border: 1px solid var(--ch-border); border-radius: var(--ch-radius);
  font-family: var(--ch-font); overflow: hidden;
  background: var(--ch-page); box-shadow: var(--ch-shadow);
  position: relative;
}

/* On phones and tablets the virtual keyboard must not compress the app.
   Use position:fixed + inset:0 so the app occupies the full screen and
   is immune to viewport resize events triggered by the keyboard.
   dvh (dynamic viewport height) is the W3C solution for this exact problem.  */
@media (max-width: 1024px) {
  #wpcc-app {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;   /* dvh = shrinks with keyboard, stable baseline */
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    z-index: 9990;
  }
}

/* ── Sidebar ────────────────────────────────────────────────────── */
#wpcc-sidebar {
  width: 240px; min-width: 240px; max-width: 240px;
  border-right: 1px solid var(--ch-border); background: var(--ch-card);
  padding: 0; overflow-y: auto; overflow-x: hidden;
  box-sizing: border-box; flex-shrink: 0;
  display: flex; flex-direction: column; min-height: 0;
}
#wpcc-main {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--ch-card); position: relative; overflow: hidden;
}

/* ── Profile bar ────────────────────────────────────────────────── */
.wpcc-profile-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--ch-shell); border-bottom: 1px solid var(--ch-shell2);
  min-width: 0; flex-shrink: 0;
}
.wpcc-my-name {
  flex: 1; font-size: 15px; font-weight: 700; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.wpcc-btn-edit-profile {
  background: rgba(255,255,255,.14); border: none; cursor: pointer;
  font-size: 18px; font-weight: 700; color: rgba(255,255,255,.85);
  padding: 0; border-radius: 10px; transition: background .15s, color .15s;
  line-height: 1; flex-shrink: 0;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
}
.wpcc-btn-edit-profile:hover { background: rgba(255,255,255,.22); color: #fff; }
.wpcc-my-avatar { display: flex; align-items: center; flex-shrink: 0; }

/* ── Avatars ────────────────────────────────────────────────────── */
.wpcc-avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-block; }
.wpcc-avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff;
  font-size: 11px; font-weight: 800; flex-shrink: 0; letter-spacing: .3px;
}

/* ── Search ─────────────────────────────────────────────────────── */
.wpcc-search-wrap {
  position: relative; margin: 10px 12px 8px; z-index: 50; flex-shrink: 0;
}
#wpcc-search {
  width: 100%; box-sizing: border-box; margin: 0;
  padding: 9px 16px; border: 1px solid var(--ch-border);
  border-radius: var(--ch-pill); font-size: 15px; font-family: var(--ch-font);
  background: var(--ch-page); color: var(--ch-text);
  outline: none; transition: border-color .15s; display: block;
}
#wpcc-search:focus { border-color: var(--ch-primary); }
#wpcc-search::placeholder { color: var(--ch-muted); }
#wpcc-search-results {
  position: fixed; z-index: 200;
  min-width: 240px; width: max-content; max-width: min(380px, 92vw);
  background: var(--ch-card); border: 1px solid var(--ch-border);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.22);
  max-height: 320px; overflow-y: auto; overflow-x: hidden; box-sizing: border-box;
}
#wpcc-search-results:empty { display: none; }
.wpcc-search-item {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; cursor: pointer;
  border-bottom: 1px solid #f5f5f5; font-size: 15px;
  min-width: 0; transition: background .12s;
}
.wpcc-search-item:hover { background: var(--ch-page); }
.wpcc-search-name {
  flex: 1; min-width: 0; color: var(--ch-text); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wpcc-search-empty { color: var(--ch-muted); font-style: italic; cursor: default; }
/* legacy alias */
.wpcc-user-row { display: flex; align-items: center; gap: 8px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #f5f5f5; font-size: 15px; min-width: 0; transition: background .12s; }
.wpcc-user-row:hover { background: var(--ch-page); }
.wpcc-user-row-name { flex: 1; min-width: 0; color: var(--ch-text); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Sidebar section headings ───────────────────────────────────── */
#wpcc-sidebar h3 {
  font-size: 10px !important; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--ch-muted); margin: 14px 14px 5px; padding: 0;
}
.wpcc-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding: 0 14px;
}
.wpcc-section-header h3 { margin: 0; padding: 0; }

/* ── Online dots ────────────────────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.online  { background: var(--ch-green2); }
.dot.offline { background: var(--ch-faint); }
.wpcc-online-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ch-green2); flex-shrink: 0; margin-left: 4px;
}
.wpcc-online-dot-sm {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ch-green2); border: 2px solid var(--ch-card);
}

/* ── Chat item rows (DM + Group) ────────────────────────────────── */
.wpcc-chat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer;
  border-left: 3px solid transparent;
  border-bottom: 1px solid #f5f5f5;
  transition: background .12s; box-sizing: border-box; min-width: 0;
}
.wpcc-chat-item:hover { background: var(--ch-page); }
.wpcc-chat-item.active { background: #ede9fe !important; border-left-color: var(--ch-primary) !important; }
.wpcc-chat-item-avatar { position: relative; flex-shrink: 0; }
.wpcc-chat-item-info   { flex: 1; min-width: 0; }
.wpcc-chat-item-name   { font-size: 15px; font-weight: 700; color: var(--ch-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpcc-chat-item-last   { font-size: 13px; color: var(--ch-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpcc-chat-delete-btn  { flex-shrink: 0; background: none; border: none; color: var(--ch-faint); font-size: 13px; cursor: pointer; padding: 2px 4px; border-radius: 4px; opacity: 0; transition: opacity .15s, color .15s; line-height: 1; }
.wpcc-chat-item:hover .wpcc-chat-delete-btn { opacity: 1; }
.wpcc-chat-delete-btn:hover { color: var(--ch-danger); }
.wpcc-no-chats { font-size: 14px; color: var(--ch-muted); padding: 8px 14px; }

/* ── Group-specific item styles ─────────────────────────────────── */
.wpcc-group-item.wpcc-removed-group { opacity: .65; }
.wpcc-group-item.wpcc-group-locked  .wpcc-group-name { color: var(--ch-muted); }
.wpcc-group-name    { font-weight: 700; color: var(--ch-text); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpcc-removed-tag   { font-size: 9px; background: var(--ch-danger); color: #fff; border-radius: 10px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.wpcc-locked-tag    { font-size: 9px; background: var(--ch-warn); color: #fff; border-radius: 10px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.wpcc-group-pic-sm  { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.wpcc-group-initials-sm { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.wpcc-group-badge { font-size: 9px; border-radius: 10px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; font-weight: 700; }
.wpcc-group-badge-added   { background: var(--ch-green2); color: #fff; }
.wpcc-group-badge-removed { background: var(--ch-danger); color: #fff; }
.wpcc-group-badge-enabled { background: var(--ch-primary); color: #fff; }
.wpcc-no-groups { font-size: 14px; color: var(--ch-muted); padding: 8px 14px; }

/* legacy class names kept for any remaining references */
.wpcc-chat-row { padding: 10px 14px; cursor: pointer; border-left: 3px solid transparent; border-bottom: 1px solid #f5f5f5; transition: background .12s; }
.wpcc-chat-row:hover { background: var(--ch-page); }
.wpcc-chat-row-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wpcc-chat-row-name { font-size: 15px; font-weight: 700; color: var(--ch-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.wpcc-chat-row-snippet { font-size: 13px; color: var(--ch-muted); margin-top: 2px; padding-left: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wpcc-group-row { display: flex; align-items: center; gap: 8px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid #f5f5f5; font-size: 15px; transition: background .12s; min-width: 0; box-sizing: border-box; }
.wpcc-group-row:hover { background: var(--ch-page); }
.wpcc-active-row { background: #ede9fe !important; border-left: 3px solid var(--ch-primary) !important; }

/* ── Unread badge (sidebar) ─────────────────────────────────────── */
.wpcc-unread-badge {
  flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--ch-danger); color: #fff;
  border-radius: 9px; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; box-sizing: border-box; margin-left: 4px;
}

/* ── Blocked badge (sidebar chat rows) ──────────────────────────── */
.wpcc-blocked-badge { font-size: 9px; background: var(--ch-muted); color: #fff; border-radius: 10px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }

/* ── Buttons ────────────────────────────────────────────────────── */
.wpcc-btn-new-group {
  background: var(--ch-primary); color: #fff;
  border: none; border-radius: var(--ch-pill);
  padding: 4px 12px; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: background .15s; flex-shrink: 0;
}
.wpcc-btn-new-group:hover { background: var(--ch-primary-dk); }
.wpcc-btn-create { background: var(--ch-green2); color: #fff; border: none; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; }
.wpcc-btn-create:hover  { background: var(--ch-green); }
.wpcc-btn-cancel { background: #6c757d; color: #fff; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; }
.wpcc-btn-cancel:hover  { background: #5a6268; }
.wpcc-btn-manage { background: var(--ch-page); color: var(--ch-text); border: 1px solid var(--ch-border); border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.wpcc-btn-manage:hover  { background: #e8eaf0; }
.wpcc-btn-block  { background: var(--ch-danger); color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.wpcc-btn-block:hover    { background: #b02a37; }
.wpcc-btn-block:disabled { opacity: .55; cursor: not-allowed; }
.wpcc-btn-unblock { background: #6c757d; color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.wpcc-btn-unblock:hover    { background: #5a6268; }
.wpcc-btn-unblock:disabled { opacity: .55; cursor: not-allowed; }
.wpcc-btn-danger { background: var(--ch-danger); color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.wpcc-btn-danger:hover { background: #b02a37; }

/* ── Create-group form ──────────────────────────────────────────── */
.wpcc-create-group-form {
  background: var(--ch-page); border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius); padding: 12px 14px;
  margin: 8px 12px; box-sizing: border-box;
}
.wpcc-create-group-form input[type="text"],
.wpcc-create-group-select {
  width: 100%; box-sizing: border-box; padding: 8px 12px;
  border: 1px solid var(--ch-border); border-radius: 8px;
  margin-bottom: 8px; font-size: 13px; font-family: var(--ch-font);
  background: var(--ch-card); outline: none; color: var(--ch-text);
  transition: border-color .15s;
}
.wpcc-create-group-form input[type="text"]:focus,
.wpcc-create-group-select:focus { border-color: var(--ch-primary); }
/* Style the select arrow to match the chat design */
.wpcc-create-group-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.wpcc-form-row { display: flex; gap: 8px; }

/* ── Chat header ────────────────────────────────────────────────── */
#wpcc-chat-header {
  display: none; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--ch-border);
  background: var(--ch-card); gap: 10px; flex-shrink: 0; min-height: 60px;
}
#wpcc-chat-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; font-weight: 700; color: var(--ch-text);
}
#wpcc-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
#wpcc-pinned-zone    { flex-shrink: 0; }

/* ── Info button ─────────────────────────────────────────────────── */
.wpcc-btn-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--ch-page); color: var(--ch-muted); font-size: 22px; font-weight: 700;
  cursor: pointer; transition: background .15s, color .15s; line-height: 1; padding: 0;
}
.wpcc-btn-info:hover { background: #e8eaf0; color: var(--ch-primary); }

/* ── Back button ────────────────────────────────────────────────── */
#wpcc-back-btn.wpcc-btn-back {
  display: inline-flex; align-items: center; justify-content: center;
  visibility: hidden;
  background: none; border: none; cursor: pointer;
  font-size: 22px; font-weight: 900; line-height: 1; color: var(--ch-text);
  padding: 2px 10px 2px 2px; border-radius: 6px;
  flex-shrink: 0; min-width: 44px; min-height: 44px;
}

/* ── Moderator badge ────────────────────────────────────────────── */
.wpcc-moderator-badge { display: inline-block; font-size: 9px; font-weight: 700; color: #fff; background: #7c3aed; border-radius: 4px; padding: 1px 5px; margin-left: 5px; letter-spacing: .4px; vertical-align: middle; }
.wpcc-mod-tag         { display: inline-block; font-size: 9px; font-weight: 700; color: #fff; background: #7c3aed; border-radius: 4px; padding: 1px 5px; margin-left: 5px; letter-spacing: .4px; vertical-align: middle; }
.wpcc-btn-mod-assign, .wpcc-btn-mod-active { border: none; border-radius: 6px; cursor: pointer; font-size: 11px; padding: 3px 8px; margin-left: 3px; transition: background .15s; }
.wpcc-btn-mod-assign { background: #ede9fe; color: #7c3aed; }
.wpcc-btn-mod-assign:hover { background: #ddd6fe; }
.wpcc-btn-mod-active { background: #7c3aed; color: #fff; }
.wpcc-btn-mod-active:hover { background: #6d28d9; }

/* ── Toggle messaging ───────────────────────────────────────────── */
#wpcc-toggle-msg-btn { background: none; border: 1px solid var(--ch-border); border-radius: 8px; cursor: pointer; font-size: 15px; padding: 4px 8px; color: var(--ch-muted); transition: background .15s, color .15s; }
#wpcc-toggle-msg-btn:hover { background: #fff3cd; color: #856404; }

/* ── Public group preview & join request UI ─────────────────────── */
.wpcc-group-public-preview { opacity: .85; }
.wpcc-join-tag {
  display: inline-block; font-size: 10px; font-weight: 700;
  border-radius: 8px; padding: 2px 7px; margin-top: 3px;
  line-height: 1.4; width: fit-content;
}
.wpcc-join-public  { background: #e8f5e9; color: #1e7e34; }
.wpcc-join-pending { background: #fff3cd; color: #856404; }

/* Join request row in the admin panel */
.wpcc-jr-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; border-bottom: 1px solid #f5f5f5;
}
.wpcc-jr-row:last-child { border-bottom: none; }
.wpcc-jr-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wpcc-jr-group { font-size: 11px; color: #888; }
.wpcc-jr-btns { display: flex; gap: 6px; flex-shrink: 0; }
