/**
 * YouTube Video Downloader - Custom CSS Styling
 * Enhanced animations, transitions, and YouTube-specific styling
 * Maintains light theme consistency with modern design patterns
 */

/* Enhanced Animation Keyframes */
@keyframes pulse-red {
    0%,
    100% {
        transform: scale(1);
        background-color: rgb(239 68 68);
    }
    50% {
        transform: scale(1.05);
        background-color: rgb(220 38 38);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes progress-bar {
    0% {
        width: 0%;
    }
    50% {
        width: 60%;
    }
    100% {
        width: 100%;
    }
}

/* YouTube Brand Colors and Gradients */
.youtube-gradient {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
}

.youtube-gradient-hover {
    background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
}

/* Enhanced Input Styling */
#youtube-url {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23E5E7EB' stroke-width='2' stroke-dasharray='0' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
    border: none;
}

#youtube-url:focus {
    background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23EF4444' stroke-width='2' stroke-dasharray='0' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    transform: translateY(-1px);
}

#youtube-url.border-red-300 {
    background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='12' ry='12' stroke='%23FCA5A5' stroke-width='2' stroke-dasharray='6,4' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-2px);
    }
    20%,
    40%,
    60%,
    80% {
        transform: translateX(2px);
    }
}

/* Enhanced Button Styling */
#downloadBtn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#downloadBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px) scale(1.02);
}

#downloadBtn:active:not(:disabled) {
    transform: translateY(-1px) scale(1.01);
}

#downloadBtn:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    cursor: not-allowed;
}

/* Button Loading State */
#downloadBtn.loading {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    position: relative;
}

#downloadBtn.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

/* Quality Options Enhanced Styling */
.quality-option {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.quality-option::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.1), transparent);
    transition: left 0.5s ease;
}

.quality-option:hover::before {
    left: 100%;
}

.quality-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.quality-option.selected {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #ef4444;
    transform: scale(1.02);
}

/* Video Preview Animation */
#videoPreview {
    animation: slide-up 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#videoPreview .bg-white {
    animation: fade-in 0.8s ease-out 0.2s both;
}

/* Thumbnail Enhancement */
#videoThumbnail {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

#videoThumbnail:hover {
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

/* Enhanced Loading Spinner */
#loadingSpinner {
    animation: bounce-in 0.6s ease-out;
}

#loadingSpinner .animate-pulse {
    animation: pulse-red 2s infinite;
}

#loadingSpinner .bg-gradient-to-r {
    animation: progress-bar 3s ease-in-out infinite;
}

/* Error Message Styling */
#errorMessage {
    animation: slide-up 0.5s ease-out;
}

#errorMessage .bg-red-100 {
    animation: pulse 2s infinite;
}

/* Toast Enhancements */
#toast {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

#toast.show {
    animation: bounce-in 0.5s ease-out;
}

/* Format Selection Enhancement */
input[type="radio"]:checked + div {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #ef4444;
    color: #dc2626;
    transform: scale(1.02);
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.2);
}

/* Feature Badges Animation */
.feature-badge {
    transition: all 0.3s ease;
}

.feature-badge:hover {
    transform: translateY(-2px) scale(1.05);
}

/* Video Stats Grid Enhancement */
.video-stats .bg-gray-50 {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.video-stats .bg-gray-50::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.05), transparent);
    transition: left 0.8s ease;
}

.video-stats .bg-gray-50:hover::before {
    left: 100%;
}

.video-stats .bg-gray-50:hover {
    background-color: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Progress Indicator */
.download-progress {
    position: relative;
    height: 4px;
    background-color: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.download-progress::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 2px;
    animation: progress-bar 2s ease-in-out infinite;
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .quality-option {
        padding: 1rem;
    }

    #videoThumbnail {
        width: 120px;
        height: 90px;
    }

    .video-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    #toast {
        right: 1rem;
        bottom: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

@media (max-width: 640px) {
    .quality-option {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    #videoPreview .flex {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    #videoThumbnail {
        width: 200px;
        height: 150px;
        margin-bottom: 1rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

/* High Performance Animations */
* {
    will-change: auto;
}

.quality-option:hover,
#downloadBtn:hover,
#videoThumbnail:hover {
    will-change: transform, box-shadow;
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Indicators */
.quality-option:focus,
#downloadBtn:focus,
input[type="radio"]:focus + div {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* Video Preview Enhancements */
.video-info-section {
    position: relative;
}

.video-info-section::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 2px;
}

/* Enhanced Shadow System */
.shadow-youtube {
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.1), 0 2px 4px -1px rgba(239, 68, 68, 0.06);
}

.shadow-youtube-lg {
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.1), 0 4px 6px -2px rgba(239, 68, 68, 0.05);
}

.shadow-youtube-xl {
    box-shadow: 0 20px 25px -5px rgba(239, 68, 68, 0.1), 0 10px 10px -5px rgba(239, 68, 68, 0.04);
}
