/* ========================================== */
/* Instagram-style Adaptive Video Streaming CSS */
/* ========================================== */

/* Main video container */
.adaptive-video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin: 10px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Video.js player styling */
.video-js {
    width: 100% !important;
    height: auto !important;
    min-height: 200px;
    max-height: 400px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.video-js .vjs-poster {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Instagram-style controls */
.video-js .vjs-control-bar {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
    padding: 8px 12px;
    font-size: 14px;
}

.video-js .vjs-big-play-button {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 24px;
    color: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.video-js .vjs-big-play-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-js .vjs-big-play-button .vjs-icon-placeholder::before {
    line-height: 70px;
}

/* Custom quality selector */
.vjs-quality-selector {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    color: white;
    font-weight: 500;
    backdrop-filter: blur(10px);
    z-index: 10;
    transition: all 0.3s ease;
}

.vjs-quality-selector:hover {
    background: rgba(0, 0, 0, 0.9);
}

.vjs-quality-selector select {
    background: transparent;
    border: none;
    color: white;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

.vjs-quality-selector option {
    background: #333;
    color: white;
}

/* Network indicator */
.video-network-indicator {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 196, 180, 0.9);
    border-radius: 20px;
    padding: 4px 8px;
    font-size: 10px;
    color: white;
    font-weight: 600;
    z-index: 10;
    display: none;
    backdrop-filter: blur(10px);
}

.video-network-indicator.active {
    display: block;
    animation: fadeInScale 0.3s ease-out;
}

.video-network-indicator.slow {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
}

.video-network-indicator.fast {
    background: rgba(40, 167, 69, 0.9);
}

/* Buffer indicator */
.video-buffer-indicator {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    color: white;
    display: none;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    z-index: 15;
}

.video-buffer-indicator.active {
    display: flex;
    animation: fadeInUp 0.3s ease-out;
}

.video-buffer-indicator .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid #00c4b4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Instagram-style loading skeleton */
.video-loading-skeleton {
    width: 100%;
    height: 250px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.video-loading-skeleton::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-loading-skeleton::before {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 52%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: #666;
    z-index: 1;
}

/* Error state */
.video-error-state {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 14px;
    text-align: center;
    padding: 20px;
    border: 2px dashed #dee2e6;
}

.video-error-state i {
    font-size: 32px;
    color: #dc3545;
    margin-bottom: 10px;
}

.video-error-retry {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.video-error-retry:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

/* Responsive design */
@media (max-width: 768px) {
    .adaptive-video-container {
        border-radius: 8px;
        margin: 8px 0;
    }
    
    .video-js {
        min-height: 180px;
        max-height: 300px;
    }
    
    .video-js .vjs-big-play-button {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .video-js .vjs-big-play-button .vjs-icon-placeholder::before {
        line-height: 60px;
    }
    
    .vjs-quality-selector {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .video-network-indicator {
        top: 8px;
        left: 8px;
        padding: 3px 6px;
        font-size: 9px;
    }
    
    .video-buffer-indicator {
        bottom: 40px;
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .video-loading-skeleton {
        height: 200px;
    }
    
    .video-error-state {
        height: 160px;
        font-size: 13px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .video-js {
        min-height: 160px;
        max-height: 250px;
    }
    
    .video-js .vjs-big-play-button {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
    
    .video-js .vjs-big-play-button .vjs-icon-placeholder::before {
        line-height: 50px;
    }
}

/* Dark mode adjustments */
.dark-mode .video-loading-skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #404040 50%, #2a2a2a 75%);
    background-size: 200% 100%;
}

.dark-mode .video-loading-skeleton::after {
    background: rgba(255, 255, 255, 0.1);
}

.dark-mode .video-loading-skeleton::before {
    color: #aaa;
}

.dark-mode .video-error-state {
    background: linear-gradient(135deg, #343a40, #495057);
    border-color: #495057;
    color: #adb5bd;
}

.dark-mode .vjs-quality-selector {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.dark-mode .video-buffer-indicator {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Animations */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

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

/* Accessibility improvements */
.video-js .vjs-control:focus {
    outline: 2px solid #00c4b4;
    outline-offset: 2px;
}

.vjs-quality-selector:focus {
    outline: 2px solid #00c4b4;
    outline-offset: 2px;
}

/* Performance optimizations */
.adaptive-video-container {
    contain: layout style paint;
    will-change: transform;
}

.video-js video {
    object-fit: cover;
    background: #000;
}

/* Instagram-style video hover effects */
.adaptive-video-container:hover .vjs-quality-selector {
    opacity: 1;
    visibility: visible;
}

.adaptive-video-container:hover .video-network-indicator {
    opacity: 0.8;
}

/* Quality badge styling */
.video-quality-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.video-quality-badge.hd {
    background: rgba(40, 167, 69, 0.8);
}

.video-quality-badge.auto {
    background: rgba(0, 123, 255, 0.8);
}
