/* ========================================
   VideoSubs Plugin Styles
   ======================================== */

/* Block Container */
.videosubs-block {
    display: block;
}

/* Video Iframe */
iframe[src*="youtube"],
iframe[src*="youtu.be"] {
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
}

/* Video Containers */
.media-wrap.videosubs-processed,
.media-wrap-video.videosubs-processed,
.videosubs-processed {
    overflow: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
}

.media-wrap.videosubs-processed iframe,
.media-wrap-video.videosubs-processed iframe,
.videosubs-processed iframe {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    position: absolute;
    inset: 0;
}

.media-wrap,
.media-wrap-video {
    position: relative;
    width: 100%;
}

/* Sync Wrapper */
.videosubs-sync-wrapper {
    position: relative;
    margin-top: 0;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

.videosubs-sync-wrapper:hover {
    opacity: 0.95;
}

/* Subtitle Display */
.videosubs-subtitles-below {
    width: 100%;
    height: 50px; /* Fixed height for 2 lines of text */
    /*padding: 10px 50px;  Extra padding for buttons on sides */
    margin: 10px 0;
    background: transparent;
    border: 1px dashed #ddd;
    font-size: 1em;
    line-height: 1.3;
    text-align: center;
    color: #333;
    position: relative;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    gap: 5px;
}

/* Light Mode Hover Effects */
.videosubs-sync-wrapper:hover .videosubs-subtitles-below {
    border-color: #999;
}

/* Play/Pause Button */
.videosubs-play-pause {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #111;
    opacity: 0.7;
    transition: opacity 0.3s ease, color 0.3s ease;
    z-index: 2;
}

.videosubs-play-pause:hover {
    opacity: 1;
}

.videosubs-play-pause .ph {
    font-size: 20px;
    line-height: 1;
}

/* Subtitles Content */
.videosubs-subtitles-content {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    box-sizing: border-box;
    text-overflow: ellipsis;
    word-break: break-word;
    hyphens: auto;
    text-align: center;
    white-space: normal;
    position: relative;
    z-index: 1;
    min-width: 0; /* Allow flex item to shrink */
    padding-right: 20px; /* Compensate for missing toggle button on desktop */
}

/* Toggle Widget Button (Mobile) */
.videosubs-toggle-widget {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #111;
    opacity: 0.7;
    transition: opacity 0.3s ease, color 0.3s ease;
    z-index: 2;
}

.videosubs-toggle-widget:hover {
    opacity: 1;
}

.videosubs-toggle-widget .ph {
    font-size: 20px;
    line-height: 1;
}

/* Light Mode - Play/Pause button states */
.videosubs-sync-wrapper.videosubs-stopped .videosubs-play-pause {
    color: #000;
    opacity: 0.8;
}

/* Legacy support for direct children (backward compatibility) */
.videosubs-subtitles-below > .videosubs-cue-active {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
    margin: 0;
    text-align: center;
    line-height: 1.4;
    white-space: normal;
    position: relative;
    z-index: 1;
}

.videosubs-subtitles-below.active {
    background: #fff;
    border-color: #ccc;
    height: 50px; /* Maintain fixed height when active */
    overflow: hidden; /* Ensure content respects height */
}

.videosubs-subtitles-below .videosubs-cue-active {
    font-weight: 500;
    color: #000;
}


/* Dark Mode - Subtitle Display */
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-subtitles-below {
    background: transparent;
    border-color: #333;
    color: #fff;
}

/* Dark Mode - Buttons */
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-play-pause,
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-toggle-widget {
    color: #ccc;
    opacity: 0.7;
}

/* Dark Mode - Stopped state */
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-sync-wrapper.videosubs-stopped .videosubs-play-pause {
    color: #fff;
    opacity: 0.9;
}

/* Dark Mode Hover Effects */
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-sync-wrapper:hover .videosubs-subtitles-below {
    border-color: #666;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-play-pause:hover,
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-toggle-widget:hover {
    color: #fff;
    opacity: 1;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-subtitles-below .videosubs-cue-active {
    color: #fff;
}


/* Sidebar Widget */
.videosubs-sidebar-widget {
    margin: 30px 0;
    position: relative;
}

/* Mobile Widget - Positioned below subtitle div */
.videosubs-mobile-widget {
    display: none; /* Hidden on desktop by default */
    overflow: hidden;
}

.videosubs-mobile-widget .videosubs-widget-content {
    grid-template-rows: 0fr;
    margin-top: 0;
    transition: grid-template-rows 450ms cubic-bezier(0.16, 1, 0.3, 1), margin-top 450ms cubic-bezier(0.16, 1, 0.3, 1), opacity 450ms cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

.videosubs-mobile-widget.is-expanded {
    margin-top: 10px;
}

.videosubs-mobile-widget.is-expanded .videosubs-widget-content {
    grid-template-rows: 1fr;
    opacity: 1;
}

.videosubs-mobile-widget .videosubs-widget-content .videosubs-collapsible-inner {
    max-height: 300px;
}

.videosubs-sidebar-widget .widget-title {
    margin-bottom: 10px;
    padding-right: 20px;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color 0.2s ease;
}

.videosubs-sidebar-widget .widget-title:hover {
    color: #2196F3;
}

.videosubs-sidebar-widget .widget-title::after {
    content: "\e32a"; /* ph-minus */
    font-family: "Phosphor";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    color: #666;
    transition: opacity 0.3s ease;
    speak: never;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
}

.videosubs-sidebar-widget .widget-title.is-collapsed::after {
    content: "\e3d4"; /* ph-plus */
}

/* Collapsible Grid Transition Utility */
.videosubs-collapsible {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 450ms cubic-bezier(0.16, 1, 0.3, 1), opacity 450ms cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

.videosubs-collapsible.is-expanded {
    grid-template-rows: 1fr;
    opacity: 1;
}

.videosubs-collapsible-inner {
    min-height: 0;
    overflow: hidden;
}

/* Widget Content */
.videosubs-widget-content {
    position: relative;
}

/* Scrollable inner container */
.videosubs-widget-content .videosubs-collapsible-inner {
    max-height: 400px;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar {
    width: 8px;
}

.videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar-track {
    background: transparent;
}

.videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Widget Text Container */
.videosubs-widget-text-container {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    text-align: left;
    user-select: text;
    padding: 10px 0;
}

/* Widget Lines */
.videosubs-widget-line {
    padding: 8px;
    margin-bottom: 1px;
    border-left: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.videosubs-widget-line:hover {
    background: #f8f9fa;
}

.videosubs-widget-line.active {
    background: #e8f4fd;
    border-left-color: #2196F3;
}

.videosubs-widget-line.active .videosubs-widget-timestamp {
    color: #2196F3;
    font-weight: 600;
}

.videosubs-widget-line.active .videosubs-widget-text {
    color: #1976d2;
    font-weight: 500;
}

/* Widget Timestamp */
.videosubs-widget-timestamp {
    font-size: 9px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* Widget Text */
.videosubs-widget-text {
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

/* Dark Mode - Widget */
:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-sidebar-widget .widget-title:hover {
    color: #64b5f6;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-sidebar-widget .widget-title::after {
    color: #ccc;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-content .videosubs-collapsible-inner {
    scrollbar-color: #555 transparent;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar-thumb {
    background: #555;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-content .videosubs-collapsible-inner::-webkit-scrollbar-thumb:hover {
    background: #777;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-text-container {
    color: #fff;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-line:hover {
    background: #2a2a2a;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-line.active {
    background: #1a3448;
    border-left-color: #64b5f6;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-line.active .videosubs-widget-timestamp {
    color: #64b5f6;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-line.active .videosubs-widget-text {
    color: #90caf9;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-timestamp {
    color: #888;
}

:is(.skin-dark, .mode--alt--b, .article-layout-skin-2) .videosubs-widget-text {
    color: #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
    .videosubs-subtitles-below {
        /*padding: 10px 50px 10px 50px;  Space for buttons on both sides */
        font-size: small;
        height: 50px; /* Maintain fixed height */
    }
    
    .videosubs-play-pause {
        width: 40px;
        height: 40px;
    }
    
    .videosubs-toggle-widget {
        display: flex; /* Show toggle button on mobile */
    }
    
    /* Remove padding compensation on mobile since toggle button is visible */
    .videosubs-subtitles-content {
        padding-right: 0;
    }
    
    /* Hide desktop sidebar widget on mobile */
    .sidebar .videosubs-sidebar-widget {
        display: none;
    }
    
    /* Show mobile widget below subtitle div */
    .videosubs-mobile-widget {
        display: block;
    }
    
    /* Mobile widget styling */
    .content-area .zeen-widget {
        padding: 0 0px 30px;
        margin: 0px -5px;
    }
    
    /* Override padding for mobile widget specifically */
    .videosubs-mobile-widget {
        padding: 0 !important;
    }
    
    /* Sync Wrapper mobile adjustments */
    .videosubs-sync-wrapper {
        position: relative;
        margin: 0 -10px;
        cursor: pointer;
        pointer-events: auto;
        transition: opacity 0.2s ease;
    }
    
    .videosubs-widget-content .videosubs-collapsible-inner {
        max-height: 300px;
    }
    
    .videosubs-widget-text-container {
        font-size: 13px;
        line-height: 1.5;
    }
    
    .videosubs-widget-line {
        padding: 6px 10px;
        margin-bottom: 3px;
    }
    
    .videosubs-widget-timestamp {
        font-size: 8px;
        margin-bottom: 2px;
    }
    
    .videosubs-widget-text {
        font-size: 12px;
    }
    
    /* Make subtitle cue text smaller on mobile to match widget text scaling */
    .videosubs-subtitles-content .videosubs-cue-active,
    .videosubs-subtitles-below .videosubs-cue-active {
        font-size: .9em; /* Scales down from parent's small size */
    }
}