/* ============================================
   SPHERE LIVE STREAMING - MODERN PLAYER CONTROLS
   Phase 1: Theater mode, fullscreen, stream info overlay
   ============================================ */

:root {
  --player-control-bg: rgba(24, 25, 26, 0.95);
  --player-control-hover: rgba(58, 59, 60, 0.95);
  --sphere-teal: #0891b2;
  --sphere-green: #06d6a0;
  --live-red: #f02849;
}

/* ============================================
   THEATER MODE & FULLSCREEN LAYOUT
   ============================================ */

/* Theater mode - wider video container */
.live-viewer-container.theater-mode {
  max-width: 1400px !important;
  margin: 0 auto;
}

.live-viewer-container.theater-mode .live-video-section {
  flex: 0 0 100%;
  max-width: 100%;
}

.live-viewer-container.theater-mode .live-chat-section {
  position: fixed;
  right: 0;
  top: 60px;
  bottom: 0;
  width: 350px;
  z-index: 999;
  background: var(--dark-bg, #18191a);
  border-left: 1px solid var(--border-color, #3e4042);
}

/* Fullscreen mode */
.live-viewer-container.fullscreen-mode {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #000;
  max-width: 100% !important;
}

.live-viewer-container.fullscreen-mode .live-video-section {
  flex: 1;
  max-width: 100%;
  height: 100%;
}

.live-viewer-container.fullscreen-mode .live-chat-section {
  display: none;
}

.live-viewer-container.fullscreen-mode .stream-info-overlay {
  opacity: 0;
  transition: opacity 0.3s;
}

.live-viewer-container.fullscreen-mode:hover .stream-info-overlay {
  opacity: 1;
}

/* ============================================
   MODERN PLAYER CONTROLS BAR
   ============================================ */

.modern-player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  padding: 60px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}

.live-video-container:hover .modern-player-controls,
.modern-player-controls.active {
  opacity: 1;
}

.modern-player-controls button {
  background: var(--player-control-bg);
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
}

.modern-player-controls button:hover {
  background: var(--player-control-hover);
  transform: scale(1.05);
}

.modern-player-controls button:active {
  transform: scale(0.95);
}

.modern-player-controls button svg {
  width: 20px;
  height: 20px;
}

/* Volume control slider */
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--player-control-bg);
  padding: 8px 12px;
  border-radius: 8px;
}

.volume-slider {
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  position: relative;
  cursor: pointer;
}

.volume-slider-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sphere-teal), var(--sphere-green));
  border-radius: 2px;
  width: 100%;
  position: relative;
}

.volume-slider-thumb {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.volume-slider-thumb:active {
  cursor: grabbing;
}

/* Spacer to push right-aligned controls */
.player-controls-spacer {
  flex: 1;
}

/* Quality selector dropdown */
.quality-selector {
  position: relative;
}

.quality-dropdown {
  position: absolute;
  bottom: 50px;
  right: 0;
  background: var(--player-control-bg);
  border-radius: 8px;
  padding: 8px;
  min-width: 120px;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.quality-dropdown.active {
  display: block;
}

.quality-option {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: 14px;
  transition: background 0.2s;
}

.quality-option:hover {
  background: var(--player-control-hover);
}

.quality-option.selected {
  background: linear-gradient(135deg, var(--sphere-teal), var(--sphere-green));
}

/* ============================================
   STREAM INFO OVERLAY
   ============================================ */

.stream-info-overlay {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  z-index: 90;
  pointer-events: none;
}

.stream-info-card {
  background: var(--player-control-bg);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 16px;
  display: inline-flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.stream-info-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stream-info-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--sphere-teal);
}

.stream-info-details {
  flex: 1;
  min-width: 0;
}

.stream-info-username {
  font-size: 16px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stream-info-verified {
  width: 16px;
  height: 16px;
  color: var(--sphere-teal);
}

.stream-info-title {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-info-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.stream-info-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--live-red);
}

.stream-info-live-dot {
  width: 8px;
  height: 8px;
  background: var(--live-red);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

.stream-info-viewers {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stream-info-viewers svg {
  width: 16px;
  height: 16px;
}

.stream-info-duration {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stream-info-duration svg {
  width: 16px;
  height: 16px;
}

.stream-info-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(8, 145, 178, 0.2);
  border: 1px solid rgba(8, 145, 178, 0.4);
  border-radius: 16px;
  font-size: 12px;
  color: var(--sphere-teal);
  font-weight: 500;
}

/* ============================================
   ENHANCED CHAT PANEL
   ============================================ */

.live-chat-messages {
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  scroll-behavior: smooth;
}

.live-chat-message {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.live-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.live-chat-content {
  flex: 1;
  min-width: 0;
}

.live-chat-username {
  font-size: 14px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.live-chat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.live-chat-badge.streamer {
  background: linear-gradient(135deg, var(--sphere-teal), var(--sphere-green));
  color: white;
}

.live-chat-badge.mod {
  background: #10b981;
  color: white;
}

.live-chat-badge.verified {
  background: #3b82f6;
  color: white;
}

.live-chat-text {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  word-wrap: break-word;
  line-height: 1.4;
}

.live-chat-timestamp {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

/* Pinned message styling */
.live-chat-message.pinned {
  background: rgba(8, 145, 178, 0.1);
  border-left: 3px solid var(--sphere-teal);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.live-chat-message.pinned::before {
  content: "📌 PINNED";
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--sphere-teal);
  margin-bottom: 8px;
}

/* Super chat / tip message styling */
.live-chat-message.super-chat {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(168, 85, 247, 0.2));
  border: 2px solid rgba(236, 72, 153, 0.5);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.live-chat-message.super-chat::before {
  content: "💰";
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 24px;
  opacity: 0.3;
}

.live-chat-message.super-chat .live-chat-username {
  color: #ec4899;
  font-size: 15px;
}

.live-chat-tip-amount {
  display: inline-block;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  margin-left: 6px;
}

/* ============================================
   LIVE INDICATOR BADGES
   ============================================ */

.live-indicator-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--live-red);
  border: 2px solid var(--dark-bg, #18191a);
  border-radius: 50%;
  z-index: 10;
  animation: pulse-live-badge 2s infinite;
}

@keyframes pulse-live-badge {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(240, 40, 73, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(240, 40, 73, 0);
  }
}

/* Live badge on profile pictures */
.profile-pic-container,
.user-avatar-container {
  position: relative;
}

.profile-pic-container.is-live::after,
.user-avatar-container.is-live::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: var(--live-red);
  border: 2px solid var(--dark-bg, #18191a);
  border-radius: 50%;
  animation: pulse-live-badge 2s infinite;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 768px) {
  /* Stack video and chat vertically */
  .live-viewer-container {
    flex-direction: column !important;
  }

  .live-video-section {
    flex: 0 0 auto !important;
    height: 56.25vw; /* 16:9 aspect ratio */
    max-width: 100% !important;
  }

  .live-chat-section {
    flex: 1 !important;
    max-width: 100% !important;
    height: auto !important;
  }

  /* Theater mode on mobile = just full width */
  .live-viewer-container.theater-mode .live-chat-section {
    position: relative;
    right: auto;
    top: auto;
    bottom: auto;
    width: 100%;
  }

  /* Stream info overlay - smaller on mobile */
  .stream-info-overlay {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .stream-info-card {
    padding: 12px;
    max-width: 100%;
  }

  .stream-info-avatar {
    width: 36px;
    height: 36px;
  }

  .stream-info-username {
    font-size: 14px;
  }

  .stream-info-title {
    font-size: 12px;
  }

  .stream-info-meta {
    font-size: 11px;
    gap: 12px;
  }

  /* Touch-friendly controls */
  .modern-player-controls {
    padding: 80px 12px 16px;
    gap: 8px;
  }

  .modern-player-controls button {
    width: 44px;
    height: 44px;
  }

  .volume-control {
    display: none; /* Hide volume slider on mobile - use device volume */
  }

  /* Chat messages - bigger touch targets */
  .live-chat-message {
    padding: 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
  }
}

/* ============================================
   LOADING SKELETONS
   ============================================ */

.stream-loading-skeleton {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #242526 25%, #3a3b3c 50%, #242526 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

.live-viewer-container {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.live-video-section,
.live-chat-section {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade in animation for entering stream */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.live-viewer-container.entering {
  animation: fadeIn 0.4s ease;
}

/* ============================================
   DESKTOP LAYOUT - VIDEO + CHAT SIDE BY SIDE
   ============================================ */

@media (min-width: 769px) {
  .live-viewer-container {
    flex-direction: row !important;
  }

  .live-viewer-container .live-video-section {
    flex: 1;
    min-width: 0;
    position: relative;
  }

  .live-viewer-container .live-chat-section {
    flex: 0 0 380px;
    max-width: 380px;
    background: #18191a;
    border-left: 1px solid #3e4042;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
  }
}

/* Video container within video section */
.live-video-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ============================================
   CHAT HEADER
   ============================================ */

.live-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(24, 25, 26, 0.95);
  border-bottom: 1px solid #3e4042;
  flex-shrink: 0;
}

.live-chat-header-title {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.live-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-chat-mod-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.live-chat-mod-btn:hover {
  background: rgba(8, 145, 178, 0.3);
  transform: scale(1.05);
}

/* ============================================
   PINNED MESSAGE AREA
   ============================================ */

.live-pinned-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.15), rgba(6, 214, 160, 0.1));
  border-bottom: 1px solid rgba(8, 145, 178, 0.3);
  flex-shrink: 0;
  animation: slideDown 0.3s ease;
}

.pinned-message-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--sphere-teal, #0891b2);
  white-space: nowrap;
  text-transform: uppercase;
}

.pinned-message-content {
  flex: 1;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinned-message-dismiss {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pinned-message-dismiss:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* ============================================
   CHAT COMMENTS - ENHANCED LAYOUT
   ============================================ */

.live-comment {
  display: flex;
  gap: 10px;
  padding: 8px 16px;
  transition: background 0.15s;
}

.live-comment:hover {
  background: rgba(255,255,255,0.03);
}

.live-comment.super-chat {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(168, 85, 247, 0.1));
  border-left: 3px solid #ec4899;
  margin: 4px 8px;
  border-radius: 8px;
}

.live-comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.live-comment-reply-btn,
.live-comment-view-replies {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.2s;
}

.live-comment-reply-btn:hover,
.live-comment-view-replies:hover {
  color: var(--sphere-teal, #0891b2);
}

.live-comment-replies {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
  padding-left: 16px;
  border-left: 2px solid rgba(255,255,255,0.1);
}

/* Comments container fill remaining space */
.live-chat-section .live-comments-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Actions bar fixed at bottom */
.live-chat-section .live-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(24, 25, 26, 0.95);
  border-top: 1px solid #3e4042;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.live-chat-section .live-comment-input {
  flex: 1;
  min-width: 100px;
  padding: 10px 14px;
  background: #3a3b3c;
  border: 1px solid transparent;
  border-radius: 20px;
  color: white;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.live-chat-section .live-comment-input:focus {
  border-color: var(--sphere-teal, #0891b2);
  background: #242526;
}

.live-chat-section .live-comment-input::placeholder {
  color: rgba(255,255,255,0.4);
}

/* ============================================
   BROADCASTER ENHANCED CHAT
   ============================================ */

.broadcast-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  pointer-events: none;
}

.broadcast-chat-header > * {
  pointer-events: auto;
}

.broadcast-chat-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.broadcast-chat-header-actions {
  display: flex;
  gap: 6px;
}

/* Broadcaster enhanced comments feed */
.live-broadcast-screen .live-comments-feed .live-chat-message {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  backdrop-filter: blur(4px);
  animation: slideInRight 0.3s ease;
}

.live-broadcast-screen .live-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.live-broadcast-screen .live-chat-content {
  flex: 1;
  min-width: 0;
}

.live-broadcast-screen .live-chat-username {
  font-size: 12px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.live-broadcast-screen .live-chat-badge {
  font-size: 9px;
  padding: 1px 4px;
}

.live-broadcast-screen .live-chat-text {
  font-size: 13px;
  color: rgba(255,255,255,0.95);
  word-wrap: break-word;
  line-height: 1.3;
}

.live-broadcast-screen .live-chat-timestamp {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}
