/* ========== NoteMap 主题变量 ========== */
/* 主题灵感：holidays-calendar.net 蓝紫低饱和·莫兰迪色系 */

:root {
    /* --- 背景层 --- */
    --bg-page: #f5f4f4;
    --bg-card: #ffffff;
    --bg-row: #fbfbff;
    --bg-row-hover: #e8e8f0;
    --bg-graph-hover: #f5f6fa;
    --bg-btn: #ffffff;
    --bg-btn-hover: #f2f2f8;
    --bg-input-disabled: #f0f0f0;
    --bg-modal: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.4);
    --bg-tooltip: rgba(33, 37, 41, 0.9);
    --bg-ghost: #ffffff;
    --bg-danger-header: #fff0f1;

    /* --- 文字层 --- */
    --text-primary: #212529;
    --text-body: #3d4150;
    --text-secondary: #555555;
    --text-muted: #7a7e98;
    --text-faint: #9c9ba1;
    --text-placeholder: #a5a9bd;
    --text-link: #3b4268;
    --text-link-hover: #2d3454;
    --text-on-primary: #ffffff;
    --text-danger: #dc3545;
    --text-success: #28a745;
    --text-danger-muted: #49527a;

    /* --- 强调色（蓝紫色系） --- */
    --accent: #3b4268;
    --accent-hover: #49527a;
    --accent-dark: #2d3454;
    --accent-pressed: #232333;
    --accent-disabled: #b8bcd0;
    --accent-rgb: 59, 66, 104;

    /* --- 功能色（保留语义） --- */
    --success: #28a745;
    --success-hover: #218838;
    --success-light: #66bb6a;
    --danger: #dc3545;
    --danger-hover: #c82333;
    --danger-icon: #e57373;
    --danger-border: #f3d7d7;
    --warning: #febc41;
    --warning-light: #ffd166;
    --cancel: #6770a2;
    --cancel-hover: #49527a;
    --submit: #3b4268;
    --submit-hover: #2d3454;

    /* --- 边框 --- */
    --border-main: #dee2e6;
    --border-subtle: #e2e4f4;
    --border-guide: #ced0df;
    --border-input: #ced0df;
    --border-divider: #e2e4f4;
    --border-faint: #e2e4f4;
    --border-btn: #ced0df;
    --border-danger: #ffd1d5;
    --border-dashed: #ced0df;

    /* --- 阴影 --- */
    --shadow-sm: rgba(59, 66, 104, 0.06);
    --shadow-md: rgba(59, 66, 104, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.3);
    --shadow-tooltip: rgba(59, 66, 104, 0.2);
    --shadow-drag: rgba(59, 66, 104, 0.25);

    /* --- kn_map 专用 --- */
    --bg-toolbar: rgba(255, 255, 255, 0.9);
    --bg-md-toolbar: rgba(255, 255, 255, 0.95);
    --bg-md-hint: rgba(255, 255, 255, 0.9);
    --grid-color: #e0e0e0;
    --node-border: #ced0df;
    --node-shadow: rgba(59, 66, 104, 0.2);
    --node-shadow-drag: rgba(59, 66, 104, 0.4);
    --node-selected-border: #3b82f6;
    --node-selected-glow-rgb: 59, 130, 246;

    /* --- 右键菜单 --- */
    --ctx-bg: #ffffff;
    --ctx-border: #ced0df;
    --ctx-text: #212529;
    --ctx-text-muted: #7a7e98;
    --ctx-highlight: #e8eaf2;
    --ctx-separator: #e2e4f4;
    --ctx-shadow: 2px 2px 8px rgba(59, 66, 104, 0.15);
    --ctx-sub-shadow: 2px 2px 6px rgba(59, 66, 104, 0.12);

    /* --- canvas 边缘线 --- */
    --canvas-edge: #9c9ba1;

    /* --- 图标色 (非主色图标) --- */
    --icon-muted: #c1c6d1;
    --icon-md: #9c9ba1;
    --icon-md-hover: #3b4268;
    --icon-graph: #6770a2;
    --icon-graph-hover: #3b4268;
    --icon-back: #6770a2;

    /* --- MD 文档标签 --- */
    --md-label: #6770a2;
    --md-label-hover: #49527a;

    /* --- Header --- */
    --header-bg: #3b4268;

    /* --- 搜索框 (深色 header 上的半透明) --- */
    --search-border: rgba(255, 255, 255, 0.3);
    --search-bg: rgba(255, 255, 255, 0.12);
    --search-bg-focus: rgba(255, 255, 255, 0.2);
    --search-border-focus: rgba(255, 255, 255, 0.6);
    --search-placeholder: rgba(255, 255, 255, 0.6);
}

/* ========== 暗色模式 ========== */
/* 网站无暗色，以下为以深蓝紫为基调推导的配套深色版 */

[data-theme="dark"] {
    /* --- 背景层 --- */
    --bg-page: #232333;
    --bg-card: #2d2e44;
    --bg-row: #282940;
    --bg-row-hover: #353652;
    --bg-graph-hover: #2d2e44;
    --bg-btn: #353652;
    --bg-btn-hover: #3d3e5c;
    --bg-input-disabled: #232333;
    --bg-modal: #2d2e44;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --bg-tooltip: rgba(45, 46, 68, 0.95);
    --bg-ghost: #353652;
    --bg-danger-header: #3a2326;

    /* --- 文字层 --- */
    --text-primary: #e8eaf2;
    --text-body: #b8bcd0;
    --text-secondary: #9094a8;
    --text-muted: #6b6f88;
    --text-faint: #4a4d68;
    --text-placeholder: #4a4d68;
    --text-link: #8b95c4;
    --text-link-hover: #a5aecd;
    --text-on-primary: #ffffff;
    --text-danger: #ef5350;
    --text-success: #66bb6a;
    --text-danger-muted: #e8eaf2;

    /* --- 强调色 --- */
    --accent: #8b95c4;
    --accent-hover: #a5aecd;
    --accent-dark: #6770a2;
    --accent-pressed: #5a6594;
    --accent-disabled: #4a4d68;
    --accent-rgb: 139, 149, 196;

    /* --- 功能色 --- */
    --success: #66bb6a;
    --success-hover: #81c784;
    --success-light: #81c784;
    --danger: #e57373;
    --danger-hover: #ef5350;
    --danger-icon: #ef5350;
    --danger-border: #4a2a2a;
    --warning: #febc41;
    --warning-light: #ffd166;
    --cancel: #6b6f88;
    --cancel-hover: #7a7e98;
    --submit: #49527a;
    --submit-hover: #5a6594;

    /* --- 边框 --- */
    --border-main: #3d3e5c;
    --border-subtle: #353652;
    --border-guide: #4a4d68;
    --border-input: #4a4d68;
    --border-divider: #3d3e5c;
    --border-faint: #353652;
    --border-btn: #4a4d68;
    --border-danger: #4a2a2a;
    --border-dashed: #4a4d68;

    /* --- 阴影 --- */
    --shadow-sm: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.4);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --shadow-tooltip: rgba(0, 0, 0, 0.3);
    --shadow-drag: rgba(0, 0, 0, 0.4);

    /* --- kn_map 专用 --- */
    --bg-toolbar: rgba(45, 46, 68, 0.9);
    --bg-md-toolbar: rgba(45, 46, 68, 0.95);
    --bg-md-hint: rgba(45, 46, 68, 0.9);
    --grid-color: #e0e0e0;
    --node-border: #4a4d68;
    --node-shadow: rgba(0, 0, 0, 0.5);
    --node-shadow-drag: rgba(0, 0, 0, 0.7);
    --node-selected-border: #8fb0ff;
    --node-selected-glow-rgb: 143, 176, 255;

    /* --- 右键菜单（暗色模式） --- */
    --ctx-bg: #2d2e44;
    --ctx-border: #4a4d68;
    --ctx-text: #e8eaf2;
    --ctx-text-muted: #9094a8;
    --ctx-highlight: #3d3e5c;
    --ctx-separator: #353652;
    --ctx-shadow: 2px 2px 12px rgba(0,0,0,0.5);
    --ctx-sub-shadow: 2px 2px 8px rgba(0,0,0,0.4);

    /* --- canvas 边缘线（暗色模式） --- */
    --canvas-edge: #6b6f88;

    /* --- 图标色 --- */
    --icon-muted: #4a4d68;
    --icon-md: #6b6f88;
    --icon-md-hover: #8b95c4;
    --icon-graph: #5a6594;
    --icon-graph-hover: #8b95c4;
    --icon-back: #6b6f88;

    /* --- MD 文档标签 --- */
    --md-label: #9094a8;
    --md-label-hover: #b8bcd0;

    /* --- Header --- */
    --header-bg: #2d3454;

    /* --- 搜索框 --- */
    --search-border: rgba(255, 255, 255, 0.25);
    --search-bg: rgba(255, 255, 255, 0.1);
    --search-bg-focus: rgba(255, 255, 255, 0.18);
    --search-border-focus: rgba(255, 255, 255, 0.5);
    --search-placeholder: rgba(255, 255, 255, 0.5);
}

/* ========== 主题切换按钮 ========== */

.theme-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    border-radius: 4px !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.15) !important;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    transition: background 140ms ease;
    padding: 0 !important;
    font-size: 0;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

/* 亮色模式显示月亮图标 */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }

/* 暗色模式显示太阳图标 */
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ========== 暗色模式 SVG 图标覆盖 ========== */
/* 图标颜色同步蓝紫主题：原 #64b5f6(亮蓝) → #8b95c4(亮蓝紫) */

[data-theme="dark"] .btn-icon.btn-edit {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b95c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M11.5 2.5l2 2-7.5 7.5H4v-2L11.5 2.5z'/><path d='M10 4l2 2'/></svg>");
}

[data-theme="dark"] .btn-icon.btn-delete {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ef5350' stroke-width='1.8' stroke-linecap='round'><path d='M3.5 3.5l9 9M12.5 3.5l-9 9'/></svg>");
    border-color: var(--danger-border);
}

[data-theme="dark"] .btn-icon.btn-add-graph-sm {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16' fill='none' stroke='%2366bb6a' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M3 8h6M6 5v6'/><circle cx='15' cy='3.5' r='1.8'/><circle cx='18' cy='9' r='1.8'/><circle cx='15' cy='13' r='1.8'/><path d='M16.3 4.2l1 4M16.3 4.2l-1 7.5M16.3 11.7l1.3-1.5'/></svg>");
    border-color: var(--danger-border);
}

[data-theme="dark"] .btn-icon.btn-add-md-sm {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 16' fill='none' stroke='%238b95c4' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M3 8h6M6 5v6'/><path d='M12 1.5h5l2.5 2.5v10.5h-7.5z'/><path d='M17 1.5V4.5h2.5'/><path d='M14 8h4M14 10h4M14 12h2.5'/></svg>");
    border-color: var(--border-btn);
}

[data-theme="dark"] .tree-label-md::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b6f88' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M3 1.5h7L13 4.5v10H3z'/><path d='M10 1.5V4.5h3'/><path d='M5.5 8h5M5.5 10.5h5M5.5 12.5h3'/></svg>");
}

[data-theme="dark"] .tree-label-md:hover::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b95c4' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M3 1.5h7L13 4.5v10H3z'/><path d='M10 1.5V4.5h3'/><path d='M5.5 8h5M5.5 10.5h5M5.5 12.5h3'/></svg>");
}

[data-theme="dark"] .tree-label-graph::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a6594' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><circle cx='4' cy='4' r='2'/><circle cx='12' cy='6' r='2'/><circle cx='8' cy='12' r='2'/><path d='M5.7 4.8l4.6 1M5.2 5.5l2.2 4.5M10.3 7.5L9 10.5'/></svg>");
}

[data-theme="dark"] .tree-label-graph:hover::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b95c4' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><circle cx='4' cy='4' r='2'/><circle cx='12' cy='6' r='2'/><circle cx='8' cy='12' r='2'/><path d='M5.7 4.8l4.6 1M5.2 5.5l2.2 4.5M10.3 7.5L9 10.5'/></svg>");
}

/* ========== jstree hover/clicked 主题覆盖 ========== */
/* 第三方库默认硬编码 #e7f4f9(hover)/#beebff(clicked) 浅蓝，暗色模式下太耀眼，统一用主题变量 */
.jstree-default .jstree-hovered,
.jstree-default .jstree-wholerow-hovered,
.jstree-default.jstree-checkbox-no-clicked .jstree-clicked.jstree-hovered,
.jstree-default.jstree-checkbox-no-clicked > .jstree-wholerow-ul .jstree-wholerow-clicked.jstree-wholerow-hovered {
    background: var(--bg-row-hover) !important;
    box-shadow: none !important;
}
.jstree-default .jstree-clicked,
.jstree-default .jstree-wholerow-clicked {
    background: rgba(var(--accent-rgb), 0.15) !important;
    box-shadow: none !important;
}
