/**
 * Public styles for the JJ AWS IVS plugin
 */

.jj-aws-ivs-player-container,
.jj-aws-ivs-recording-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    background-color: #000;
    overflow: hidden;
}

.jj-aws-ivs-player {
    display: block;
    width: 100%;
    aspect-ratio: var(--aspect-ratio, 16/9);
    background-color: #000;
}

.jj-aws-ivs-player-offline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 18px;
    text-align: center;
    padding: 20px;
}

.jj-aws-ivs-player-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    color: #ff5252;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

/* Custom Controls Styles */
.jj-aws-ivs-player-container:hover .jj-aws-ivs-custom-controls,
.jj-aws-ivs-recording-container:hover .jj-aws-ivs-custom-controls,
.jj-aws-ivs-player-container.controls-active .jj-aws-ivs-custom-controls,
.jj-aws-ivs-recording-container.controls-active .jj-aws-ivs-custom-controls {
    opacity: 1;
    pointer-events: auto;
}

.jj-aws-ivs-custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.jj-aws-ivs-controls-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.jj-aws-ivs-play-pause,
.jj-aws-ivs-mute,
.jj-aws-ivs-fullscreen {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.jj-aws-ivs-play-pause:hover,
.jj-aws-ivs-mute:hover,
.jj-aws-ivs-fullscreen:hover {
    opacity: 1;
}

.jj-aws-ivs-progress-container {
    flex-grow: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.jj-aws-ivs-progress-bar {
    height: 100%;
    width: 100%;
    position: relative;
}

.jj-aws-ivs-progress {
    position: absolute;
    height: 100%;
    background: #ff0000;
    border-radius: 2px;
    width: 0;
}

.jj-aws-ivs-time {
    font-size: 14px;
    color: white;
    opacity: 0.8;
    white-space: nowrap;
}

/* Ensure controls are visible when video is paused */
.jj-aws-ivs-player:not(.playing) ~ .jj-aws-ivs-custom-controls {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive styles */
@media (max-width: 768px) {
    .jj-aws-ivs-player,
    .jj-aws-ivs-recording-player,
    /* Override Swiper and theme video styles */
    .swiper-slide .jj-aws-ivs-player,
    .swiper-slide .jj-aws-ivs-recording-player,
    .swiper-container .jj-aws-ivs-player,
    .swiper-container .jj-aws-ivs-recording-player,
    .swiper .jj-aws-ivs-player,
    .swiper .jj-aws-ivs-recording-player {
        /* Mobile zoom effect - 120% creates a cropped square-ish look */
        aspect-ratio: 1/1 !important;
        object-fit: cover !important;
        transform: scale(1.2) !important;
        width: 100% !important;
        height: auto !important;
    }
    
    /* Ensure poster overlays match the video scaling */
    .jj-aws-ivs-poster-overlay {
        transform: scale(1.2) !important;
        object-fit: cover !important;
    }
    
    /* Ensure containers handle the scaled content */
    .jj-aws-ivs-player-container,
    .jj-aws-ivs-recording-container,
    .swiper-slide .jj-aws-ivs-player-container,
    .swiper-slide .jj-aws-ivs-recording-container {
        position: relative !important;
        width: 100% !important;
        overflow: hidden !important; /* Hide the scaled overflow */
    }
    
    /* Override any theme video wrapper styles */
    .swiper-slide video,
    .swiper-container video,
    .swiper video {
        max-height: none !important;
        height: auto !important;
    }
}

/* iOS-specific video improvements */
.jj-aws-ivs-player,
.jj-aws-ivs-recording-player {
    /* Ensure videos work properly on iOS */
    -webkit-playsinline: true;
    -webkit-appearance: none;
    /* Prevent iOS zoom on video tap */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* iOS-specific poster overlay improvements */
.jj-aws-ivs-poster-overlay {
    /* Ensure poster image displays correctly on iOS */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* iOS fallback play button styling */
.jj-aws-ivs-big-play-button.ios-fallback {
    background-color: rgba(0, 0, 0, 0.8);
    border: 3px solid #fff;
}

.jj-aws-ivs-big-play-button.ios-fallback:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Ensure videos are properly sized on iOS Safari */
@supports (-webkit-appearance: none) {
    .jj-aws-ivs-player,
    .jj-aws-ivs-recording-player {
        /* Force hardware acceleration on iOS */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Improve rendering performance */
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

.jj-aws-ivs-mute {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 5px;
  font-size: 20px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.jj-aws-ivs-mute svg {
  display: block;
  width: 20px;
  height: 20px;
}

.jj-aws-ivs-volume-slider {
  width: 100px;
  margin: 0 10px;
  height: 8px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  vertical-align: middle;
}

.jj-aws-ivs-volume-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: #fff;
  border-radius: 4px;
}

.jj-aws-ivs-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  margin-top: -5px;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  position: relative;
  z-index: 2;
}

.jj-aws-ivs-volume-slider:focus {
  outline: none;
}

.jj-aws-ivs-volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.jj-aws-ivs-volume-slider::-ms-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.jj-aws-ivs-volume-slider::-ms-fill-lower {
  background: #fff;
  border-radius: 4px;
}

.jj-aws-ivs-volume-slider::-ms-fill-upper {
  background: #fff;
  border-radius: 4px;
}

.jj-aws-ivs-volume-slider::-moz-range-track {
  background-color: #fff;
  height: 8px;
  border-radius: 4px;
}

.jj-aws-ivs-player-container:fullscreen,
.jj-aws-ivs-recording-container:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.jj-aws-ivs-player-container:fullscreen video,
.jj-aws-ivs-recording-container:fullscreen video {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain;
  background: #000;
}

/* Recording player styles */
.jj-aws-ivs-recording-player {
    display: block;
    width: 100%;
    aspect-ratio: var(--aspect-ratio, 16/9);
    background-color: #000;
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 16/9) {
    .jj-aws-ivs-recording-player {
        height: 400px;
    }
}

@media (max-width: 768px) {
    .jj-aws-ivs-recording-player {
        aspect-ratio: var(--mobile-aspect-ratio, var(--aspect-ratio, 16/9));
    }
}

/* Audio Toggle Button Styles */
.jj-aws-ivs-audio-button-container {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 20;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

/* Show audio button on hover or when video is paused */
.jj-aws-ivs-player-container:hover .jj-aws-ivs-audio-button-container,
.jj-aws-ivs-recording-container:hover .jj-aws-ivs-audio-button-container,
.jj-aws-ivs-player-container.controls-active .jj-aws-ivs-audio-button-container,
.jj-aws-ivs-recording-container.controls-active .jj-aws-ivs-audio-button-container {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile audio button positioning and behavior */
@media (max-width: 768px) {
    .jj-aws-ivs-audio-button-container {
        /* Position slightly right of center for better balance */
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(15px); /* Small offset right of center */
        opacity: 0;
        pointer-events: none;
    }
    
    /* Only show on touch/active state, not always visible */
    .jj-aws-ivs-player-container.controls-active .jj-aws-ivs-audio-button-container,
    .jj-aws-ivs-recording-container.controls-active .jj-aws-ivs-audio-button-container,
    .jj-aws-ivs-player-container.mobile-touched .jj-aws-ivs-audio-button-container,
    .jj-aws-ivs-recording-container.mobile-touched .jj-aws-ivs-audio-button-container {
        opacity: 1;
        pointer-events: auto;
    }
}

.jj-aws-ivs-audio-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.jj-aws-ivs-audio-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.jj-aws-ivs-speaker-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Speaker icon SVG embedded as background */
.jj-aws-ivs-speaker-icon {
    background-image: url('data:image/svg+xml;utf8,<svg width="18" height="18" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 7V13H7L12 18V2L7 7H3Z" fill="white"/></svg>');
}

/* Muted state - show speaker with slash through it */
.jj-aws-ivs-audio-toggle.muted .jj-aws-ivs-speaker-icon {
    background-image: url('data:image/svg+xml;utf8,<svg width="18" height="18" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 7V13H7L12 18V2L7 7H3Z" fill="white"/><line x1="2" y1="2" x2="18" y2="18" stroke="white" stroke-width="2.5" stroke-linecap="round"/></svg>');
}

.jj-aws-ivs-audio-text {
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Big Play Button Overlay Styles */
.jj-aws-ivs-big-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.jj-aws-ivs-big-play-button:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.jj-aws-ivs-big-play-button:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Play button triangle icon */
.jj-aws-ivs-big-play-icon {
    width: 0;
    height: 0;
    border-left: 20px solid rgba(255, 255, 255, 0.9);
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    margin-left: 4px; /* Slight offset to center the triangle visually */
}

.jj-aws-ivs-big-play-button:hover .jj-aws-ivs-big-play-icon {
    border-left-color: rgba(255, 255, 255, 1);
}

/* Hide the big play button when video is playing */
.jj-aws-ivs-player-container.video-playing .jj-aws-ivs-big-play-button,
.jj-aws-ivs-recording-container.video-playing .jj-aws-ivs-big-play-button {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.8);
}

/* Responsive styles for mobile */
@media (max-width: 768px) {
    .jj-aws-ivs-big-play-button {
        width: 70px;
        height: 70px;
        border-width: 2px;
    }
    
    .jj-aws-ivs-big-play-icon {
        border-left-width: 16px;
        border-top-width: 10px;
        border-bottom-width: 10px;
        margin-left: 3px;
    }
}

/* Ensure the play button is hidden when poster overlay is not visible */
.jj-aws-ivs-poster-overlay:not([style*="display: none"]) ~ .jj-aws-ivs-big-play-button {
    display: flex;
}

.jj-aws-ivs-poster-overlay[style*="display: none"] ~ .jj-aws-ivs-big-play-button {
    display: none;
}

/* Fullscreen button container - positioned next to audio button */
.jj-aws-ivs-fullscreen-button-container {
    position: absolute;
    bottom: 15px;
    right: 200px; /* Position to the left of audio button on desktop */
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.jj-aws-ivs-player-container:hover .jj-aws-ivs-fullscreen-button-container,
.jj-aws-ivs-recording-container:hover .jj-aws-ivs-fullscreen-button-container {
    opacity: 1;
}

/* Mobile positioning - center both buttons with consistent spacing */
@media (max-width: 768px) {
    .jj-aws-ivs-fullscreen-button-container {
        /* Position consistently left of center with good spacing from audio button */
        bottom: 20px;
        top: auto;
        left: 50%;
        right: auto;
        transform: translateX(-140px); /* Further left for better spacing */
        opacity: 0;
        pointer-events: none;
    }
    
    /* Only show on touch/active state, matching audio button behavior */
    .jj-aws-ivs-player-container.controls-active .jj-aws-ivs-fullscreen-button-container,
    .jj-aws-ivs-recording-container.controls-active .jj-aws-ivs-fullscreen-button-container,
    .jj-aws-ivs-player-container.mobile-touched .jj-aws-ivs-fullscreen-button-container,
    .jj-aws-ivs-recording-container.mobile-touched .jj-aws-ivs-fullscreen-button-container {
        opacity: 1;
        pointer-events: auto;
    }
}

.jj-aws-ivs-fullscreen-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.jj-aws-ivs-fullscreen-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-1px);
}

.jj-aws-ivs-fullscreen-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Fullscreen icon SVG embedded as background - expand arrows */
.jj-aws-ivs-fullscreen-icon {
    background-image: url('data:image/svg+xml;utf8,<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" fill="white"/></svg>');
}

/* Exit fullscreen icon - compress arrows */
.jj-aws-ivs-fullscreen-toggle.exit-fullscreen .jj-aws-ivs-fullscreen-icon {
    background-image: url('data:image/svg+xml;utf8,<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" fill="white"/></svg>');
}

.jj-aws-ivs-fullscreen-text {
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Fullscreen styles */
.jj-aws-ivs-player-container:fullscreen,
.jj-aws-ivs-recording-container:fullscreen {
    background: #000;
    width: 100vw !important;
    height: 100vh !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jj-aws-ivs-player-container:fullscreen video,
.jj-aws-ivs-recording-container:fullscreen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    transform: none !important; /* Remove scaling in fullscreen */
    aspect-ratio: 16/9 !important; /* Use natural ratio in fullscreen */
}

/* iOS Fullscreen Rotation Support */
/* Enable rotation for video elements in fullscreen */
video.jj-aws-ivs-player,
video.jj-aws-ivs-recording-player {
    /* Allow the video to rotate freely */
    -webkit-transform-origin: center center;
    transform-origin: center center;
    
    /* Ensure video can use full screen in both orientations */
    max-width: 100vw;
    max-height: 100vh;
}

/* iOS-specific fullscreen video enhancements */
@supports (-webkit-appearance: none) {
    /* This targets WebKit browsers (Safari) */
    video.jj-aws-ivs-player:fullscreen,
    video.jj-aws-ivs-recording-player:fullscreen,
    video.jj-aws-ivs-player:-webkit-full-screen,
    video.jj-aws-ivs-recording-player:-webkit-full-screen {
        /* Optimize for fullscreen viewing */
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain !important;
        background: #000 !important;
    }
}

/* Landscape orientation optimizations for mobile devices */
@media screen and (orientation: landscape) and (max-width: 1024px) {
    /* When phone is rotated to landscape */
    video.jj-aws-ivs-player,
    video.jj-aws-ivs-recording-player {
        /* Fill the available width in landscape */
        width: 100vw !important;
        height: auto !important;
        max-height: 100vh !important;
    }
    
    /* Ensure containers don't interfere with rotation */
    .jj-aws-ivs-player-container,
    .jj-aws-ivs-recording-container {
        /* Allow flexible sizing in landscape */
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
    }
}

/* Portrait to landscape transition support */
@media screen and (orientation: portrait) and (max-width: 768px) {
    /* Maintain proper sizing when rotating back to portrait */
    video.jj-aws-ivs-player,
    video.jj-aws-ivs-recording-player {
        transition: width 0.3s ease, height 0.3s ease;
    }
}

/* Body classes for rotation state management */
body.jj-ivs-fullscreen-active {
    /* Ensure the body can handle fullscreen video rotation */
    overflow: hidden;
}

body.jj-ivs-landscape {
    /* Additional optimizations when in landscape during fullscreen */
    /* These classes can be used for future enhancements */
}

body.jj-ivs-portrait {
    /* Additional optimizations when in portrait during fullscreen */
    /* These classes can be used for future enhancements */
}

/* iOS Safari-specific fullscreen video rotation optimizations */
@supports (-webkit-touch-callout: none) {
    /* This targets iOS Safari specifically */
    body.jj-ivs-fullscreen-active video.jj-aws-ivs-player,
    body.jj-ivs-fullscreen-active video.jj-aws-ivs-recording-player {
        /* Ensure smooth rotation transitions */
        -webkit-transition: -webkit-transform 0.3s ease;
        transition: transform 0.3s ease;
    }
    
    /* Landscape-specific optimizations for iOS */
    body.jj-ivs-landscape video.jj-aws-ivs-player,
    body.jj-ivs-landscape video.jj-aws-ivs-recording-player {
        /* Optimize for landscape viewing */
        -webkit-transform-origin: center center;
        transform-origin: center center;
    }
} 