/**
 * MoviePilot API Integration Styles
 */

/* 媒体展示容器 */
.moviepilot-media-showcase {
    display: block;
    margin: 20px 0;
}

/* 网格布局 */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

/* 媒体卡片 */
.media-card {
    border: 1px solid #ddd;
    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;
    cursor: pointer;
    background: #fff;
}

.media-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* 海报区域 */
.media-poster {
    position: relative;
    padding-top: 150%; /* 2:3 比例 */
    background: #f8f9fa;
}

.media-poster img,
.media-poster .no-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-poster .no-poster {
    background: #e9ecef;
    color: #6c757d;
    font-size: 14px;
}

/* 海报角落信息 */
.poster-corner {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 6px;
    font-size: 11px;
    z-index: 2;
    border-radius: 3px;
}

.top-left {
    top: 8px;
    left: 8px;
}

.top-right {
    top: 8px;
    right: 8px;
}

.bottom-left {
    bottom: 8px;
    left: 8px;
}

.bottom-right {
    bottom: 8px;
    right: 8px;
}

/* 星级评分 */
.star {
    color: #ddd;
    font-size: 12px;
}

.star.full {
    color: #ffc107;
}

.star.half {
    color: #ffc107;
}

/* 媒体信息 */
.media-info {
    padding: 12px;
}

.media-title {
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 600;
    color: #212529;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 媒体操作按钮 */
.media-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.media-actions button {
    flex: 1;
    padding: 5px;
    font-size: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

/* 为网格中的按钮应用与弹窗中相同的样式 */
.media-actions .favorite-btn {
    background: #007bff;
    color: white;
}

.media-actions .favorite-btn:hover {
    background: #0056b3;
}

.media-actions .download-btn {
    background: #28a745;
    color: white;
}

.media-actions .download-btn:hover {
    background: #1e7e34;
}

.media-actions .share-btn {
    background: #ffc107;
    color: #212529;
}

.media-actions .share-btn:hover {
    background: #e0a800;
}

.media-actions .play-btn {
    background: #dc3545;
    color: white;
}

.media-actions .play-btn:hover {
    background: #c82333;
}

/* 弹窗样式 - 上下左右居中 (增强兼容性版本) */
.moviepilot-modal {
    position: fixed !important;
    z-index: 999999 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0,0,0,0.8) !important;
    display: none !important;
    /* 使用Flexbox实现居中 */
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
    -webkit-box-align: center !important;
    -ms-flex-align: center !important;
    align-items: center !important;
    -webkit-box-pack: center !important;
    -ms-flex-pack: center !important;
    justify-content: center !important;
    /* 兼容性备用方案 */
    text-align: center !important;
    overflow: auto !important;
    opacity: 0 !important;
    visibility: hidden !important;
    -webkit-transition: opacity 0.3s ease, visibility 0.3s ease !important;
    -moz-transition: opacity 0.3s ease, visibility 0.3s ease !important;
    -o-transition: opacity 0.3s ease, visibility 0.3s ease !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
}

.moviepilot-modal.show {
    opacity: 1 !important;
    visibility: visible !important;
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
}

/* 兼容性备用方案：当Flexbox不工作时 */
.moviepilot-modal.fallback-center {
    text-align: center !important;
}

.moviepilot-modal.fallback-center:before {
    content: '' !important;
    display: inline-block !important;
    height: 100% !important;
    vertical-align: middle !important;
    margin-right: -0.25em !important;
}

.moviepilot-modal.fallback-center .moviepilot-modal-content {
    display: inline-block !important;
    vertical-align: middle !important;
    text-align: left !important;
}

.moviepilot-modal-content {
    background-color: #fff !important;
    padding: 0 !important;
    border-radius: 10px !important;
    width: 90% !important;
    max-width: 900px !important;
    max-height: 90vh !important;
    overflow: hidden !important;
    position: relative !important;
    /* 使用transform实现动画效果 */
    -webkit-transform: translate(0, 20px) !important;
    -moz-transform: translate(0, 20px) !important;
    -ms-transform: translate(0, 20px) !important;
    -o-transform: translate(0, 20px) !important;
    transform: translate(0, 20px) !important;
    -webkit-transition: -webkit-transform 0.3s ease !important;
    -moz-transition: -moz-transform 0.3s ease !important;
    -o-transition: -o-transform 0.3s ease !important;
    transition: transform 0.3s ease !important;
    /* 兼容性设置 */
    margin: auto !important;
    /* 防止在某些主题中被覆盖 */
    box-sizing: border-box !important;
    /* 确保内容不会被截断 */
    min-width: 300px !important;
}

.moviepilot-modal.show .moviepilot-modal-content {
    -webkit-transform: translate(0, 0) !important;
    -moz-transform: translate(0, 0) !important;
    -ms-transform: translate(0, 0) !important;
    -o-transform: translate(0, 0) !important;
    transform: translate(0, 0) !important;
}

/* 针对不同浏览器的兼容性处理 */
@supports not (display: flex) {
    .moviepilot-modal {
        text-align: center !important;
    }
    
    .moviepilot-modal:before {
        content: '' !important;
        display: inline-block !important;
        height: 100% !important;
        vertical-align: middle !important;
        margin-right: -0.25em !important;
    }
    
    .moviepilot-modal-content {
        display: inline-block !important;
        vertical-align: middle !important;
        text-align: left !important;
    }
}

/* 针对特定主题的额外兼容性处理 */
.moviepilot-modal-content *,
.moviepilot-modal-content *:before,
.moviepilot-modal-content *:after {
    -webkit-box-sizing: border-box !important;
    -moz-box-sizing: border-box !important;
    box-sizing: border-box !important;
}

.moviepilot-modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
    z-index: 1001;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.moviepilot-modal-close:hover,
.moviepilot-modal-close:focus {
    color: #000;
    background-color: rgba(0,0,0,0.1);
}

/* 弹窗内容区域 */
.modal-media-content {
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-media-header {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
}

.modal-media-poster {
    flex: 0 0 30%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.modal-media-poster img {
    width: 100%;
    height: auto;
    display: block;
}

.modal-media-details {
    flex: 1;
}

.modal-media-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 28px;
    font-weight: 700;
    color: #212529;
}

.modal-media-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.modal-media-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #6c757d;
}

.modal-media-meta-item .star {
    font-size: 16px;
}

.modal-media-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.modal-media-genre {
    background: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.modal-media-overview {
    margin: 20px 0;
    line-height: 1.7;
    color: #495057;
}

.modal-media-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-media-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.modal-media-actions .favorite-btn {
    background: #007bff;
    color: white;
}

.modal-media-actions .favorite-btn:hover {
    background: #0056b3;
}

.modal-media-actions .download-btn {
    background: #28a745;
    color: white;
}

.modal-media-actions .download-btn:hover {
    background: #1e7e34;
}

.modal-media-actions .share-btn {
    background: #ffc107;
    color: #212529;
}

.modal-media-actions .share-btn:hover {
    background: #e0a800;
}

.modal-media-actions .play-btn {
    background: #dc3545;
    color: white;
}

.modal-media-actions .play-btn:hover {
    background: #c82333;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .media-info {
        padding: 10px;
    }
    
    .media-title {
        font-size: 13px;
    }
    
    .poster-corner {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .moviepilot-modal-content {
        width: 95%;
        margin: 20px auto;
    }
    
    .modal-media-header {
        flex-direction: column;
    }
    
    .modal-media-poster {
        flex: none;
        width: 100%;
    }
    
    .modal-media-title {
        font-size: 22px;
    }
    
    .modal-media-content {
        padding: 20px;
    }
}