﻿* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft Yahei", sans-serif;
    background: radial-gradient(circle at 20% 20%, #ecf3ff, #f7f8ff 40%, #f5f5f7 100%);
    color: #0f172a;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #111827, #1f2937);
    color: #f9fafb;
    gap: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.header input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.12);
    color: #f9fafb;
    outline: none;
    transition: border 0.2s, background 0.2s;
}

.header input[type="text"]:focus {
    border-color: #93c5fd;
    background: rgba(255,255,255,0.18);
}

.header button {
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(79,70,229,0.35);
}

.main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 260px;
    padding: 16px;
    border-right: 1px solid rgba(15,23,42,0.06);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    overflow-y: auto;
    box-shadow: inset -1px 0 0 rgba(15,23,42,0.05);
    border-radius: 0 16px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar h2 {
    margin: 6px 0 4px 0;
    font-size: 13px;
    color: #6b7280;
    letter-spacing: 0.3px;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-list li {
    padding: 0;
}

.tree-item {
    position: relative;
    padding-left: 0;
}

.tree-item > ul {
    list-style: none;
    padding-left: 20px;
    margin: 2px 0 0 0;
    position: relative;
}

/* 收起状态：隐藏子列表 */
.tree-item > ul.collapsed {
    display: none;
}

/* 隐藏所有树形连接线 */
.tree-item::before {
    display: none;
}

.tree-item > ul::before {
    display: none;
}

/* 确保 tree-row 在连线上方 */
.tree-row {
    position: relative;
    z-index: 1;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: background 0.15s ease;
}

.tree-row:hover {
    background: rgba(239, 246, 255, 0.6);
}

.tree-row.selected {
    background: rgba(239, 246, 255, 0.8);
}

.tree-row.selected .tree-name {
    color: #2563eb;
    font-weight: 600;
}

.tree-row.selected .tree-folder-icon {
    color: #2563eb;
}

.tree-toggle {
    width: 14px;
    font-size: 12px;
    color: #6b7280;
    user-select: none;
    cursor: pointer;
    transition: color 0.2s;
}

.tree-toggle:hover {
    color: #ff0000;
}

.tree-spacer {
    width: 14px;
}

.tree-folder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    flex-shrink: 0;
    margin-right: 2px;
}

.tree-folder-icon svg {
    width: 16px;
    height: 16px;
}

.tree-name {
    font-size: 13px;
    color: #0f172a;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
}

/* 分类选择器弹窗中的树形结构交互 */
#categorySelectorTree .tree-name {
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

#categorySelectorTree .tree-name:hover {
    background: #eef2ff;
    color: #2563eb;
}

#categorySelectorTree .tree-row {
    padding: 4px 0;
}

.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    border: 1px solid rgba(79,70,229,0.25);
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    color: #1f2937;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.chip:hover {
    border-color: rgba(79,70,229,0.5);
}

.content {
    flex: 1;
    display: flex;
    padding: 12px;
    gap: 12px;
    overflow: hidden;
    flex-direction: column;
}

.toolbar-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(15,23,42,0.05);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 12px 30px rgba(15,23,42,0.06);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.toolbar-group.stats {
    gap: 10px;
    justify-content: flex-end;
}

.stat-card {
    padding: 8px 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    border: 1px solid rgba(79,70,229,0.2);
    min-width: 80px;
}

.stat-label {
    font-size: 11px;
    color: #6b7280;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.article-list {
    width: 100%;
    overflow-y: auto;
    background: transparent;
    border: none;
    padding: 4px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.article-item {
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.05);
    box-shadow: 0 12px 24px rgba(15,23,42,0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.article-item:hover {
    background: #f4f6ff;
    box-shadow: 0 16px 28px rgba(15,23,42,0.08);
}

.article-item-title {
    font-weight: 700;
    font-size: 15px;
    color: #0f172a;
    letter-spacing: 0.1px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-item-category-path {
    font-size: 9px;
    color: #000000;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
    opacity: 0.7;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-item-update-time {
    font-size: 9px;
    color: #000000;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0.6;
    line-height: 1.2;
}

.article-item-meta {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.editor input[type="text"] {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.editor textarea {
    flex: 1;
    resize: vertical;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    min-height: 160px;
}

/* Markdown 编辑器整体高度约束，防止拖拽超出视口 */
.markdown-editor-layout {
    flex: 1;
    min-height: 0;
    max-height: 75vh; /* 避免拖动 splitter 时整体过高 */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Markdown 编辑器内的 textarea 可拖拽高度 */
.markdown-editor-layout textarea.form-control {
    resize: vertical;
    min-height: 200px;
    flex: 1;
    height: auto;
    max-height: 55vh; /* 限制源码框高度，防止被拖到看不见底部 */
    overflow: auto;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 8px;
    margin-top: 8px;
    padding-bottom: 8px;
}

.editor-actions button {
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.editor-actions #btnSave {
    background: linear-gradient(135deg, #10b981, #0ea571);
    color: #fff;
    box-shadow: 0 10px 20px rgba(16,185,129,0.25);
}

.editor-actions #btnCancel {
    background: #e5e7eb;
    color: #374151;
}

.tag-cloud span {
    display: inline-block;
    margin: 4px 6px 4px 0;
    padding: 4px 10px;
    border-radius: 9999px;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    font-size: 12px;
    cursor: pointer;
    color: #1f2937;
    border: 1px solid rgba(79,70,229,0.15);
}

.tag-cloud span:hover {
    background: #dbeafe;
    border-color: rgba(79,70,229,0.35);
}

.hidden {
    display: none;
}

/* 简单弹窗样式 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    width: min(900px, 92vw);
    max-height: 90vh;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15,23,42,0.16);
    padding: 24px;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 85vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.modal-header h3 {
    margin: 0;
    flex: 1;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header button {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-actions .icon-btn {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(79,70,229,0.2);
    background: #eef2ff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-actions .icon-btn.hidden {
    display: none !important;
}

.modal-actions .icon-btn:hover {
    background: #dbeafe;
}

.modal-actions .icon-btn svg {
    width: 16px;
    height: 16px;
}

.modal-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
}

.modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#modalEditor {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

#modalEditor.hidden {
    display: none;
}

.markdown-preview-content.hidden {
    display: none;
}

.modal-content.fullscreen {
    width: 100vw;
    height: 85vh;
    max-height: none;
}

/* 全局滚动条优化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-thumb {
    background: rgba(15,23,42,0.16);
    border-radius: 999px;
}
::-webkit-scrollbar-track {
    background: transparent;
}


/* ========== Admin UI Enhancements ========== */
.admin-content {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-nav li {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-weight: 600;
}

.admin-nav li.active,
.admin-nav li:hover {
    background: #eef2ff;
    color: #1f2937;
}

.panel {
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 18px 36px rgba(15,23,42,0.08);
}

.panel.muted {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.admin-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-toolbar input,
.admin-toolbar select {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    font-size: 13px;
}

.admin-toolbar button {
    padding: 3px 3px;
    border-radius: 6px;
    border: 1px solid rgba(79,70,229,0.2);
    background: #ffffff;
    cursor: pointer;
    font-weight: 600;
}

.admin-toolbar button.primary {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    border: none;
    box-shadow: 0 12px 28px rgba(79,70,229,0.3);
}

.admin-toolbar button.secondary {
    background: #f8fafc;
    color: #4b5563;
    border: 1px solid rgba(79,70,229,0.15);
    font-size: 12px;
    padding: 6px 10px;
}

.admin-toolbar button.secondary:hover {
    background: #eef2ff;
    border-color: rgba(79,70,229,0.3);
}

.admin-toolbar button.danger {
    background: #ef4444;
    color: #fff;
    border: 1px solid #dc2626;
}

.admin-toolbar button.danger:hover {
    background: #dc2626;
    border-color: #b91c1c;
}

.admin-toolbar label.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
    border: 1px solid rgba(79,70,229,0.2);
    padding: 4px 8px;
    border-radius: 999px;
    background: #f8fafc;
}

.table-wrap {
    overflow: auto;
    border-radius: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15,23,42,0.06);
}

.admin-table thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(15,23,42,0.05);
    text-align: left;
}

.admin-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.admin-table td.update-time-cell {
    padding: 8px 12px;
    position: relative;
}

.admin-table td.update-time-cell .update-time {
    font-size: 9px;
    color: #9ca3af;
    opacity: 0.8;
    line-height: 1.2;
}

.admin-table td.update-time-cell .category-path {
    font-size: 8px;
    color: #6b7280;
    opacity: 0.7;
    line-height: 1.3;
    margin-top: 2px;
}

.admin-table td.update-time-cell .row-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.admin-table tbody tr:hover td.update-time-cell .row-actions {
    display: flex !important;
}

/* 选中高亮 */
.admin-table tbody tr.selected {
    background: #eef2ff !important;
}

/* 行悬停高亮 */
.admin-table tbody tr:hover {
    background: #f3f6ff;
}

/* 选中行悬停稍深 */
.admin-table tbody tr.selected:hover {
    background: #e0e7ff !important;
}

.admin-table button {
    padding: 6px 10px;
    border: none;
    background: #eef2ff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    border: 1px solid rgba(79,70,229,0.2);
    margin-right: 4px;
}

.admin-table button:hover {
    background: #dbeafe;
    border-color: rgba(79,70,229,0.35);
}

.row-actions {
    display: none;
    gap: 4px;
}

tr:hover .row-actions {
    display: inline-flex;
}

.row-actions .icon-btn {
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(79,70,229,0.2);
    background: #eef2ff;
    cursor: pointer;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.row-actions .icon-btn svg {
    font-size: 12px;
}

.row-actions .icon-btn.danger {
    border-color: rgba(220,38,38,0.35);
    background: #fee2e2;
}

.row-actions .icon-btn.danger:hover {
    background: #fecaca;
}

/* 标签管理表格样式 */
.admin-table td.tag-name-cell {
    position: relative;
    padding-right: 100px; /* 为操作按钮留出空间 */
}

.admin-table td.tag-name-cell .tag-name-display {
    display: inline-block;
    max-width: calc(100% - 120px); /* 避免与操作按钮重叠 */
}

.admin-table td.tag-name-cell .tag-name-edit {
    width: calc(100% - 120px);
    padding: 4px 8px;
    border: 1px solid rgba(79,70,229,0.3);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.admin-table td.tag-name-cell .tag-name-edit:focus {
    outline: none;
    border-color: rgba(79,70,229,0.6);
    box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}

.admin-table td.tag-name-cell .row-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    align-items: center;
}

/* 标签管理表格操作按钮悬停显示 */
.admin-table tbody tr:hover td.tag-name-cell .row-actions {
    display: flex !important;
}

.cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cat-list li {
    padding: 0;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    background: transparent;
    box-shadow: none;
}

.cat-actions {
    display: none;
    gap: 4px;
    margin-left: 8px;
}

.cat-actions .icon-btn {
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(79,70,229,0.15);
    background: #eef2ff;
    cursor: pointer;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cat-actions .icon-btn svg {
    font-size: 12px;
}

.cat-actions .icon-btn.danger {
    border-color: rgba(220,38,38,0.35);
    background: #fee2e2;
}

.cat-actions .icon-btn:hover {
    background: #dbeafe;
}

.cat-actions .icon-btn.danger:hover {
    background: #fecaca;
}

/* 悬浮节点时才显示操作图标 */
.tree-row:hover .cat-actions {
    display: inline-flex;
}

.placeholder-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.placeholder-buttons button {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px dashed rgba(15,23,42,0.2);
    background: #fff;
    color: #6b7280;
    cursor: not-allowed;
}

.tree-toggle-global {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tiny-switch {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 14px;
}

.tiny-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tiny-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e5e7eb;
    transition: background-color 0.2s;
    border-radius: 16px;
}

.tiny-slider:before {
    position: absolute;
    content: "";
    height: 10px;
    width: 10px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: transform 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tiny-switch input:checked + .tiny-slider {
    background-color: #4f46e5;
}

.tiny-switch input:checked + .tiny-slider:before {
    transform: translateX(10px);
}

.tiny-label {
    font-size: 11px;
    color: #6b7280;
    margin-left: 4px;
}

/* clickable title in admin list */
.admin-title-link {
    color: #0f172a; /* normal text color */
    cursor: pointer;
    text-decoration: none;
}
.admin-title-link:hover {
    color: #2563eb; /* hover blue */
}

/* Mobile enhancements */
.mobile-menu-btn {
    display: none;
    border: 1px solid rgba(255,255,255,0.25);
    background: transparent;
    color: #f9fafb;
    border-radius: 8px;
    padding: 6px 10px;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1900;
}

/* 顶部导航 */
.topnav {
    display: flex;
    gap: 8px;
    margin-left: 16px;
    align-items: center;
}
.topnav a {
    padding: 6px 10px;
    border-radius: 8px;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    transition: background .15s ease, color .15s ease;
}
.topnav a:hover {
    background: rgba(255,255,255,0.12);
}
.topnav a.active {
    background: #eef2ff;
    color: #1f2937;
}

/* 文章管理独立页布局 */
.articles-main {
    display: flex;
    gap: 12px;
    padding: 12px;
}
.articles-cat-panel {
    width: 260px;
    flex: 0 0 260px;
}
.articles-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 分类右键菜单 */
.context-menu {
    position: fixed;
    z-index: 2200;
    background: #fff;
    border: 1px solid rgba(15,23,42,0.1);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15,23,42,0.16);
    min-width: 160px;
    overflow: hidden;
}
.context-menu.hidden { display: none; }
.context-menu ul { list-style: none; margin: 6px 0; padding: 0; }
.context-menu li { padding: 8px 12px; font-size: 13px; color: #1f2937; cursor: pointer; }
.context-menu li:hover { background: #eef2ff; }
.context-menu li.divider { padding: 0; margin: 6px 0; border-top: 1px solid rgba(15,23,42,0.1); cursor: default; }

@media (max-width: 768px) {
    .mobile-menu-btn { display: inline-block; }
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        height: calc(100vh - 56px);
        width: 80vw;
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 2001;
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .mobile-overlay.hidden { display: none; }
    .header { gap: 6px; }
    .header input[type="text"] { flex: 1; min-width: 0; }
    .modal-content { width: 100vw; height: 85vh; max-height: none; border-radius: 0; padding: 16px; }
    .admin-table { display: block; overflow-x: auto; }
    .articles-main { flex-direction: column; }
    .articles-cat-panel { width: auto; flex: none; }
}
