/* Simple Video Manager - Optimized TikTok-style Interface */

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    box-sizing: border-box;
}

:root {
    --vh: 1vh;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

body {
    overscroll-behavior-y: none;
    touch-action: pan-y;
    position: fixed;
    -webkit-overflow-scrolling: touch;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Desktop body styling */
@media (min-width: 769px) {
    body:has(.svm-video-container) {
        background: #0a0a0a;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
    }
}

.svm-video-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    background: #000;
    touch-action: pan-y;
}

/* Desktop: Limit width and center */
@media (min-width: 769px) {
    .svm-video-container {
        width: min(450px, 100vw);
        max-width: 450px;
        height: 100vh;
        margin: 0 auto;
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
        position: relative;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .svm-video-container {
        width: min(400px, 100vw);
        max-width: 400px;
    }
}

/* Full page mode override */
.svm-fullpage-container .svm-video-container {
    max-width: 100% !important;
    box-shadow: none;
    width: 100% !important;
}

.svm-video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.svm-video-wrapper::-webkit-scrollbar {
    display: none;
}

/* Swiper specific styles */
.svm-video-wrapper.swiper {
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

.svm-video-wrapper .swiper-wrapper {
    transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}

.svm-video-item {
    position: relative;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    cursor: pointer;
}

.svm-video-item.swiper-slide {
    flex-shrink: 0;
}

.svm-video-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
}

/* Ensure video covers full screen on mobile */
@media (max-width: 768px) {
    .svm-video-player {
        object-fit: cover !important;
        min-width: 100%;
        min-height: 100%;
    }
}

/* Desktop: Maintain 9:16 aspect ratio */
@media (min-width: 769px) {
    .svm-video-player {
        object-fit: contain;
    }
}

/* Video info overlay - TikTok style */
.svm-video-info {
    position: absolute;
    bottom: 40px;
    left: 16px;
    right: 80px;
    color: #fff;
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    animation: slideInUp 0.4s ease-out;
    pointer-events: none;
}

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

.svm-video-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #fff;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.svm-video-description {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.95);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.svm-video-meta {
    margin-top: 8px;
}

.svm-video-categories,
.svm-video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 5px;
}

.svm-category,
.svm-tag {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    pointer-events: auto;
}

.svm-category:hover,
.svm-tag:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Mute button - Top left position */
.svm-mute-button-top {
    position: absolute;
    top: 20px;
    right: 16px;
    z-index: 20;
    width: 50px;
    height: 44px;
    border-radius: 50%;
    background: hsla(0,0%,100%,.6) !important;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

.svm-mute-button-top:active {
    transform: scale(0.9);
}

.svm-mute-button-top:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.svm-mute-button-top.unmuted {
    background: rgba(0,0,0,.1) !important;
}

.svm-mute-button-top .unmute-icon {
    animation: soundWave 1s ease-in-out infinite;
}

@keyframes soundWave {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Right side controls - Navigation buttons */
.svm-video-controls {
    position: absolute;
    right: 12px;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 15;
    animation: slideInRight 0.4s ease-out;
}

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

.svm-video-controls button {
    width: 55px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.svm-video-controls button::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.3), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.svm-video-controls button:active {
    transform: scale(0.9);
}

.svm-video-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.svm-video-controls button:hover::before {
    opacity: 1;
}

/* Navigation buttons styling */
.svm-prev-video,
.svm-next-video {
    background: rgba(255, 255, 255, 0.15);
}

.svm-prev-video:hover,
.svm-next-video:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Progress bar - TikTok style */
.svm-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
}

.svm-progress-fill {
    height: 100%;
    background: #ec1a3b;
    width: 0;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(255, 60, 80, 0.6);
}

/* Buffer indicator */
.svm-buffer-indicator {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    transition: width 0.3s;
    z-index: 1;
}

/* Remove big play button */
.svm-big-play {
    display: none !important;
}

/* Loading spinner - TikTok style */
.svm-video-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    pointer-events: none;
}

.svm-video-loader .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading message */
.svm-loading {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    animation: fadeInOut 1.5s ease-in-out infinite;
    z-index: 25;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Video error state - TikTok style */
.video-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    padding: 32px 24px;
    border-radius: 16px;
    max-width: 280px;
}

.video-error p {
    font-size: 15px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.video-error button {
    background: linear-gradient(135deg, #FF3C50, #FF8C00);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.video-error button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 60, 80, 0.4);
}

.video-error button:active {
    transform: translateY(0);
}

/* Video.js custom styling */
.video-js {
    width: 100%;
    height: 100%;
}

.video-js .vjs-loading-spinner,
.video-js .vjs-control-bar,
.video-js .vjs-big-play-button {
    display: none !important;
}

/* Hide native controls */
.svm-video-player::-webkit-media-controls {
    display: none !important;
}

.svm-video-player::-webkit-media-controls-enclosure {
    display: none !important;
}

/* Responsive - Mobile optimization */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .svm-video-container {
        max-width: 100%;
        width: 100vw;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .svm-video-wrapper {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .svm-video-item {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .svm-video-player {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    
    .svm-video-info {
        bottom: 30px;
        left: 12px;
        right: 70px;
    }
    
    .svm-video-title {
        font-size: 15px;
    }
    
    .svm-video-description {
        font-size: 13px;
    }
    
    .svm-video-controls {
        right: 10px;
        bottom: 30px;
        gap: 5px;
    }
    
    .svm-video-controls button {
        width: 50px;
        height: 44px;
        font-size: 20px;
    }
    
    .svm-mute-button-top {
        top: 16px;
        right: 12px;
        width: 45px;
        height: 40px;
        font-size: 18px;
    }
}

/* Desktop optimization - Show video in proper aspect ratio */
@media (min-width: 769px) {
    .svm-video-container {
        max-width: 450px;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
        border-radius: 0;
    }
    
    .svm-video-player {
        object-fit: contain;
    }
    
    .svm-video-info {
        bottom: 30px;
        left: 20px;
        right: 90px;
    }
    
    .svm-video-controls {
        right: 16px;
        bottom: 130px;
    }
    
    /* Hover effects on desktop */
    .svm-video-controls button:hover {
        transform: scale(1.15);
    }
    
    /* Show cursor pointer on interactive elements */
    .svm-video-player,
    .svm-mute-button-top {
        cursor: pointer;
    }
}

/* Large desktop - Add max constraint */
@media (min-width: 1200px) {
    .svm-video-container {
        max-width: 420px;
    }
}

/* Landscape mode optimization */
@media (orientation: landscape) and (max-height: 500px) {
    .svm-video-info {
        bottom: 30px;
        font-size: 12px;
    }
    
    .svm-video-title {
        font-size: 14px;
        -webkit-line-clamp: 1;
    }
    
    .svm-video-description {
        display: none;
    }
    
    .svm-video-controls {
        bottom: 70px;
        gap: 5px;
    }
    
    .svm-video-controls button {
        width: 44px;
        height: 40px;
    }
    
    .svm-mute-button-top {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
    }
}

/* Fade transitions */
.svm-video-item {
    opacity: 0;
    animation: fadeIn 0.4s forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Touch feedback */
.svm-video-item.touching {
    filter: brightness(0.95);
}

/* Performance optimizations */
.svm-video-item,
.svm-video-player {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.svm-video-info,
.svm-video-controls {
    will-change: transform;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for keyboard navigation */
.svm-video-controls button:focus-visible,
.svm-mute-button-top:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Sound unmuted indicator */
.svm-sound-indicator {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 30;
    animation: slideDown 0.3s ease-out;
    pointer-events: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.svm-sound-indicator.hide {
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    to {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

/* ============================================
   PAGE VIDEO FEED STYLES
   ============================================ */

.svm-fullpage-container {
    display: flex;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    position: relative;
}

/* Sidebar Styles */
.svm-sidebar {
    width: 250px;
    background: #1a1a1a;
    border-right: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 100;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    position: sticky;
    top: 0;
}

.svm-sidebar::-webkit-scrollbar {
    width: 6px;
}

.svm-sidebar::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.svm-sidebar::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.svm-sidebar::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.svm-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #333;
}

.svm-sidebar-header a {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
    display: block;
    transition: color 0.3s;
}

.svm-sidebar-header a:hover {
    color: #ff0050;
}

.svm-sidebar-section {
    padding: 15px 0;
    border-bottom: 1px solid #333;
}

.svm-sidebar-section h3 {
    color: #fff;
    padding: 0 20px 10px;
    font-size: 16px;
    font-weight: 500;
}

.svm-category-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.svm-category-list li {
    position: relative;
}

.svm-category-list a {
    color: #ccc;
    text-decoration: none;
    padding: 12px 20px;
    display: block;
    transition: all 0.3s;
    position: relative;
}

.svm-category-list a:hover {
    color: #fff;
    background: rgba(255, 0, 80, 0.1);
    padding-left: 30px;
}

.svm-category-list a.active {
    color: #ff0050;
    background: rgba(255, 0, 80, 0.2);
    border-left: 3px solid #ff0050;
}

.svm-category-list a .count {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #999;
}

/* Main Content Area */
.svm-main-content {
    flex: 1;
    position: relative;
    background: #000;
    overflow: auto;
}

/* Grid Layout Styles */
.svm-grid-container {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    overflow-y: auto;
}

.svm-grid-header {
    margin-bottom: 30px;
    text-align: center;
}

.svm-grid-header h1 {
    color: #fff;
    font-size: 32px;
    margin-bottom: 10px;
}

.svm-grid-header p {
    color: #999;
    font-size: 16px;
}

.svm-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.svm-grid-item {
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    text-decoration: none;
}

.svm-grid-item:hover {
    box-shadow: 0 8px 24px rgba(255, 0, 80, 0.3);
}

.svm-grid-item-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 177.78%; /* 9:16 aspect ratio */
    background: #000;
    overflow: hidden;
}

.svm-grid-item-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.svm-grid-item-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.svm-grid-item:hover .svm-grid-item-play {
    opacity: 1;
}

.svm-grid-item-play svg {
    width: 24px;
    height: 24px;
    fill: #000;
    margin-left: 4px;
}

.svm-grid-item-info {
    padding: 15px;
    position: absolute;
    bottom:0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, #000 82.69%);
    width:100%;
}

.svm-grid-item-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.svm-grid-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.svm-grid-item-meta span {
    font-size: 12px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #f1f1f1;
}

/* Mobile Toggle Button */
.svm-sidebar-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #333;
    color: #fff;
    padding: 10px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.svm-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* Loading screen */
.svm-initial-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    text-align: center;
}

/* Overlay for mobile */
.svm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
}

.svm-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .svm-sidebar {
        position: fixed;
        left: -250px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 150;
    }
    
    .svm-sidebar.active {
        left: 0;
    }
    
    .svm-sidebar-toggle {
        display: flex;
    }
    
    .svm-main-content {
        width: 100%;
    }
    
    .svm-video-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .svm-grid-container {
        padding: 20px 15px;
    }
    
    .svm-fullpage-container {
        flex-direction: column;
    }
}

/* Prevent iOS Safari bounce */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        position: fixed;
        overflow: hidden;
    }
    
    .svm-video-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

/* Fix for iOS Safari bottom bar */
@supports (padding: max(0px)) {
    .svm-video-info {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    .svm-video-controls {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

.unmute-icon {
    background-image:url(../img/volume.svg);
    background-repeat:no-repeat;
    background-position:  center center;
    width:20px;
    height:20px;
}

.mute-icon {
    background-image:url(../img/volume-xmark.svg);
    background-repeat:no-repeat;
    background-position:  center center;
    width:20px;
    height:20px;
}