/* Video container responsive styles */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Video error container */
.video-error-container {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    background-color: #f9fafb;
}

.dark .video-error-container {
    background-color: #374151;
    border-color: #6b7280;
}

/* YouTube thumbnail fallback styles */
.youtube-thumbnail-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background-color: #f3f4f6;
    transition: all 0.3s ease;
}

.youtube-thumbnail-container:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dark .youtube-thumbnail-container {
    background-color: #374151;
}

/* Broken image handling */
.youtube-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.youtube-thumbnail-image:not([src]),
.youtube-thumbnail-image[src=""],
.youtube-thumbnail-image[src*="data:image/svg+xml"] {
    opacity: 0;
}

/* Loading state */
.youtube-thumbnail-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Play button overlay improvements */
.youtube-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 10;
}

.youtube-play-overlay:hover {
    background: rgba(255, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 0, 0, 0.3);
}

.youtube-play-icon {
    width: 24px;
    height: 24px;
    color: white;
    margin-left: 2px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Fallback overlay improvements */
.youtube-fallback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.95);
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    backdrop-filter: blur(4px);
}

.dark .youtube-fallback-overlay {
    background: rgba(39, 39, 42, 0.95);
    border-color: #52525b;
}

.youtube-fallback-image {
    max-width: 60%;
    max-height: 60%;
    opacity: 0.6;
    filter: grayscale(0.3);
}

.youtube-fallback-text {
    margin-top: 8px;
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
}

.dark .youtube-fallback-text {
    color: #9ca3af;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .youtube-play-overlay {
        width: 50px;
        height: 50px;
    }
    
    .youtube-play-icon {
        width: 20px;
        height: 20px;
    }
    
    .video-container {
        border-radius: 6px;
    }
}

/* Article image improvements */
.article-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Card hover effects for video thumbnails */
.card:has(.youtube-thumbnail-container):hover .youtube-thumbnail-container {
    transform: scale(1.02);
}

/* Accessibility improvements */
.youtube-play-overlay:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.youtube-thumbnail-container:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Error state styling */
.youtube-error-state {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    color: #dc2626;
}

.dark .youtube-error-state {
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    border-color: #dc2626;
    color: #fca5a5;
}
