/* 预览弹窗样式 */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.preview-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: previewModalFadeIn 0.3s ease-out;
}

@keyframes previewModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    flex-shrink: 0;
    position: relative;
    z-index: 1000; /* 确保头部始终在最上层 */
}

.preview-header h2 {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

.preview-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    line-height: 1;
}

.preview-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
    transform: scale(1.1);
}

.preview-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    padding: 0 20px;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    position: relative;
    z-index: 999; /* 确保标签页在图片之上 */
}

.preview-tabs::-webkit-scrollbar {
    height: 4px;
}

.preview-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.preview-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.preview-tab {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.preview-tab:hover {
    color: #333;
    background-color: rgba(0, 0, 0, 0.05);
}

.preview-tab.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background-color: white;
    font-weight: 600;
}

.preview-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #007bff;
}

.preview-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

/* 完全重写图片容器 - 无滚动条，自由拖拽 */
.preview-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: hidden; /* 完全隐藏滚动条 */
}

.preview-image-container.active {
    display: block;
}

.image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden; /* 完全隐藏滚动条 */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    background: #f8f9fa;
}

.image-wrapper.dragging {
    cursor: grabbing;
}

.preview-image {
    position: absolute;
    max-width: none; /* 移除尺寸限制 */
    max-height: none; /* 移除尺寸限制 */
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transition: none; /* 移除过渡动画 */
    transform-origin: center center; /* 统一使用中心作为变换原点 */
    pointer-events: none; /* 防止图片本身干扰拖拽 */
}

/* 图片占位符样式 */
.image-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    border-radius: 8px;
    color: #666;
}

/* 缩放控制按钮 */
.preview-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.zoom-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.zoom-btn:active {
    transform: translateY(0);
}

/* 预览加载状态 */
.preview-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.preview-loading-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: loadingPulse 0.3s ease-out;
}

@keyframes loadingPulse {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preview-loading-content p {
    margin: 0;
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .preview-modal-content {
        width: 95%;
        height: 95%;
        border-radius: 8px;
    }
    
    .preview-header {
        padding: 15px;
    }
    
    .preview-header h2 {
        font-size: 18px;
    }
    
    .preview-close-btn {
        font-size: 20px;
        padding: 6px 10px;
    }
    
    .preview-tabs {
        padding: 0 15px;
    }
    
    .preview-tab {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .preview-loading-content {
        padding: 30px;
        margin: 20px;
    }
    
    .loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    .preview-loading-content p {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .preview-modal-content {
        width: 98%;
        height: 98%;
    }
    
    .preview-header {
        padding: 12px;
    }
    
    .preview-header h2 {
        font-size: 16px;
    }
    
    .preview-tabs {
        padding: 0 12px;
    }
    
    .preview-tab {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    .preview-modal {
        background-color: rgba(0, 0, 0, 0.9);
    }
    
    .preview-modal-content {
        background: #1a1a1a;
        color: #fff;
    }
    
    .preview-header {
        background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
        border-bottom-color: #333;
    }
    
    .preview-header h2 {
        color: #fff;
    }
    
    .preview-close-btn {
        color: #ccc;
    }
    
    .preview-close-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    
    .preview-tabs {
        background: #2d2d2d;
        border-bottom-color: #333;
    }
    
    .preview-tab {
        color: #ccc;
    }
    
    .preview-tab:hover {
        color: #fff;
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .preview-tab.active {
        background-color: #1a1a1a;
        color: #007bff;
    }
    
    .preview-content {
        background: #1a1a1a;
    }
    
    .image-wrapper {
        background: #1a1a1a;
    }
    
    .preview-loading-content {
        background: #1a1a1a;
        color: #fff;
    }
    
    .preview-loading-content p {
        color: #ccc;
    }
}

/* 重复样式已删除，保留主要样式定义 */

/* 下载按钮加载动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}