/**
 * BuilderSolve Video Showcase Styles - Fixed Version
 * @version 4.0.0 - Complete rewrite with modern CSS and proper responsive design
 */

/* CSS Custom Properties */
:root {
    --primary-blue: #3b82f6;
    --primary-purple: #8b5cf6;
    --primary-gradient: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-white: #ffffff;
    --bg-overlay: rgba(255, 255, 255, 0.95);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
    --backdrop-blur: blur(12px);
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-white);
}

/* Main Wrapper */
.video-showcase-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5rem 0;
    overflow: hidden;
    isolation: isolate;
}

/* Background Elements */
.video-background {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.video-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.05) 0%,
        rgba(147, 51, 234, 0.05) 25%,
        rgba(236, 72, 153, 0.03) 50%,
        rgba(34, 197, 94, 0.05) 75%,
        rgba(59, 130, 246, 0.05) 100%
    );
}

.video-pattern {
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(147, 51, 234, 0.1) 0%, transparent 50%);
    background-size: 60rem 60rem;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg); 
    }
    50% { 
        transform: translateY(-20px) rotate(180deg); 
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
    position: relative;
    z-index: 1;
}

.video-showcase-content {
    text-align: center;
    position: relative;
}

/* Header */
.video-header {
    margin-bottom: 4rem;
    opacity: 0;
    transform: translateY(2rem);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-header.in-view,
.video-showcase-wrapper.in-view .video-header {
    opacity: 1;
    transform: translateY(0);
}

.video-title {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    margin: 0 0 1.5rem 0;
    letter-spacing: -0.025em;
}

.video-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Player Container */
.video-player-container {
    position: relative;
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(2rem);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-player-container.in-view,
.video-showcase-wrapper.in-view .video-player-container {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s;
}

/* Tabs Container */
.video-tabs-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    z-index: 10;
}

.video-tabs {
    display: inline-flex;
    background: var(--bg-overlay);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-radius: var(--radius-full);
    padding: 0.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    gap: 0.25rem;
    position: relative;
    overflow: hidden;
}

.video-tabs::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.3),
        rgba(255, 255, 255, 0.1)
    );
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* Tab Buttons */
.video-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    z-index: 2;
    font-family: inherit;
    outline: none;
    text-decoration: none;
}

.video-tab:hover {
    color: var(--text-primary);
    transform: translateY(-1px);
}

.video-tab:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.video-tab.active {
    color: white;
    background: var(--primary-gradient);
    box-shadow: 
        0 4px 15px rgba(59, 130, 246, 0.4),
        var(--shadow-sm);
    transform: translateY(-2px);
}

.tab-icon {
    font-size: 1.1em;
    opacity: 0.8;
}

.video-tab.active .tab-icon {
    opacity: 1;
}

/* Player Wrapper */
.video-player-wrapper {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.video-player {
    background: var(--bg-overlay);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    position: relative;
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.video-player:hover {
    transform: translateY(-2px);
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.2);
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    overflow: hidden;
}

.youtube-player-div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: inherit;
    z-index: 1;
}

.youtube-player-div iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: inherit;
}

/* Loading Overlay */
.video-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
    transition: opacity var(--transition-normal);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.video-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.video-loading-spinner {
    margin-bottom: 1rem;
}

.spinner-ring {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { 
        transform: rotate(360deg); 
    }
}

.loading-text {
    margin: 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* Error Overlay */
.video-error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 15;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    animation: fadeIn var(--transition-normal);
}

.video-error-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.video-error-content {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
    }
    40%, 43% {
        transform: translateY(-8px);
    }
    70% {
        transform: translateY(-4px);
    }
    90% {
        transform: translateY(-2px);
    }
}

.error-title {
    font-size: 1.5rem;
    margin: 0 0 1rem 0;
    color: #ef4444;
    font-weight: 600;
}

.error-message {
    color: #d1d5db;
    margin: 0 0 2rem 0;
    line-height: 1.5;
}

.retry-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.retry-button:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.retry-button:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.retry-button:active {
    transform: translateY(0);
}

.retry-icon {
    animation: rotate 1s linear infinite paused;
}

.retry-button:hover .retry-icon {
    animation-play-state: running;
}

@keyframes rotate {
    to {
        transform: rotate(360deg);
    }
}

/* Video Info */
.video-info {
    padding: 2rem;
    text-align: left;
    background: inherit;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.video-current-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

.video-current-description {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1rem;
    margin: 0;
}

/* Controls Info */
.video-controls-info {
    opacity: 0;
    transform: translateY(2rem);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-controls-info.in-view,
.video-showcase-wrapper.in-view .video-controls-info {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.4s;
}

.controls-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .video-showcase-wrapper {
        padding: 3rem 0;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .video-header {
        margin-bottom: 2.5rem;
    }
    
    .video-tabs {
        flex-wrap: wrap;
        justify-content: center;
        border-radius: var(--radius-md);
        max-width: 90vw;
        padding: 0.375rem;
    }
    
    .video-tab {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 80px;
    }
    
    .tab-text {
        font-size: 0.8rem;
    }
    
    .video-player {
        border-radius: var(--radius-md);
        margin: 0 0.5rem;
    }
    
    .video-container,
    .video-loading-overlay,
    .video-error-overlay {
        border-radius: 12px 12px 0 0;
    }
    
    .video-info {
        padding: 1.5rem;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }
    
    .video-current-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .video-showcase-wrapper {
        padding: 2rem 0;
    }
    
    .video-header {
        margin-bottom: 2rem;
    }
    
    .video-tabs {
        border-radius: var(--radius-sm);
        padding: 0.25rem;
        gap: 0.125rem;
    }
    
    .video-tab {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }
    
    .video-player {
        margin: 0 0.25rem;
    }
    
    .video-error-content {
        padding: 1.5rem;
    }
    
    .error-icon {
        font-size: 2.5rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .video-tabs {
        border: 2px solid var(--text-primary);
        background: var(--bg-white);
    }
    
    .video-tab:focus-visible {
        border: 2px solid var(--text-primary);
    }
    
    .video-tab.active {
        background: var(--text-primary);
        color: var(--bg-white);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .video-pattern,
    .spinner-ring,
    .error-icon,
    .retry-icon {
        animation: none;
    }
    
    .video-header,
    .video-player-container,
    .video-controls-info {
        transition: none;
        opacity: 1;
        transform: none;
    }
    
    .spinner-ring {
        border: 4px solid var(--primary-blue);
    }
}

/* Print Styles */
@media print {
    .video-showcase-wrapper {
        break-inside: avoid;
    }
    
    .video-player {
        border: 2px solid var(--text-primary);
    }
    
    .video-container::after {
        content: 'Video content not available in print';
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-white);
        color: var(--text-primary);
        font-weight: bold;
    }
}