/* 数学公式编辑器专用样式 */

/* 工具栏 */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar-left {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
}

.tool-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.tool-btn:hover .latex-symbol,
.tool-btn:hover sup,
.tool-btn:hover sub {
    color: #ffffff !important;
}

.tool-btn .latex-symbol {
    font-size: 0.9rem;
    font-family: 'Times New Roman', serif;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn .latex-symbol sup,
.tool-btn .latex-symbol sub {
    font-size: 0.7em;
    line-height: 1;
}

#outputFormat {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    font-size: 0.875rem;
}

/* 编辑器容器 */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
}

@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
}

/* 面板通用样式 */
.editor-panel,
.preview-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* LaTeX输入区域 */
.latex-input {
    width: 100%;
    min-height: 250px;
    padding: 1rem;
    border: none;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-sizing: border-box;
}

.latex-input:focus {
    outline: none;
}

.latex-input::placeholder {
    color: var(--text-muted);
}

/* 错误提示 */
.error-message {
    padding: 0.5rem 1rem;
    background: #fef2f2;
    color: #dc2626;
    font-size: 0.875rem;
    display: none;
    border-top: 1px solid #fecaca;
}

/* 预览区域 */
.preview-area {
    min-height: 250px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.preview-placeholder p {
    margin: 0.5rem 0;
}

.preview-placeholder .placeholder-example {
    font-family: 'Consolas', monospace;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: inline-block;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

/* 公式模板区域 */
.templates-section {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.templates-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

#templateSearch {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    width: 200px;
    background: var(--bg-primary);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.template-item {
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.template-item:hover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.05);
}

.template-preview {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    text-align: center;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-preview .katex {
    font-size: 1.1rem;
}

.template-name {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

.template-code {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.25rem;
    word-break: break-all;
}

/* 输出代码区域 */
.output-section {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.output-header {
    margin-bottom: 0.75rem;
}

.output-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.output-code {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: #1e1e1e;
    color: #d4d4d4;
    resize: vertical;
    box-sizing: border-box;
}

.output-code:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 使用说明 */
.usage-guide {
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.usage-header {
    margin-bottom: 0.75rem;
}

.usage-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.usage-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.usage-item {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.usage-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.usage-item p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.usage-item code {
    padding: 0.125rem 0.375rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* KaTeX样式增强 */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 0;
}

/* 数学符号展示 */
.latex-symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
}

.latex-symbols span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-family: 'Times New Roman', serif;
}

/* 响应式调整 */
@media (max-width: 576px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left {
        justify-content: center;
    }
    
    .toolbar-right {
        justify-content: center;
    }
    
    .preview-actions {
        flex-wrap: wrap;
    }
    
    .templates-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    #templateSearch {
        width: 100%;
    }
}