/* ============================================
   Secure File Preview - 前端预览样式
   ============================================ */

/* ---- 加载动画 ---- */
@keyframes sfp-spin {
    to { transform: rotate(360deg); }
}

@keyframes sfp-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- 容器基础 ---- */
.sfp-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
    line-height: 1.6;
}

.sfp-container * {
    box-sizing: border-box;
}

/* ---- 信息栏 ---- */
.sfp-info-bar .sfp-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sfp-info-bar .sfp-toolbar-btn:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* ---- 预览内容区 ---- */
.sfp-content-area {
    position: relative;
    background: #ffffff;
}

.sfp-content-area::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.sfp-content-area::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.sfp-content-area::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.sfp-content-area::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 加载状态 */
.sfp-loader {
    animation: sfp-fade-in 0.3s ease-out;
}

/* ---- Word 文档预览样式 ---- */
.sfp-word-document {
    padding: 32px 48px;
    max-width: 900px;
    margin: 0 auto;
    color: #1e293b;
    animation: sfp-fade-in 0.4s ease-out;
}

.sfp-word-document h1 {
    font-size: 26px;
    line-height: 1.35;
    margin: 20px 0 12px;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.sfp-word-document h2 {
    font-size: 21px;
    line-height: 1.4;
    margin: 18px 0 10px;
    color: #1e293b;
}

.sfp-word-document h3 {
    font-size: 17px;
    line-height: 1.45;
    margin: 14px 0 8px;
    color: #334155;
}

.sfp-word-document h4, .sfp-word-document h5, .sfp-word-document h6 {
    margin: 12px 0 6px;
    color: #475569;
}

.sfp-word-document p, .sfp-para {
    text-align: justify;
}

/* Word 表格样式 */
.sfp-table {
    font-size: 13.5px;
}

.sfp-table th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.02em;
}

.sfp-table td {
    color: #334155;
    transition: background-color 0.15s;
}

.sfp-table tr:hover td {
    background-color: #fafbfc;
}

.sfp-table a {
    word-break: break-all;
}

/* ---- PPT 幻灯片预览样式 ---- */
.sfp-presentation {
    position: relative;
}

.sfp-slide {
    background: #fff !important;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.sfp-slide:not(:first-child) {
    display: none; /* 默认只显示第一页，通过JS切换 */
}

.sfp-slide.sfp-active {
    display: block;
    animation: sfp-fade-in 0.3s ease-out;
}

/* PPT 形状文本 */
.sfp-shape-title {
    overflow: hidden;
}

.sfp-shape-body {
    font-size: 14px;
    color: #374151;
    line-height: 1.55;
}

.sfp-shape-textbox {
    font-size: 13px;
    color: #4b5563;
}

/* PPT 图片 */
.sfp-slide-image {
    max-width: 100%;
}

/* PPT 表格占位 */
.sfp-chart-placeholder {
    margin: 16px;
}

/* ---- Excel 工作簿预览样式 ---- */
.sfp-excel-workbook {
    /* 每个sheet默认全部显示（可通过JS折叠） */
}

.sfp-excel-sheet + .sfp-excel-sheet {
    margin-top: 24px;
    border-top: 2px dashed #cbd5e1;
    padding-top: 24px;
}

.sfp-excel-sheet:first-child .sfp-excel-sheet {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.sfp-excel-table td,
.sfp-excel-table th {
    transition: background-color 0.12s ease;
}

.sfp-excel-table tbody tr:hover td {
    background-color: #eff6ff;
}

.sfp-excel-table td[style*="background"],
.sfp-excel-table th[style*="background"] {
    /* 有自定义背景色的单元格不受hover影响 */
}

.sfp-excel-table tbody tr:hover td[style*="background"] {
    /* 保持原背景色 */
}

/* Excel 单元格内文字不换行（除非设置了wrapText） */
.sfp-excel-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.sfp-excel-table td[style*="white-space:normal"] {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    max-width: none;
}

/* ---- 错误/提示信息 ---- */
.sfp-error {
    padding: 40px 30px;
    text-align: center;
    background: #fefce8;
    border-radius: 8px;
    margin: 24px;
    color: #854d0e;
}

.sfp-error h3 {
    margin-bottom: 10px;
    font-size: 16px;
}

.sfp-error p {
    margin: 4px 0;
    font-size: 13px;
    color: #a16207;
}

/* ---- 水印层 ---- */
.sfp-watermark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
    opacity: 0.08;
    background-repeat: repeat;
    background-position: 0 0;
    user-select: none;
    -webkit-user-select: none;
}

/* ---- 全屏模式 ---- */
.sfp-container.sfp-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999;
    border-radius: 0 !important;
    max-width: none !important;
}

.sfp-container.sfp-fullscreen .sfp-content-area {
    height: calc(100vh - 56px) !important;
}

/* ---- 响应式适配 ---- */
@media screen and (max-width: 768px) {
    .sfp-word-document {
        padding: 16px 20px;
        max-width: 100% !important;
    }

    .sfp-info-bar {
        flex-wrap: wrap;
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    .sfp-info-bar .sfp-toolbar {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .sfp-format-icon {
        font-size: 22px !important;
    }

    .sfp-filename {
        font-size: 13px !important;
    }

    .sfp-meta {
        flex-wrap: wrap;
        gap: 6px !important;
        font-size: 10px !important;
    }

    .sfp-zoom-control,
    .sfp-slide-nav,
    .sfp-sheet-nav {
        font-size: 11px !important;
    }

    /* 移动端表格横向滚动 */
    .sfp-table,
    .sfp-excel-table {
        min-width: 500px;
        font-size: 12px;
    }

    .sfp-slide {
        transform-origin: top center;
    }

    /* 工具栏按钮简化 */
    .sfp-toolbar-btn span {
        display: none; /* 只显示图标 */
    }
}

@media screen and (max-width: 480px) {
    .sfp-word-document {
        padding: 12px 14px;
    }

    .sfp-word-document h1 {
        font-size: 20px;
    }

    .sfp-word-document h2 {
        font-size: 17px;
    }

    /* 隐藏部分工具栏元素以节省空间 */
    .sfp-fullscreen-btn {
        display: none;
    }
}

/* ---- 打印样式（可选） ---- */
@media print {
    .sfp-info-bar,
    .sfp-watermark,
    .sfp-loader {
        display: none !important;
    }

    .sfp-content-area {
        height: auto !important;
        overflow: visible !important;
    }

    .sfp-slide {
        page-break-after: always;
        display: block !important;
    }

    .sfp-container {
        border: none !important;
        box-shadow: none !important;
    }
}
