/* ===================================================== */
/* ===== ULTRA PREMIUM FEED CSS — ELITE MASTER BUILD ==== */
/* ===== VERIFIED • NO SHORTCUTS ======================= */
/* ===================================================== */

/* ================= RESET ================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ================= ROOT SYSTEM ================= */
:root {
  --bg-main: #000;
  --bg-soft: #0a0a0a;
  --card-bg: #111;
  --text-main: #fff;
  --text-muted: #aaa;

  --accent: #ff2d55;
  --blue: #00c6ff;
  --orange: #ff7a18;

  --overlay-dark: rgba(0,0,0,0.92);
  --glass: rgba(255,255,255,0.06);
  --nav-bg: rgba(0,0,0,0.85);
  --shadow-heavy: 0 30px 80px rgba(0,0,0,0.9);
}

/* ================= LIGHT MODE ================= */
body.light-mode {
  --bg-main: #f6f7fb;
  --bg-soft: #ffffff;
  --card-bg: #ffffff;
  --text-main: #111;
  --text-muted: #555;
  --overlay-dark: rgba(255,255,255,0.9);
  --glass: rgba(0,0,0,0.05);
  --nav-bg: rgba(255,255,255,0.95);
}

body.light-mode { background: var(--bg-main); color: var(--text-main); }
body.light-mode .brand-title { text-shadow: none; }
body.light-mode .card { background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.15), inset 0 0 10px rgba(0,0,0,0.03); }
body.light-mode .overlay { background: linear-gradient(to top, rgba(255,255,255,0.95), transparent); }
body.light-mode .info, body.light-mode .action span, body.light-mode .story span { color: #111; }
body.light-mode .action i { color: #111; }
body.light-mode .bottom-nav { background: rgba(255,255,255,0.9); color: #111; border-top: 1px solid rgba(0,0,0,0.1); }
body.light-mode .bottom-nav div { color: #111; }
body.light-mode .btn, body.light-mode .join-btn { box-shadow: 0 6px 18px rgba(0,0,0,0.15), inset 0 0 8px rgba(255,255,255,0.4); }
body.light-mode .feature-card { box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
body.light-mode .glass { background: rgba(255,255,255,0.6); backdrop-filter: blur(10px); }

/* ================= BODY ================= */
body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  transition: 0.3s ease;
}

/* ================= APP ================= */
.app {
  padding: 16px;
  padding-bottom: 140px;
}

/* ================= HEADER ================= */
.header {
  text-align: center;
  position: relative;
  margin-bottom: 20px;
}

.brand-title {
  font-size: 34px;
  font-weight: 900;
  background: linear-gradient(45deg, gold, orange);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.theme-toggle {
  position: absolute;
  right: 0;
  top: 5px;
}

/* ===================================================== */
/* ===== STORIES SECTION — INSTAGRAM STYLE ============= */
/* ===================================================== */

.stories-section {
  background: rgba(255,255,255,0.04);
  border-radius: 18px;
  margin: 0 0 20px;
  padding: 12px 0 10px;
  border: 1px solid rgba(255,255,255,0.06);
}

body.light-mode .stories-section {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}

/* ── Search bar ── */
.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 9px 16px;
  margin: 0 14px 12px;
  border: 1.5px solid rgba(255,255,255,0.1);
  transition: border-color 0.2s, background 0.2s;
}

.search-bar-wrap:focus-within {
  border-color: rgba(255,110,199,0.6);
  background: rgba(255,255,255,0.1);
}

body.light-mode .search-bar-wrap {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
}
body.light-mode .search-bar-wrap:focus-within {
  border-color: #ff2d55;
}

.search-bar-wrap i {
  color: #888;
  font-size: 14px;
  flex-shrink: 0;
}

.search-bar-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 14px;
  font-family: 'Segoe UI', sans-serif;
}

.search-bar-wrap input::placeholder { color: #666; }
body.light-mode .search-bar-wrap input { color: #111; }
body.light-mode .search-bar-wrap input::placeholder { color: #999; }
body.light-mode .search-bar-wrap i { color: #777; }

.search-clear {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  line-height: 1;
  display: none;
  transition: color 0.2s;
}
.search-clear:hover { color: #ccc; }

/* ── Search results dropdown ── */
.search-results-wrap {
  margin: 0 14px;
}

.search-results-drop {
  display: none;
  background: rgba(15,12,40,0.98);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.search-results-drop.open { display: block; }

body.light-mode .search-results-drop {
  background: rgba(255,255,255,0.98);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(255,255,255,0.07); }
body.light-mode .search-result-item:hover { background: rgba(0,0,0,0.04); }

.search-result-item img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ff6ec7;
  flex-shrink: 0;
}

.search-result-item .r-info {
  flex: 1;
  min-width: 0;
}

.search-result-item .r-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item .r-user {
  font-size: 12px;
  color: #888;
  margin-top: 1px;
}

body.light-mode .search-result-item .r-name { color: #111; }
body.light-mode .search-result-item .r-user { color: #666; }

.search-result-item .r-add-btn {
  background: linear-gradient(90deg, #ff6ec7, #ff2d55);
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
}

.search-result-item .r-add-btn:hover { opacity: 0.85; }

.search-result-item .r-add-btn.added {
  background: #2a2a2a;
  color: #777;
  cursor: default;
}
body.light-mode .search-result-item .r-add-btn.added {
  background: #e0e0e0;
  color: #999;
}

.search-no-result {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 13px;
}

/* ── Stories scrollable row ── */
.stories {
  display: flex;
  gap: 14px;
  padding: 2px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.stories::-webkit-scrollbar { display: none; }

/* ── Each story wrapper ── */
.story-wrap {
  position: relative;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  width: 74px;
  padding-bottom: 2px;
}

/* ── Avatar gradient ring (Instagram style) ── */
.story-avatar-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(135deg, #ff6ec7, #ff2d55);
  display: block;
  margin: 0 auto 5px;
}

.story-wrap.online .story-avatar-ring {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}
.story-wrap.you .story-avatar-ring {
  background: linear-gradient(135deg, #ffcc70, #ff6ec7);
}
.story-wrap.friend-added .story-avatar-ring {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
}

/* ── Avatar image ── */
.story-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2.5px solid #0f0c29;
  background: #1a1a2e;
  transition: transform 0.2s;
}
body.light-mode .story-avatar { border-color: #f5f7fa; }

.story-wrap:hover .story-avatar { transform: scale(1.07); }

/* ── Online dot ── */
.online-dot {
  position: absolute;
  bottom: 28px;
  right: 1px;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border-radius: 50%;
  border: 2.5px solid #0f0c29;
  pointer-events: none;
  z-index: 2;
}
body.light-mode .online-dot { border-color: #f5f7fa; }

/* ── Friend tick badge (top-right) ── */
.friend-tick {
  position: absolute;
  top: 0;
  right: 0;
  width: 21px;
  height: 21px;
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  border-radius: 50%;
  border: 2px solid #0f0c29;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: white;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 3;
}

.story-wrap.friend-added .friend-tick {
  opacity: 1;
  transform: scale(1);
}

body.light-mode .friend-tick { border-color: #f5f7fa; }

/* ── Name labels ── */
.story-real-name {
  font-size: 11.5px;
  font-weight: 500;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 72px;
  margin: 0 auto 1px;
}

.story-username {
  font-size: 10px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 72px;
  margin: 0 auto;
}

body.light-mode .story-real-name { color: #222; }
body.light-mode .story-username   { color: #666; }

/* ================= FEATURES ================= */
.features {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
}

.feature-card {
  flex: 1;
  height: 140px;
  border-radius: 22px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-heavy);
  transition: transform 0.25s;
}
.feature-card:hover { transform: scale(1.04); }

.feature-card.left  { background: linear-gradient(135deg, #ff7eb3, #ff758c); }
.feature-card.right { background: linear-gradient(135deg, #43e97b, #38f9d7); }

.feature-card h3 { margin: 0 0 10px; font-size: 15px; }

.premium-btn {
  background: rgba(255,255,255,0.25);
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  color: white;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.premium-btn:hover { background: rgba(255,255,255,0.4); }

/* ================= LIVE SECTION ================= */
.section-title {
  font-size: 22px;
  margin-bottom: 14px;
}

/* ===================================================== */
/* ===== FEED GRID ===================================== */
/* ===================================================== */
.feed {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: visible;
  scroll-snap-type: none;
  padding: 4px;
}
.feed::-webkit-scrollbar { display: none; }

/* ================= CARD ================= */
.card {
  position: relative;
  width: 160px;
  height: 420px;
  min-width: 160px;
  max-width: 160px;
  min-height: 420px;
  max-height: 420px;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: var(--card-bg);
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: transform 0.2s ease;
}

#liveFeed .card {
  width: auto;
  max-width: none;
  min-width: 0;
}

.card:hover { transform: scale(1.03); }

/* ================= VIDEO ================= */
.card-video {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.card-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  position: relative;
  filter: brightness(0.9) contrast(1.05);
  transform: scale(1.05);
  transition: transform 0.4s ease;
}
.card:hover .card-video video { transform: scale(1.1); }

/* ================= THUMBNAIL ================= */
.card-video img.thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  transition: opacity 0.4s ease;
}
.card-video video { position: absolute; inset: 0; z-index: 2; opacity: 0; }

/* ================= BLUR OVERLAY ================= */
.video-blur {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(10px);
  background: rgba(0,0,0,0.15);
  z-index: 2;
  pointer-events: none;
}
.card:hover .video-blur {
  backdrop-filter: blur(0px);
  background: rgba(0,0,0,0.05);
}

/* TikTok depth gradient */
.card-video::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 10%, rgba(0,0,0,0.2) 40%, transparent 70%);
  z-index: 3;
  pointer-events: none;
}

/* ================= SHIMMER ================= */
.shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, rgba(255,255,255,0.05) 20%, rgba(255,255,255,0.25) 40%, rgba(255,255,255,0.05) 60%);
  background-size: 200% 100%;
  animation: shimmerMove 1.2s infinite;
  transition: opacity 0.4s ease;
  z-index: 4;
  opacity: 0.6;
  mix-blend-mode: overlay;
}
.card:hover .shimmer { opacity: 0; }

@keyframes shimmerMove {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ================= CANVAS THUMB ================= */
.thumb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, #1a1a2e 25%, #2a2a4e 50%, #1a1a2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-shimmer.hidden { display: none; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.thumb-shimmer-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.25);
  font-size: 13px;
}
.thumb-shimmer-icon i { font-size: 44px; }

/* ================= PAUSE OVERLAY ================= */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 5;
}
.pause-icon {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.pause-label { color: rgba(255,255,255,0.92); font-size: 13px; font-weight: 600; }
.tap-hint    { color: rgba(255,255,255,0.5);  font-size: 11px; margin-top: 5px; }
.card.paused .pause-overlay { opacity: 1; }

/* ================= LIVE BADGE ================= */
.live-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: red;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.25s;
  box-shadow: 0 0 12px rgba(255,0,0,0.8), 0 0 24px rgba(255,100,0,0.6);
  animation: livePulse 1.2s infinite;
}

@keyframes livePulse {
  0%   { transform: scale(1);    opacity: 1; }
  50%  { transform: scale(1.08); opacity: 0.85; }
  100% { transform: scale(1);    opacity: 1; }
}

.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: white;
  flex-shrink: 0;
  animation: blink 1.2s infinite;
}
.card.paused .live-dot { animation: none; opacity: 0.4; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* ================= VIEWER COUNT ================= */
.viewer-count {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0,0,0,0.52);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 11px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ================= CARD OVERLAY ================= */
.overlay {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 15px;
  background: linear-gradient(transparent, rgba(0,0,0,0.88));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}
.overlay-user { font-size: 13px; font-weight: 600; }

.join-btn {
  background: linear-gradient(90deg, #00c6ff, #0072ff);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.2s;
}
.join-btn:hover { opacity: 0.82; }

/* ================= CARD DEPTH FX ================= */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 26px;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.6);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: 0.3s;
}
.card:hover::before { opacity: 1; }

/* ===================================================== */
/* ===== LIVE FEED GRID ================================= */
/* ===================================================== */
#liveFeed {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
  gap: 18px !important;
  padding: 10px;
}
#liveFeed .card {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 9 / 16;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 0 !important;
  max-height: none !important;
}
#liveFeed .card-video img { width: 100%; height: 100%; object-fit: cover; }
#liveFeed .overlay { padding: 12px; font-size: 14px; }
#liveFeed:has(.card:only-child) {
  grid-template-columns: 1fr;
  max-width: 320px;
  margin: auto;
}

/* ===================================================== */
/* ===== BOTTOM NAV ==================================== */
/* ===================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding: 12px 0 16px;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  z-index: 9999;
}

.bottom-nav div {
  flex: 1;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.2s;
}
.bottom-nav div:hover { opacity: 0.65; }
.bottom-nav i    { font-size: 20px; display: block; color: white; }
.bottom-nav span { font-size: 11px; color: white; }

body.light-mode .bottom-nav i    { color: #111; }
body.light-mode .bottom-nav span { color: #111; }

/* Nav profile avatar */
.nav-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #ff6ec7;
  object-fit: cover;
  display: block;
  margin: 0 auto 2px;
}

/* Nav friend mini-avatars (chat + invite) */
.nav-friends-row {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 26px;
  margin-bottom: 2px;
}
.nav-friend-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #0f0c29;
  object-fit: cover;
  margin-left: -5px;
  background: #333;
}
.nav-friend-dot:first-child { margin-left: 0; }
body.light-mode .nav-friend-dot { border-color: #f5f7fa; }

/* ===================================================== */
/* ===== FULLSCREEN MODE =============================== */
/* ===================================================== */
.fullscreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100vh;
  background: var(--bg-main);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
}
.fullscreen.active { display: flex; }
.full-card {
  height: 100vh; width: 100%;
  position: relative;
  scroll-snap-align: start;
}
.full-card video { width: 100%; height: 100%; object-fit: cover; }

/* ================= ACTION BAR ================= */
.action-bar {
  position: absolute;
  right: 14px; bottom: 140px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  align-items: center;
}
.action { text-align: center; color: white; cursor: pointer; }
.action i { font-size: 32px; transition: 0.2s; }
.action span { font-size: 12px; }
.action:active i { transform: scale(1.2); }
.action.like.active i { color: #ff2d55; }
.back-btn {
  position: absolute;
  top: 20px; left: 16px;
  border: none; padding: 10px;
  border-radius: 50%;
  color: white;
  background: rgba(0,0,0,0.5);
}

/* ===================================================== */
/* ===== HEART SYSTEM ================================== */
/* ===================================================== */
.big-heart {
  position: absolute;
  top: 50%; left: 50%;
  font-size: 100px;
  opacity: 0;
  transform: translate(-50%,-50%);
}
.heart {
  position: absolute;
  font-size: 28px;
  animation: floatUp 1s ease forwards;
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(0.6); opacity: 1; }
  100% { transform: translateY(-150px) scale(1.5); opacity: 0; }
}

/* ===================================================== */
/* ===== UTILITY ======================================= */
/* ===================================================== */
.no-live-msg { text-align: center; width: 100%; opacity: 0.7; padding: 50px 0; font-size: 15px; }

.fade-in  { animation: fadeIn 0.5s ease; }
.scale-in { animation: scaleIn 0.4s ease; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.mt-1 { margin-top: 8px; }   .mt-2 { margin-top: 16px; }   .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.center { justify-content: center; align-items: center; }

html { scroll-behavior: smooth; }