/* GrpLife Video Feed - Frontend Styles */

.grplife-video-gallery {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Remove margin for single video galleries in Elementor */
.elementor-widget-shortcode .grplife-video-gallery {
    margin: 0 !important;
    padding: 0 !important;
}

.grplife-videos-container {
    display: grid;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* No gap for single video */
.grplife-videos-container:has(.grplife-video-item:only-child) {
    gap: 0;
}

/* Grid Layout */
.grplife-layout-grid .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Single video in grid - expand to full width */
.grplife-layout-grid .grplife-videos-container:has(.grplife-video-item:only-child) {
    grid-template-columns: 1fr !important;
    display: grid !important;
}

/* Alternative selector for browsers without :has() support */
.grplife-layout-grid .grplife-videos-container .grplife-video-item:only-child {
    grid-column: 1 / -1;
    max-width: none !important;
    width: 100% !important;
}

/* Force single video to be full width regardless of container settings */
.grplife-video-gallery:has(.grplife-video-item:only-child) .grplife-videos-container {
    grid-template-columns: 1fr !important;
}

.grplife-video-gallery .grplife-video-item:only-child {
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
}

/* List Layout */
.grplife-layout-list .grplife-videos-container {
    grid-template-columns: 1fr;
    gap: 15px;
}

.grplife-layout-list .grplife-video-item {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 15px;
    align-items: start;
}

.grplife-layout-list .grplife-video-thumbnail {
    width: 320px;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .grplife-layout-list .grplife-video-item {
        grid-template-columns: 1fr;
    }

    .grplife-layout-list .grplife-video-thumbnail {
        width: 100%;
    }
}

/* Carousel Layout */
.grplife-layout-carousel {
    position: relative;
}

.grplife-carousel-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.grplife-carousel-wrapper {
    overflow: hidden;
    flex: 1;
}

.grplife-layout-carousel .grplife-videos-container {
    display: flex;
    transition: transform 0.3s ease;
    gap: 20px;
}

.grplife-layout-carousel .grplife-video-item {
    min-width: 280px;
    flex-shrink: 0;
}

.grplife-carousel-prev,
.grplife-carousel-next {
    background: #333;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.grplife-carousel-prev:hover,
.grplife-carousel-next:hover {
    background: #555;
}

.grplife-carousel-prev:disabled,
.grplife-carousel-next:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Video Item */
.grplife-video-item {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.grplife-video-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Full width video item in single-video galleries */
.grplife-video-item:only-child {
    max-width: none !important;
    width: 100% !important;
    min-width: 100% !important;
}

.grplife-video-item:only-child .grplife-video-thumbnail {
    width: 100% !important;
}

.grplife-video-item:only-child .grplife-video-thumbnail img {
    width: 100% !important;
    height: 100% !important;
}

/* Video Thumbnail */
.grplife-video-thumbnail {
    position: relative;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
}

.grplife-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

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

.grplife-video-thumbnail a {
    display: block;
    position: relative;
    text-decoration: none;
    width: 100%;
    height: 100%;
}

/* Play Overlay */
.grplife-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: grplife-pulse 2.5s ease-in-out infinite;
}

.grplife-video-thumbnail:hover .grplife-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
    animation: none;
}

.grplife-play-icon {
    width: 36px;
    height: 36px;
    color: transparent;
    stroke: #333;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Pulsing animation for play button */
@keyframes grplife-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.75;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.95;
        box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.75;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
}

/* Duration Badge */
.grplife-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

/* Video Meta */
.grplife-video-meta {
    padding: 15px;
}

.grplife-video-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.grplife-video-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.grplife-video-title a:hover {
    color: #1976d2;
}

.grplife-video-date {
    color: #666;
    font-size: 13px;
    margin-bottom: 8px;
}

.grplife-video-description {
    color: #555;
    font-size: 14px;
    line-height: 1.4;
    margin-top: 8px;
}

/* Size Variations */
.grplife-size-small .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.grplife-size-small .grplife-video-title {
    font-size: 14px;
}

.grplife-size-small .grplife-video-meta {
    padding: 12px;
}

.grplife-size-high .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.grplife-size-high .grplife-video-title {
    font-size: 18px;
}

/* Error and No Videos Messages */
.grplife-error,
.grplife-no-videos {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.grplife-error {
    background: #fff5f5;
    border-color: #fed7d7;
    color: #c53030;
}

/* Responsive Design */
@media (max-width: 768px) {
    .grplife-layout-grid .grplife-videos-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .grplife-layout-list .grplife-video-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .grplife-layout-list .grplife-video-thumbnail {
        width: 100%;
    }

    .grplife-layout-carousel .grplife-video-item {
        min-width: 250px;
    }

    .grplife-video-meta {
        padding: 12px;
    }

    .grplife-video-title {
        font-size: 15px;
    }

    .grplife-play-overlay {
        width: 70px;
        height: 70px;
    }

    .grplife-play-icon {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .grplife-layout-grid .grplife-videos-container {
        grid-template-columns: 1fr;
    }

    .grplife-layout-carousel .grplife-video-item {
        min-width: 200px;
    }

    .grplife-carousel-prev,
    .grplife-carousel-next {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .grplife-play-overlay {
        width: 60px;
        height: 60px;
    }

    .grplife-play-icon {
        width: 24px;
        height: 24px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .grplife-video-item {
        background: #2d3748;
        color: #e2e8f0;
    }

    .grplife-video-title a {
        color: #e2e8f0;
    }

    .grplife-video-title a:hover {
        color: #90cdf4;
    }

    .grplife-video-date {
        color: #a0aec0;
    }

    .grplife-video-description {
        color: #cbd5e0;
    }

    .grplife-play-overlay {
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

    .grplife-error,
    .grplife-no-videos {
        background: #2d3748;
        border-color: #4a5568;
        color: #a0aec0;
    }

    .grplife-error {
        background: #742a2a;
        border-color: #c53030;
        color: #fed7d7;
    }
}

/* Accessibility */
.grplife-video-thumbnail:focus,
.grplife-video-title a:focus {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

.grplife-carousel-prev:focus,
.grplife-carousel-next:focus {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

/* Loading State */
.grplife-video-gallery.loading {
    opacity: 0.6;
    pointer-events: none;
}

.grplife-video-gallery.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1976d2;
    border-radius: 50%;
    animation: grplife-spin 1s linear infinite;
}

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

/* Poster image is now used as video thumbnail, no separate styles needed */

/* Thumbnails Only Mode */
.grplife-thumbnails-only .grplife-video-item {
    background: transparent;
    box-shadow: none;
}

.grplife-thumbnails-only .grplife-video-item:hover {
    transform: none;
    box-shadow: none;
}

.grplife-thumbnails-only .grplife-video-thumbnail {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grplife-thumbnails-only .grplife-video-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Adjust grid for thumbnails-only mode */
.grplife-thumbnails-only.grplife-layout-grid .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
}

.grplife-thumbnails-only.grplife-size-small .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.grplife-thumbnails-only.grplife-size-high .grplife-videos-container {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* List layout with thumbnails-only */
.grplife-thumbnails-only.grplife-layout-list .grplife-video-item {
    display: block;
}

.grplife-thumbnails-only.grplife-layout-list .grplife-video-thumbnail {
    width: 100%;
}

/* Carousel layout with thumbnails-only */
.grplife-thumbnails-only.grplife-layout-carousel .grplife-video-item {
    min-width: 240px;
}

/* Responsive adjustments for thumbnails-only mode */
@media (max-width: 768px) {
    .grplife-thumbnails-only.grplife-layout-grid .grplife-videos-container {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }

    .grplife-thumbnails-only.grplife-layout-carousel .grplife-video-item {
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .grplife-thumbnails-only.grplife-layout-grid .grplife-videos-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .grplife-thumbnails-only.grplife-layout-carousel .grplife-video-item {
        min-width: 150px;
    }

    .grplife-gallery-poster {
        margin-bottom: 20px;
    }
}

/* Dark mode support for thumbnails-only mode */
@media (prefers-color-scheme: dark) {
    .grplife-thumbnails-only .grplife-video-thumbnail {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    }

    .grplife-thumbnails-only .grplife-video-thumbnail:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    }
}

/* Full-width utility class for single video display */
.grplife-full-width {
    width: 100%;
    max-width: 100%;
}

.grplife-full-width .grplife-videos-container {
    grid-template-columns: 1fr;
    width: 100%;
}

.grplife-full-width .grplife-video-item {
    width: 100%;
    max-width: 100%;
}

.grplife-full-width .grplife-video-thumbnail {
    max-height: 600px;
    width: 100%;
}

.grplife-full-width .grplife-video-thumbnail img {
    object-position: center;
    width: 100%;
}

/* Elementor compatibility - ensure full width in Elementor containers */
.elementor-widget-shortcode .grplife-video-gallery {
    width: 100% !important;
    max-width: 100% !important;
}

.elementor-widget-shortcode .grplife-videos-container {
    width: 100% !important;
}

.elementor-widget-shortcode .grplife-video-item {
    width: 100% !important;
}

/* Force single video to full width in Elementor */
.elementor-widget-shortcode .grplife-video-item:only-child {
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
}

.elementor-widget-shortcode .grplife-videos-container:has(.grplife-video-item:only-child) {
    grid-template-columns: 1fr !important;
}

.elementor-widget-shortcode .grplife-video-item:only-child .grplife-video-thumbnail {
    width: 100% !important;
}

.elementor-widget-shortcode .grplife-video-item:only-child .grplife-video-thumbnail img {
    width: 100% !important;
}