/**
 * Markdown转Word页面样式 (Modernized)
 */

.md2word-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 100px); /* Adjust based on navbar height */
    padding: 20px;
    background: #f0f2f5; /* Subtle modern gray background */
}

/* 面板通用样式 */
.editor-panel,
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #374151;
}

.panel-title i {
    font-size: 18px;
    color: #4f46e5; /* Primary indigo color */
}

.btn-help {
    margin-left: 12px;
    background: #e0e7ff;
    color: #4338ca;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.btn-help:hover {
    background: #c7d2fe;
}

/* Video Modal Styles */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.video-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.video-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.video-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #111827;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: #111827;
}

.video-modal-body {
    padding: 0;
    background: #000;
}

.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-action {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #f3f4f6;
    color: #1f2937;
    border-color: #d1d5db;
}

/* 编辑器区域 */
.editor-wrapper {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background: #fafafa;
}

.markdown-editor {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
    padding: 24px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 15px;
    line-height: 1.7;
    resize: none;
    outline: none;
    background: transparent;
    color: #374151;
}

.markdown-editor::placeholder {
    color: #9ca3af;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    font-size: 13px;
    color: #6b7280;
}

.char-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 底部操作按钮区 */
.action-buttons {
    display: flex;
    gap: 12px;
}

.btn-convert {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-convert:hover {
    background: #4338ca;
}

.btn-convert i {
    font-size: 15px;
}

/* 右侧header下载按钮 */
.btn-download-header {
    min-width: 34px;
    padding: 0 12px;
    height: 34px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 6px;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-download-header:hover:not(:disabled) {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.btn-download-header:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
}

.btn-download-header:disabled i {
    opacity: 0.5;
}

/* 预览区域 */
.preview-wrapper {
    flex: 1;
    padding: 24px 12px;
    overflow: auto;
    background: #f3f4f6; /* Gray background to make the paper pop */
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.word-preview {
    width: 100%;
    max-width: 900px; /* Increased from 820px to widen the preview area */
    min-height: 1050px; 
    padding: 40px 20px; /* Reduced side padding */
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: '微软雅黑', 'Microsoft YaHei', sans-serif;
    font-size: 12pt;
    line-height: 1.8;
    color: #333;
    border-radius: 2px;
}

/* Word预览内容样式 */
.word-preview h1 {
    font-size: 22pt;
    font-weight: bold;
    margin: 24px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
    color: #111827;
}

.word-preview h2 {
    font-size: 16pt;
    font-weight: bold;
    margin: 20px 0 12px 0;
    color: #1f2937;
}

.word-preview h3 {
    font-size: 14pt;
    font-weight: bold;
    margin: 16px 0 10px 0;
    color: #374151;
}

.word-preview h4,
.word-preview h5,
.word-preview h6 {
    font-size: 12pt;
    font-weight: bold;
    margin: 14px 0 8px 0;
    color: #4b5563;
}

.word-preview p {
    margin: 0 0 12px 0;
    text-indent: 2em;
}

.word-preview ul,
.word-preview ol {
    margin: 12px 0;
    padding-left: 2em;
}

.word-preview li {
    margin: 6px 0;
}

.word-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 10.5pt;
}

.word-preview th,
.word-preview td {
    border: 1px solid #d1d5db;
    padding: 10px 14px;
    text-align: left;
}

.word-preview th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.word-preview blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid #4f46e5;
    background: #f9fafb;
    color: #4b5563;
    border-radius: 0 4px 4px 0;
}

.word-preview pre {
    margin: 16px 0;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 10pt;
    line-height: 1.6;
}

.word-preview code {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 10pt;
    background: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
    color: #0f172a;
}

.word-preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.word-preview hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

.word-preview strong {
    font-weight: 600;
    color: #111827;
}

.word-preview em {
    font-style: italic;
}

.word-preview del {
    text-decoration: line-through;
    color: #9ca3af;
}

/* 空状态 */
.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: #9ca3af;
    text-align: center;
}

.preview-empty i {
    font-size: 56px;
    margin-bottom: 16px;
    color: #d1d5db;
}

.preview-empty p {
    margin: 8px 0;
    text-indent: 0;
    font-size: 15px;
}

.preview-hint {
    font-size: 13px;
    color: #d1d5db;
}

/* 字体选择器 */
.mode-select,
.font-select,
.font-size-select {
    padding: 6px 30px 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background-color: #fff;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 6px center;
    background-repeat: no-repeat;
    background-size: 16px 16px;
    transition: border-color 0.2s;
}

.mode-select:hover,
.font-select:hover,
.font-size-select:hover {
    border-color: #d1d5db;
}

.mode-select:focus,
.font-select:focus,
.font-size-select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.mode-select {
    background-color: #fdf4ff;
    border-color: #f5d0fe;
    color: #a21caf;
    font-weight: 500;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a21caf' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

.mode-select:hover {
    background-color: #fae8ff;
    border-color: #e879f9;
}

.font-select:disabled,
.font-size-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f9fafb;
}

/* 公文模式预览样式 */
.word-preview.official-mode {
    font-family: '仿宋', FangSong, serif;
    font-size: 16pt;
    line-height: 28pt;
}

.word-preview .official-title {
    font-family: '黑体', SimHei, sans-serif;
    font-size: 22pt;
    font-weight: bold;
    text-align: center;
    text-indent: 0;
    margin: 0 0 28pt 0;
    color: #000;
    border-bottom: none;
}

.word-preview .official-h1 {
    font-family: '黑体', SimHei, sans-serif;
    font-size: 16pt;
    font-weight: normal;
    text-indent: 2em;
    margin: 0;
    color: #000;
    border-bottom: none;
}

.word-preview .official-h2 {
    font-family: '楷体', KaiTi, serif;
    font-size: 16pt;
    font-weight: normal;
    text-indent: 2em;
    margin: 0;
    color: #000;
}

.word-preview .official-h3 {
    font-family: '仿宋', FangSong, serif;
    font-size: 16pt;
    font-weight: bold;
    text-indent: 2em;
    margin: 0;
    color: #000;
}

.word-preview .official-h4 {
    font-family: '仿宋', FangSong, serif;
    font-size: 16pt;
    font-weight: normal;
    text-indent: 2em;
    margin: 0;
    color: #000;
}

.word-preview .official-p {
    font-family: '仿宋', FangSong, serif;
    font-size: 16pt;
    text-indent: 2em;
    text-align: justify;
    margin: 0;
    color: #000;
}

.word-preview .official-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14pt 0;
    font-family: '仿宋', FangSong, serif;
    font-size: 14pt;
}

.word-preview .official-table th,
.word-preview .official-table td {
    border: 1px solid #000;
    padding: 6pt 8pt;
    text-align: left;
    color: #000;
    font-weight: normal;
    text-indent: 0;
}

.word-preview .official-table th {
    background: #F0F0F0;
    font-family: '黑体', SimHei, sans-serif;
    text-align: center;
}

.word-preview .official-list {
    font-family: '仿宋', FangSong, serif;
    font-size: 16pt;
    margin: 0;
    padding-left: 2em;
    color: #000;
}

.word-preview .official-list li {
    text-indent: 0;
    margin: 0;
}

/* 响应式 */
@media (max-width: 1200px) {
    .md2word-container {
        flex-direction: column;
        height: auto;
    }

    .editor-panel,
    .preview-panel {
        min-height: 500px;
    }

    .word-preview {
        padding: 20px 12px; /* Even less padding on smaller screens */
    }

    .action-panel {
        flex-direction: row;
        justify-content: center;
        padding: 10px 0;
    }

    .btn-convert,
    .btn-download {
        flex-direction: row;
        padding: 10px 20px;
    }
}

@media (max-width: 768px) {
    /* 针对手机屏幕进一步优化转Word页面的padding */
    .page-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .md2word-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        gap: 2;
    }
    
    .editor-panel,
    .preview-panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .preview-wrapper {
        padding: 12px 0;
    }
}

/* 加载状态 */
.btn-convert.loading,
.btn-download.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-convert.loading i,
.btn-download.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
