/* 素材下载器前端样式 - 优化版 */

/* 全局重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* 主容器样式 */
.material-downloader-page {
    min-height: calc(100vh - 20px);
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 页面头部样式 */
.page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 0 40px; /* 增加顶部内边距 */
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-top: 80px;
}

.page-title {
    font-size: 2rem; /* 减小字体大小 */
    margin: 0 0 10px 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-description {
    font-size: 1rem;
    margin: 0;
    opacity: 0.95;
    max-width: 800px;
    margin: 0 auto;
}

/* 页面内容样式 */
.page-content {
    padding: 30px 0;
}

/* 排序控制样式 */
.sort-controls {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eaeaea;
    max-width: 300px;
}

.sort-controls label {
    font-weight: 500;
    color: #555;
    font-size: 0.95rem;
}

.sort-controls select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.sort-controls select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sort-controls select:hover {
    border-color: #bbb;
}

/* 素材网格布局 - 更紧凑的设计 */
.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); /* 减小最小宽度 */
    gap: 20px; /* 减小间距 */
    margin-top: 20px;
}

/* 素材项样式 - 紧凑版本 */
.material-item {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid #eaeaea;
    position: relative;
}

.material-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

/* 素材缩略图区域 - 紧凑版本 */
.material-thumbnail {
    height: 180px; /* 减小高度 */
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.material-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.material-thumbnail:hover img {
    transform: scale(1.05);
}

/* 文件图标样式 */
.file-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: #444;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 下载按钮样式（缩略图左下角的圆形按钮） */
.thumbnail-download-button {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: rgba(102, 126, 234, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
}

.thumbnail-download-button:hover {
    background-color: rgba(102, 126, 234, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    color: white;
}

/* 查看按钮样式（缩略图右下角的圆形按钮） */
.thumbnail-view-button {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(74, 111, 165, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
}

.thumbnail-view-button:hover {
    background-color: rgba(53, 84, 131, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* 鼠标悬停在图片上时显示按钮 */
.material-thumbnail:hover .thumbnail-download-button,
.material-thumbnail:hover .thumbnail-view-button {
    opacity: 1;
    visibility: visible;
}

.download-icon, .view-icon {
    font-size: 16px;
}

/* 为了让查看按钮在缩略图上更好看，添加缩略图渐变效果 */
.material-thumbnail::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.material-thumbnail:hover::after {
    opacity: 1;
}

/* 素材信息区域 - 紧凑版本 */
.material-info {
    padding: 15px;
}

/* 模态框样式 - 优化版，提供沉浸式图片浏览体验 */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 当模态框显示时应用的样式类 */
.modal.show {
    display: flex;
    opacity: 1;
}

/* 确保JavaScript设置的内联样式可以正常工作 */
#image-preview-modal {
    display: none;
}

/* 缩略图可点击提示效果 */
.preview-image-trigger {
    cursor: pointer;
    transition: all 0.2s ease;
}

.material-thumbnail:hover .preview-image-trigger {
    transform: scale(1.03);
}

/* 优化模态框内容，使其完全匹配图片大小 */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    vertical-align: middle;
}

/* 优化图片容器 */
.modal-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    background: transparent;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
}

/* 优化图片显示 - 确保按比例适配窗口并居中 */
.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin: auto;
    display: block;
}

.modal-caption {
    display: none; /* 隐藏标题、描述和下载按钮区域 */
}

/* 优化关闭按钮 */
.close-modal {
    position: fixed;
    top: 20px;
    right: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 50px;
    text-align: center;
    border: none;
    padding: 0;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
    z-index: 1001;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    transform: scale(1.1);
}

.preview-download-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.preview-download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
    color: white;
}

/* 响应式模态框 */
@media screen and (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        max-width: 95%;
    }
    
    .modal-image-container {
        padding: 15px;
        max-height: 60vh;
    }
    
    .modal-caption {
        padding: 15px;
    }
    
    .modal-caption h3 {
        font-size: 1.2rem;
    }
    
    .close-modal {
        font-size: 30px;
        top: 10px;
        right: 15px;
    }
}

.material-info h3 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.material-description-short {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 10px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 素材元数据样式 */
.material-meta-compact {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.meta-item-small {
    font-size: 0.85rem;
    color: #777;
    display: flex;
    align-items: center;
    gap: 4px;
}





/* 下载计数特殊样式 */
.meta-item-small i[class="meta-icon"]:nth-of-type(2) {
    color: #667eea;
    font-weight: bold;
}

.meta-icon {
    font-size: 0.9rem;
}

/* 无素材状态 */
.no-materials {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); /* 更小的卡片在移动设备上 */
        gap: 15px;
    }
    
    .material-thumbnail {
        height: 150px;
    }
    
    .page-header {
        padding: 30px 0;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* 更紧凑的在小屏幕上 */
    }
    
    .material-info {
        padding: 12px;
    }
    
    .material-info h3 {
        font-size: 1rem;
    }
    
    .download-button {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

.material-item:hover .material-thumbnail img {
    transform: scale(1.05);
}

/* 文件图标样式 */
.file-icon {
    font-size: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.material-item:hover .file-icon {
    transform: scale(1.05);
}

.file-icon.file-pdf {
    background: #ff4d4f;
    color: white;
}

.file-icon.file-zip,
.file-icon.file-rar {
    background: #1890ff;
    color: white;
}

/* 素材信息区域 */
.material-info {
    padding: 25px;
}

.material-info h3 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
}

.material-description {
    color: #666;
    margin: 0 0 20px 0;
    line-height: 1.6;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 元信息样式 */
.material-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: #666;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #eaeaea;
}

/* 下载计数特殊样式 */
.meta-item.download-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: transform 0.2s ease;
}

.meta-item.download-count:hover {
    transform: scale(1.05);
}

.meta-item.download-count .meta-icon {
    font-size: 1.1rem;
}

.meta-icon {
    font-size: 1rem;
}



.button-icon {
    font-size: 1.1rem;
}

.button-text {
    flex: 1;
}

/* 无素材状态样式 */
.no-materials {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.empty-state-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.7;
}

.no-materials p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

/* 响应式设计 - 平板设备 */
@media (max-width: 768px) {
    .page-header {
        padding: 40px 0;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .page-description {
        font-size: 1rem;
    }
    
    .page-content {
        padding: 30px 0;
    }
    
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .material-thumbnail {
        height: 180px;
    }
    
    .file-icon {
        font-size: 3rem;
        width: 100px;
        height: 100px;
    }
}

/* 响应式设计 - 移动设备 */
@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .page-header {
        padding: 30px 0;
    }
    
    .page-title {
        font-size: 1.75rem;
    }
    
    .page-content {
        padding: 20px 0;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .material-thumbnail {
        height: 160px;
    }
    
    .material-info {
        padding: 20px;
    }
    
    .material-info h3 {
        font-size: 1.2rem;
    }
    
    .download-button {
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    
    .material-meta {
        gap: 8px;
        font-size: 0.8rem;
    }
    
    .meta-item {
        padding: 5px 10px;
    }
    
    .no-materials {
        padding: 60px 15px;
    }
    
    .empty-state-icon {
        font-size: 4rem;
    }
}

/* 响应式设计 - 大屏幕设备 */
@media (min-width: 1400px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .container {
        max-width: 1400px;
    }
}