/* Advanced Video Block - Optimized CSS */

/* Base styles */
.advanced-video-block {
    position: relative;
    min-height: 200px;
}

.video-block-title {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

.video-block-description {
    line-height: 1.6;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

/* Video Item Container */
.video-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    will-change: transform;
}

.video-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Active video styling */
.video-item.video-active {
    border: 2px solid #007bff;
    box-shadow: 0 8px 30px rgba(0,123,255,0.3);
    position: relative;
}

.video-item.video-active:hover {
    transform: translateY(-2px);
}

/* Visual indicator for active video */
.video-active-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #007bff;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: pulse 2s infinite;
}

.video-active-indicator i {
    font-size: 0.7rem;
}

/* Hidden video playing indicator */
.video-item.video-playing-hidden {
    border: 2px solid #ff6b35;
    background: linear-gradient(45deg, #fff 0%, #fff5f5 100%);
}

.video-item.video-playing-hidden::before {
    content: "🎵 Audio Playing";
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff6b35;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Thumbnail Styles */
.video-thumbnail-wrapper {
    position: relative;
    background: #000;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    aspect-ratio: 16/9;
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                      linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                      linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    will-change: transform;
}

/* Video Player Container for Inline Playback */
.video-player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-player-container.loaded {
    opacity: 1;
}

.video-player-container iframe,
.video-player-container video {
    width: 100%;
    height: 100%;
    border: none;
}

/* Stop button for active videos */
.video-stop-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.8);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.video-stop-button:hover {
    background: rgba(255,0,0,0.8);
    transform: scale(1.1);
}

.video-stop-button i {
    font-size: 0.8rem;
}

.video-thumbnail-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Play Button */
.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(18, 55, 121, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    will-change: transform;
    color: white;
    font-size: 20px;
}

.video-play-button i {
    color: white;
}

.video-play-button:focus {
    outline: 2px solid #123779;
    outline-offset: 2px;
}

/* Video Content */
.video-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.video-title {
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.video-description {
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    margin: 0;
}

/* Video Type Badge */
.video-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 5px 8px;
    border-radius: 15px;
    font-size: 0.8rem;
    backdrop-filter: blur(10px);
    z-index: 2;
}

.video-type-badge i {
    margin-right: 3px;
}

/* Placeholder Styles */
.video-placeholder {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.placeholder-content {
    text-align: center;
}

.placeholder-content i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    display: block;
}

.placeholder-content span {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Modal Styles */
.video-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-modal.show {
    opacity: 1;
}

.video-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 90%;
    max-width: 900px;
    max-height: 90%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-modal.show .video-modal-content {
    transform: translate(-50%, -50%) scale(1);
}

.video-modal-header {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    flex-grow: 1;
    padding-right: 1rem;
}

.video-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.video-modal-close:hover {
    background-color: rgba(0,0,0,0.1);
}

.video-modal-body {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.video-modal-body iframe,
.video-modal-body video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Grid Layout */
.video-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(var(--cols-desktop, 3), 1fr);
    align-items: stretch;
}

.video-grid .video-grid-item {
    width: 100%;
    display: flex;
    align-items: stretch;
}

.video-grid .video-item {
    margin: 0;
    width: 100%;
}

/* Slider Styles */
.video-slider-wrapper {
    position: relative;
}

.video-slider .slick-track {
    display: flex !important;
    align-items: stretch;
}

.video-slider .slick-slide {
    outline: none;
    height: auto;
    display: flex !important;
    align-items: stretch;
}

.video-slider .slick-slide > div {
    padding: 0 10px;
    width: 100%;
    display: flex;
    align-items: stretch;
}

.video-slide-item {
    display: flex !important;
    align-items: stretch;
    height: 100% !important;
}

.video-slider .slick-dots {
    bottom: -50px;
}

.video-slider .slick-dots li {
    margin: 0 5px;
}

.video-slider .slick-dots li button:before {
    font-size: 12px;
    color: rgba(0,0,0,0.5);
    transition: color 0.3s ease;
}

.video-slider .slick-dots li.slick-active button:before {
    color: #007bff;
}

/* Loading States */
.video-loading {
    background: #f8f9fa !important;
    background-image: linear-gradient(45deg, transparent 35%, rgba(255,255,255,.5) 35%, rgba(255,255,255,.5) 65%, transparent 65%),
                      linear-gradient(-45deg, transparent 35%, rgba(0,0,0,.1) 35%, rgba(0,0,0,.1) 65%, transparent 65%) !important;
    background-size: 20px 20px !important;
    background-position: 0 0, 10px 10px !important;
    animation: loading 1s linear infinite !important;
}

@keyframes loading {
    0% { background-position: 0 0, 10px 10px; }
    100% { background-position: 20px 20px, 30px 30px; }
}

/* Error States */
.video-error {
    height: 100%;
    background: #f8d7da;
    color: #721c24;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    min-height: 200px;
}

.video-error i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .video-grid {
        grid-template-columns: repeat(var(--cols-tablet, 2), 1fr);
    }
}

@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(var(--cols-mobile, 1), 1fr);
        gap: 1rem;
    }
    
    .video-content {
        padding: 1rem;
    }
    
    .video-modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .video-modal-header {
        padding: 0.75rem 1rem;
    }
    
    .video-modal-title {
        font-size: 1rem;
    }
    
    .video-play-button {
        width: 50px;
        height: 50px;
    }
    
    .video-play-button::after {
        border-left-width: 12px;
        border-top-width: 8px;
        border-bottom-width: 8px;
        border-left-color: #123779;
    }
    
    .video-play-button:hover::after {
        border-left-color: #ffffff;
    }
}

@media (max-width: 480px) {
    .advanced-video-block {
        padding: 2rem 0;
    }
    
    .video-grid {
        gap: 0.75rem;
    }
    
    .video-content {
        padding: 0.75rem;
    }
    
    .video-title {
        font-size: 1rem;
    }
    
    .video-description {
        font-size: 0.85rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .video-item,
    .video-thumbnail,
    .video-play-button,
    .video-modal,
    .video-modal-content {
        transition: none !important;
        animation: none !important;
    }
}

/* Unmute Button */
.video-unmute-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(18, 55, 121, 0.95);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    opacity: 1;
}

.video-unmute-button:hover {
    background: rgba(18, 55, 121, 1);
    transform: scale(1.05);
}

.video-unmute-button:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.video-unmute-button.unmuted {
    background: rgba(40, 167, 69, 0.95);
}

.video-unmute-button.unmuted:hover {
    background: rgba(40, 167, 69, 1);
}

.video-unmute-button i {
    font-size: 16px;
}

/* Muted Info Overlay */
.video-muted-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out infinite;
}

.video-muted-info i {
    font-size: 14px;
}

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

/* Print styles */
@media print {
    .video-modal,
    .video-play-button {
        display: none !important;
    }
    
    .video-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .video-item {
        border: 2px solid #000;
    }
    
    .video-play-button {
        background: #fff;
        border: 2px solid #000;
    }
    
    .video-type-badge {
        background: #000;
        border: 1px solid #fff;
    }
}
