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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* 容器布局 */
.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 工具栏样式 */
.toolbar {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
}

.toolbar h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
}

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

/* 导入组样式 */
.import-group {
    position: relative;
    display: inline-block;
}

.import-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 180px;
    display: none;
    margin-top: 4px;
}

.import-dropdown.show {
    display: block;
}

.import-option {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #495057;
    transition: background-color 0.2s ease;
}

.import-option:hover {
    background: #f8f9fa;
}

.import-option:first-child {
    border-radius: 6px 6px 0 0;
}

.import-option:last-child {
    border-radius: 0 0 6px 6px;
}

.import-option .icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* 按钮样式 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

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

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

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

.btn-secondary:hover {
    background: #545b62;
}

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

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* 编辑器容器 */
.editor-container {
    flex: 1;
    display: flex;
    height: calc(100vh - 80px);
}

/* 面板样式 */
.editor-panel, .preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid #e9ecef;
}

.preview-panel {
    border-right: none;
}

.panel-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #495057;
}

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

/* 编辑器文本区域 */
#editor {
    flex: 1;
    border: none;
    outline: none;
    padding: 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    background: #fafbfc;
    color: #24292e;
}

#editor:focus {
    background: white;
}

/* 预览内容 */
.preview-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: white;
}

/* Markdown 内容样式 */
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    color: #2c3e50;
}

.preview-content h1 {
    font-size: 2rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.preview-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.3rem;
}

.preview-content h3 {
    font-size: 1.25rem;
}

.preview-content p {
    margin-bottom: 1rem;
}

.preview-content ul,
.preview-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

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

.preview-content blockquote {
    margin: 1rem 0;
    padding: 0 1rem;
    color: #6a737d;
    border-left: 4px solid #dfe2e5;
    background: #f6f8fa;
}

.preview-content code {
    background: #f6f8fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85em;
    color: #e83e8c;
}

.preview-content pre {
    background: #f6f8fa;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
}

.preview-content pre code {
    background: none;
    padding: 0;
    color: #24292e;
}

.preview-content table {
    border-collapse: collapse;
    margin: 1rem 0;
    width: 100%;
}

.preview-content th,
.preview-content td {
    border: 1px solid #dfe2e5;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.preview-content th {
    background: #f6f8fa;
    font-weight: 600;
}

.preview-content a {
    color: #0366d6;
    text-decoration: none;
}

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

.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1rem 0;
}

.preview-content hr {
    border: none;
    height: 1px;
    background: #e9ecef;
    margin: 2rem 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    
    .editor-panel,
    .preview-panel {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .preview-panel {
        border-bottom: none;
    }
    
    .toolbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .toolbar-right {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* 隐藏预览时的样式 */
.preview-hidden .preview-panel {
    display: none;
}

.preview-hidden .editor-panel {
    border-right: none;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 加载状态 */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 消息提示 */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
    word-wrap: break-word;
}

.message-success {
    background: #28a745;
}

.message-error {
    background: #dc3545;
}

.message-info {
    background: #17a2b8;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #495057;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body input,
.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    margin-bottom: 1rem;
    transition: border-color 0.2s ease;
}

.modal-body input:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.modal-body textarea {
    resize: vertical;
    min-height: 120px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

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

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