/**
 * YouTube Videos Feature Styles
 * Beautiful, responsive design with smooth animations
 * Designed for optimal user experience and visual appeal
 */

/* ========================================
   Modal Container & Layout
   ======================================== */

.youtube-modal .modal-content {
    max-width: 1400px;
    width: 92%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ========================================
   Header Styling
   ======================================== */

.youtube-header {
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    color: white;
    padding: 1.75rem 2rem;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.2);
}

.youtube-header-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.youtube-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    animation: pulse-youtube 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-youtube {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
}

.youtube-title-section {
    flex: 1;
}

.youtube-title-section h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.youtube-subtitle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.youtube-badge {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 16px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.video-count {
    font-size: 0.9rem;
    opacity: 0.95;
    font-weight: 500;
}

.youtube-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 300;
}

.youtube-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

/* ========================================
   Category Filters
   ======================================== */

.youtube-controls {
    background: #f8f9fa;
    border-bottom: 2px solid #e5e7eb;
    padding: 0;
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    padding: 1.25rem 1.75rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.category-filters::-webkit-scrollbar {
    height: 6px;
}

.category-filters::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.category-filters::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.category-filter {
    padding: 0.65rem 1.35rem;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    background: white;
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.category-filter::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 0, 0, 0.1), transparent);
    transition: left 0.5s ease;
}

.category-filter:hover::before {
    left: 100%;
}

.category-filter:hover {
    border-color: #FF0000;
    color: #FF0000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.15);
}

.category-filter.active {
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    border-color: #CC0000;
    color: white;
    box-shadow: 0 4px 16px rgba(255, 0, 0, 0.3);
    transform: scale(1.02);
}

.category-filter.active:hover {
    transform: scale(1.02) translateY(-2px);
}

/* ========================================
   Loading States
   ======================================== */

.youtube-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.youtube-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid #f0f0f0;
    border-top: 5px solid #FF0000;
    border-radius: 50%;
    animation: spin-youtube 0.8s linear infinite;
    margin-bottom: 1.5rem;
}

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

.loading-text {
    font-size: 1.1rem;
    color: #64748b;
    font-weight: 500;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ========================================
   Content Area & Videos Grid
   ======================================== */

.youtube-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.youtube-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.youtube-content::-webkit-scrollbar {
    width: 10px;
}

.youtube-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.youtube-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

.youtube-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.75rem;
    padding: 2rem 1.75rem;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Video Cards
   ======================================== */

.video-card {
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: slideUp 0.4s ease-out backwards;
}

.video-card:nth-child(1) { animation-delay: 0.05s; }
.video-card:nth-child(2) { animation-delay: 0.1s; }
.video-card:nth-child(3) { animation-delay: 0.15s; }
.video-card:nth-child(4) { animation-delay: 0.2s; }
.video-card:nth-child(5) { animation-delay: 0.25s; }
.video-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.16);
    z-index: 10;
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.1);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 0, 0, 0) 0%, rgba(255, 0, 0, 0.4) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    opacity: 0;
}

.video-card:hover .video-overlay {
    opacity: 1;
}

.video-overlay svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.video-card:hover .video-overlay svg {
    transform: scale(1.2);
}

.video-info {
    padding: 1.25rem;
    background: white;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.65rem 0;
    line-height: 1.45;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.9rem;
}

.video-channel {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.video-channel::before {
    content: '▶';
    color: #FF0000;
    font-size: 0.7rem;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.video-date {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.video-date::before {
    content: '🕒';
    font-size: 0.85rem;
}

.subscriber-count {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: #64748b;
    font-weight: 600;
}

.subscriber-count::before {
    content: '👥';
    font-size: 0.85rem;
}

/* Quality Badge (appears on thumbnail) */
.quality-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    }
}

/* ========================================
   No Videos State
   ======================================== */

.no-videos {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    color: #64748b;
    animation: fadeIn 0.5s ease-out;
}

.no-videos svg {
    margin-bottom: 1.5rem;
    opacity: 0.5;
    stroke: #94a3b8;
}

.no-videos p {
    font-size: 1.15rem;
    font-weight: 500;
    margin: 0;
}

/* ========================================
   Footer
   ======================================== */

.youtube-footer {
    background: #f8f9fa;
    border-top: 2px solid #e5e7eb;
    padding: 1.25rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.youtube-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

#youtube-source {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#youtube-source::before {
    content: '🎬';
    font-size: 1rem;
}

.cache-badge {
    background: #10b981;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-refresh {
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.25);
}

.btn-refresh:hover {
    background: linear-gradient(135deg, #CC0000 0%, #AA0000 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 0, 0, 0.35);
}

.btn-refresh:active {
    transform: translateY(0);
}

.btn-refresh svg {
    transition: transform 0.6s ease;
}

.btn-refresh:hover svg {
    transform: rotate(180deg);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1200px) {
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .youtube-modal .modal-content {
        width: 96%;
        max-height: 94vh;
        border-radius: 12px;
    }

    .youtube-header {
        padding: 1.25rem 1.5rem;
        border-radius: 12px 12px 0 0;
    }

    .youtube-icon {
        width: 48px;
        height: 48px;
    }

    .youtube-title-section h2 {
        font-size: 1.4rem;
    }

    .category-filters {
        padding: 1rem 1.25rem;
        gap: 0.4rem;
    }

    .category-filter {
        padding: 0.55rem 1.1rem;
        font-size: 0.85rem;
    }

    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.25rem;
        padding: 1.5rem 1.25rem;
    }

    .youtube-footer {
        padding: 1rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .youtube-modal .modal-content {
        width: 98%;
        max-height: 96vh;
    }

    .youtube-header {
        padding: 1rem 1.25rem;
    }

    .youtube-title-section h2 {
        font-size: 1.2rem;
    }

    .youtube-subtitle {
        font-size: 0.8rem;
    }

    .videos-grid {
        grid-template-columns: 1fr;
        padding: 1.25rem 1rem;
        gap: 1.25rem;
    }

    .video-info {
        padding: 1rem;
    }

    .btn-refresh {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .youtube-content {
        background: #1e293b;
    }

    .video-card {
        background: #334155;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }

    .video-title {
        color: #f1f5f9;
    }

    .video-channel {
        color: #cbd5e1;
    }

    .video-meta {
        color: #94a3b8;
    }

    .youtube-footer {
        background: #1e293b;
        border-top-color: #334155;
    }

    #youtube-source {
        color: #cbd5e1;
    }
}

/* ========================================
   Accessibility Enhancements
   ======================================== */

.video-card:focus-visible {
    outline: 3px solid #FF0000;
    outline-offset: 4px;
}

.category-filter:focus-visible {
    outline: 3px solid #FF0000;
    outline-offset: 2px;
}

.btn-refresh:focus-visible {
    outline: 3px solid #FF0000;
    outline-offset: 3px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Video Player Modal (Embedded YouTube)
   ======================================== */

.video-player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.video-player-overlay.show {
    display: flex;
}

.video-player-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.video-player-header {
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-player-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    padding-right: 1rem;
    line-height: 1.4;
}

.video-player-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.75rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.video-player-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

.video-player-iframe-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

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

.video-player-info {
    background: #1a1a1a;
    color: white;
    padding: 1.25rem 1.5rem;
}

.video-channel-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.video-channel-icon {
    width: 12px;
    height: 12px;
    color: #FF0000;
}

.video-channel-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e0e0e0;
}

.video-description {
    font-size: 0.9rem;
    color: #b0b0b0;
    line-height: 1.6;
    max-height: 4.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.video-player-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.video-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.video-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Mobile responsive video player */
@media (max-width: 768px) {
    .video-player-container {
        width: 95%;
        max-width: none;
    }

    .video-player-header {
        padding: 0.75rem 1rem;
    }

    .video-player-title {
        font-size: 0.95rem;
    }

    .video-player-close {
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
    }

    .video-player-info {
        padding: 1rem;
    }

    .video-player-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .video-action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .video-player-container {
        width: 98%;
        border-radius: 8px;
    }

    .video-player-header {
        padding: 0.5rem 0.75rem;
    }

    .video-player-title {
        font-size: 0.85rem;
    }
}

/* Load More Button Styles */
.youtube-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    border: none;
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.25);
}

.btn-load-more:hover {
    background: linear-gradient(135deg, #CC0000 0%, #AA0000 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 0, 0, 0.35);
}

.btn-load-more:active {
    transform: translateY(0);
}

.btn-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-load-more .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin-youtube 0.6s linear infinite;
}
