/* TMDB Lightbox Styles - tmdb_lightbox.css (Version 1.0.16 - Cast Scroll Fix) */

/* Overlay */
.tmdb-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 99990;
    display: none; 
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    font-family: Arial, Helvetica, sans-serif;
}

.tmdb-lightbox-overlay.tmdb-show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* Lightbox Modal */
.tmdb-lightbox-modal {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    z-index: 99991;
    width: 90%;
    max-width: 700px; 
    max-height: 85vh; /* Overall height constraint */
    display: flex;
    flex-direction: column; 
    position: relative; 
    overflow: hidden; /* Prevent modal from being stretched by oversized content */
    transform: scale(0.95);
    transition: transform 0.25s ease-in-out;
}

.tmdb-lightbox-overlay.tmdb-show .tmdb-lightbox-modal {
    transform: scale(1);
}

/* Close Button */
.tmdb-lightbox-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    font-weight: normal;
    color: #aaa;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    z-index: 10; 
}
.tmdb-lightbox-close:hover {
    color: #333;
}

/* Lightbox Header */
.tmdb-lightbox-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 15px;
    text-align: left; 
    flex-shrink: 0; /* Prevent header from shrinking */
}
.tmdb-lightbox-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: #333;
    font-weight: 600;
    font-family: Arial, Helvetica, sans-serif !important;
}

/* Tabs Navigation */
.tmdb-lightbox-tabs {
    display: flex;
    justify-content: flex-start; 
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap; 
    flex-shrink: 0; /* Prevent tabs from shrinking */
}
.tmdb-lightbox-tabs button {
    padding: 10px 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 0.95em;
    color: #555;
    border-bottom: 3px solid transparent;
    margin-right: 10px; 
    transition: color 0.2s, border-bottom-color 0.2s;
    font-family: Arial, Helvetica, sans-serif !important;
}
.tmdb-lightbox-tabs button.tmdb-active-tab {
    color: #007bff;
    border-bottom-color: #007bff;
    font-weight: 600;
}
.tmdb-lightbox-tabs button:hover {
    color: #0056b3;
}

/* Tab Content Wrapper (intermediate flex container if needed by JS structure) */
.tmdb-lightbox-content-wrapper {
    flex-grow: 1;
    display: flex; /* This allows its child (.tmdb-lightbox-content) to also use flex-grow */
    flex-direction: column;
    overflow: hidden; /* This is important if .tmdb-lightbox-content handles scrolling */
    min-height: 0; /* For flex children context */
}

/* Tab Content Area - Main parent for tab panes */
.tmdb-lightbox-content {
    flex-grow: 1; 
    overflow: hidden; /* This parent will hide overflow; active pane below will scroll */
    display: flex; /* To manage the single active pane */
    flex-direction: column; /* Active pane will be its child */
    min-height: 0; /* Essential for nested flex scrolling */
    /* border: 1px dashed green; /* DEBUG */
}

.tmdb-tab-pane {
    display: none !important; 
    animation: tmdbFadeIn 0.3s;
    /* border: 1px dotted blue; /* DEBUG */
    /* Padding will be applied to specific panes if needed or to content within */
}

.tmdb-tab-pane.tmdb-active-pane {
    display: block !important; /* Or 'flex' if its direct children need more complex flex layout */
    flex-grow: 1; /* Take available space from .tmdb-lightbox-content */
    overflow-y: auto !important; /* <<< THIS MAKES THE ACTIVE PANE SCROLLABLE */
    min-height: 0; /* Crucial for a flex item that needs to scroll its own content */
    padding: 10px 15px; /* Add some padding inside the scrollable pane */
}

@keyframes tmdbFadeIn {
    from { opacity: 0.6; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cast Tab */
.tmdb-cast-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.tmdb-cast-list li {
    display: flex;
    align-items: center;
    padding: 8px 0; 
    border-bottom: 1px solid #f0f0f0;
}
.tmdb-cast-list li:last-child {
    border-bottom: none;
}
.tmdb-cast-list img.tmdb-actor-photo {
    width: 45px; 
    height: 68px; 
    object-fit: cover;
    border-radius: 3px;
    margin-right: 12px;
    background-color: #e9ecef; 
}
.tmdb-actor-info strong {
    display: block;
    font-size: 0.9em; 
    color: #333;
    font-weight: 600;
}
.tmdb-actor-info span {
    font-size: 0.8em; 
    color: #666;
}

/* Series Info Tab - Inline styles from JS V1.0.13 will primarily define its look */
/* #tmdb-series-info-content.tmdb-tab-pane.tmdb-active-pane can have the padding from the generic rule above */


/* Loading Spinner */
.tmdb-lightbox-loader {
    display: none; 
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid #f0f0f0; 
    border-top: 4px solid #007bff; 
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: tmdbSpin 0.8s linear infinite;
    z-index: 15; 
}
.tmdb-lightbox-modal.tmdb-loading .tmdb-lightbox-loader { display: block; }
.tmdb-lightbox-modal.tmdb-loading .tmdb-lightbox-content-wrapper { opacity: 0.6; }
@keyframes tmdbSpin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* Responsive adjustments */
@media (max-width: 600px) {
    .tmdb-lightbox-modal { padding: 15px; width: 95%; max-height: 90vh; }
    .tmdb-lightbox-close { top: 8px; right: 10px; font-size: 26px; }
    .tmdb-lightbox-tabs button { padding: 8px 10px; font-size: 0.9em; }
    .tmdb-tab-pane.tmdb-active-pane { padding: 8px; } /* Adjust padding for mobile */
    .tmdb-actor-info strong { font-size: 0.85em; }
    .tmdb-actor-info span { font-size: 0.75em; }
    /* Series info text size is controlled by JS inline styles, but pane padding is adjusted */
    #tmdb-series-info-content.tmdb-tab-pane.tmdb-active-pane {
        font-size: 13px !important; 
    }
}
/* Added for TMDB Lightbox V1.0.17 - Enhanced Details */

.tmdb-details-grid {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping for smaller screens */
    gap: 20px; /* Space between poster and text content */
}

.tmdb-details-poster-container {
    flex: 0 0 200px; /* Poster width, don't grow, don't shrink */
    max-width: 200px; /* Ensure it doesn't get too wide on flex bugs */
}

.tmdb-details-poster {
    width: 100%;
    height: auto;
    border-radius: 4px;
    background-color: #f0f0f0; /* Placeholder background */
    object-fit: cover;
}

.tmdb-details-text-content {
    flex: 1 1 300px; /* Grow and shrink, with a base width */
    min-width: 250px; /* Prevent text from getting too squeezed */
}

.tmdb-detail-item {
    margin-bottom: 8px;
    font-size: 0.9em;
    line-height: 1.5;
}
.tmdb-detail-item strong {
    color: #333;
    margin-right: 5px;
}
.tmdb-detail-value {
    color: #555;
}

.tmdb-genre-badge {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-right: 5px;
    margin-bottom: 5px; /* For wrapping */
}

.tmdb-rating .tmdb-detail-value {
    font-weight: bold;
    color: #007bff; /* Or a gold/yellow color for ratings */
}
/* Example: Adding a star icon (requires font awesome or similar, or SVG)
.tmdb-rating .tmdb-detail-value::before {
    content: '\f005'; 
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-right: 4px;
    color: #ffc107;
}
*/

.tmdb-overview .tmdb-detail-value {
    display: block; /* Make overview take its own lines */
    white-space: pre-wrap; /* Respect newlines in overview text */
    word-break: break-word;
}

.tmdb-external-link-container {
    margin-top: 15px;
}

.tmdb-external-link {
    display: inline-block;
    padding: 6px 12px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85em;
    transition: background-color 0.2s;
}
.tmdb-external-link:hover {
    background-color: #0056b3;
    color: white;
}
.tmdb-external-icon {
    margin-left: 5px;
}

.tmdb-error-message {
    color: #dc3545; /* Bootstrap danger color */
    padding: 10px;
    border: 1px solid #f5c6cb;
    background-color: #f8d7da;
    border-radius: 4px;
    font-size: 0.9em;
}

.tmdb-no-info { /* For styling "暂无演员信息" etc. in lists */
    padding: 10px;
    color: #6c757d;
    font-style: italic;
    font-size: 0.9em;
}

/* Responsive adjustments for details grid */
@media (max-width: 600px) {
    .tmdb-details-grid {
        flex-direction: column; /* Stack poster and text vertically */
        gap: 15px;
    }
    .tmdb-details-poster-container {
        flex-basis: auto; /* Reset basis */
        max-width: 150px; /* Smaller poster on mobile */
        margin: 0 auto 10px auto; /* Center poster */
    }
    .tmdb-detail-item {
        font-size: 0.85em;
    }
}
/* --- 触发器按钮样式 (TMDB Lightbox V1.0.17+ related) --- */
.tmdb-trigger-button {
    display: inline-block; 
    padding: 10px 18px;   
    font-size: 0.95em;    
    font-weight: 500;     
    color: #ffffff !important; /* 文字颜色 - 白色 (使用 !important 强制覆盖主题链接色) */
    background-color: #007bff; 
    border: 1px solid transparent; 
    border-radius: 5px;   
    text-decoration: none !important; /* 同时确保去除主题可能添加的下划线 */
    cursor: pointer;       
    text-align: center;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
    line-height: 1.5; 
}

.tmdb-trigger-button:hover,
.tmdb-trigger-button:focus {
    color: #ffffff !important; /* 悬停时也确保是白色 */
    background-color: #0056b3; 
    text-decoration: none !important; /* 悬停时也去除下划线 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tmdb-trigger-button:active {
    color: #ffffff !important; /* 点击时也确保是白色 */
    background-color: #004085; 
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
/* ==========================================================================
   TMDB Lightbox Theme-Aware Styles (Follows html[data-bs-theme])
   ========================================================================== */

/* --- 默认/亮色模式下的灯箱链接颜色 (确保在亮色背景下可读) --- */
.tmdb-lightbox-modal a,
.tmdb-lightbox-modal a:visited {
    color: #007bff; /* Bootstrap 默认链接蓝 */
    text-decoration: none;
}
.tmdb-lightbox-modal a:hover,
.tmdb-lightbox-modal a:focus {
    color: #0056b3;
    text-decoration: underline;
}
/* 已有特殊样式的按钮链接（如TMDB外部链接按钮）将保持其原有样式 */
.tmdb-lightbox-modal .tmdb-external-link,
.tmdb-lightbox-modal .tmdb-external-link:visited,
.tmdb-lightbox-modal .tmdb-external-link:hover,
.tmdb-lightbox-modal .tmdb-external-link:focus {
    color: #ffffff !important; /* 保持按钮文字为白色 */
    text-decoration: none;
}


/* --- 夜间模式 (当 html[data-bs-theme="dark"] 时生效) --- */

html[data-bs-theme="dark"] .tmdb-lightbox-modal {
    background-color: #2f3136; /* 深灰色背景 (类似Discord暗色) */
    color: #dcddde;            /* 浅灰色主文字 */
    border: 1px solid #40444b; /* 深色边框 */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6); /* 夜间模式下阴影可以更深 */
}

html[data-bs-theme="dark"] .tmdb-lightbox-close {
    color: #b9bbbe; /* 关闭按钮颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-close:hover {
    color: #ffffff;
}

html[data-bs-theme="dark"] .tmdb-lightbox-header {
    border-bottom-color: #40444b; /* 分隔线颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-header h3 {
    color: #ffffff; /* 标题文字颜色 */
}

html[data-bs-theme="dark"] .tmdb-lightbox-tabs {
    border-bottom-color: #40444b; /* 标签页分隔线颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-tabs button {
    color: #b9bbbe; /* 未激活标签按钮文字颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-tabs button.tmdb-active-tab {
    color: #82aaff; /* 激活标签按钮文字颜色 (浅蓝色强调) */
    border-bottom-color: #82aaff; /* 激活标签下边框颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-tabs button:hover {
    color: #ffffff; /* 鼠标悬停标签按钮文字颜色 */
}

/* 内容区域文本颜色 */
html[data-bs-theme="dark"] .tmdb-detail-item strong {
    color: #e1e3e6; /* 详情标签文字 */
}
html[data-bs-theme="dark"] .tmdb-detail-item .tmdb-detail-value,
html[data-bs-theme="dark"] .tmdb-overview .tmdb-detail-value { /* 确保简介文字也变浅 */
    color: #b9bbbe; /* 详情值文字 */
}

html[data-bs-theme="dark"] .tmdb-genre-badge {
    background-color: #40444b; /* 类型徽章背景 */
    color: #dcddde;            /* 类型徽章文字 */
}

html[data-bs-theme="dark"] .tmdb-rating .tmdb-detail-value {
    color: #82aaff; /* 评分文字颜色 */
}

html[data-bs-theme="dark"] .tmdb-external-link {
    background-color: #5865f2; /* "在TMDB查看"按钮背景色 (类似Discord按钮蓝) */
    color: #ffffff;
}
html[data-bs-theme="dark"] .tmdb-external-link:hover {
    background-color: #4752c4;
}

/* 演员列表 */
html[data-bs-theme="dark"] .tmdb-cast-list li {
    border-bottom-color: #40444b; /* 列表项分隔线 */
}
html[data-bs-theme="dark"] .tmdb-cast-list img.tmdb-actor-photo {
    background-color: #292b2f; /* 演员图片占位背景 */
}
html[data-bs-theme="dark"] .tmdb-actor-info strong {
    color: #e1e3e6; /* 演员名 */
}
html[data-bs-theme="dark"] .tmdb-actor-info span {
    color: #b9bbbe; /* 角色名 */
}

/* 灯箱内通用链接颜色 (夜间模式) */
html[data-bs-theme="dark"] .tmdb-lightbox-modal a,
html[data-bs-theme="dark"] .tmdb-lightbox-modal a:visited {
    color: #82aaff; /* 夜间模式下的链接颜色 */
}
html[data-bs-theme="dark"] .tmdb-lightbox-modal a:hover,
html[data-bs-theme="dark"] .tmdb-lightbox-modal a:focus {
    color: #9cbfff;
}
/* 确保已特殊处理的按钮链接文字颜色在夜间模式下依然正确 */
html[data-bs-theme="dark"] .tmdb-lightbox-modal .tmdb-external-link,
html[data-bs-theme="dark"] .tmdb-lightbox-modal .tmdb-external-link:visited,
html[data-bs-theme="dark"] .tmdb-lightbox-modal .tmdb-external-link:hover,
html[data-bs-theme="dark"] .tmdb-lightbox-modal .tmdb-external-link:focus {
    color: #ffffff !important; 
    text-decoration: none;
}

/* 加载动画 (如果需要，也可以调整颜色，但通常保持现状即可) */
/*
html[data-bs-theme="dark"] .tmdb-lightbox-loader {
    border: 4px solid #40444b; 
    border-top: 4px solid #82aaff; 
}
*/

/* 错误消息和无信息提示的暗色模式适配 (可选) */
html[data-bs-theme="dark"] .tmdb-error-message {
    color: #f8d7da; /* 浅红色文字 */
    background-color: #521b22; /* 深红色背景 */
    border-color: #8c2f39;   /* 深红色边框 */
}
html[data-bs-theme="dark"] .tmdb-no-info {
    color: #868e96; /* 暗色模式下的中性提示文字 */
}