/* 自定义样式 */

/* 侧边栏链接激活状态 */
.sidebar-link.active {
    background-color: #e0f2fe;
    color: #0369a1;
}

.dark .sidebar-link.active {
    background-color: #1e3a5f;
    color: #7dd3fc;
}

/* 卡片悬停效果 */
.tool-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Markdown编辑器样式 */
.markdown-editor {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.6;
    tab-size: 4;
}

/* Markdown预览样式 */
.markdown-preview h1 {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #e5e7eb;
}

.markdown-preview h2 {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #e5e7eb;
}

.markdown-preview h3 {
    font-size: 1.25em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.markdown-preview h4 {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.markdown-preview h5, .markdown-preview h6 {
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.markdown-preview p {
    margin-bottom: 1em;
}

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

.markdown-preview ul {
    list-style-type: disc;
}

.markdown-preview ol {
    list-style-type: decimal;
}

.markdown-preview li {
    margin-bottom: 0.25em;
}

.markdown-preview blockquote {
    border-left: 4px solid #d1d5db;
    padding-left: 1em;
    margin-bottom: 1em;
    color: #6b7280;
    font-style: italic;
}

.markdown-preview pre {
    background-color: #f3f4f6;
    border-radius: 0.375rem;
    padding: 1em;
    margin-bottom: 1em;
    overflow-x: auto;
}

.markdown-preview code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875em;
    background-color: #f3f4f6;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
}

.markdown-preview pre code {
    background-color: transparent;
    padding: 0;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
}

.markdown-preview a {
    color: #0ea5e9;
    text-decoration: underline;
}

.markdown-preview a:hover {
    color: #0284c7;
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 2em 0;
}

.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.markdown-preview th, .markdown-preview td {
    border: 1px solid #d1d5db;
    padding: 0.5em 0.75em;
    text-align: left;
}

.markdown-preview th {
    background-color: #f9fafb;
    font-weight: 600;
}

/* TOC目录样式 */
.toc {
    max-height: 300px;
    overflow-y: auto;
}

.toc a {
    color: #374151;
    text-decoration: none;
}

.dark .toc a {
    color: #d1d5db;
}

.toc a:hover {
    color: #0ea5e9;
}

.toc ul {
    list-style-type: none;
    padding-left: 1em;
}

.toc > ul {
    padding-left: 0;
}

.toc li {
    margin-bottom: 0.25em;
}

/* 图片预览样式 */
.image-preview {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* 拖放区域样式 */
.drop-zone {
    border: 2px dashed #d1d5db;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    border-color: #0ea5e9;
    background-color: #f0f9ff;
}

.dark .drop-zone {
    border-color: #4b5563;
}

.dark .drop-zone.drag-over {
    border-color: #38bdf8;
    background-color: #0c4a6e;
}

/* 按钮样式 */
.btn-primary {
    background-color: #0ea5e9;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #0284c7;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* 滚动条样式 */
::-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: #a1a1a1;
}

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: #6b7280;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .markdown-editor-container {
        flex-direction: column;
    }
    
    .markdown-editor, .markdown-preview-container {
        width: 100% !important;
        height: 300px;
    }
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* 错误提示样式 */
.error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.dark .error-message {
    background-color: #451a1a;
    border-color: #7f1d1d;
    color: #fecaca;
}

/* 成功提示样式 */
.success-message {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.dark .success-message {
    background-color: #052e16;
    border-color: #14532d;
    color: #bbf7d0;
}

/* 返回顶部按钮 */
#back-to-top {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

#back-to-top:hover {
    transform: translateY(-2px);
}

#back-to-top:active {
    transform: translateY(0);
}

/* LED 全屏大字 - 闪烁动画 */
@keyframes led-blink-anim {
    0% { opacity: 1; }
    50% { opacity: 0.1; }
    100% { opacity: 1; }
}

/* ============== EPUB/HTML预览样式 ============== */
#preview-text h1,
#preview-text .epub-title {
    font-size: 1.75em;
    font-weight: 700;
    margin: 1em 0 0.5em 0;
    padding-bottom: 0.3em;
    border-bottom: 2px solid #e5e7eb;
    color: #1f2937;
}

#preview-text h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.8em 0 0.4em 0;
    color: #374151;
}

#preview-text h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 0.6em 0 0.3em 0;
    color: #4b5563;
}

#preview-text h4,
#preview-text h5,
#preview-text h6 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0.5em 0 0.3em 0;
    color: #6b7280;
}

#preview-text p {
    margin: 0.6em 0;
    line-height: 1.8;
    text-align: justify;
}

#preview-text .epub-chapter {
    margin-bottom: 2em;
    padding-bottom: 1em;
    border-bottom: 1px dashed #d1d5db;
}

#preview-text .epub-author {
    color: #6b7280;
    font-style: italic;
    margin-top: 1em;
}

#preview-text ul,
#preview-text ol {
    margin: 0.6em 0;
    padding-left: 2em;
}

#preview-text ul {
    list-style-type: disc;
}

#preview-text ol {
    list-style-type: decimal;
}

#preview-text li {
    margin: 0.3em 0;
    line-height: 1.6;
}

#preview-text blockquote {
    border-left: 4px solid #d1d5db;
    padding: 0.5em 1em;
    margin: 0.8em 0;
    background-color: #f9fafb;
    color: #4b5563;
    font-style: italic;
}

#preview-text pre {
    background-color: #f3f4f6;
    border-radius: 0.5em;
    padding: 1em;
    margin: 0.8em 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

#preview-text code {
    background-color: #f3f4f6;
    padding: 0.15em 0.4em;
    border-radius: 0.25em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

#preview-text pre code {
    background-color: transparent;
    padding: 0;
}

#preview-text a {
    color: #0ea5e9;
    text-decoration: underline;
}

#preview-text a:hover {
    color: #0284c7;
}

#preview-text img {
    max-width: 100%;
    height: auto;
    margin: 1em 0;
    border-radius: 0.5em;
}

#preview-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

#preview-text th,
#preview-text td {
    border: 1px solid #d1d5db;
    padding: 0.5em 0.75em;
    text-align: left;
}

#preview-text th {
    background-color: #f3f4f6;
    font-weight: 600;
}

#preview-text hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5em 0;
}

.dark #preview-text h1,
.dark #preview-text .epub-title {
    border-bottom-color: #4b5563;
    color: #f9fafb;
}

.dark #preview-text h2,
.dark #preview-text h3 {
    color: #e5e7eb;
}

.dark #preview-text h4,
.dark #preview-text h5,
.dark #preview-text h6 {
    color: #d1d5db;
}

.dark #preview-text p {
    color: #e5e7eb;
}

.dark #preview-text .epub-chapter {
    border-bottom-color: #4b5563;
}

.dark #preview-text .epub-author {
    color: #9ca3af;
}

.dark #preview-text blockquote {
    border-left-color: #4b5563;
    background-color: #1f2937;
    color: #d1d5db;
}

.dark #preview-text pre {
    background-color: #1f2937;
}

.dark #preview-text code {
    background-color: #1f2937;
    color: #e5e7eb;
}

.dark #preview-text th,
.dark #preview-text td {
    border-color: #4b5563;
}

.dark #preview-text th {
    background-color: #374151;
}

/* ============== Markdown语法说明面板 ============== */
.syntax-panel {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dark .syntax-panel {
    background-color: #1f2937;
    border-color: #374151;
}

.syntax-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.dark .syntax-panel-header {
    border-color: #374151;
}

.syntax-panel-body {
    padding: 1rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.syntax-group {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.dark .syntax-group {
    background-color: #111827;
    border-color: #374151;
}

.syntax-group h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.dark .syntax-group h4 {
    color: #d1d5db;
}

.syntax-group pre {
    background-color: #f3f4f6;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.5;
    overflow-x: auto;
    margin: 0;
}

.dark .syntax-group pre {
    background-color: #1f2937;
}

.syntax-group pre code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #374151;
    background: transparent;
    padding: 0;
}

.dark .syntax-group pre code {
    color: #d1d5db;
}

/* ============== 预览区主题样式 ============== */

/* 默认主题 */
.preview-theme-default {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* GitHub风格 */
.preview-theme-github {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #24292f;
    word-wrap: break-word;
}

.preview-theme-github h1 {
    font-size: 2em;
    border-bottom: 1px solid #d0d7de;
    padding-bottom: 0.3em;
    color: #1f2328;
}

.preview-theme-github h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #d0d7de;
    padding-bottom: 0.3em;
    color: #1f2328;
}

.preview-theme-github h3 {
    font-size: 1.25em;
    color: #1f2328;
}

.preview-theme-github p {
    margin-bottom: 16px;
}

.preview-theme-github code {
    background-color: rgba(175, 184, 193, 0.2);
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-size: 85%;
}

.preview-theme-github pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 16px;
    overflow: auto;
    border: 1px solid #d0d7de;
}

.preview-theme-github pre code {
    background-color: transparent;
    padding: 0;
}

.preview-theme-github blockquote {
    border-left: 4px solid #d0d7de;
    padding: 0 16px;
    color: #656d76;
    margin: 0 0 16px 0;
}

.preview-theme-github a {
    color: #0969da;
    text-decoration: none;
}

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

.preview-theme-github table {
    border-spacing: 0;
    border-collapse: collapse;
}

.preview-theme-github th, .preview-theme-github td {
    padding: 6px 13px;
    border: 1px solid #d0d7de;
}

.preview-theme-github th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.preview-theme-github hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #d0d7de;
    border: 0;
}

/* Notion风格 */
.preview-theme-notion {
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    line-height: 1.5;
    color: #37352f;
    max-width: 100%;
}

.preview-theme-notion h1 {
    font-size: 1.875em;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: #37352f;
    border-bottom: none;
}

.preview-theme-notion h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #37352f;
    border-bottom: none;
}

.preview-theme-notion h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #37352f;
}

.preview-theme-notion p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.preview-theme-notion ul, .preview-theme-notion ol {
    padding-left: 1.5em;
    margin-bottom: 0.75rem;
}

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

.preview-theme-notion code {
    background-color: #f1f1ef;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 85%;
    color: #eb5757;
}

.preview-theme-notion pre {
    background-color: #f7f6f3;
    border-radius: 4px;
    padding: 16px;
    overflow: auto;
    border: 1px solid #e3e2de;
}

.preview-theme-notion pre code {
    background-color: transparent;
    color: #37352f;
    padding: 0;
}

.preview-theme-notion blockquote {
    border-left: 3px solid #37352f;
    padding-left: 1em;
    color: #37352f;
    margin: 0 0 0.75rem 0;
    opacity: 0.9;
}

.preview-theme-notion a {
    color: #2eaadc;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.preview-theme-notion table {
    width: 100%;
    border-collapse: collapse;
}

.preview-theme-notion th, .preview-theme-notion td {
    padding: 0.5em 0.75em;
    border: 1px solid #e3e2de;
    text-align: left;
}

.preview-theme-notion th {
    background-color: #f7f6f3;
    font-weight: 600;
}

.preview-theme-notion hr {
    border: none;
    border-top: 1px solid #e3e2de;
    margin: 1.5em 0;
}

/* 打字机风格 */
.preview-theme-typewriter {
    font-family: 'Courier New', Courier, 'Noto Serif', Georgia, serif;
    line-height: 1.8;
    color: #2c2c2c;
    background-color: #faf8f5;
    padding: 2rem;
    border-radius: 0.5rem;
}

.preview-theme-typewriter h1 {
    font-size: 1.75em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1em;
    border-bottom: 2px solid #2c2c2c;
    padding-bottom: 0.5em;
    letter-spacing: 0.05em;
}

.preview-theme-typewriter h2 {
    font-size: 1.4em;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid #999;
    padding-bottom: 0.3em;
}

.preview-theme-typewriter h3 {
    font-size: 1.2em;
    font-weight: 700;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.preview-theme-typewriter p {
    margin-bottom: 1em;
    text-align: justify;
}

.preview-theme-typewriter code {
    background-color: #eee;
    padding: 0.15em 0.4em;
    border-radius: 2px;
    font-size: 90%;
    border: 1px solid #ddd;
}

.preview-theme-typewriter pre {
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 2px;
    padding: 1em;
    overflow: auto;
}

.preview-theme-typewriter pre code {
    background-color: transparent;
    border: none;
    padding: 0;
}

.preview-theme-typewriter blockquote {
    border-left: 3px solid #2c2c2c;
    padding-left: 1em;
    font-style: italic;
    color: #555;
    margin: 1em 0;
}

.preview-theme-typewriter a {
    color: #2c2c2c;
    text-decoration: underline;
    text-decoration-style: dashed;
}

.preview-theme-typewriter table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.preview-theme-typewriter th, .preview-theme-typewriter td {
    border: 1px solid #999;
    padding: 0.5em 0.75em;
    text-align: left;
}

.preview-theme-typewriter th {
    background-color: #ddd;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}

.preview-theme-typewriter hr {
    border: none;
    text-align: center;
    margin: 2em 0;
}

.preview-theme-typewriter hr::after {
    content: '* * *';
    color: #999;
    letter-spacing: 0.5em;
}

/* 优雅风格 */
.preview-theme-elegant {
    font-family: 'Georgia', 'Times New Roman', 'Noto Serif', serif;
    line-height: 1.8;
    color: #4a4a4a;
    max-width: 100%;
}

.preview-theme-elegant h1 {
    font-size: 2em;
    font-weight: 400;
    color: #2c3e50;
    margin-bottom: 0.75em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.4em;
    letter-spacing: 0.02em;
}

.preview-theme-elegant h2 {
    font-size: 1.6em;
    font-weight: 400;
    color: #2c3e50;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 0.3em;
}

.preview-theme-elegant h3 {
    font-size: 1.3em;
    font-weight: 600;
    color: #34495e;
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}

.preview-theme-elegant p {
    margin-bottom: 1.2em;
    text-align: justify;
    text-indent: 2em;
}

.preview-theme-elegant ul, .preview-theme-elegant ol {
    padding-left: 2em;
    margin-bottom: 1.2em;
}

.preview-theme-elegant li {
    margin-bottom: 0.4em;
}

.preview-theme-elegant code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    background-color: #f0f0f0;
    padding: 0.2em 0.5em;
    border-radius: 3px;
    font-size: 85%;
    color: #c0392b;
}

.preview-theme-elegant pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    border-radius: 6px;
    padding: 1.2em;
    overflow: auto;
    margin: 1.5em 0;
}

.preview-theme-elegant pre code {
    background-color: transparent;
    color: #f8f8f2;
    padding: 0;
}

.preview-theme-elegant blockquote {
    border-left: 4px solid #3498db;
    background-color: #ecf0f1;
    padding: 1em 1.5em;
    margin: 1.5em 0;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: #555;
}

.preview-theme-elegant a {
    color: #3498db;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.2s ease;
}

.preview-theme-elegant a:hover {
    border-bottom-color: #3498db;
}

.preview-theme-elegant table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}

.preview-theme-elegant th, .preview-theme-elegant td {
    padding: 0.75em 1em;
    border: 1px solid #ddd;
    text-align: left;
}

.preview-theme-elegant th {
    background-color: #3498db;
    color: white;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.preview-theme-elegant tr:nth-child(even) {
    background-color: #f9f9f9;
}

.preview-theme-elegant hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #3498db, transparent);
    margin: 2em 0;
}