/**
 * YouTube Videos Widget Styles
 * Simple, clean CSS for grid and horizontal scroll layouts
 */

/* Container */
.yt-widget-container {
    position: relative;
    width: 100%;
}

/* Error Message */
.yt-widget-error {
    padding: 20px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Grid Layouts */
.yt-widget-grid {
    display: grid;
    gap: 20px;
    width: 100%;
}

/* Grid Column Variations */
.grid-2 .yt-widget-grid {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 .yt-widget-grid {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 .yt-widget-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* List Layout */
.list .yt-widget-grid {
    grid-template-columns: 1fr;
}

/* Horizontal Scroll Layouts */
.yt-widget-horizontal {
    display: flex;
    flex-direction: row;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
}

/* Horizontal Scroll - CSS Snap */
.horizontal-scroll .yt-widget-horizontal {
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
}

.horizontal-scroll .yt-video-card {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* Horizontal Scroll - Free */
.horizontal-free .yt-widget-horizontal {
    scroll-behavior: smooth;
}

.horizontal-free .yt-video-card {
    flex-shrink: 0;
}

/* Horizontal Scroll - Arrows */
.horizontal-scroll-arrows .yt-widget-horizontal {
    scroll-behavior: smooth;
}

.horizontal-scroll-arrows .yt-video-card {
    flex-shrink: 0;
}

/* Horizontal Card Width */
.yt-widget-horizontal .yt-video-card {
    width: 320px;
    min-width: 320px;
}

/* Custom Scrollbar for Horizontal Layouts */
.yt-widget-horizontal::-webkit-scrollbar {
    height: 8px;
}

.yt-widget-horizontal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.yt-widget-horizontal::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.yt-widget-horizontal::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Navigation Arrows */
.yt-scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #000;
    transition: all 0.3s ease;
    user-select: none;
}

.yt-scroll-arrow:hover {
    background-color: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.yt-scroll-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.yt-scroll-arrow.yt-scroll-left {
    left: 10px;
}

.yt-scroll-arrow.yt-scroll-right {
    right: 10px;
}

.yt-scroll-arrow.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Video Card */
.yt-video-card {
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.yt-video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Video Link */
.yt-video-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Thumbnail */
.yt-video-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background-color: #000;
    overflow: hidden;
}

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

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

/* Play Overlay */
.yt-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.9;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.yt-video-card:hover .yt-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Video Content */
.yt-video-content {
    padding: 16px;
}

/* Video Title */
.yt-video-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: #000;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Video Meta */
.yt-video-meta {
    display: flex;
    gap: 12px;
    font-size: 14px;
    color: #606060;
}

.yt-video-views,
.yt-video-date {
    display: inline-block;
}

.yt-video-views::after {
    content: " • ";
    margin-left: 12px;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .grid-4 .yt-widget-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-3 .yt-widget-grid,
    .grid-4 .yt-widget-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .yt-widget-horizontal .yt-video-card {
        width: 280px;
        min-width: 280px;
    }
    
    .yt-scroll-arrow {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .grid-2 .yt-widget-grid,
    .grid-3 .yt-widget-grid,
    .grid-4 .yt-widget-grid {
        grid-template-columns: 1fr;
    }
    
    .yt-widget-horizontal .yt-video-card {
        width: 240px;
        min-width: 240px;
    }
    
    .yt-video-title {
        font-size: 14px;
    }
    
    .yt-video-meta {
        font-size: 12px;
    }
}

/* Fade Indicators for Horizontal Scroll */
.horizontal-free .yt-widget-container::before,
.horizontal-free .yt-widget-container::after,
.horizontal-scroll .yt-widget-container::before,
.horizontal-scroll .yt-widget-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    pointer-events: none;
    z-index: 5;
}

.horizontal-free .yt-widget-container::before,
.horizontal-scroll .yt-widget-container::before {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

.horizontal-free .yt-widget-container::after,
.horizontal-scroll .yt-widget-container::after {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

/* Dark Mode Support (optional, matches user's theme) */
@media (prefers-color-scheme: dark) {
    .yt-video-card {
        background-color: #1e1e1e;
    }
    
    .yt-video-title {
        color: #fff;
    }
    
    .yt-video-meta {
        color: #aaa;
    }
    
    .yt-widget-horizontal::-webkit-scrollbar-track {
        background: #2a2a2a;
    }
    
    .yt-widget-horizontal::-webkit-scrollbar-thumb {
        background: #555;
    }
    
    .yt-widget-horizontal::-webkit-scrollbar-thumb:hover {
        background: #777;
    }
    
    .yt-scroll-arrow {
        background-color: rgba(30, 30, 30, 0.9);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .yt-scroll-arrow:hover {
        background-color: rgba(30, 30, 30, 1);
    }
    
    .horizontal-free .yt-widget-container::before,
    .horizontal-scroll .yt-widget-container::before {
        background: linear-gradient(to right, rgba(30, 30, 30, 1), rgba(30, 30, 30, 0));
    }
    
    .horizontal-free .yt-widget-container::after,
    .horizontal-scroll .yt-widget-container::after {
        background: linear-gradient(to left, rgba(30, 30, 30, 1), rgba(30, 30, 30, 0));
    }
}
