/* General container for all reels */
.faceinstavideos-category-container {
    padding: 20px;
    background-color: #f0f2f5;
    border-radius: 8px;
    margin-bottom: 30px;
    position: relative;
    z-index: 1; /* Lower z-index to avoid conflicts with Divi menu */
}

.faceinstavideos-category-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

/* Subcategory Section */
.faceinstavideos-subcategory-section {
    margin-bottom: 40px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    position: relative;
}

.faceinstavideos-subcategory-section h3 {
    font-size: 1.5em;
    color: #555;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* Horizontal Scroll Wrapper */
.faceinstavideos-horizontal-scroll-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 1;
}

.faceinstavideos-reels-carousel {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-bottom: 15px;
    gap: 20px;
    flex-grow: 1;
    align-items: flex-start;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Improved scrollbar styling */
.faceinstavideos-reels-carousel::-webkit-scrollbar {
    height: 8px;
}

.faceinstavideos-reels-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.faceinstavideos-reels-carousel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
    transition: background 0.3s ease;
}

.faceinstavideos-reels-carousel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Scroll Buttons - Desktop Only by default */
.faceinstavideos-scroll-button {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.5em;
    z-index: 2;
    flex-shrink: 0;
    margin: 0 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    user-select: none;
    outline: none;
    position: relative;
}

.faceinstavideos-scroll-button:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

.faceinstavideos-scroll-button:focus {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.faceinstavideos-scroll-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.faceinstavideos-scroll-button.faceinstavideos-scroll-left {
    order: -1;
}

.faceinstavideos-scroll-button.faceinstavideos-scroll-right {
    order: 1;
}

/* Individual Reel Item (Preview) */
.faceinstavideos-reel-item {
    /* Desktop fixed width */
    flex: 0 0 280px;
    min-width: 280px;
    max-width: 280px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    min-height: 480px;
    box-sizing: border-box;
    position: relative;
    padding-bottom: 40px;
}

.faceinstavideos-reel-item:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.faceinstavideos-video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 177.77%; /* (16 / 9) * 100% - for 9:16 aspect ratio */
    height: 0;
    overflow: hidden;
    background-color: #000;
    border-radius: 8px 8px 0 0;
}

.faceinstavideos-video-wrapper iframe,
.faceinstavideos-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    max-width: 100% !important;
    max-height: 100% !important;
    display: block;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Thumbnail Container for Lazy Loading */
.faceinstavideos-thumbnail-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.3s ease;
}

/* When thumbnail image is loaded, add overlay for better play button visibility */
.faceinstavideos-thumbnail-container[style*="background-image"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
    pointer-events: none;
}

.faceinstavideos-play-button {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    color: #333;
    font-size: 24px;
    position: relative;
    z-index: 15; /* Above the overlay */
}

.faceinstavideos-play-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
}

.faceinstavideos-play-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.faceinstavideos-play-button svg {
    margin-left: 4px; /* Slight offset to center the play triangle */
}

.faceinstavideos-thumbnail-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    z-index: 5;
    font-weight: 500;
}

/* Specific Adjustments for Instagram/Facebook Embeds */
.faceinstavideos-video-wrapper > *:not(iframe):not(video) {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
}

.faceinstavideos-video-wrapper > *:not(iframe):not(video) iframe,
.faceinstavideos-video-wrapper > *:not(iframe):not(video) video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Specific Instagram media styling */
.faceinstavideos-video-wrapper .instagram-media {
    width: 100% !important;
    min-width: unset !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.faceinstavideos-video-wrapper .instagram-media iframe {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
}

/* Preview Info (always visible) */
.faceinstavideos-preview-info {
    padding: 15px;
    text-align: center;
    background-color: #fff;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 0 0 8px 8px;
}

.faceinstavideos-video-name-preview {
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* Transcript in preview */
.faceinstavideos-transcript-preview {
    font-size: 0.9em;
    color: #555;
    line-height: 1.4em;
    max-height: calc(1.4em * 6);
    overflow-y: auto;
    text-align: left;
    padding-right: 5px;
    flex-shrink: 0;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f1f1f1;
}

.faceinstavideos-transcript-preview::-webkit-scrollbar {
    width: 6px;
}

.faceinstavideos-transcript-preview::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.faceinstavideos-transcript-preview::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.faceinstavideos-transcript-preview::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.faceinstavideos-transcript-preview p {
    margin: 0 0 8px 0;
    padding: 0;
}

.faceinstavideos-transcript-preview p:last-child {
    margin-bottom: 0;
}

/* Post image preview styles */
.faceinstavideos-image-preview {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.faceinstavideos-image-preview .image-order {
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
}

.faceinstavideos-image-preview .image-text {
    flex: 1;
    font-size: 0.9em;
    line-height: 1.3;
    color: #333;
}

/* Copy Button Styles */
.faceinstavideos-copy-button {
    background-color: #007bff;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-top: auto;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    transition: all 0.3s ease;
    font-weight: 500;
    outline: none;
    user-select: none;
}

.faceinstavideos-copy-button:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.faceinstavideos-copy-button:focus {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.faceinstavideos-copy-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.faceinstavideos-copy-feedback {
    display: none;
    color: green;
    font-size: 12px;
    text-align: center;
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
    font-weight: 500;
    z-index: 10;
}

/* Loading states */
.faceinstavideos-reel-item.loading {
    opacity: 0.7;
}

.faceinstavideos-reel-item.loading .faceinstavideos-play-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}

/* Add to your existing CSS */
.faceinstavideos-scroll-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    background-color: rgba(0, 0, 0, 0.3);
}

.faceinstavideos-scroll-button:disabled:hover {
    transform: none;
    background-color: rgba(0, 0, 0, 0.3);
}

.faceinstavideos-reel-item.loading .faceinstavideos-play-button svg {
    opacity: 0;
}

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

/* Responsive adjustments */
@media (max-width: 1024px) {
    .faceinstavideos-reel-item {
        flex: 0 0 260px;
        min-width: 260px;
        max-width: 260px;
    }

    .faceinstavideos-reels-carousel {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    /* Hide scroll buttons on tablets and mobile */
    .faceinstavideos-scroll-button {
        display: none;
    }

    .faceinstavideos-horizontal-scroll-wrapper {
        margin: 0;
        padding: 0 10px;
        justify-content: flex-start;
    }

    .faceinstavideos-reels-carousel {
        gap: 15px;
        padding-left: 5px;
        padding-right: 5px;
    }

    .faceinstavideos-reel-item {
        flex: 0 0 85%;
        min-width: 85%;
        max-width: 85%;
        min-height: 400px;
        margin-left: 0;
        margin-right: 0;
    }

    .faceinstavideos-category-container {
        padding: 15px;
    }

    .faceinstavideos-subcategory-section {
        padding: 15px;
    }

    .faceinstavideos-play-button {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .faceinstavideos-reel-item {
        flex: 0 0 95%;
        min-width: 95%;
        max-width: 95%;
        min-height: 380px;
    }

    .faceinstavideos-horizontal-scroll-wrapper {
        padding: 0 5px;
    }

    .faceinstavideos-reels-carousel {
        gap: 10px;
    }

    .faceinstavideos-category-container {
        padding: 10px;
        margin-bottom: 20px;
    }

    .faceinstavideos-category-container h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }

    .faceinstavideos-subcategory-section h3 {
        font-size: 1.3em;
    }

    .faceinstavideos-play-button {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
}

/* Ensure compatibility with Divi and prevent conflicts */
.faceinstavideos-category-container * {
    box-sizing: border-box;
}

/* Override any theme styles that might interfere */
.faceinstavideos-reel-item h4,
.faceinstavideos-reel-item p,
.faceinstavideos-reel-item button {
    font-family: inherit;
    line-height: inherit;
}

/* Accessibility improvements */
.faceinstavideos-scroll-button:focus-visible,
.faceinstavideos-copy-button:focus-visible,
.faceinstavideos-play-button:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .faceinstavideos-scroll-button,
    .faceinstavideos-copy-button,
    .faceinstavideos-play-button {
        display: none;
    }

    .faceinstavideos-reels-carousel {
        display: block;
        overflow: visible;
    }

    .faceinstavideos-reel-item {
        break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .faceinstavideos-reel-item {
        border: 2px solid;
    }

    .faceinstavideos-scroll-button,
    .faceinstavideos-play-button {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .faceinstavideos-scroll-button,
    .faceinstavideos-copy-button,
    .faceinstavideos-play-button,
    .faceinstavideos-reel-item {
        transition: none;
    }

    .faceinstavideos-reels-carousel {
        scroll-behavior: auto;
    }
}
