/**
 * iframe Optimization Styles - Community Cache
 * 
 * This file contains CSS styles for iframe optimization including
 * YouTube thumbnails and play buttons.
 * 
 * @package Community_Cache
 * @since 1.0.0
 */

/* YouTube Thumbnail Placeholder */
.wpsc-youtube-placeholder {
    position: relative;
    display: inline-block;
    cursor: pointer;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #000;
    border: 2px solid transparent;
}

.wpsc-youtube-placeholder:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    border-color: #ff0000;
}

.wpsc-youtube-placeholder:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.wpsc-youtube-placeholder img {
    display: block;
    width: 100%;
    height: auto;
    border: none;
    outline: none;
    transition: filter 0.3s ease;
}

.wpsc-youtube-placeholder:hover img {
    filter: brightness(1.1) contrast(1.05);
}

/* YouTube Play Button */
.wpsc-youtube-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 56px;
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.9), rgba(204, 0, 0, 0.9));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.wpsc-youtube-play-button::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 24px solid #fff;
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    margin-left: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.wpsc-youtube-placeholder:hover .wpsc-youtube-play-button {
    background: linear-gradient(135deg, rgba(255, 0, 0, 1), rgba(204, 0, 0, 1));
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.wpsc-youtube-placeholder:active .wpsc-youtube-play-button {
    transform: translate(-50%, -50%) scale(1.05);
}

/* YouTube iframe */
.wpsc-youtube-iframe {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.wpsc-youtube-iframe:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

/* Vimeo Thumbnail Placeholder */
.wpsc-vimeo-placeholder {
    position: relative;
    display: inline-block;
    cursor: pointer;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #000;
    border: 2px solid transparent;
}

.wpsc-vimeo-placeholder:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    border-color: #1ab7ea;
}

.wpsc-vimeo-placeholder:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.wpsc-vimeo-placeholder img {
    display: block;
    width: 100%;
    height: auto;
    border: none;
    outline: none;
    transition: filter 0.3s ease;
}

.wpsc-vimeo-placeholder:hover img {
    filter: brightness(1.1) contrast(1.05);
}

/* Vimeo Play Button */
.wpsc-vimeo-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 56px;
    background: linear-gradient(135deg, rgba(26, 183, 234, 0.9), rgba(0, 173, 239, 0.9));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(26, 183, 234, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.wpsc-vimeo-play-button::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 24px solid #fff;
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    margin-left: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.wpsc-vimeo-placeholder:hover .wpsc-vimeo-play-button {
    background: linear-gradient(135deg, rgba(26, 183, 234, 1), rgba(0, 173, 239, 1));
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 6px 20px rgba(26, 183, 234, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
}

.wpsc-vimeo-placeholder:active .wpsc-vimeo-play-button {
    transform: translate(-50%, -50%) scale(1.05);
}

/* Vimeo iframe */
.wpsc-vimeo-iframe {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.wpsc-vimeo-iframe:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

/* Generic iframe styling */
iframe[data-src] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    position: relative;
    transition: all 0.3s ease;
}

iframe[data-src]:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #adb5bd;
}

iframe[data-src]::before {
    content: 'Loading content...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #6c757d;
    pointer-events: none;
    font-weight: 500;
}

/* Loading state improvements */
iframe[data-loading-state="pending"] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: #dee2e6;
}

iframe[data-loading-state="loading"] {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: #2196f3;
}

iframe[data-loading-state="loaded"] {
    background: transparent;
    border: none;
}

iframe[data-loading-state="error"] {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border-color: #f44336;
}

/* Responsive design */
@media (max-width: 768px) {
    .wpsc-youtube-play-button,
    .wpsc-vimeo-play-button {
        width: 48px;
        height: 36px;
        font-size: 16px;
    }
    
    .wpsc-youtube-play-button::before,
    .wpsc-vimeo-play-button::before {
        border-left: 14px solid #fff;
        border-top: 9px solid transparent;
        border-bottom: 9px solid transparent;
        margin-left: 3px;
    }
    
    .wpsc-advanced-loading-indicator {
        min-width: 160px;
        padding: 15px;
        font-size: 13px;
    }
    
    .wpsc-loading-spinner {
        width: 32px;
        height: 32px;
        margin-bottom: 12px;
    }
    
    .wpsc-loading-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .wpsc-youtube-play-button,
    .wpsc-vimeo-play-button {
        width: 40px;
        height: 30px;
        font-size: 14px;
    }
    
    .wpsc-youtube-play-button::before,
    .wpsc-vimeo-play-button::before {
        border-left: 12px solid #fff;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        margin-left: 2px;
    }
    
    .wpsc-advanced-loading-indicator {
        min-width: 140px;
        padding: 12px;
        font-size: 12px;
    }
    
    .wpsc-loading-spinner {
        width: 28px;
        height: 28px;
        margin-bottom: 10px;
    }
    
    .wpsc-loading-text {
        font-size: 12px;
    }
    
    .wpsc-retry-button {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wpsc-youtube-play-button,
    .wpsc-vimeo-play-button {
        background: #000;
        border: 2px solid #fff;
    }
    
    .wpsc-youtube-placeholder:hover .wpsc-youtube-play-button,
    .wpsc-vimeo-placeholder:hover .wpsc-vimeo-play-button {
        background: #333;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wpsc-youtube-placeholder,
    .wpsc-youtube-play-button,
    .wpsc-vimeo-placeholder,
    .wpsc-vimeo-play-button {
        transition: none;
    }
    
    .wpsc-youtube-placeholder:hover,
    .wpsc-vimeo-placeholder:hover {
        transform: none;
    }
    
    .wpsc-youtube-placeholder:hover .wpsc-youtube-play-button,
    .wpsc-vimeo-placeholder:hover .wpsc-vimeo-play-button {
        transform: translate(-50%, -50%);
    }
    
    .wpsc-spinner,
    .wpsc-spinner-ring {
        animation: none;
    }
    
    .wpsc-progress-bar::after {
        animation: none;
    }
    
    .wpsc-advanced-loading-indicator {
        backdrop-filter: none;
    }
}

/* Loading Indicators */
.wpsc-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wpsc-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: wpsc-spin 1s linear infinite;
}

@keyframes wpsc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Advanced Loading Indicators */
.wpsc-advanced-loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #333;
    min-width: 200px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.wpsc-loading-spinner {
    position: relative;
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
}

.wpsc-spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: wpsc-spin-ring 1.5s linear infinite;
}

.wpsc-spinner-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-top-color: #00a0d2;
    animation-delay: -0.5s;
    animation-duration: 1.2s;
}

.wpsc-spinner-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-top-color: #005177;
    animation-delay: -1s;
    animation-duration: 0.9s;
}

@keyframes wpsc-spin-ring {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wpsc-loading-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    color: #333;
}

.wpsc-loading-progress {
    width: 100%;
    height: 4px;
    background: rgba(0, 115, 170, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.wpsc-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.wpsc-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: wpsc-progress-shimmer 2s infinite;
}

@keyframes wpsc-progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Error States */
.wpsc-error-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.wpsc-error-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #d63638;
}

.wpsc-error-details {
    font-size: 12px;
    color: #666;
    margin-bottom: 15px;
}

.wpsc-retry-button {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.wpsc-retry-button:hover {
    background: #005177;
}

.wpsc-retry-button:active {
    transform: translateY(1px);
}

/* Error Indicators */
.wpsc-error-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #ff0000;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 14px;
    color: #ff0000;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Enhanced lazy loading iframe styles */
iframe[data-src] {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #ddd;
    border-radius: 4px;
    position: relative;
}

iframe[data-src]::before {
    content: 'Loading content...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #999;
    pointer-events: none;
}

/* Loading state improvements */
iframe[data-loading-indicator="true"] {
    background: #f9f9f9;
}

/* Theme Compatibility */
/* Ensure compatibility with popular WordPress themes */
.wp-block-embed .wpsc-youtube-placeholder,
.wp-block-embed .wpsc-vimeo-placeholder,
.entry-content .wpsc-youtube-placeholder,
.entry-content .wpsc-vimeo-placeholder,
.widget .wpsc-youtube-placeholder,
.widget .wpsc-vimeo-placeholder {
    max-width: 100%;
    height: auto;
}

/* Gutenberg block compatibility */
.wp-block-embed__wrapper .wpsc-youtube-placeholder,
.wp-block-embed__wrapper .wpsc-vimeo-placeholder {
    width: 100%;
    height: auto;
}

/* Twenty Twenty-One theme compatibility */
.twenty-twenty-one .wpsc-youtube-placeholder,
.twenty-twenty-one .wpsc-vimeo-placeholder {
    border-radius: 8px;
}

/* Twenty Twenty-Two theme compatibility */
.twenty-twenty-two .wpsc-youtube-placeholder,
.twenty-twenty-two .wpsc-vimeo-placeholder {
    border-radius: 6px;
}

/* Twenty Twenty-Three theme compatibility */
.twenty-twenty-three .wpsc-youtube-placeholder,
.twenty-twenty-three .wpsc-vimeo-placeholder {
    border-radius: 10px;
}

/* Astra theme compatibility */
.ast-separate-container .wpsc-youtube-placeholder,
.ast-separate-container .wpsc-vimeo-placeholder {
    margin: 1rem 0;
}

/* GeneratePress theme compatibility */
.gp-container .wpsc-youtube-placeholder,
.gp-container .wpsc-vimeo-placeholder {
    margin: 1.5rem 0;
}

/* OceanWP theme compatibility */
.oceanwp-container .wpsc-youtube-placeholder,
.oceanwp-container .wpsc-vimeo-placeholder {
    margin: 1rem 0;
}

/* Elementor compatibility */
.elementor-widget-video .wpsc-youtube-placeholder,
.elementor-widget-video .wpsc-vimeo-placeholder {
    width: 100%;
    height: auto;
}

/* Beaver Builder compatibility */
.fl-node .wpsc-youtube-placeholder,
.fl-node .wpsc-vimeo-placeholder {
    width: 100%;
    height: auto;
}

/* Divi theme compatibility */
.et_pb_video .wpsc-youtube-placeholder,
.et_pb_video .wpsc-vimeo-placeholder {
    width: 100%;
    height: auto;
}

/* WooCommerce compatibility */
.woocommerce .wpsc-youtube-placeholder,
.woocommerce .wpsc-vimeo-placeholder {
    margin: 1rem 0;
}

/* Modern CSS Features */
/* CSS Grid support for iframe containers */
.wpsc-iframe-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

/* Flexbox improvements */
.wpsc-youtube-placeholder,
.wpsc-vimeo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* CSS Custom Properties for theming */
:root {
    --wpsc-youtube-color: #ff0000;
    --wpsc-vimeo-color: #1ab7ea;
    --wpsc-border-radius: 12px;
    --wpsc-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --wpsc-shadow-hover: 0 12px 35px rgba(0, 0, 0, 0.25);
    --wpsc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --wpsc-youtube-color: #ff4444;
        --wpsc-vimeo-color: #4dd0e1;
        --wpsc-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
        --wpsc-shadow-hover: 0 12px 35px rgba(0, 0, 0, 0.6);
    }
    
    .wpsc-youtube-placeholder,
    .wpsc-vimeo-placeholder {
        background: #1a1a1a;
        border-color: #333;
    }
    
    iframe[data-src] {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    iframe[data-src]::before {
        color: #a0aec0;
    }
}

/* Additional Modern CSS Features */
/* Container queries support (when available) */
@container (min-width: 400px) {
    .wpsc-youtube-play-button,
    .wpsc-vimeo-play-button {
        width: 90px;
        height: 63px;
    }
}

/* Focus-visible for better keyboard navigation */
.wpsc-youtube-placeholder:focus-visible,
.wpsc-vimeo-placeholder:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0, 115, 170, 0.2);
}

/* Improved touch targets for mobile */
@media (pointer: coarse) {
    .wpsc-youtube-play-button,
    .wpsc-vimeo-play-button {
        min-width: 44px;
        min-height: 44px;
    }
    
    .wpsc-retry-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* High DPI display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .wpsc-youtube-play-button::before,
    .wpsc-vimeo-play-button::before {
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    }
}

/* Animation performance optimizations */
.wpsc-youtube-placeholder,
.wpsc-vimeo-placeholder,
.wpsc-youtube-play-button,
.wpsc-vimeo-play-button {
    will-change: transform, box-shadow;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Improved loading states */
.wpsc-advanced-loading-indicator {
    contain: layout style paint;
}

/* Better error state styling */
.wpsc-error-indicator {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    border: 2px solid #f44336;
    color: #c62828;
    font-weight: 500;
}

/* Enhanced accessibility */
.wpsc-youtube-placeholder[aria-label],
.wpsc-vimeo-placeholder[aria-label] {
    position: relative;
}

.wpsc-youtube-placeholder[aria-label]::after,
.wpsc-vimeo-placeholder[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    bottom: -1.5rem;
    left: 0;
    right: 0;
    font-size: 0.75rem;
    color: #666;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wpsc-youtube-placeholder[aria-label]:hover::after,
.wpsc-vimeo-placeholder[aria-label]:hover::after {
    opacity: 1;
}

/* Print styles */
@media print {
    .wpsc-youtube-placeholder,
    .wpsc-vimeo-placeholder {
        display: none;
    }
    
    .wpsc-loading-indicator,
    .wpsc-error-indicator,
    .wpsc-advanced-loading-indicator {
        display: none;
    }
    
    iframe[data-src] {
        background: transparent;
        border: 1px solid #000;
    }
}
