/* style.css */
:root {
    --primary-color: #4a90e2;
    --success-color: #50c878;
    --warning-color: #ffa500;
    --danger-color: #ff4757;
    --bg-color: #f8f9fa;
    --text-color: #333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 2px solid #eee;
}

.header h1 {
    margin: 0;
    color: var(--primary-color);
    font-weight: 600;
}

.controls {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.success {
    background: var(--success-color);
    color: white;
}

.btn.warning {
    background: var(--warning-color);
    color: white;
}

.btn.danger {
    background: var(--danger-color);
    color: white;
}

.btn:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    height: 80vh;
}

#markdown_input {
    min-width: 200px;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: none;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color 0.2s;
}

#markdown_input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.preview-area {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.preview-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

/* 代码块样式 */
pre {
    position: relative;
    background: #f8f8f8;
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    border: 1px solid #e0e0e0;
}

pre code {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 表格样式 */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

th, td {
    padding: 0.75rem;
    border: 1px solid #eee;
    text-align: left;
}

th {
    background: #f8f9fa;
    font-weight: 600;
}

img {
    max-width: 100%;
    border-radius: 4px;
    margin: 1rem 0;
}

/* 错误弹窗样式 */
.error-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fff;
    border: 1px solid var(--danger-color);
    border-radius: 8px;
    padding: 1rem;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    min-width: 300px;
}

.error-popup .error-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.error-popup .error-message {
    color: var(--danger-color);
    font-size: 16px;
    flex-grow: 1;
    margin-right: 0.5rem;
}

.error-popup .error-close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--danger-color);
}

/* 支持开发者容器 */
.sponsor-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

/* 主按钮样式 */
.sponsor-main-btn {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    color: #946ce6;
    font-weight: 500;
    gap: 8px;
}

.sponsor-main-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.dropdown-arrow {
    transition: transform 0.2s;
}

/* 修复hover效果 */
.sponsor-btn.with-dropdown {
    position: relative;
    transition: none;
}

.sponsor-btn.with-dropdown:hover {
    transform: none;
    box-shadow: none;
}

/* 下拉菜单 */
.dropdown-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 8px 0;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 显示状态 */
.with-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.with-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* 菜单项样式 */
.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
    gap: 12px;
}

.menu-item:hover {
    background: #f8f9fa;
}

.menu-icon {
    flex-shrink: 0;
}

/* 友情链接容器 */
.friend-links-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 1000;
}

.friend-links-btn {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    color: #4A90E2;
    font-weight: 500;
    gap: 8px;
}

.friend-links-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.friend-links-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 8px 0;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.friend-links.with-dropdown.active .friend-links-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
        gap: 1rem;
    }

    #markdown_input {
        height: 300px;
        font-size: 16px;
    }

    .preview-area {
        min-height: 400px;
        overflow-y: auto;
        margin-bottom: 60px;
    }

    .controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .export-btns {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        width: 100%;
    }

    .btn {
        width: 100%;
        padding: 0.8rem;
        font-size: 14px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .error-popup {
        top: 10px;
        padding: 0.75rem;
        min-width: unset;
        width: 90%;
    }

    .error-popup .error-message {
        font-size: 14px;
    }

    .error-popup .error-close-btn {
        font-size: 18px;
    }

    .sponsor-container,
    .friend-links-container {
        bottom: 15px;
        right: 15px;
    }

    .sponsor-main-btn,
    .friend-links-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    .dropdown-menu,
    .friend-links-menu {
        min-width: 200px;
    }

    .menu-item {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    #markdown_input {
        height: 250px;
    }

    .preview-area {
        min-height: 350px;
    }

    .export-btns {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 0.7rem;
        font-size: 13px;
    }

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

    .preview-header h3 {
        font-size: 1.1rem;
    }

    .dropdown-menu,
    .friend-links-menu {
        right: auto;
        left: 0;
        min-width: 280px;
    }

    .friend-links-container {
        bottom: 80px;
    }
}