/**
 * 文件预览页面样式
 * File Preview Styles
 */

/* ============================================
   基础样式 / Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for better mobile support */
}

body {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.preview-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: auto;
    background: #fff;
}

/* ============================================
   加载状态 / Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1890ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 16px;
    color: #666;
    font-size: 14px;
}

/* ============================================
   错误状态 / Error Overlay
   ============================================ */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
}

.error-icon {
    font-size: 48px;
    color: #ff4d4f;
    margin-bottom: 16px;
}

.error-text {
    color: #ff4d4f;
    font-size: 14px;
    text-align: center;
    max-width: 80%;
    margin-bottom: 16px;
}

.error-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.retry-action-btn,
.download-action-btn {
    padding: 8px 24px;
    background: #fff;
    color: #333;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.retry-action-btn:hover,
.download-action-btn:hover {
    background: #f5f5f5;
    border-color: #40a9ff;
    color: #40a9ff;
}

/* ============================================
   PDF 预览 / PDF Embed
   ============================================ */
.pdf-embed {
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================
   HTML 预览 / HTML Preview
   ============================================ */
.html-preview {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
    overflow: hidden; /* 禁止容器滚动，由 iframe 内部控制 */
}

.html-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ============================================
   图片预览 / Image Preview
   ============================================ */
.image-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    padding: 20px;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   文本/代码预览 / Text/Code Preview
   ============================================ */
.text-preview {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 20px;
    background: #fff;
}

.text-preview pre {
    margin: 0;
    padding: 16px;
    background: #f6f8fa;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
}

.text-preview pre code {
    background: transparent;
    padding: 0;
    border: none;
}

/* ============================================
   Markdown 预览 / Markdown Preview
   ============================================ */
.markdown-preview {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 40px;
    background: #fff;
}

.markdown-preview .markdown-body {
    max-width: 900px;
    margin: 0 auto;
    font-size: 16px;
    line-height: 1.6;
    color: #24292e;
}

.markdown-preview .markdown-body h1,
.markdown-preview .markdown-body h2 {
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-preview .markdown-body h1 {
    font-size: 2em;
    margin: 0.67em 0;
}

.markdown-preview .markdown-body h2 {
    font-size: 1.5em;
    margin: 0.75em 0;
}

.markdown-preview .markdown-body h3 {
    font-size: 1.25em;
    margin: 1em 0;
}

.markdown-preview .markdown-body code {
    background: #f6f8fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 85%;
}

.markdown-preview .markdown-body pre {
    background: #f6f8fa;
    padding: 16px;
    border-radius: 6px;
    overflow: auto;
}

.markdown-preview .markdown-body pre code {
    background: transparent;
    padding: 0;
}

.markdown-preview .markdown-body blockquote {
    margin: 1em 0;
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
}

.markdown-preview .markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.markdown-preview .markdown-body table th,
.markdown-preview .markdown-body table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-preview .markdown-body table th {
    background: #f6f8fa;
    font-weight: 600;
}

.markdown-preview .markdown-body img {
    max-width: 100%;
    box-sizing: border-box;
}

.markdown-preview .markdown-body a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-preview .markdown-body a:hover {
    text-decoration: underline;
}

/* ============================================
   工具类 / Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   移动端响应式 / Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .markdown-preview {
        padding: 20px;
    }

    .text-preview {
        padding: 16px;
    }

    .text-preview pre {
        padding: 12px;
        font-size: 12px;
    }
}
