/**
 * Carousel styles for YT Playlist plugin using Swiper.js
 * Ensures the carousel is responsive and visually consistent.
 */

/* Main Swiper Container */
.yt-playlist-carousel.swiper {
    position: relative;
    overflow: hidden;
    margin: 2rem auto;
    padding: 0 1rem 2.5rem; /* Add padding for pagination */
    max-width: 100%;
}

/* Swiper Slides - Base styles for all carousel item views */
.yt-playlist-carousel .swiper-slide {
    width: 280px; /* Default slide width */
    max-width: 90%;
    height: auto; /* Let content define height */
    display: flex;
    justify-content: center;
}

/* View 1: Full Thumbnail with Metadata Below */
.yt-playlist-carousel .swiper-slide .yt-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.yt-playlist-carousel .swiper-slide .yt-card:hover {
    border-color: var(--yt-primary-color, #2271b1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.yt-playlist-carousel .swiper-slide .yt-thumbnail-wrapper {
    width: 100%;
    height: auto;
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.yt-playlist-carousel .swiper-slide .yt-thumbnail-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yt-playlist-carousel .swiper-slide .yt-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.yt-playlist-carousel .swiper-slide .yt-info h3 {
    font-size: 16px;
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.3;
    color: #333;
}

.yt-playlist-carousel .swiper-slide .yt-info .views,
.yt-playlist-carousel .swiper-slide .yt-info .date {
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

/* View 2: Grid Style (similar to default grid view) */
.yt-playlist-carousel .swiper-slide.yt-card-grid-view {
    width: 360px; /* Set max width for grid view items */
    max-width: 100%; /* Ensure it doesn't exceed container width */
}
.yt-playlist-carousel .yt-card.yt-card-grid-view {
    display: block;
    width: 100%;
    height: auto;
    background-color: #fff;
    border: 1px solid var(--yt-playlist-border-color);
    border-radius: var(--yt-playlist-radius);
    overflow: hidden;
    box-shadow: var(--yt-playlist-shadow);
    transition: var(--yt-playlist-transition);
    cursor: pointer;
    max-width: 360px;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view:hover {
    transform: translateY(-6px); /* From yt-playlist-grid .yt-video-item:hover */
    box-shadow: 0 6px 20px rgba(0,0,0,0.15); /* From yt-playlist-grid .yt-video-item:hover */
    border-color: var(--yt-primary-color, #2271b1); /* Keep primary color hover */
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-thumbnail-wrapper {
    position: relative; /* From yt-video-thumbnail in base.css */
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-thumbnail-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-info {
    padding: 1rem; /* From yt-video-info in base.css */
    flex-grow: 0; /* Do not grow */
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-info h3 {
    font-size: 1rem; /* From yt-video-title in base.css */
    font-weight: 600; /* From yt-video-title in base.css */
    margin: 0 0 0.5rem; /* From yt-video-title in base.css */
    line-height: 1.3; /* From yt-video-title in base.css */
    color: var(--yt-playlist-text-color); /* From yt-video-title in base.css */
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-info .views,
.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-info .date {
    font-size: 0.85rem; /* From yt-video-info .views/.date in base.css */
    color: #777; /* From yt-video-info .views/.date in base.css */
    margin-bottom: 0.25rem; /* From yt-video-info .views/.date in base.css */
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-info .date {
    font-style: italic; /* From yt-video-info .date in base.css */
}

/* Play button overlay for grid view */
.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-play-button {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view:hover .yt-play-button {
    opacity: 1;
}

.yt-playlist-carousel .yt-card.yt-card-grid-view .yt-play-button svg {
    width: 60px;
    height: 60px;
    fill: #fff;
}
.yt-playlist-carousel .swiper-button-prev,
.yt-playlist-carousel .swiper-button-next {
    color: var(--yt-primary-color, #2271b1); /* Use primary color from settings */
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    transition: background-color 0.3s, color 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.yt-playlist-carousel .swiper-button-prev:hover,
.yt-playlist-carousel .swiper-button-next:hover {
    background-color: var(--yt-primary-color, #2271b1);
    color: #fff;
}

.yt-playlist-carousel .swiper-button-prev::after,
.yt-playlist-carousel .swiper-button-next::after {
    font-size: 18px;
    font-weight: bold;
}

/* Pagination (Dots) */
.yt-playlist-carousel .swiper-pagination {
    bottom: 0;
}

.yt-playlist-carousel .swiper-pagination-bullet {
    background-color: #ccc;
    opacity: 1;
    transition: background-color 0.3s, transform 0.3s;
}

.yt-playlist-carousel .swiper-pagination-bullet-active {
    background-color: var(--yt-primary-color, #2271b1);
    transform: scale(1.2);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .yt-playlist-carousel .swiper-slide {
        width: 250px;
    }

    .yt-playlist-carousel .swiper-button-prev,
    .yt-playlist-carousel .swiper-button-next {
        width: 40px;
        height: 40px;
    }

    .yt-playlist-carousel .swiper-button-prev::after,
    .yt-playlist-carousel .swiper-button-next::after {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .yt-playlist-carousel {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .yt-playlist-carousel .swiper-slide {
        width: 220px;
    }

    /* Hide navigation arrows on very small screens to save space */
    .yt-playlist-carousel .swiper-button-prev,
    .yt-playlist-carousel .swiper-button-next {
        display: none;
    }
}