/* User profile pop-up — theme-aware */
.user-profile-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(6px);
}
.user-profile-popup-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ── Card shell ───────────────────────────────────────── */
.user-profile-popup-card {
  background: #181a23;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px) scale(0.97);
  opacity: 0;
  animation: user-profile-pop-in 0.22s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}
@keyframes user-profile-pop-in {
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ── Loading / error states ──────────────────────────── */
.user-profile-popup-loading {
  padding: 44px 40px;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.user-profile-popup-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: user-profile-spin 0.8s linear infinite;
}
@keyframes user-profile-spin {
  to { transform: rotate(360deg); }
}

/* ── Banner ───────────────────────────────────────────── */
/* overflow: visible so the avatar can extend below the banner.
   The card's own overflow: hidden clips everything to the card boundary. */
.user-profile-popup-banner {
  height: 82px;
  background:
    radial-gradient(ellipse at 15% 65%, rgba(74, 144, 226, 0.8) 0%, transparent 55%),
    radial-gradient(ellipse at 88% 30%, rgba(120, 255, 214, 0.55) 0%, transparent 50%),
    linear-gradient(140deg, #0c1e3d 0%, #0f1827 55%, #0a1520 100%);
  position: relative;
  flex-shrink: 0;
  overflow: visible;
}

/* ── Avatar wrap — absolute inside banner, straddles the boundary ── */
/* The wrap is positioned; avatar + badge sit inside it. */
.user-profile-popup-avatar-wrap {
  position: absolute;
  left: 20px;
  bottom: -37px;   /* 37px = half of 74px avatar, so avatar straddles banner edge */
  z-index: 1;
  display: inline-block;
  line-height: 0;
}

.user-profile-popup-avatar {
  display: block;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid #181a23;
  outline: 2px solid rgba(74, 144, 226, 0.5);
  object-fit: cover;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

/* Status badge — colored circle on the bottom-right of the avatar */
.user-profile-popup-status-badge {
  position: absolute;
  bottom: 4px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2.5px solid #181a23;   /* matches card bg — creates the "ring" separation */
}
.user-profile-popup-status-badge.online  { background: #22c55e; }
.user-profile-popup-status-badge.busy    { background: #ef4444; }
.user-profile-popup-status-badge.afk     { background: #f59e0b; }
.user-profile-popup-status-badge.offline { background: #6b7280; }

/* ── Info block — sits below the banner, leaves room for the avatar ── */
/* avatar = 74px + 3px border*2 = 80px visual. It extends 37px below banner.
   padding-top = 37 + 12px gap = 49px so name/feeling clear the avatar. */
.user-profile-popup-info {
  padding: 49px 20px 14px;
}

/* keep .user-profile-popup-head-text as a no-op alias in case old HTML is cached */
.user-profile-popup-head-text {
  flex: 1;
  min-width: 0;
}

.user-profile-popup-name {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f1f1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-popup-status {
  margin: 0 0 3px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  gap: 5px;
}

.user-profile-popup-feeling {
  margin: 0;
  font-size: 0.77rem;
  color: rgba(120, 255, 214, 0.8);
  font-style: italic;
}

/* ── Bio ──────────────────────────────────────────────── */
.user-profile-popup-bio {
  margin: 0 16px 14px;
  padding: 10px 14px;
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border-left: 2px solid rgba(74, 144, 226, 0.45);
  max-height: 80px;
  overflow-y: auto;
}

/* ── Stats chips ──────────────────────────────────────── */
.user-profile-popup-stats {
  padding: 0 16px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(74, 144, 226, 0.1);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(74, 144, 226, 0.22);
  letter-spacing: 0.01em;
}
.user-profile-chip .material-symbols-outlined {
  font-size: 13px;
  opacity: 0.75;
}

/* ── Footer ───────────────────────────────────────────── */
.user-profile-popup-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-profile-popup-meta {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.42);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-profile-popup-actions {
  display: flex;
  gap: 8px;
}

/* ── Buttons ──────────────────────────────────────────── */
.user-profile-popup-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #f1f1f1;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, filter 0.18s ease;
}
.user-profile-popup-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.user-profile-popup-btn:active:not(:disabled) {
  transform: translateY(0);
}
.user-profile-popup-btn.primary {
  background: #4a90e2;
  border-color: transparent;
  color: #fff;
}
.user-profile-popup-btn.primary:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
}
.user-profile-popup-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}
.user-profile-popup-btn.danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.32);
  color: #f87171;
}
.user-profile-popup-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.58);
  color: #ef4444;
  transform: translateY(-1px);
}
.user-profile-popup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.user-profile-popup-error {
  margin: 0 0 10px;
  color: #f87171;
  font-size: 0.88rem;
}

/* ── Status dots ──────────────────────────────────────── */
.user-profile-popup-card .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.user-profile-popup-card .status-dot.online  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25); }
.user-profile-popup-card .status-dot.busy    { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25); }
.user-profile-popup-card .status-dot.afk     { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25); }
.user-profile-popup-card .status-dot.offline { background: rgba(255, 255, 255, 0.28); }

/* ── Pending-out state ────────────────────────────────── */
.user-profile-popup-pending-out {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-profile-popup-pending-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.85);
}
.user-profile-pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a90e2;
  flex-shrink: 0;
  animation: user-profile-pending-pulse 1.5s ease-in-out infinite;
}
@keyframes user-profile-pending-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.25); }
}
.user-profile-popup-pending-hint {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.38);
  margin: 0;
  line-height: 1.45;
}

/* ── Light theme overrides ────────────────────────────── */
html.theme-earth-sky .user-profile-popup-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}
html.theme-earth-sky .user-profile-popup-avatar {
  border-color: #ffffff;
  outline-color: rgba(74, 144, 226, 0.4);
}
html.theme-earth-sky .user-profile-popup-status-badge {
  border-color: #ffffff;
}
html.theme-earth-sky .user-profile-popup-name {
  color: #111827;
}
html.theme-earth-sky .user-profile-popup-status {
  color: rgba(0, 0, 0, 0.48);
}
html.theme-earth-sky .user-profile-popup-feeling {
  color: #0d9488;
}
html.theme-earth-sky .user-profile-popup-bio {
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.65);
  border-left-color: rgba(74, 144, 226, 0.5);
}
html.theme-earth-sky .user-profile-chip {
  background: rgba(74, 144, 226, 0.08);
  color: rgba(0, 0, 0, 0.65);
  border-color: rgba(74, 144, 226, 0.22);
}
html.theme-earth-sky .user-profile-popup-footer {
  border-top-color: rgba(0, 0, 0, 0.07);
}
html.theme-earth-sky .user-profile-popup-meta {
  color: rgba(0, 0, 0, 0.42);
}
html.theme-earth-sky .user-profile-popup-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #111827;
}
html.theme-earth-sky .user-profile-popup-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.07);
}
html.theme-earth-sky .user-profile-popup-btn.primary {
  background: #4a90e2;
  border-color: transparent;
  color: #fff;
}
html.theme-earth-sky .user-profile-popup-btn.secondary {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}
html.theme-earth-sky .user-profile-popup-btn.danger {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.28);
  color: #ef4444;
}
html.theme-earth-sky .user-profile-popup-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
}
html.theme-earth-sky .user-profile-popup-close {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(255, 255, 255, 0.85);
}
html.theme-earth-sky .user-profile-popup-close:hover {
  background: rgba(0, 0, 0, 0.45);
}
html.theme-earth-sky .user-profile-popup-pending-label {
  color: rgba(0, 0, 0, 0.8);
}
html.theme-earth-sky .user-profile-popup-pending-hint {
  color: rgba(0, 0, 0, 0.4);
}
