/* =====================================================
   APP PAGE — app.html styles
   ===================================================== */

/* ── Name Entry Overlay ───────────────────────────────── */
.name-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(7, 7, 16, 0.96);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.4s ease;
}
.name-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  padding: 52px 44px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg), var(--glow);
  animation: fadeInUp 0.5s ease both;
}
.name-modal-icon {
  font-size: 3.2rem;
  margin-bottom: 20px;
  display: block;
  animation: float 3s ease-in-out infinite;
}
.name-modal h2 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}
.name-modal p {
  font-size: 0.95rem;
  color: var(--text-sub);
  margin-bottom: 28px;
  line-height: 1.65;
}
.name-input-wrap {
  position: relative;
  margin-bottom: 18px;
}
.name-input {
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--r-full);
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
  outline: none;
  text-align: center;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.name-input::placeholder { color: var(--text-muted); }
.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.18);
}
.name-go-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--r-full);
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 4px 22px rgba(124, 92, 252, 0.42);
  transition: transform var(--ease), box-shadow var(--ease);
}
.name-go-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 92, 252, 0.6);
}
.name-skip {
  display: block;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--ease);
}
.name-skip:hover { color: var(--text-sub); }

/* ── App Shell ────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ── App Navbar ───────────────────────────────────────── */
.app-nav {
  height: 58px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}
.app-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-right: auto;
}
.app-nav-logo .live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--live-red);
  box-shadow: 0 0 6px var(--live-red);
  animation: pulse-dot 1.6s ease-in-out infinite;
}
.app-nav-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--r-full);
  transition: color var(--ease), background var(--ease);
}
.app-nav-link:hover { color: var(--text-sub); background: var(--bg-card); }

/* ── Main Area ────────────────────────────────────────── */
.app-main {
  display: grid;
  grid-template-columns: 1fr 380px;
  overflow: hidden;
}

/* ── Stream Panel ─────────────────────────────────────── */
.stream-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
  position: relative;
}

.stream-video {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

/* Real camera video layer (enabled once permission is granted) */
.camera-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  z-index: 1;
  transform: scaleX(-1); /* mirror preview like common front camera UX */
}
.stream-video.camera-active .camera-feed { display: block; }
.stream-video.camera-active::before { opacity: 0.15; }
.camera-glass-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 80% at 50% 10%, rgba(255,255,255,0.2) 0%, transparent 50%),
    linear-gradient(145deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.03) 45%, rgba(0,0,0,0.12) 100%);
  mix-blend-mode: soft-light;
  backdrop-filter: blur(1px) saturate(120%);
}

/* Animated fake webcam feed */
.stream-video::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 80% at 30% 40%, rgba(124,92,252,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 70% 60%, rgba(233,30,140,0.08) 0%, transparent 55%),
    linear-gradient(160deg, #0d0d1e 0%, #050510 50%, #0d0520 100%);
  background-size: 200% 200%;
  animation: gradMove 12s ease infinite;
}

/* Noise grain overlay */
.stream-video::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.35;
  pointer-events: none;
}

.stream-hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 22px;
  z-index: 2;
}

.stream-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--live-red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: var(--r-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 2px 12px rgba(255, 59, 59, 0.5);
}
.live-badge .live-indicator {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.top-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.mode-btn {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  padding: 6px 10px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.mode-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.mode-btn.active {
  background: rgba(124,92,252,0.26);
  border-color: rgba(124,92,252,0.65);
  color: #d7cbff;
}

.viewer-count {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}
.viewer-count svg { width: 13px; height: 13px; fill: currentColor; opacity: 0.75; }

.stream-timer {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Center avatar — you are live */
.stream-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  text-align: center;
  z-index: 2;
  transition: opacity var(--ease), transform var(--ease);
}
.stream-avatar-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 3px solid var(--live-red);
  box-shadow: 0 0 0 6px rgba(255,59,59,0.2), 0 0 40px rgba(255,59,59,0.15);
  background: linear-gradient(135deg, #1a0a2e, #2a1a3e);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 2.8rem;
  animation: pulse-dot 3s ease-in-out infinite;
}
.stream-you-live {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: var(--r-full);
}
.stream-video.live-started .stream-center {
  opacity: 0;
  transform: translate(-50%, -62%);
  pointer-events: none;
}

/* Stream title bottom */
.stream-hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.stream-title-display {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stream-reactions {
  display: flex;
  gap: 8px;
}

/* In-video comments overlay while keeping right-side chat. */
.overlay-comments {
  position: absolute;
  left: 16px;
  bottom: 96px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(68%, 460px);
  pointer-events: none;
}
.overlay-comment {
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.92);
  font-size: 0.8rem;
  line-height: 1.45;
  animation: slideInRight 0.25s ease both;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overlay-comment strong {
  color: var(--accent-light);
  margin-right: 6px;
}
.overlay-comment.gold {
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(66, 50, 8, 0.55);
}
.overlay-comment.gold strong { color: var(--gold-light); }
.reaction-btn {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background var(--ease), transform var(--ease);
}
.reaction-btn:hover { background: rgba(255,255,255,0.12); transform: scale(1.05); }
.reaction-btn:active { transform: scale(0.95); }
#like-count { font-size: 0.78rem; opacity: 0.85; }

/* Floating hearts container */
.hearts-container {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 50px;
  pointer-events: none;
  z-index: 3;
}
.floating-heart {
  position: absolute;
  bottom: 0;
  font-size: 1.4rem;
  animation: heartFloat 2.4s ease-out forwards;
  pointer-events: none;
}

/* ── Stream Controls Bar ──────────────────────────────── */
.stream-controls {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.stream-title-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  padding: 9px 18px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--ease);
}
.stream-title-input::placeholder { color: var(--text-muted); }
.stream-title-input:focus { border-color: var(--accent); }
.record-btn {
  background: rgba(124,92,252,0.28);
  border: 1px solid rgba(124,92,252,0.52);
  color: #efeaff;
  padding: 7px 13px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  transition: background var(--ease), transform var(--ease), border-color var(--ease);
  white-space: nowrap;
}
.record-btn:hover { background: rgba(124,92,252,0.24); transform: scale(1.02); }
.record-btn.recording {
  background: rgba(255,59,59,0.16);
  border-color: rgba(255,59,59,0.4);
  color: #ff9b9b;
}
.record-status {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
  min-width: 84px;
  text-align: center;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-full);
  padding: 4px 8px;
}
.end-stream-btn {
  background: rgba(255,59,59,0.15);
  border: 1px solid rgba(255,59,59,0.35);
  color: var(--live-red);
  padding: 9px 20px;
  border-radius: var(--r-full);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--ease), transform var(--ease);
  white-space: nowrap;
}
.end-stream-btn:hover { background: rgba(255,59,59,0.25); transform: scale(1.02); }

/* Vertical mode emulates a centered TikTok-like frame. */
.stream-video.mode-vertical .camera-feed {
  width: min(54vw, 390px);
  max-width: 390px;
  height: 88%;
  max-height: 88%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scaleX(-1);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.12);
}
.stream-video.mode-vertical .camera-glass-overlay {
  width: min(54vw, 390px);
  max-width: 390px;
  height: 88%;
  max-height: 88%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 24px;
  overflow: hidden;
}

/* ── Chat Panel ───────────────────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow: hidden;
}
.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chat-header-title .chat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 6px rgba(46,204,113,0.7);
  animation: pulse-dot 2s ease-in-out infinite;
}
.chat-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
}

/* Comment feed */
.comments-feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

/* ── Individual Comment ───────────────────────────────── */
.comment {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  animation: slideInRight 0.35s cubic-bezier(0.2, 0, 0.2, 1) both;
  transition: background var(--ease);
}
.comment:hover { background: var(--bg-card); }

/* Gold (VIP / paid) comment */
.comment.gold {
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  animation: goldGlow 3s ease-in-out infinite, slideInRight 0.35s cubic-bezier(0.2, 0, 0.2, 1) both;
}
.comment.gold:hover { background: rgba(255,215,0,0.12); }

/* Comment with viewer's name highlight */
.comment.name-mention {
  background: rgba(124,92,252,0.06);
  border: 1px solid rgba(124,92,252,0.2);
}

.comment-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.comment.gold .comment-avatar {
  border: 2px solid var(--gold);
  box-shadow: 0 0 8px rgba(255,215,0,0.4);
}

.comment-body { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: 5px; margin-bottom: 2px; }

.comment-user {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comment.gold .comment-user { color: var(--gold); }

.comment-badge {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.comment-msg {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.55;
  word-break: break-word;
}
.comment.gold .comment-msg { color: rgba(255,240,180,0.9); }

/* Viewer name highlight within comment text */
.name-highlight {
  color: var(--accent-light);
  font-weight: 700;
  background: rgba(124,92,252,0.12);
  padding: 0 3px;
  border-radius: 3px;
}

/* ── App Bottom Bar ───────────────────────────────────── */
.app-bottom {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.app-bottom-left { display: flex; align-items: center; gap: 14px; }
.app-bottom-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.app-bottom-stat strong { color: var(--text-sub); font-weight: 600; }
.app-bottom-right { display: flex; align-items: center; gap: 10px; }
.app-bottom-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color var(--ease);
}
.app-bottom-link:hover { color: var(--accent-light); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .app-main { grid-template-columns: 1fr; grid-template-rows: 1fr 320px; }
  .chat-panel { border-left: none; border-top: 1px solid var(--border); }
  .stream-center { display: none; }
}

@media (max-width: 600px) {
  .app-main { grid-template-rows: 240px 1fr; }
  .stream-controls { flex-wrap: wrap; }
  .top-controls { width: 100%; justify-content: flex-end; }
  .mode-btn { font-size: 0.7rem; padding: 5px 8px; }
  .record-btn { font-size: 0.7rem; padding: 6px 9px; }
  .hud-right { flex-direction: column; align-items: flex-end; gap: 6px; }
  .stream-video.mode-vertical .camera-feed,
  .stream-video.mode-vertical .camera-glass-overlay {
    width: min(68vw, 330px);
  }
  .overlay-comments { width: calc(100% - 32px); bottom: 84px; }
  .name-modal { padding: 36px 24px; }
}
