/* Inherit the main slideshow styles from start-page.css */
#archiveSlideshow {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 4rem;
    gap: 1rem;
}

/* Use the same slide styles for consistency */
.slide {
    flex: 0 0 calc(100% - 8rem);
    aspect-ratio: 16/9;
    transition: all 0.5s ease;
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: 1rem;
    transform-origin: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.slide::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 30%, rgba(0, 0, 0, 0) 50%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}

.slide:not(.active) {
    transform: scale(0.9);
    opacity: 0.5;
}

/* Specific styling for archive navigation buttons */
#archivePrevSlide, #archiveNextSlide {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#archivePrevSlide {
    left: 1rem;
}

#archiveNextSlide {
    right: 1rem;
}

#archivePrevSlide:hover, #archiveNextSlide:hover {
    opacity: 1;
}

#archivePrevSlide:active, #archiveNextSlide:active,
#archivePrevSlide:focus, #archiveNextSlide:focus,
#archivePrevSlide:focus-visible, #archiveNextSlide:focus-visible {
    transform: translateY(-50%);
    outline: 0 !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    border: none !important;
}

/* Optimize the archive tab for performance */
#archivePanel {
    width: 100%;
    margin: 0;
    overflow: visible !important;
}

/* Series content styling for better performance */
.season-content {
    display: none;
}

.season-content.active {
    display: block;
}

.tab-button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
}

.tab-button.active {
    color: #ffffff;
    font-weight: 600;
}

.tab-button.active:after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #ef4444;
}

/* Performance optimizations for lists */
.grid.gap-3 {
    contain: content;
}

.episode-item {
    contain: layout;
}

/* Added from archive.js */

/* Styles for hiding slideshow during search */
#archivePanel.search-active .slideshow-wrapper {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

/* Styles for the custom archive video player */
#archivePlayerOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    position: relative; /* Context for absolute children */
    overflow: hidden; /* Prevent scrollbars */
}

.video-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(rgba(0,0,0,0.8), transparent);
    color: white;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show top bar on overlay hover */
#archivePlayerOverlay:hover .video-top-bar {
    opacity: 1;
}

.video-title-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align text to the left */
    gap: 0.25rem; /* Space between main title and subtitle */
}

.main-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.sub-title {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.75); /* Slightly darker color */
    line-height: 1.2;
}

.series-name {
    font-weight: bold;
}

.episode-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
    border-radius: 50%;
}

.close-btn:hover {
    color: #ef4444;
    background-color: rgba(255, 255, 255, 0.1);
}

.video-thumbnail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: opacity 0.5s ease;
    cursor: pointer; /* Allow clicking thumbnail to play */
}

.video-thumbnail-overlay .play-icon {
    width: 80px;
    height: 80px;
    background-color: rgba(239, 68, 68, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumbnail-overlay .play-icon i {
    color: white;
    font-size: 32px;
    margin-left: 8px; /* Slight offset for play icon */
}

.video-thumbnail-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#archiveVideo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background-color: black;
    object-fit: contain;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    z-index: 4;
}

.custom-player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show controls on overlay hover */
#archivePlayerOverlay:hover .custom-player-controls {
    opacity: 1;
}

.custom-player-controls button {
    background: transparent;
    border: none;
    color: white;
    padding: 0.5rem;
    margin: 0 0.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.custom-player-controls button:hover {
    color: #ef4444;
}

#archiveTimelineContainer {
    height: 8px;
    background-color: rgba(75, 85, 99, 0.3);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

#archiveTimeline {
    background-color: #ef4444;
    border-radius: inherit;
    height: 100%;
    transition: width 0.1s linear;
}

#archiveTimelineContainer:hover {
    height: 12px;
    transition: height 0.2s ease;
}

#archiveTimelineContainer:hover #archiveTimeline {
    height: 100%;
    transition: height 0.2s ease;
}

.quality-selector {
    position: absolute;
    bottom: 70px; /* Adjust based on control height */
    right: 10px;
    background-color: rgba(42, 42, 42, 0.9);
    border-radius: 8px;
    padding: 1rem;
    color: white;
    min-width: 200px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 20; /* Above controls */
}

.quality-selector.visible {
    opacity: 1;
    pointer-events: auto;
}

.quality-option {
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.quality-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.quality-option .quality-check {
    margin-right: 0.5rem;
    visibility: hidden;
    width: 1em; /* Reserve space */
}

.quality-option.selected .quality-check {
    visibility: visible;
}

.quality-header {
    font-weight: bold;
    margin-bottom: 0.5rem;
    padding: 0 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.info-popup {
    /* Repurpose or remove these styles for episode list */
}

.episode-list-popup {
    position: absolute;
    bottom: 70px; /* Adjust based on control height */
    right: 60px; /* Adjust position */
    background-color: rgba(28, 28, 28, 0.95);
    border-radius: 8px;
    color: white;
    width: 350px; /* Adjust width */
    max-height: 400px; /* Limit height */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 20; /* Above controls */
    display: flex;
    flex-direction: column;
    transform: translateY(10px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.episode-list-popup.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.episode-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.episode-list-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.close-popup-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
}

.close-popup-btn:hover {
    color: white;
}

.episode-list-container {
    overflow-y: auto;
    padding: 0.5rem;
    flex-grow: 1;
}

.episode-list-container::-webkit-scrollbar {
    width: 6px;
}

.episode-list-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.season-group {
    margin-bottom: 0.5rem;
}

.season-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.6rem 0.5rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.season-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.season-toggle-icon {
    color: rgba(255, 255, 255, 0.4);
}

.season-episodes-content {
    max-height: 500px; /* Or some large enough value */
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding: 0.25rem 0;
}

.season-group.collapsed .season-episodes-content {
    max-height: 0;
    padding: 0;
}

.episode-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 0.75rem;
}

.episode-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.episode-item.active {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-weight: 500;
}

.episode-item.unaired {
     opacity: 0.6;
     cursor: not-allowed;
 }

.episode-item-number {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    width: 2.5em; /* Fixed width for alignment */
    text-align: right;
    flex-shrink: 0;
}

.episode-item.active .episode-item-number {
     color: #ef4444;
}

.episode-item-title {
    font-size: 0.9rem;
    line-height: 1.3;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-loading {
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

/* Fullscreen styles */
#archivePlayerOverlay:-webkit-full-screen,
#archivePlayerOverlay:-ms-fullscreen,
#archivePlayerOverlay:fullscreen {
    width: 100vw;
    height: 100vh;
}
/* No specific adjustments needed for children in fullscreen
   as absolute positioning handles it relative to the now-fullscreen overlay */

/* Resume playback overlay styles */
.resume-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.resume-dialog {
    background: rgba(45, 45, 45, 0.9);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
}
.resume-dialog h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.resume-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
