/* ---------- 全局变量 ---------- */
:root {
    --sidebar-bg: #2C2E2F;
    --panel-bg: #f9fbfd;
    --card-border: #eef2f6;
    --text-muted: #5f7d9c;
    --hover-bg: #2a3b4e;
}

/* ---------- 基础布局 ---------- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--panel-bg);
    height: 100vh;
    overflow: hidden;
}

/* 自定义滚动条 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* 侧边栏通用结构 */
.sidebar {
    position: relative;
    background-color: var(--sidebar-bg);
    color: #b4c2d0;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: visible;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar:not(.collapsed) {
    width: 280px;
}

.sidebar-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #3f5570;
}
.sidebar-header .logo {
    font-size: 28px;
}
.sidebar-header .title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e6edf5;
    white-space: nowrap;
}

/* 分类树容器 */
.category-tree {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    margin: 20px 0;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.category-tree::-webkit-scrollbar {
    display: none;
}

/* 分类节点基础样式 */
.tree-node {
    list-style: none;
}
.tree-node-content {
    display: flex;
    align-items: center;
    padding: 0px 40px 0px 40px;
    cursor: pointer;
    color: #979898;
    transition: all 0.1s;
    font-size: 13px;
}
.tree-node-content:hover {
    color: #e6edf5;
}
.tree-node-content.active {
    color: #e6edf5;
}
.node-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.node-icon i {
    font-size: 13px;
    vertical-align: middle;
}
.node-icon img {
    max-width: 18px;
    max-height: 18px;
    object-fit: contain;
}
.node-name {
    flex: 1;
    white-space: nowrap;
}
.expand-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #8fa3bc;
    margin-left: auto;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.expand-icon.expanded {
    transform: rotate(90deg);
}

/* 子节点容器（折叠/展开动画） */
.child-nodes {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.child-nodes.expanded {
    max-height: 500px;
}
.child-nodes .tree-node-content {
    padding-left: 72px;
}
.child-nodes .node-icon {
    display: none;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #3f5570;
    position: relative;
}

/* 折叠侧边栏时隐藏文字和箭头 */
.sidebar.collapsed .sidebar-header .title,
.sidebar.collapsed .tree-node-content .node-name,
.sidebar.collapsed .expand-icon,
.sidebar.collapsed .sidebar-footer span {
    display: none;
}
.sidebar.collapsed .tree-node-content {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.sidebar.collapsed .node-icon {
    margin-right: 0;
}
.sidebar.collapsed .node-icon i {
    font-size: 1.5rem;
}

/* 右侧主面板 */
.main-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    padding: 24px 32px;
    overflow: hidden;
}
.panel-header {
    height: 80px;
    margin: -24px -32px 24px -32px;
    padding: 0 32px;
    background: white;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* 折叠按钮 */
.collapse-btn {
    background: none;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #5f7d9c;
    font-size: 1.2rem;
    transition: all 0.2s;
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.collapse-btn i {
    font-size: 1.2rem;
}
.collapse-btn:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

/* 搜索框通用样式 */
.search-container {
    display: flex;
    align-items: center;
    background-color: #f0f4fa;
    border: 1px solid #dde5ef;
    border-radius: 30px;
    height: 40px;
    padding: 0 4px;
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
}
.search-engine-selector {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 8px;
    cursor: pointer;
    border-right: 1px solid #dde5ef;
}
.engine-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
.engine-icon i {
    font-size: 1.2rem;
}
.engine-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    min-width: 180px;
    margin-top: 5px;
    white-space: nowrap;
}
.engine-dropdown.show {
    display: block;
}
.engine-option {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.1s;
}
.engine-option:hover {
    background: #eef2f6;
}
.engine-option .engine-icon-small {
    width: 24px;
    text-align: center;
}
.search-input {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    padding: 0 12px;
    font-size: 0.95rem;
    outline: none;
    color: #1e293b;
}
.search-input::placeholder {
    color: #8fa3bc;
}
.search-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: #5f7d9c;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.search-btn i {
    font-size: 1.2rem;
}
.search-btn:hover {
    background: #e2eaf5;
    color: #1e3a6b;
}

/* 按钮通用样式（在线版和本地版共享基础样式） */
.import-btn,
.github-link {
    flex-shrink: 0;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    box-sizing: border-box;
    line-height: 1;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    transition: all 0.2s;
    background: none;
    cursor: pointer;
    color: #5f7d9c;
    font-size: 0.9rem;
    text-decoration: none;
}
.import-btn i,
.github-link i {
    margin-right: 6px;
    font-size: 1rem;
}
.import-btn:hover,
.github-link:hover {
    background: #eef2f6;
    color: #1e3a6b;
}

/* 下拉菜单容器与菜单宽度控制（统一位置） */
.header-right .dropdown {
    display: inline-block;
    position: relative;
}
/* 下拉菜单容器：宽度自动适应内容，但至少与按钮等宽 */
.header-right .dropdown-menu {
    min-width: 100%;          /* 至少和按钮一样宽 */
    width: auto;              /* 如果内容更长，则自动扩展 */
    left: 0 !important;
    right: auto !important;
}

/* 下拉菜单项样式（通用） */
.header-right .dropdown-menu .dropdown-item {
    color: #5f7d9c;
    font-size: 0.9rem;
    background-color: transparent;
    padding: 6px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-right .dropdown-menu .dropdown-item:hover,
.header-right .dropdown-menu .dropdown-item:focus {
    background-color: #eef2f6;
    color: #1e3a6b;
}

/* 卡片网格容器 */
.bookmark-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 4px 20px;
}

/* 卡片样式 */
.card {
    border: 1px solid #eef2f6;  /* #eef2f6 #e6ecf2 */
    border-radius: 12px;
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 20px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.card:hover {
    box-shadow: 0 8px 20px rgba(0,20,50,0.08);
    border-color: #d0e0f0;
}
.card-body {
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: center;
}
.card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.card-icon i {
    font-size: 16px;
}
.card-icon img {
    max-width: 16px;
    max-height: 16px;
    object-fit: contain;
}
.card-content {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}
.card-description {
    font-size: 13px;
    color: rgb(151, 152, 152);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 !important;
    line-height: 1.5;
    padding-right: 32px;
}
.card-title {
    font-weight: bold;
    font-size: 13px;
    color: rgb(151, 152, 152);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    line-height: 1.5;
    padding-right: 24px;
    margin-bottom: 0;
}
.card-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: 100%;
    overflow-x: hidden;   /* 隐藏溢出，但不会有滚动条 */
}
.tag {
    background: #eef2f6;
    color: #1e3a6b;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    white-space: nowrap;
    line-height: 1.5;
    flex-shrink: 0;
}
.tag-more {
    background: #eef2f6;
    color: #1e3a6b;
    cursor: default;
}
.tag:hover {
    background: #eef2f6;
    color: #1e3a6b;
}
.edit-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: #9bb1cc;
    padding: 8px 10px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 10;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    background: transparent; /* 默认无背景 */
}
.card:hover .edit-btn {
    opacity: 1;
    background: #f0f4fa;
}
.edit-btn:hover {
    background: #e2eaf5;
}
.card-toast {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e2b3c;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    pointer-events: none;
    border: 1px solid #3f5570;
}
.card-toast::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #1e2b3c;
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.1));
    z-index: 101;
}
.card:hover .card-toast {
    opacity: 1;
    visibility: visible;
}

/* 自定义图标选择器 */
.custom-icon-selector {
    position: relative;
    width: 100%;
    margin-bottom: 8px;
}
.selected-icon {
    border: 2px solid #dde5ef;
    border-radius: 20px;
    padding: 10px 16px;
    background: #f9fcff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}
.selected-icon-preview {
    display: flex;
    align-items: center;
    margin-right: 8px;
    width: 24px;
    justify-content: center;
}
.selected-icon-preview i {
    font-size: 1.2rem;
}
.selected-icon-text {
    flex: 1;
    color: #1e293b;
}
.caret {
    font-size: 0.8rem;
    color: #5f7d9c;
    transition: transform 0.2s;
}
.caret.open {
    transform: rotate(180deg);
}
.icon-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 4px;
    padding: 16px;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.icon-dropdown-panel.show {
    display: block;
}
/* 修改为三列 */
.icon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}
.icon-column {
    display: flex;
    flex-direction: column;
}
.column-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: #3e5670;
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eef2f6;
}
.icon-option {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #1e293b;
}
.icon-option:hover {
    background: #eef2f6;
}
.icon-option i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}
.custom-icon-input {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    border-top: 1px solid #eef2f6;
    padding-top: 16px;
}
.custom-icon-input input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dde5ef;
    border-radius: 20px;
    outline: none;
    font-size: 0.9rem;
}
.custom-icon-input button {
    padding: 8px 16px;
    background: #1e3c72;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.custom-icon-input button:hover {
    background: #143157;
}

/* 分类管理弹窗中的新增分类区域（已被独立模态框替代，保留基础样式） */
#categoryManageModal .card {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
#toggleAddCategoryBtn {
    text-decoration: none;
    border: none;
    background: none;
    color: #1e3c72;
}
#toggleAddCategoryBtn:hover,
#toggleAddCategoryBtn:focus {
    text-decoration: none;
    outline: none;
}
#addCategoryForm .card-body {
    text-align: center;
}
#addCategoryForm .form-label,
#addCategoryForm .form-control,
#addCategoryForm .form-select {
    text-align: left;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
}
#addCategoryForm .btn {
    width: auto;
    margin-top: 32px;
}
#categoryManageModal .card-header {
    cursor: pointer;
    user-select: none;
}
#categoryManageModal .card-header:hover {
    background-color: #f0f4fa;
}
.form-label {
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    font-size: 12px;
    cursor: help;
    margin-left: 4px;
    position: relative;
    flex-shrink: 0;
}
.info-icon:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 5px;
}
.priority-input {
    width: 80px !important;
}
.icon-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    background: white;
    border: 1px solid #dde5ef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
    padding: 4px 0;
}
.icon-suggestions .suggestion-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.icon-suggestions .suggestion-item:hover {
    background: #eef2f6;
}
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}
.suggestion-item i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.suggestion-class {
    color: #6c757d;
    font-size: 0.8rem;
    white-space: nowrap;
}
.suggestion-item.more-link {
    border-top: 1px solid #dee2e6;
    margin-top: 4px;
    color: #0d6efd;
    font-weight: 500;
}
.suggestion-item.more-link i {
    color: #0d6efd;
}
.private-cell {
    text-align: left;
    vertical-align: middle;
}
#bookmarkModal .modal-footer .form-check {
    margin-bottom: 0;
    line-height: 1.5;
}

/* 内部容器，包裹图标、文字和箭头，并添加下边框 */
.node-inner {
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid #313437;
    padding: 12px 0;
    gap: 8px;
}
.sidebar.collapsed .node-inner {
    justify-content: center;
    gap: 0;
    width: auto;
}
.sidebar.collapsed .node-icon {
    margin-right: 0;
}
.child-nodes .tree-node-content .node-name {
    border-bottom: none;
}
.sidebar.collapsed .node-content-wrapper {
    border-bottom: none;
}
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
    gap: 0;
}
.sidebar.collapsed .sidebar-header .logo {
    margin-right: 0;
}
.sidebar.collapsed .sidebar-header .title {
    display: none;
}
.title-wrapper {
    display: flex;
    align-items: center;  /* 垂直居中对齐 */
    gap: 8px;
}
.badge {
    font-size: 0.6rem;
    font-weight: normal;
    background: #4a627a;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    position: static;
    transform: translateY(-2px);  /* 向上移动2像素，可根据需要调整 */
}
/* 显示快捷键提示区域 */
.sidebar-footer {
    display: block !important;
}
.shortcut-hint {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #2a3b4e;
    color: #b4c2d0;
    padding: 8px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    border: 1px solid #3f5570;
    cursor: pointer;
}

kbd {
    background: #1e2b3c;
    color: #e6edf5;
    padding: 1px 6px;
    border-radius: 6px;
    font-family: var(--bs-font-monospace);
    font-size: 0.75rem;
    display: inline-block;
}

.sidebar.collapsed .shortcut-hint .hint-text {
    display: none;
}
.sidebar.collapsed .shortcut-hint .hint-icon {
    display: inline-block;
}
.sidebar.collapsed .shortcut-hint {
    padding: 8px 0;
}
.hint-icon {
    display: none;
    font-size: 1.2rem;
    color: #b4c2d0;
    cursor: pointer;
}

/* 可点击标题 */
.sidebar-header .title {
    cursor: pointer;
}

/* 突出显示“更多”图标选项 */
.icon-option.more-option {
    color: #e67e22;      /* 蓝色 */
}
.icon-option.more-option:hover {
    color: #d35400;
    background: #eef2f6;
}
/* 优化模态框样式 */
.modal-content {
    border-radius: 28px;
    box-shadow: 0 20px 35px -8px rgba(0, 0, 0, 0.2);
    border: none;
}
.modal-header .btn-close {
    opacity: 0.6;
}
.modal-header .btn-close:hover {
    opacity: 1;
}
.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.tag-more-tooltip .tooltip-tag {
    background: #eef2f6;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    margin: 2px;
    display: inline-block;
}
.tag-more-tooltip .tooltip-tag:hover {
    background: #d0e0f0;
}
#loginModal .modal-footer {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}
.category-section {
    margin-bottom: 2rem;
}
.category-section-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: #1e2a3a;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

/* 语言切换器样式 */
.language-switcher {
    position: relative;
}
.lang-btn {
    background: none;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #5f7d9c;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.lang-btn:hover {
    background: #eef2f6;
    color: #1e3a6b;
}
.lang-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #e0e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    min-width: 120px;
    margin-top: 4px;
}
.lang-dropdown.show {
    display: block;
}
.lang-option {
    display: block;
    padding: 8px 16px;
    color: #5f7d9c;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.1s;
}
.lang-option:hover {
    background: #eef2f6;
    color: #1e3a6b;
}
.modal-body .btn-sm {
    white-space: nowrap;
    display: inline-block;
    vertical-align: baseline;
}