/* ===== POPUP WRAPPER ===== */
.popup {
  display: none;
}

/* ===== OVERLAY ===== */
.profilePopup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
  isolation: isolate;
}

.profilePopup-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== MODAL ===== */
.profilePopup-modal {
  width: 400px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  background: #000;
  border-radius: 16px;
  border: 0.5px solid #2a2a2a;
  position: relative;
  transform: scale(0.88);
  transition: transform 0.3s ease;
  scrollbar-width: none;
}

.profilePopup-modal::-webkit-scrollbar {
  display: none;
}

.profilePopup-overlay.active .profilePopup-modal {
  transform: scale(1);
}

.profilePopup-modal.lb-open {
  overflow: hidden;
}

/* ===== CLOSE BUTTON ===== */
.profilePopup-close {
  position: absolute;
  right: 10px;
  top: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.profilePopup-close:hover {
  background: rgba(0, 0, 0, 0.65);
}

/* ===== COVER ===== */
.profilePopup-cover {
  height: 75px;
  background: linear-gradient(135deg, #f058a0, #f7a04b, #fcdf5b);
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-shrink: 0;
}

/* ===== AVATAR ===== */
.profilePopup-avatar-wrap {
  position: absolute;
  bottom: -36px;
  left: 16px;
}

.profilePopup-avatar-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f9a825, #f058a0, #a259f7);
  padding: 2.5px;
  transition: transform 0.2s;
}

.profilePopup-avatar-ring:hover {
  transform: scale(1.06);
}

.profilePopup-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #000;
  border: 3px solid #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.profilePopup-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===== BODY ===== */
.profilePopup-body {
  padding: 48px 16px 16px;
}

/* ===== NAME ROW ===== */
.profilePopup-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.profilePopup-name {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  margin-bottom: 2px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.profilePopup-verified {
  background: #3797f0;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
}

.profilePopup-handle {
  font-size: 13px;
  color: #aaa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== BUTTONS ===== */
.profilePopup-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.profilePopup-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.profilePopup-btn:active {
  transform: scale(0.97);
}

.profilePopup-btn-follow {
  background: #3797f0;
  color: #fff;
}

.profilePopup-btn-follow:hover {
  background: #1877d2;
}

.profilePopup-btn-msg {
  background: #262626;
  color: #fff;
  border: 0.5px solid #3a3a3a;
}

.profilePopup-btn-msg:hover {
  background: #333;
}

/* ===== BIO ===== */
.profilePopup-bio {
  font-size: 13px;
  color: #dfdfdf;
  line-height: 1.6;
  margin-bottom: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.profilePopup-tag {
  color: #4da3ff;
  cursor: pointer;
}

/* ===== STORIES / HIGHLIGHTS ===== */
/* ===== STORIES / HIGHLIGHTS ===== */
.profilePopup-stories {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 10px 0 5px;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  max-width: 100%;
  cursor: grab;
  scroll-behavior: smooth;
  
  /* Completely hide scrollbar on all devices */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.profilePopup-stories:active {
  cursor: grabbing;
}

/* Hide scrollbar for Chrome, Safari, Opera */
.profilePopup-stories::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

/* For desktop - keep scrollbar hidden even on hover */
@media (min-width: 768px) {
  .profilePopup-stories {
    scrollbar-width: none;
  }
  
  .profilePopup-stories:hover {
    scrollbar-width: thin;
    scrollbar-color: #4a4a4a #1a1a1a; /* thumb color track color */
  }
  
  .profilePopup-stories:hover::-webkit-scrollbar {
    display: block;
    height: 2px; /* Ultra thin */
  }
  
  .profilePopup-stories::-webkit-scrollbar {
    display: none;
  }
  .profilePopup-stories::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 2px;
    transition: background 0.2s ease;
  }
  
  .profilePopup-stories:hover::-webkit-scrollbar-track {
    background: rgba(26, 26, 26, 0.6); /* Dark semi-transparent track */
  }
  
  .profilePopup-stories:hover::-webkit-scrollbar-thumb {
    background: #4a4a4a; /* Medium gray thumb */
  }
  
  .profilePopup-stories:hover::-webkit-scrollbar-thumb:hover {
    background: #6a6a6a; /* Lighter on hover */
  }
}

/* Ensure on desktop without hover, scrollbar remains hidden */
@media (min-width: 768px) {
  .profilePopup-stories::-webkit-scrollbar {
    display: none;
  }
}

.profilePopup-story {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  min-width: 60px;
  flex-shrink: 0;
}

.profilePopup-story-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f9a825, #f058a0, #a259f7);
  padding: 2px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.profilePopup-story-ring:hover {
  transform: scale(1.08);
}

/* Greyed-out ring for "New Post" or empty stories */
.profilePopup-story-ring.pp-no-story {
  background: #444;
}

.profilePopup-story-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #1a1a1a;
  border: 2px solid #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.profilePopup-story-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profilePopup-story-name {
  font-size: 10px;
  color: #aaa;
  text-align: center;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== STATS ===== */
.profilePopup-stats {
  display: flex;
  border-top: 0.5px solid #1e1e1e;
  border-bottom: 0.5px solid #1e1e1e;
  padding: 12px 0;
  margin-bottom: 4px;
}

.profilePopup-stat {
  flex: 1;
  text-align: center;
}

.profilePopup-stat + .profilePopup-stat {
  border-left: 0.5px solid #1e1e1e;
}

.profilePopup-num {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.profilePopup-label {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== TABS ===== */
.profilePopup-tabs {
  display: flex;
  border-bottom: 0.5px solid #1e1e1e;
  margin: 0 -16px;
}

.profilePopup-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profilePopup-tab.active {
  color: #fff;
  border-bottom: 2px solid #fff;
}

/* ===== GRID ===== */
.profilePopup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 2px -16px 0;
}

.profilePopup-post {
  aspect-ratio: 1;
  background: #111;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.profilePopup-post img,
.profilePopup-post video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s;
  display: block;
}

.profilePopup-post:hover img,
.profilePopup-post:hover video {
  transform: scale(1.06);
}

.profilePopup-post .pp-reel-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profilePopup-post .pp-likes {
  position: absolute;
  bottom: 5px;
  left: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.profilePopup-post:hover .pp-likes {
  opacity: 1;
}

/* ===== LOADER ===== */
.profilePopup-loader {
  display: flex;
  justify-content: center;
  padding: 16px;
}

.profilePopup-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: ppSpin 0.7s linear infinite;
}

@keyframes ppSpin {
  to { transform: rotate(360deg); }
}

/* ===== LIGHTBOX ===== */
.profilePopup-lightbox {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  z-index: 10001;
  border-radius: 16px;
  animation: ppFadeIn 0.2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes ppFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.profilePopup-lb-inner {
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.profilePopup-lb-inner img,
.profilePopup-lb-inner video {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}

.profilePopup-lb-close {
  position: absolute;
  top: -38px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.profilePopup-lb-caption {
  margin-top: 12px;
  color: #ccc;
  font-size: 12px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== COVER HANDLE TEXT ===== */
#profilePopup-id {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.3), 0 0 10px rgba(255,255,255,0.4);
  padding: 6px 14px;
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

/* ===== STORY VIEWER ===== */
.pp-sv-overlay {
  position: absolute;
  inset: 0;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.96);
  border-radius: 16px;
  animation: ppFadeIn 0.2s ease;
}

.pp-sv-inner {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  display: flex;
  flex-direction: column;
}

/* Progress bars */
.pp-sv-bars {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.pp-sv-bar-wrap {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  overflow: hidden;
}

.pp-sv-bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: none;
}

/* Header */
.pp-sv-header {
  position: absolute;
  top: 22px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.pp-sv-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pp-sv-avatar-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f9a825, #f058a0, #a259f7);
  padding: 2px;
  flex-shrink: 0;
}

.pp-sv-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #222;
  border: 2px solid #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.pp-sv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.pp-sv-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.pp-sv-time {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.pp-sv-close {
  background: rgba(0,0,0,0.4);
  border: none;
  color: #fff;
  font-size: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.pp-sv-close:hover {
  background: rgba(0,0,0,0.65);
}

/* Media */
.pp-sv-media-wrap {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
}

/* Caption */
.pp-sv-caption {
  position: absolute;
  bottom: 24px;
  left: 16px;
  right: 16px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  text-align: center;
  z-index: 10;
  background: rgba(0,0,0,0.3);
  padding: 6px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* Tap zones (left / right) */
.pp-sv-tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  z-index: 9;
  cursor: pointer;
}

.pp-sv-tap-left  { left: 0; }
.pp-sv-tap-right { right: 0; }

/* Lightbox header with download and close buttons */
.profilePopup-lb-header {
  position: absolute;
  top: -38px;
  right: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.profilePopup-lb-download {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.profilePopup-lb-download:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.profilePopup-lb-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.profilePopup-lb-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Better touch feedback for mobile */
.profilePopup-story {
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y; /* Allow touch scrolling but preserve clicks */
}

.profilePopup-story-ring,
.profilePopup-story-img {
  pointer-events: auto; /* Ensure clicks register */
}

.profilePopup-story {
  scroll-snap-align: start;
}

.profilePopup-stories:active {
  cursor: grabbing;
}

/* Custom scrollbar for desktop (optional) */
.profilePopup-stories::-webkit-scrollbar {
  height: 4px;
  display: block;
}

.profilePopup-stories::-webkit-scrollbar-track {
  background: #222;
  border-radius: 4px;
}

.profilePopup-stories::-webkit-scrollbar-thumb {
  background: #666;
  border-radius: 4px;
}

.profilePopup-stories::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* Add invisible padding areas between stories for better drag area */
.profilePopup-story {
  margin: 0 2px;
}


@media (min-width: 768px) {
  .profilePopup-stories::-webkit-scrollbar-thumb {
    transition: background 0.3s ease;
  }
  
  .profilePopup-stories:hover::-webkit-scrollbar-thumb {
    background: #666;
  }
}

/* Optional: Add fade effect to indicate scrollable content */
.profilePopup-stories {
  position: relative;
}

.profilePopup-stories::after {
  content: '';
  position: sticky;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.3));
  pointer-events: none;
  z-index: 1;
}

/* Left side fade */
.profilePopup-stories::before {
  content: '';
  position: sticky;
  left: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to left, transparent, rgba(0,0,0,0.3));
  pointer-events: none;
  z-index: 1;
}