/* ================================================================
   LOKTUBE PWA APP FIX — Production Polish
   Fixes: black screens, safe area, nav overlap, app-like feel
   ================================================================ */

/* ── Safe Area / Notch Support ── */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ── PWA Installed App Styles ── */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .navbar {
    padding-top: var(--safe-top);
  }
  .mobile-bottom-nav {
    padding-bottom: calc(var(--safe-bottom) + 4px);
  }
  body { /* No browser chrome bounce */
    overscroll-behavior: none;
  }
}

/* ── Bottom Nav — exact reference image style ── */
.mobile-bottom-nav {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--bg, #0A0A0A) !important;
  border-top: 1px solid var(--border, rgba(255,107,0,.18)) !important;
  padding-bottom: max(var(--safe-bottom), 8px);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.mobile-bottom-nav-inner {
  display: flex !important;
  align-items: center;
  justify-content: space-around;
  padding: 4px 0 2px;
  max-width: 600px;
  margin: 0 auto;
}
.mbn-item {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--text2, #9A8070);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  min-width: 44px;
  border-radius: 10px;
  transition: color .15s, background .15s;
  position: relative;
}
.mbn-item i {
  font-size: 21px !important;
  display: block;
  line-height: 1;
}
.mbn-item span {
  font-size: 9.5px !important;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.mbn-item.active,
.mbn-item:active {
  color: var(--accent, #FF6B00) !important;
}
.mbn-item.active i {
  filter: drop-shadow(0 0 6px var(--accent, #FF6B00));
}

/* Create button */
.mbn-create-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mbn-create-btn {
  width: 48px !important;
  height: 48px !important;
  border-radius: 14px !important;
  background: var(--accent, #FF6B00) !important;
  border: none !important;
  color: #fff !important;
  font-size: 22px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,107,0,.4);
  text-decoration: none;
  margin-top: -10px;
  transition: transform .18s, box-shadow .18s;
}
.mbn-create-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(255,107,0,.3);
}
.mbn-create-wrap > span {
  font-size: 9.5px !important;
  font-weight: 700;
  color: var(--text2, #9A8070);
  line-height: 1;
}
.mbn-badge {
  position: absolute !important;
  top: 4px;
  right: 6px;
  background: #ef4444 !important;
  color: #fff !important;
  font-size: 9px !important;
  font-weight: 800 !important;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Shorts page — kill duplicate nav ── */
.shorts-page .mobile-bottom-nav,
.shorts-page .bottom-nav {
  display: none !important;
}
/* Show the correct one */
.shorts-page #bottomNav {
  display: flex !important;
}

/* ── Page transitions for app feel ── */
.page-fade-in {
  animation: pageFade .22s ease;
}
@keyframes pageFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Black screen prevention ── */
.short-video[src=""],
.short-video:not([src]) {
  background: #111 !important;
}
.short-item {
  background: #0a0a0a !important;
}
/* Fallback poster when video fails */
video[src=""] {
  background: var(--bg3, #181818);
}

/* ── Watch page — no black overflow ── */
.watch-player-wrap,
.vp-outer {
  background: #000 !important;
  min-height: 200px;
}
.video-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #111;
  color: rgba(255,255,255,.5);
  font-size: 14px;
  gap: 8px;
  border-radius: 12px;
}

/* ── Story strip fix ── */
.story-strip {
  display: flex !important;
  overflow-x: auto;
  gap: 12px;
  padding: 8px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.story-strip::-webkit-scrollbar { display: none; }

/* ── Channel profile layout ── */
.ch-banner-wrap {
  width: 100%;
  aspect-ratio: 16/5;
  background: var(--g-banner, linear-gradient(135deg, #3D1500, #FF6B00));
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  position: relative;
}
.ch-stats-row {
  display: flex;
  gap: 20px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.ch-stat {
  text-align: center;
  min-width: 60px;
}
.ch-stat-val {
  font-size: 18px;
  font-weight: 900;
  color: var(--text, #F0E8DC);
  line-height: 1;
}
.ch-stat-label {
  font-size: 11px;
  color: var(--text2, #9A8070);
  font-weight: 700;
  margin-top: 3px;
}

/* ── Light theme refinements (reference image) ── */
[data-theme="light"] .mobile-bottom-nav {
  background: #fff !important;
  border-top-color: #e5e7eb !important;
}
[data-theme="light"] .mbn-item {
  color: #6b7280;
}
[data-theme="light"] .mbn-item.active {
  color: var(--accent, #FF6B00) !important;
}

/* ── Toast / Snackbar - reference style ── */
.lk-toast {
  position: fixed;
  bottom: calc(70px + var(--safe-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 99999;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,107,0,.25);
}
.lk-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Scrollbar fix for app feel ── */
* { scrollbar-width: thin; scrollbar-color: rgba(255,107,0,.25) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,107,0,.25); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Pull to refresh indicator ── */
.ptr-indicator {
  position: fixed;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent, #FF6B00);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: top .3s;
  z-index: 99999;
}
.ptr-indicator.visible { top: 60px; }

/* ── App splash overlay (for Capacitor) ── */
#app-splash {
  position: fixed;
  inset: 0;
  background: #09090f;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  transition: opacity .4s;
}
#app-splash.hidden {
  opacity: 0;
  pointer-events: none;
}
#app-splash .splash-logo {
  font-size: 52px;
  font-weight: 900;
  color: #FF6B00;
  letter-spacing: -1px;
}
#app-splash .splash-sub {
  font-size: 13px;
  color: rgba(255,255,255,.4);
  font-weight: 600;
}

/* ── Video card improvements ── */
.yt-card {
  border: 1px solid transparent;
  transition: border-color .18s, transform .18s;
}
.yt-card:hover {
  border-color: var(--border2, rgba(255,107,0,.28));
  transform: translateY(-2px);
}

/* ── Creator studio tab overflow fix ── */
.studio-nav {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.studio-nav::-webkit-scrollbar { display: none; }

/* ── Feed filter pills (reference Image 1) ── */
.cat-pills-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}
.cat-pills-row::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border, rgba(255,107,0,.18));
  color: var(--text2, #9A8070);
  background: var(--bg2, #111);
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s;
}
.cat-pill:hover,
.cat-pill.active {
  background: var(--accent, #FF6B00);
  color: #fff;
  border-color: var(--accent, #FF6B00);
}

/* ── Mobile page padding (above bottom nav) ── */
@media (max-width: 768px) {
  .main-content,
  .page-content,
  .feed-wrap,
  .watch-page-wrap {
    padding-bottom: calc(70px + var(--safe-bottom, 0px)) !important;
  }
}
