/* ============================================================
 * Markdown 转 Word 工具样式
 * ============================================================ */

/* ========== 页面布局 ========== */
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ========== 页面标题区 ========== */
.md2word-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
    padding: 60px 1.5rem 0.8rem;
    text-align: center;
    color: white;
}

.header-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.header-content h1 i {
    margin-right: 0.4rem;
    opacity: 0.9;
}

.header-content p {
    font-size: 0.95rem;
    opacity: 0.85;
    margin: 0 0 0.8rem 0;
}

.header-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
}

.header-tags .tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.78rem;
    backdrop-filter: blur(4px);
}

.header-tags .tag.formula {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.4);
}

.header-tags .tag i {
    font-size: 0.7rem;
}

/* ========== 标题横幅 ========== */
.md2word-banner {
    margin-top: 60px;
    background: #3b82f6;
    padding: 14px 1.5rem;
    text-align: center;
}

.md2word-banner h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.md2word-banner h1 i {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* ========== 主内容区 ========== */
.md2word-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem 1.5rem;
    box-sizing: border-box;
}

/* ========== 工具栏 ========== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    gap: 0.5rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #f0f7ff;
}

.toolbar-btn:active {
    transform: scale(0.97);
}

.toolbar-btn i {
    font-size: 0.85rem;
}

.btn-export {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white !important;
    border: none !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-export:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.char-count {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-left: 0.25rem;
}

/* ========== 分屏面板 ========== */
.split-panel {
    flex: 1;
    display: flex;
    gap: 0;
    min-height: 500px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.panel-left, .panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    flex-shrink: 0;
}

.panel-header i {
    color: #3b82f6;
    font-size: 0.85rem;
}

/* 输入区 */
.md-input {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 1rem;
    font-size: 0.9rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, 'Courier New', monospace;
    line-height: 1.7;
    color: #1f2937;
    background: white;
    box-sizing: border-box;
}

.md-input::placeholder {
    color: #9ca3af;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 分隔线 */
.panel-divider {
    width: 6px;
    background: #e5e7eb;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    position: relative;
}

.panel-divider:hover,
.panel-divider.dragging {
    background: #3b82f6;
}

.divider-handle {
    color: #9ca3af;
    font-size: 0.7rem;
}

.panel-divider:hover .divider-handle,
.panel-divider.dragging .divider-handle {
    color: white;
}

/* 预览区 */
.md-preview {
    flex: 1;
    padding: 1rem 1.25rem;
    overflow-y: auto;
    color: #1f2937;
    line-height: 1.8;
    font-size: 0.92rem;
}

.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
}

.preview-empty i {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.preview-empty p {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========== 预览区 Markdown 排版样式 ========== */
.md-preview h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e5e7eb;
    color: #111827;
}

.md-preview h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.25rem 0 0.6rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;
}

.md-preview h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: #374151;
}

.md-preview h4, .md-preview h5, .md-preview h6 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0.8rem 0 0.4rem 0;
    color: #4b5563;
}

.md-preview p {
    margin: 0 0 0.7rem 0;
}

.md-preview ul, .md-preview ol {
    margin: 0.3rem 0 0.7rem 0;
    padding-left: 1.5rem;
}

.md-preview li {
    margin-bottom: 0.25rem;
}

.md-preview strong {
    font-weight: 600;
    color: #111827;
}

.md-preview em {
    font-style: italic;
    color: #4b5563;
}

.md-preview blockquote {
    margin: 0.5rem 0 0.7rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid #3b82f6;
    background: #f0f7ff;
    border-radius: 0 8px 8px 0;
    color: #374151;
}

.md-preview blockquote p {
    margin: 0;
}

.md-preview code {
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: #e11d48;
}

.md-preview pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0 0.7rem 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.md-preview pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

.md-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 0.7rem 0;
    font-size: 0.88rem;
}

.md-preview th, .md-preview td {
    border: 1px solid #d1d5db;
    padding: 0.45rem 0.75rem;
    text-align: left;
}

.md-preview th {
    background: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.md-preview tr:nth-child(even) {
    background: #f9fafb;
}

.md-preview hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1rem 0;
}

.md-preview a {
    color: #3b82f6;
    text-decoration: none;
}

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

.md-preview img {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5rem 0;
}

/* MathJax 公式样式调整 */
.md-preview .MathJax {
    font-size: 1.05em !important;
}

/* ========== 使用说明 ========== */
.usage-tips {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.usage-tips h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.8rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.usage-tips h3 i {
    color: #f59e0b;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.tip-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.tip-step {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tip-text strong {
    display: block;
    font-size: 0.9rem;
    color: #1f2937;
    margin-bottom: 0.2rem;
}

.tip-text p {
    margin: 0;
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.5;
}

/* ========== 导出中遮罩 ========== */
.export-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.export-overlay.show {
    display: flex;
}

.export-loading {
    background: white;
    padding: 2rem 2.5rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.export-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.export-loading p {
    color: #374151;
    font-size: 0.95rem;
    margin: 0;
}

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

/* ========== Footer 适配 ========== */
.footer {
    margin-top: auto;
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
    .md2word-header {
        padding: 60px 1rem 1rem;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .header-content p {
        font-size: 0.85rem;
    }

    .header-tags .tag {
        font-size: 0.72rem;
        padding: 0.2rem 0.5rem;
    }

    .md2word-main {
        padding: 0 0.75rem 1rem;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .split-panel {
        flex-direction: column;
        min-height: 600px;
    }

    .panel-left, .panel-right {
        flex: none;
        height: 300px;
    }

    .panel-divider {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .divider-handle {
        transform: rotate(90deg);
    }

    .tips-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header-tags {
        gap: 0.3rem;
    }

    .toolbar-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .toolbar-btn span {
        display: none;
    }

    .panel-left, .panel-right {
        height: 250px;
    }
}
