/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to bottom, #ffffff 0%, #f0fdf4 50%, #d1fae5 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* 控制面板 */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 15px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-group label {
    font-weight: 600;
    color: #333;
}

.radio-group {
    display: flex;
    gap: 15px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
}

.radio-label input[type="radio"] {
    margin-right: 5px;
    cursor: pointer;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #10B981;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 对比容器 */
.diff-container {
    display: flex;
    height: calc(100vh - 300px);
    min-height: 500px;
}

.diff-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
}

.diff-panel:last-child {
    border-right: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.panel-header h3 {
    font-size: 16px;
    color: #333;
}

.clear-panel-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s;
}

.clear-panel-btn:hover {
    color: #e74c3c;
}

/* 上传区域 */
.upload-area {
    padding: 20px;
}

.upload-prompt {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-prompt:hover {
    border-color: #10B981;
    background: #dcfce7;
}

.upload-prompt.drag-over {
    border-color: #10B981;
    background: #d1fae5;
}

.upload-icon {
    color: #10B981;
    margin-bottom: 15px;
}

.upload-prompt p {
    margin: 5px 0;
    color: #555;
}

.file-types {
    font-size: 12px;
    color: #999;
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #e8f5e9;
    border-radius: 6px;
    border: 1px solid #4caf50;
}

.file-name {
    font-weight: 600;
    color: #333;
}

.file-status {
    color: #4caf50;
    font-size: 14px;
}

/* 内容区域 */
.content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
    position: relative;
}

/* 内容区域为空时的占位提示 */
.content-wrapper:empty::after {
    content: '📄 文档内容将在此显示';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ccc;
    font-size: 16px;
    text-align: center;
    pointer-events: none;
}

.line-numbers {
    width: 50px;
    background: linear-gradient(to right, #f5f5f5 0%, #f0f0f0 100%);
    color: #999;
    text-align: right;
    padding: 15px 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.8;
    overflow: hidden;
    user-select: none;
    border-right: 1px solid #e5e5e5;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.content-area {
    flex: 1;
    padding: 20px 25px;
    overflow-y: auto;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: white;
}

/* 内容区域空状态样式 */
.content-area:empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 50%, #fafafa 100%);
    position: relative;
}

.content-area:empty::before {
    content: '📑';
    font-size: 64px;
    opacity: 0.2;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0px);
    }
    50% {
        transform: translate(-50%, -50%) translateY(-10px);
    }
}

.content-area:empty::after {
    content: '等待文档加载...';
    color: #bbb;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
    position: absolute;
    top: calc(50% + 50px);
    left: 50%;
    transform: translateX(-50%);
}

/* 差异高亮样式 */
.diff-delete {
    background-color: #ffcdd2;
    text-decoration: line-through;
    color: #c62828;
}

.diff-insert {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.diff-replace {
    background-color: #fff9c4;
    color: #f57f17;
}

.diff-equal {
    background-color: transparent;
    color: #333;
}

/* 段落级差异样式 */
.diff-paragraph {
    padding: 12px;
    margin: 4px 0;
    border-radius: 6px;
    position: relative;
}

.diff-paragraph.deleted {
    background-color: #ffebee;
    border-left: 4px solid #e53935;
}

.diff-paragraph.inserted {
    background-color: #e8f5e9;
    border-left: 4px solid #43a047;
}

.diff-paragraph.equal {
    background-color: transparent;
}

/* 句子级差异样式 */
.diff-sentence {
    display: inline;
    padding: 2px 4px;
    margin: 0 2px;
    border-radius: 3px;
}

/* 加载动画 */
.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;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    margin-top: 20px;
    font-size: 16px;
}

/* 差异统计 */
.diff-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-weight: 600;
    color: #555;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 4px;
}

.stat-insert {
    background: #c8e6c9;
    color: #2e7d32;
}

.stat-delete {
    background: #ffcdd2;
    color: #c62828;
}

.stat-equal {
    background: #e0e0e0;
    color: #555;
}

/* 滚动条美化 */
.content-area::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

.content-area::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* AI 分析触发按钮 */
.ai-analyze-trigger {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.btn-ai-analyze {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-ai-analyze:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.btn-ai-analyze:active {
    transform: translateY(0);
}

.ai-icon {
    font-size: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* AI 分析结果面板 */
.ai-analysis-panel {
    background: white;
    border-top: 1px solid #e0e0e0;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header-ai {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
}

.panel-header-ai h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.collapse-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.collapse-icon {
    font-size: 14px;
}

.panel-body {
    padding: 0;
}

/* 标签页导航 */
.panel-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 20px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 25px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #10B981;
    background: rgba(16, 185, 129, 0.05);
}

.tab-btn.active {
    color: #10B981;
    border-bottom-color: #10B981;
    background: white;
}

.tab-icon {
    font-size: 18px;
}

/* 标签页内容 */
.tab-content {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

.tab-pane {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* AI 结果内容样式 */
.ai-result-content {
    line-height: 1.8;
    color: #333;
}

.ai-result-content h1 {
    font-size: 24px;
    color: #10B981;
    margin-bottom: 15px;
    border-bottom: 2px solid #10B981;
    padding-bottom: 10px;
}

.ai-result-content h2 {
    font-size: 20px;
    color: #059669;
    margin-top: 25px;
    margin-bottom: 12px;
}

.ai-result-content h3 {
    font-size: 17px;
    color: #555;
    margin-top: 20px;
    margin-bottom: 10px;
}

.ai-result-content p {
    margin-bottom: 12px;
    text-align: justify;
}

.ai-result-content ul {
    margin: 10px 0;
    padding-left: 25px;
}

.ai-result-content li {
    margin-bottom: 8px;
}

.ai-result-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e91e63;
}

.ai-result-content strong {
    color: #10B981;
    font-weight: 600;
}

/* 加载占位符 */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.loading-spinner-small {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(16, 185, 129, 0.2);
    border-top-color: #10B981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.loading-placeholder p {
    font-size: 14px;
    color: #999;
}

/* 错误消息 */
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #e53935;
}

.error-message p {
    font-size: 16px;
    margin-bottom: 20px;
}

.retry-btn {
    padding: 10px 24px;
    background: #10B981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #059669;
    transform: translateY(-2px);
}

/* 局部AI分析按钮样式 */
.diff-block-wrapper {
    position: relative;
    display: inline-block;
    margin: 2px 0;
}

.diff-paragraph-container {
    position: relative;
    margin: 8px 0;
    padding-right: 90px; /* 为按钮留出空间 */
}

.btn-ai-analyze-local {
    position: absolute;
    right: 5px;
    top: 8px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.diff-block-wrapper:hover .btn-ai-analyze-local,
.diff-paragraph-container:hover .btn-ai-analyze-local {
    opacity: 1;
}

.btn-ai-analyze-local:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6);
}

.btn-ai-analyze-local .ai-icon-mini {
    font-size: 16px;
}

.btn-ai-analyze-local .ai-text-mini {
    display: none;
}

/* 段落级按钮显示文字 */
.diff-paragraph-container .btn-ai-analyze-local {
    width: auto;
    padding: 8px 14px;
    border-radius: 18px;
    right: 10px;
}

.diff-paragraph-container .btn-ai-analyze-local .ai-text-mini {
    display: inline;
    font-size: 12px;
    margin-left: 4px;
}

/* 局部分析弹窗样式 */
.local-analysis-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.local-analysis-dialog {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.local-analysis-header {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.local-analysis-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.close-modal-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-modal-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.local-analysis-content {
    padding: 25px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.diff-preview {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #10B981;
}

.diff-preview strong {
    display: block;
    margin-bottom: 8px;
    color: #10B981;
}

.diff-text {
    padding: 10px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.diff-text.deleted {
    background-color: #ffebee;
    border-left: 3px solid #e53935;
}

.diff-text.inserted {
    background-color: #e8f5e9;
    border-left: 3px solid #43a047;
}

.analysis-result {
    margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .diff-container {
        flex-direction: column;
        height: auto;
    }
    
    .diff-panel {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .diff-panel:last-child {
        border-bottom: none;
    }
    
    .panel-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .tab-btn {
        white-space: nowrap;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .local-analysis-dialog {
        width: 95%;
        max-height: 90vh;
    }
    
    .btn-ai-analyze-local {
        opacity: 1;
        right: 5px;
    }
    
    .diff-paragraph-container {
        padding-right: 95px;
    }
}

