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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    overflow: hidden;
}

/* 主容器 */
.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* 头部 */
header {
    background: #f8f9fa;
    color: #333;
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0;
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.subtitle {
    font-size: 0.9rem;
    color: #666;
}

main {
    background: white;
    padding: 20px;
    flex: 1;
    overflow: hidden;
}

/* 主布局样式 */
.main-layout {
    display: flex;
    gap: 30px;
    height: 100%;
    margin-top: 0;
}

.left-sidebar, .right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.left-sidebar {
    flex: 6; /* 左侧上传和列表区域占60% */
    min-width: 0; /* 防止flex项目溢出 */
    height: 100%;
    display: flex;
    flex-direction: column;
}

.right-sidebar {
    flex: 4; /* 右侧预览区域占40% */
    min-width: 0; /* 防止flex项目溢出 */
    border-left: 1px dashed #ccc; /* 灰色虚线分隔 */
    padding-left: 30px; /* 增加左侧内边距，避免内容紧贴分隔线 */
}

/* 区域样式 */
section {
    background: white;
    padding: 15px;
    margin-bottom: 0;
}

/* 左侧区域特殊调整 */
.left-sidebar .print-actions-section {
    flex: 0 0 auto; /* 不伸缩，保持内容高度 */
}

.left-sidebar .preview-section {
    flex: 1;
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    min-height: 0; /* 允许flex子项收缩 */
    overflow: hidden;
}

/* 右侧区域特殊调整 */
.right-sidebar .upload-section {
    flex: 0 0 auto; /* 不伸缩，保持内容高度 */
}

.right-sidebar .invoice-list-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许flex子项收缩 */
    overflow: hidden;
}



/* 发票列表区域调整 */
.invoice-list-section .file-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: none; /* 移除固定高度限制 */
    padding-right: 5px; /* 为滚动条留出空间 */
}

/* 自定义滚动条样式 */
.invoice-list-section .file-list::-webkit-scrollbar {
    width: 6px;
}

.invoice-list-section .file-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.invoice-list-section .file-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.invoice-list-section .file-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 预览相关样式 */
#previewSection {
    display: none;
    height: 100%;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.preview-controls {
    padding: 15px 20px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
    position: relative;
}

.preview-controls h3 {
    margin: 0;
    flex-shrink: 0;
}

.preview-controls > div:last-child {
    margin-left: auto;
}

.zoom-controls {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.preview-scroll-container {
    overflow-y: scroll;
    height: 100%;
    padding: 0; /* 移除内边距 */
    width: 100%; /* 确保宽度为100% */
    position: relative;
    min-height: 300px;
    /* 确保滚动条始终显示 */
    -ms-overflow-style: scrollbar;
    scrollbar-width: thin;
}

#previewPagesContainer {
    display: block;
    padding: 0 !important;
    width: 100%;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible;
    position: static;
}

/* 确保预览页面以合适的大小显示并居中 */
.preview-page {
    width: auto !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 auto 20px auto !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border: none !important;
    display: block !important;
    position: static !important;
    aspect-ratio: none !important;
    box-sizing: border-box; /* 确保尺寸计算正确 */
}

.preview-page canvas {
    display: block;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px 4px 0 0;
    width: 100%;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* 缩放控制样式 */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 5px 10px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.zoom-btn {    width: 32px;    height: 32px;    border: 2px solid #ccc;    background: white;    border-radius: 4px;    cursor: pointer;    display: flex;    align-items: center;    justify-content: center;    font-size: 16px;    color: #666;}

.zoom-btn:hover {    /* 移除悬停效果，保持原始状态 */}

.zoom-btn:active {    /* 移除点击效果，保持原始状态 */}

.zoom-btn.active {
    /* 保持与非激活状态相同的样式，只通过子元素i改变图标颜色 */
}

/* 确保Font Awesome图标在点亮状态下显示绿色线条 */
.zoom-btn.active i {
    color: #28a745; /* 绿色线条 */
}

.zoom-btn i {    color: #ccc;}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* 确保预览区域在不同设备上的良好显示 */
@media (max-width: 768px) {
    .preview-scroll-container {
        height: 100%;
    }
    
    .preview-controls {
        flex-wrap: wrap;
        padding: 8px;
    }
    
    .zoom-controls {
        order: 1;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
}

/* 预览区域自定义滚动条样式 */
.preview-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.preview-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.preview-scroll-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.preview-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 15px;
        height: calc(100vh - 30px);
    }
    
    body {
        padding: 15px;
    }
    
    .main-layout {
        gap: 20px;
    }
}

@media (max-width: 1024px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: calc(100vh - 20px);
    }
    
    .main-layout {
        flex-direction: column;
        height: 100%;
        gap: 15px;
    }
    
    .left-sidebar, .right-sidebar {
        gap: 15px;
        height: auto;
    }
    
    .left-sidebar, .right-sidebar {
        flex: 1; /* 垂直布局时等宽 */
    }
    
    .left-sidebar {
        min-height: 300px;
    }
    
    .right-sidebar {
        min-height: 400px;
    }
    
    .right-sidebar .invoice-list-section .file-list {
        max-height: 400px;
    }
    
    .left-sidebar .preview-section .preview-container {
        min-height: 200px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        height: calc(100vh - 10px);
    }
    
    .main-layout {
        gap: 10px;
        margin-top: 0;
    }
    
    .left-sidebar, .right-sidebar {
        gap: 10px;
        height: auto;
    }
    
    .left-sidebar {
        min-height: 250px;
    }
    
    .right-sidebar {
        min-height: 300px;
    }
    
    section {
        padding: 15px;
    }
    
    .right-sidebar .invoice-list-section .file-list {
        max-height: 300px;
    }
    
    header {
        padding: 10px 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: 20px;
    margin-top: 0;
}

.upload-area {
    border: 2px dashed #dee2e6;
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    transition: border-color 0.2s;
    cursor: pointer;
    min-height: 120px;
}

.upload-area:hover {
    border-color: #007bff;
    background: #e3f2fd;
}

/* 拖拽样式已移除 */

.upload-content h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.upload-content p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.upload-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    color: #667eea;
}

/* 发票列表头部 */
.invoice-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.invoice-list-header h2 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.list-actions {
    display: flex;
    gap: 10px;
}

/* 文件列表样式 */
.file-list {
    flex: 1;
    overflow-y: auto;
    background: white;
    min-height: 200px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    background: white;
    cursor: default;
    transition: background-color 0.2s;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: #f8f9fa;
}

/* 拖拽状态样式已移除 */

.file-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: #667eea;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 12px;
    color: #666;
}

.file-amount {
    color: #28a745;
    font-weight: 500;
}

.file-dimensions {
    color: #666;
    font-size: 0.9em;
    margin-left: 8px;
}

.file-size {
    color: #999;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    padding: 6px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    background: #f0f0f0;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.btn-icon:hover {
    background: #e0e0e0;
}

.btn-preview {
    background: #667eea;
    color: white;
}

.btn-preview:hover {
    background: #5a6fd8;
}

.btn-preview:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-delete {
    background: #f0f0f0;
    color: #dc3545;
}

.btn-delete:hover {
    background: #dc3545;
    color: white;
}





/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
}

/* 轮廓按钮样式 */
.btn-outline-primary {
    background-color: #cce5ff;
    border: 1px solid #007bff;
    color: #007bff;
}

.btn-outline-primary:hover {
    background-color: #007bff;
    color: white;
}

.btn-outline-secondary {
    background-color: #e2e3e5;
    border: 1px solid #6c757d;
    color: #6c757d;
}

.btn-outline-secondary:hover {
    background-color: #6c757d;
    color: white;
}

.btn-outline-success {
    background-color: #d4edda;
    border: 1px solid #28a745;
    color: #28a745;
}

.btn-outline-success:hover {
    background-color: #28a745;
    color: white;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

/* 打印操作样式 */
.print-actions-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.print-info {
    margin-top: 15px;
    padding: 10px;
    background: #e7f3ff;
    border-left: 4px solid #667eea;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #495057;
}

.print-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 预览区域样式 */
.preview-section {
    padding-top: 0;
}

.preview-controls {
    padding: 10px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
}

/* 缩放控制样式 */
.zoom-controls {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 删除重复的zoom-btn样式定义，避免覆盖前面的镂空效果样式 */

.zoom-level {
    font-size: 0.9rem;
    color: #666;
    min-width: 50px;
    text-align: center;
}





/* 加载遮罩样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

#loadingText {
    font-size: 1.1rem;
}

/* 响应式设计 - 末尾的媒体查询 */
@media (max-width: 768px) {
    .container {
        padding: 5px;
    }
    
    main {
        padding: 10px;
    }
    
    .file-list {
        /* 移除grid布局，使用flex布局 */
        display: block;
    }
    
    .print-actions {
        flex-direction: column;
    }
    
    .preview-controls {
        justify-content: center;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* 裁切线样式 */
.cut-line {
    stroke: #ff0000;
    stroke-width: 0.5;
    stroke-dasharray: 5,5;
    fill: none;
}

.cut-line-vertical {
    stroke: #ff0000;
    stroke-width: 0.5;
    stroke-dasharray: 5,5;
    fill: none;
}