/* ===================================
   MEETGLE VIDEO CHAT - OPTIMIZED CSS
   =================================== */

/* === CSS VARIABLES === */
:root {
    --accent-color: #cc0000;
    --button-color: #EC4899;
    --button-hover-color: #A855F7;
    --button-active-color: #EC4899;
    --button-padding: 10px 15px;
    --button-font-size: 16px;
    --transition-duration: 0.3s;
    --text-color: #333;
    --bg-dark: #23272A;
    --bg-darker: #171717;
  }

/* ===================================
   DYNAMIC BUTTON HOVER/ACTIVE STATES
   These styles use CSS variables that can be customized via WordPress settings
   =================================== */

/* Start Chat Button Hover/Active States */
#startChatBtn:hover {
  background: var(--button-hover-color) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

#startChatBtn:active {
  background: var(--button-active-color) !important;
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Help Button Hover/Active States */
#helpBtn:hover {
  background: rgba(255,255,255,0.2) !important;
  transform: scale(1.05);
  border-color: rgba(255,255,255,0.5);
}

#helpBtn:active {
  background: rgba(255,255,255,0.15) !important;
  transform: scale(0.98);
}

/* Match Preferences Button Hover/Active States (same as help button) */
#matchPreferencesBtn:hover {
  background: rgba(255,255,255,0.2) !important;
  transform: scale(1.05);
  border-color: rgba(255,255,255,0.5);
}

#matchPreferencesBtn:active {
  background: rgba(255,255,255,0.15) !important;
  transform: scale(0.98);
}

/* === GLOBAL RESET === */
html,
body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

  /* Avoid 100vw / 100vh issues on iOS */
  width: 100%;
  height: 100%;
  min-height: 0;

  overflow-x: hidden;
  overflow-y: auto; /* default for desktop */
}

/* ===================================
   RESPONSIVE: MOBILE (≤900px)
   =================================== */
@media (max-width: 900px) {
  /* On mobile, lock the page to the viewport (no scroll) */
  html,
  body {
    overflow: hidden;       /* kill the scroll */
  }
}

/* === MAIN CONTAINER === */
#meetgle-container,
#meetgle-video-container {
  width: 100vw;
  min-height: 100vh;
  min-width: 100vw;
  max-width: 100vw;
  overflow: visible;
  display: flex;
  flex-direction: row;
  box-sizing: border-box;
  text-align: center;
  background-color: transparent;
}

/* === VIDEO LAYOUT === */
.video-chat-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
}

.video-section {
  flex: 0 1 50%;
  min-width: 0;
  max-width: 50vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  height: 100%;
}

.controls-and-chat {
  flex: 0 1 50%;
  min-width: 320px;
  max-width: 50vw;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  background-color: var(--bg-dark);
}

/* === VIDEO WRAPPERS === */
.video-wrapper {
  position: relative;
  background-color: #000;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 0;
}

.video-wrapper.remote-video {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
  margin-bottom: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.video-wrapper.local-video {
  flex: 2 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 66.66%;
  min-height: 0;
  background-color: #0F0F0F;
  position: relative;
  overflow: hidden;
}

/* === BRANDED BACKGROUND FOR LOCAL VIDEO START === */
.video-wrapper.local-video::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0F0F0F;
  z-index: 0;
}

/* Logo removed - now showing live counter instead */
.video-wrapper.local-video::after {
  display: none; /* Hide logo */
}
/* === BRANDED BACKGROUND FOR LOCAL VIDEO END === */

/* === SPARKLE BACKGROUND FOR REMOTE VIDEO (WAITING STATE) === */
.sparkle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s ease-out;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Animated gradient background */
.sparkle-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 30% 40%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 70% 60%, rgba(168, 85, 247, 0.12) 0%, transparent 50%);
  animation: gradient-rotate 15s ease-in-out infinite;
}

@keyframes gradient-rotate {
  0%, 100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  50% {
    transform: translate(5%, 5%) scale(1.1) rotate(5deg);
  }
}

/* Individual sparkles */
.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(255, 215, 0, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  animation: float 8s ease-in-out infinite;
  will-change: transform, opacity;
}

/* Sparkle positions and delays */
.sparkle:nth-child(1) { top: 15%; left: 10%; animation-delay: 0s; }
.sparkle:nth-child(2) { top: 25%; left: 85%; animation-delay: 1s; }
.sparkle:nth-child(3) { top: 40%; left: 20%; animation-delay: 2s; }
.sparkle:nth-child(4) { top: 55%; left: 75%; animation-delay: 0.5s; }
.sparkle:nth-child(5) { top: 70%; left: 15%; animation-delay: 1.5s; }
.sparkle:nth-child(6) { top: 80%; left: 65%; animation-delay: 2.5s; }
.sparkle:nth-child(7) { top: 30%; left: 50%; animation-delay: 3s; }
.sparkle:nth-child(8) { top: 60%; left: 40%; animation-delay: 1.8s; }
.sparkle:nth-child(9) { top: 10%; left: 60%; animation-delay: 2.2s; }
.sparkle:nth-child(10) { top: 85%; left: 30%; animation-delay: 0.8s; }

@keyframes float {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.6;
  }
  25% {
    transform: translateY(-15px) scale(1.2);
    opacity: 1;
  }
  50% {
    transform: translateY(-30px) scale(0.8);
    opacity: 0.7;
  }
  75% {
    transform: translateY(-15px) scale(1.1);
    opacity: 0.9;
  }
}

/* Hide sparkles when video is active */
.remote-video.has-video .sparkle-container {
  opacity: 0;
  pointer-events: none;
}
/* === END SPARKLE BACKGROUND === */

/* === LIVE COUNTER BACKGROUND FOR LOCAL VIDEO (WAITING STATE) === */
/* Shows real-time user count with floating avatars - only visible before starting chat */
.local-video .live-counter-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0F0F0F 0%, #16213e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  z-index: 2;
  opacity: 1;
  transition: opacity 0.5s ease-out;
  pointer-events: none;
}

/* Hide counter when chat starts */
.local-video.has-stream .live-counter-background {
  opacity: 0;
  pointer-events: none;
}

.online-count {
  text-align: center;
}

.count-number {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, #EC4899, #A855F7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse-count 2s ease-in-out infinite;
  line-height: 1;
}

@keyframes pulse-count {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.count-label {
  font-size: 16px;
  color: #999;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

.avatar-cloud {
  position: relative;
  width: 300px;
  height: 120px;
}

.floating-avatar {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #EC4899, #A855F7);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  animation: float-avatar 3s ease-in-out infinite;
  will-change: transform;
}

.floating-avatar:nth-child(1) { left: 0; top: 0; animation-delay: 0s; }
.floating-avatar:nth-child(2) { left: 60px; top: 30px; animation-delay: 0.5s; }
.floating-avatar:nth-child(3) { left: 120px; top: 10px; animation-delay: 1s; }
.floating-avatar:nth-child(4) { left: 180px; top: 40px; animation-delay: 1.5s; }
.floating-avatar:nth-child(5) { left: 240px; top: 20px; animation-delay: 2s; }
.floating-avatar:nth-child(6) { left: 30px; top: 70px; animation-delay: 0.7s; }
.floating-avatar:nth-child(7) { left: 150px; top: 60px; animation-delay: 1.2s; }

@keyframes float-avatar {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.1); }
}

.live-pulse {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

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

/* Mobile responsive adjustments */
@media (max-width: 900px) {
  .count-number {
    font-size: 56px;
  }

  .count-label {
    font-size: 14px;
    letter-spacing: 1px;
  }

  .live-counter-background {
    gap: 20px;
  }

  .avatar-cloud {
    width: 240px;
    height: 100px;
    transform: scale(0.85);
  }

  .floating-avatar {
    width: 45px;
    height: 45px;
    font-size: 20px;
  }

  .floating-avatar:nth-child(1) { left: 0; top: 0; }
  .floating-avatar:nth-child(2) { left: 50px; top: 25px; }
  .floating-avatar:nth-child(3) { left: 100px; top: 8px; }
  .floating-avatar:nth-child(4) { left: 150px; top: 35px; }
  .floating-avatar:nth-child(5) { left: 190px; top: 15px; }
  .floating-avatar:nth-child(6) { left: 25px; top: 60px; }
  .floating-avatar:nth-child(7) { left: 120px; top: 55px; }
}

@media (max-width: 600px) {
  .count-number {
    font-size: 48px;
  }

  .count-label {
    font-size: 12px;
  }

  .avatar-cloud {
    width: 200px;
    height: 80px;
    transform: scale(0.75);
  }

  .floating-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}
/* === END LIVE COUNTER BACKGROUND === */

/* === VIDEO ELEMENTS === */
.remote-video video,
.local-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10; /* Above background layers */
}

/* === BLUR EFFECT FOR PREVIEW === */
.remote-video.blurred video {
  filter: blur(20px);
  transition: filter 0.5s ease-out;
}

.local-video video {
  transform: none;
  background: transparent !important; /* Changed from #2a2a2a to transparent */
}

/* Hide native video controls */
video::-webkit-media-controls,
video::-moz-media-controls,
video::-ms-media-controls,
video::-o-media-controls {
  display: none !important;
}

/* === LOADING SPINNER === */
.remote-loading-spinner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.spinner {
  border: 6px solid #f3f3f3;
  border-top: 6px solid var(--button-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === CONTROL BUTTONS === */
.control-container {
  display: none; /* Hidden by default, shown when chatting */
  justify-content: space-between;
  gap: 5px;
  flex-wrap: wrap;
  margin: 10px;
}

.control-container button {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  background-color: var(--button-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color var(--transition-duration) ease;
  text-align: center;
}

.control-container button:hover,
.control-container button:focus {
  background-color: var(--button-hover-color);
}

.control-container button:active {
  background-color: var(--button-active-color);
}

/* Old stopChatBtn rule removed - now using .btn-stop class */

/* === MUTE & CAMERA BUTTONS === */
#muteBtn,
#switchCameraBtn {
  font-size: 14px;
  color: #000;
  background-color: rgba(255, 255, 255, 0.7);
  border: none;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color var(--transition-duration) ease;
}

#muteBtn:hover,
#switchCameraBtn:hover {
  background-color: rgba(200, 200, 200, 0.9);
}

#muteBtn.muted {
  background-color: #6c757d;
  color: #fff;
}

/* Heart & Spark buttons removed - now using .btn-heart and .btn-spark classes */

/* === FLAG & GENDER BUTTONS === */
#remoteFlag,
#remoteGender {
  font-size: 18px;
  border-radius: 4px;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  padding: 0;
  margin: 0;
  cursor: default;
  background: rgba(255, 255, 255, 0.7);
}

#remoteFlag:hover,
#remoteGender:hover {
  background: rgba(200, 200, 200, 0.9);
}

#remoteFlag:active,
#remoteGender:active {
  background: #f3f3f3;
}

/* Flag emoji styling */
#remoteFlag {
  color: #222;
  cursor: default;
  text-align: center;
  line-height: 36px;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif;
  font-size: 22px;
  overflow: hidden;
  vertical-align: middle;
}

/* Gender SVG icon styling - separate from flag for precise centering */
#remoteGender {
  cursor: default;
  overflow: hidden;
  padding: 0;
  line-height: 0; /* Remove any line-height that might offset the image */
}

/* Center SVG images inside gender container */
#remoteGender img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  margin: auto; /* Ensure centering with flexbox parent */
}

/* === HEART ANIMATIONS === */
.heart-anim-overlay {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  overflow: visible;
}

.heart-emoji {
  position: absolute;
  left: 50%;
  font-size: 2.5rem;
  opacity: 0.85;
  transform: translateX(-50%) scale(1);
  animation: heart-float 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes heart-float {
  0% {
    top: 10%;
    opacity: 0.9;
    transform: translateX(-50%) scale(1.2);
  }
  60% {
    opacity: 1;
    transform: translateX(-50%) scale(1.1) rotate(-10deg);
  }
  80% {
    opacity: 0.8;
    transform: translateX(-50%) scale(1.05) rotate(10deg);
  }
  100% {
    top: 80%;
    opacity: 0;
    transform: translateX(-50%) scale(0.8) rotate(0deg);
  }
}

.heart-btn-anim-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 200;
}

.heart-btn-emoji {
  position: absolute;
  left: 50%;
  bottom: 8px;
  font-size: 1.7em;
  opacity: 0.9;
  transform: translateX(-50%) scale(1);
  animation: heart-btn-flutter 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes heart-btn-flutter {
  0% {
    bottom: 8px;
    opacity: 0.9;
    transform: translateX(-50%) scale(1.2);
  }
  60% {
    opacity: 1;
    transform: translateX(-50%) scale(1.1) rotate(-10deg);
  }
  80% {
    opacity: 0.8;
    transform: translateX(-50%) scale(1.05) rotate(10deg);
  }
  100% {
    bottom: 38px;
    opacity: 0;
    transform: translateX(-50%) scale(0.8) rotate(0deg);
  }
}

/* ===================================
   RESPONSIVE: DESKTOP (900px+)
   =================================== */
@media (min-width: 901px) {
  #meetgle-video-container,
  .video-chat-layout {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
  }
}

/* ===================================
   RESPONSIVE: MOBILE (≤900px)
   =================================== */
@media (max-width: 900px) {
  .video-chat-layout {
    flex-direction: column;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
  }

  .video-section,
  .controls-and-chat {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    flex: unset !important;
    padding: 0 !important;
  }

  /* === EQUAL HEIGHT VIDEO WRAPPERS ON MOBILE (FALLBACK USING VH) === */
  .video-section {
    height: 50vh !important;
    min-height: 50vh !important;
    max-height: 50vh !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  .controls-and-chat {
    height: 50vh !important;
    min-height: 50vh !important;
    max-height: 50vh !important;
    display: block !important;
  }

  .video-wrapper.remote-video,
  .video-wrapper.local-video {
    height: 50vh !important;
    min-height: 0 !important;
    max-height: 50vh !important;
    aspect-ratio: unset !important;
    flex: unset !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* === MODERN FIX FOR iOS / MOBILE BROWSERS USING SVH === */
  @supports (height: 100svh) {
    .video-chat-layout {
      height: 100svh !important;
      min-height: 100svh !important;
      max-height: 100svh !important;
    }

    .video-section,
    .controls-and-chat {
      height: 50svh !important;
      min-height: 50svh !important;
      max-height: 50svh !important;
    }

    .video-wrapper.remote-video,
    .video-wrapper.local-video {
      height: 50svh !important;
      min-height: 0 !important;
      max-height: 50svh !important;
    }
  }

  /* Only hide remote video background, keep local video gradient */
  .video-wrapper.remote-video::before {
    display: none !important;
  }

  .remote-video video,
  .local-video video {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
  }
}

/* Removed old #heartBtn and #sparkBtn mobile styles - now using .btn-heart and .btn-spark classes */

#remoteFlag,
#remoteGender {
  font-size: 14px;
  width: 28px;
  height: 28px;
}

#remoteFlag {
  font-size: 16px;
  line-height: 28px;
}

/* Gender icon mobile - remove line-height override */
#remoteGender {
  line-height: 0;
}

/* Extra button font size on mobile */
.meetgle-extra-btn {
  font-size: 14px !important;
}

/* Next button font size on mobile */
#nextChatBtn {
  font-size: 14px !important;
}

/* Start button font size on mobile */
#startChatBtn {
  font-size: 14px !important;
}

/* ===================================
   RESPONSIVE: SMALL MOBILE (≤600px)
   =================================== */
@media (max-width: 600px) {
  .control-container {
    margin: 5px;
  }
}