/* 关系图谱页面样式 */

/* 页面布局 - 全屏显示 */
#graph-page {
    display: flex;
    height: var(--app-viewport-height, 100vh);
    overflow: hidden !important; /* 强制覆盖base.css的overflow-y: auto */
    position: fixed !important; /* 固定定位，不受base.css影响 */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important; /* 底部菜单栏上方 */
    width: 100% !important;
    max-width: 100% !important; /* 覆盖base.css的max-width */
    margin: 0 !important; /* 覆盖base.css的margin: 0 auto */
    padding: 0 !important; /* 覆盖base.css的默认padding */
}

/* 左侧工具栏（桌面端） */
.graph-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: var(--app-viewport-height, 100vh);
    background: var(--glass-white);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    box-shadow: var(--shadow-light);
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .graph-sidebar {
        background: rgba(30, 30, 30, 0.9);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    .graph-mobile-toolbar {
        background: rgba(30, 30, 30, 0.95);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar-icon-btn,
    .mobile-icon-btn {
        color: rgba(255, 255, 255, 0.7);
    }

    .sidebar-icon-btn:hover,
    .mobile-icon-btn:hover {
        background: rgba(74, 158, 255, 0.2);
        color: var(--ice-blue);
    }

    .sidebar-divider {
        background: rgba(255, 255, 255, 0.1);
    }
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
}

.sidebar-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 8px 8px;
}

.sidebar-icon-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
    border-radius: var(--radius-sm);
}

.sidebar-icon-btn:hover {
    background: var(--ice-crystal);
    color: var(--ice-blue);
}

.sidebar-icon-btn:active {
    transform: scale(0.96);
}

.sidebar-icon-btn.active {
    color: var(--mint-green);
    background: rgba(0, 212, 170, 0.15);
}

/* 新增关系激活状态（选中节点模式） */
.sidebar-icon-btn#add-relation-btn.selecting {
    background: rgba(255, 107, 0, 0.15);
    color: #FF6B00;
}

/* 批量切换激活状态 */
.sidebar-icon-btn#batch-toggle-status-btn.active {
    background: #00D4AA;
    color: white;
}

/* Tooltip提示 */
.sidebar-icon-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 56px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.sidebar-icon-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* 移动端顶部工具栏 */
.graph-mobile-toolbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--glass-white);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    padding: 0 4px;
    overflow-x: auto;
    white-space: nowrap;
    box-shadow: var(--shadow-light);
}

.mobile-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 6px 1px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    font-size: 18px;
}

.mobile-icon-btn:hover,
.mobile-icon-btn:active {
    background: var(--ice-crystal);
    color: var(--ice-blue);
}

.mobile-icon-btn.active {
    color: var(--mint-green);
    background: rgba(0, 212, 170, 0.15);
}

/* 移动端新增关系按钮激活状态（选中节点模式） */
.mobile-icon-btn#mobile-add-relation-btn.selecting {
    background: rgba(255, 107, 0, 0.15);
    color: #FF6B00;
}

.mobile-icon-btn#mobile-batch-toggle-btn.active {
    background: #00D4AA;
    color: white;
}

/* 响应式：移动端 - 简化固定布局 */
@media (max-width: 768px) {
    /* 隐藏桌面端侧边栏 */
    .graph-sidebar {
        display: none !important;
    }

    /* 图谱页面：填满整个屏幕（从顶部到底部菜单栏） */
    #graph-page {
        display: block !important;
        position: fixed !important;
        top: 0 !important;            /* 从顶部开始 */
        left: 0 !important;
        right: 0 !important;
        bottom: 80px !important;      /* 底部菜单栏上方 */
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    body.layout-debug-active #layout-debug-page {
        display: block !important;
    }

    /* 显示移动端工具栏 - 贴在 #graph-page 顶部 */
    .graph-mobile-toolbar {
        display: flex !important;
        position: absolute !important;  /* 相对于 #graph-page 定位 */
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 48px;
        margin: 0;
        padding: 0 8px;
        z-index: 1000;
    }

    /* 主内容区：从工具栏下方开始 */
    .graph-main-content {
        display: block !important;
        position: absolute !important;
        top: 48px !important;         /* 工具栏下方 */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        margin-left: 0 !important;    /* 覆盖桌面端的 margin-left: 48px */
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* 画布区：填满主内容区，固定不动 */
    .graph-canvas-wrapper {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* 详情卡片：浮在图谱区下半部，底边与图谱区底边对齐 */
    .graph-detail-panel {
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)) !important;
        width: 100% !important;
        height: auto !important;
        max-height: calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom) - 16px) !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
        z-index: 10;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important; /* 防止整个面板溢出 */
    }

    /* 隐藏状态：向下滑出 */
    .graph-detail-panel.hidden {
        transform: translateY(100%);
        opacity: 0;
    }

    /* 详情面板头部 - 固定高度，不滚动 */
    .detail-panel-header {
        flex-shrink: 0;
        flex-grow: 0;
    }

    /* 详情面板内容区：自动滚动 */
    .detail-panel-body {
        flex: 1 1 0; /* 占据剩余空间 */
        min-height: 0; /* 关键：允许flex子元素缩小 */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: var(--spacing-md) !important;
    }

    /* 详情面板底部 - 固定高度，不滚动 */
    .detail-panel-footer {
        flex-shrink: 0;
        flex-grow: 0;
        background: var(--ice-crystal);
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        padding: var(--spacing-md) !important;
    }

    /* 节点标签字体缩小 */
    .node-label {
        font-size: 10px;
    }
}

/* 移动端竖屏模式：详情面板占屏幕下半部（50%高度） */
@media (max-width: 768px) and (orientation: portrait) {
    .graph-detail-panel {
        max-height: min(calc(var(--app-vh, 1vh) * 50), calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom) - 16px)) !important;
    }
}

/* 移动端横屏模式：详情面板高度更小，确保底部按钮不超出屏幕 */
@media (max-width: 768px) and (orientation: landscape) {
    .graph-detail-panel {
        max-height: min(calc(var(--app-vh, 1vh) * 40), calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom) - 16px)) !important;
    }
}

/* 平板横屏：缩短详情面板高度，避免与底部菜单重叠 */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .graph-detail-panel {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        top: 12px !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px) !important;
        height: auto !important;
        max-height: min(calc(var(--app-vh, 1vh) * 35), calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom) - 24px)) !important;
        border-radius: 16px 16px 0 0 !important;
        z-index: 120 !important;
    }

    .graph-detail-panel.hidden {
        transform: translateY(100%);
    }
}

/* 大屏触控设备横屏（如 iPad Pro）：保留右侧面板但缩短高度，避开底部导航 */
@media (min-width: 1025px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
    .graph-detail-panel {
        top: 0 !important;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)) !important;
        height: auto !important;
        max-height: calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom)) !important;
    }
}

/* ===== 图谱布局调试页 ===== */
#layout-debug-page {
    display: none;
    height: var(--app-viewport-height, 100vh);
    overflow: hidden !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
    opacity: 1 !important;
    transform: translateX(0) !important;
}

body.layout-debug-active #layout-debug-page {
    display: flex;
}

.layout-debug-block {
    outline: 2px dashed rgba(45, 125, 210, 0.45);
    background: rgba(74, 158, 255, 0.08);
}

.layout-debug-readout-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 420px);
    z-index: 2600;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    pointer-events: auto;
}

.layout-debug-copy-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.85);
    color: #FFFFFF;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-debug-copy-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.6);
}

.layout-debug-readout {
    background: rgba(15, 23, 42, 0.9);
    color: #FFFFFF;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.5;
    width: 100%;
    min-height: 200px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    resize: vertical;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.layout-debug-safe-area {
    position: absolute;
    width: 0;
    height: 0;
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

body.layout-debug-active #graph-detail-panel {
    outline: 2px dashed rgba(45, 125, 210, 0.45);
}

/* 旧的toolbar样式 - 保留以防兼容性问题 */
.graph-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--glass-white);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    align-items: center;
}

.graph-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
}

.graph-filter-group .filter-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.graph-filter-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--ice-crystal);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.graph-filter-group label:hover {
    background: var(--ice-blue);
    color: white;
}

.graph-filter-group input[type="checkbox"],
.graph-filter-group input[type="radio"] {
    cursor: pointer;
}

/* Main content area - flex layout for canvas + detail panel */
.graph-main-content {
    display: flex;
    gap: 0;
    margin-left: 48px; /* 左侧栏宽度 */
    height: var(--app-viewport-height, 100vh);
    width: calc(100% - 48px);
}

/* Canvas wrapper - holds the SVG */
.graph-canvas-wrapper {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
    background: transparent;
    overflow: hidden;
    position: relative;
}

#relation-graph {
    width: 100%;
    height: 100%;
}

/* Detail panel - side panel on desktop, bottom on mobile */
.graph-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    width: 400px;
    min-width: 350px;
    max-width: 450px;
    height: auto;
    max-height: calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom));
    background: var(--glass-white);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.graph-detail-panel.hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Detail panel header */
.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--ice-crystal);
}

.detail-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.detail-panel-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* Detail panel body */
.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    min-height: 0;
}

.detail-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-xl) var(--spacing-md);
    font-size: 14px;
}

/* Detail panel footer */
.detail-panel-footer {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--ice-crystal);
}

.detail-panel-footer.hidden {
    display: none;
}

.detail-panel-footer .footer-spacer {
    flex: 1;
}

.detail-panel-footer button {
    min-width: 80px;
}

/* Detail form styles */
.detail-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.detail-form .input-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.detail-form .input-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 80px;
    flex-shrink: 0;
}

.detail-form input:not([type="radio"]),
.detail-form textarea,
.detail-form select {
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: all var(--transition-fast);
    flex: 1;
}

/* 状态单选按钮组 */
.detail-form .status-radio-group,
.modal .status-radio-group {
    display: flex;
    gap: 16px;
    flex: 1;
}

.detail-form .radio-label,
.modal .radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.detail-form .radio-label input[type="radio"],
.modal .radio-label input[type="radio"] {
    flex: none;
    width: auto;
    margin: 0;
    cursor: pointer;
}

.detail-form .radio-label span,
.modal .radio-label span {
    user-select: none;
}

/* Modal中的input-group也需要行布局 */
.modal .input-group:has(.status-radio-group) {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal .input-group:has(.status-radio-group) label {
    margin-bottom: 0;
    min-width: 80px;
    flex-shrink: 0;
}

.detail-form input:not([type="radio"]):focus,
.detail-form textarea:focus {
    outline: none;
    border-color: var(--ice-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.detail-form input[readonly],
.detail-form textarea[readonly] {
    background: rgba(0, 0, 0, 0.05);
    cursor: not-allowed;
    color: var(--text-secondary);
}

.detail-form textarea {
    min-height: 80px;
    resize: vertical;
}

.graph-tooltip {
    position: absolute;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: var(--radius-md);
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 200px;
}

.graph-tooltip.hidden {
    display: none;
}

.graph-tooltip h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: bold;
}

.graph-tooltip p {
    margin: 2px 0;
    font-size: 12px;
}

/* D3力导向图节点样式 */
.node-circle {
    stroke: #fff;
    stroke-width: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.node-circle:hover {
    stroke-width: 4px;
    filter: brightness(1.2);
}

.node-label {
    font-size: 12px;
    pointer-events: none;
    user-select: none;
    text-anchor: middle;
    dominant-baseline: middle;
    fill: #333; /* 浅色模式 */
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .node-label {
        fill: var(--text-primary, #F8FAFC);
    }

    .link-line {
        stroke: #64748B;
    }

    .graph-tooltip {
        background: rgba(15, 23, 42, 0.95);
        border: 1px solid rgba(100, 116, 139, 0.3);
        backdrop-filter: blur(10px);
    }

    .node-circle {
        filter: brightness(1.1);
    }

    .node-circle:hover {
        filter: brightness(1.3);
    }

    /* Detail panel dark mode */
    .detail-panel-header,
    .detail-panel-footer {
        border-color: rgba(255, 255, 255, 0.1);
    }

    .detail-panel-close:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .detail-form input,
    .detail-form textarea {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--text-primary);
    }

    .detail-form input[readonly],
    .detail-form textarea[readonly] {
        background: rgba(255, 255, 255, 0.02);
    }
}

.link-line {
    stroke: #999;
    stroke-opacity: 0.6;
    stroke-width: 2.5px;
}

.link-line.strong {
    stroke-width: 4px;
    stroke: var(--ice-blue);
}

.link-line.weak {
    stroke-width: 1.5px;
    stroke-opacity: 0.3;
}

/* 实体类型颜色 */
.node-person { fill: #FF6B9D; }        /* 粉红色 */
.node-organization { fill: #9C27B0; }  /* 紫色 */
.node-project { fill: #F59E0B; }       /* 橙色 */
.node-event { fill: #EF4444; }         /* 红色 */
.node-resource { fill: #607D8B; }      /* 蓝灰色 */
.node-location { fill: #EC4899; }      /* 粉色 */

/* 节点选中状态（新增关系模式） */
.node-circle.node-selected {
    stroke: #FF6B00 !important;
    stroke-width: 4px !important;
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 107, 0, 0.6));
}

/* Active按钮状态 */
.btn-primary.active {
    background: var(--ice-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.3);
}

/* 响应式调整 - 已合并到上面的移动端媒体查询中 */

/* 链接样式 */
.btn-link {
    color: var(--ice-blue);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-link:hover {
    background: var(--ice-crystal);
    text-decoration: underline;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

/* ===== 数据管理页面样式 ===== */
.data-management-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        var(--ice-crystal) 0%,
        #F0F9FF 25%,
        var(--ice-crystal) 50%,
        #E0F2FE 75%,
        var(--ice-crystal) 100%);
    background-attachment: fixed;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.data-management-page.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.data-mgmt-header {
    background: linear-gradient(135deg, rgba(58, 123, 213, 0.95) 0%, rgba(102, 166, 255, 0.92) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-light);
}

.data-mgmt-header h2 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
}

.close-data-mgmt {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.close-data-mgmt:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.data-mgmt-categories {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--glass-white);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    overflow-x: auto;
    scrollbar-width: thin;
}

.data-mgmt-categories::-webkit-scrollbar {
    height: 4px;
}

.data-mgmt-categories::-webkit-scrollbar-thumb {
    background: rgba(74, 158, 255, 0.3);
    border-radius: 2px;
}

.category-btn {
    padding: 8px 16px;
    border: 2px solid var(--ice-blue);
    background: transparent;
    color: var(--ice-blue);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-btn:hover {
    background: rgba(74, 158, 255, 0.1);
}

.category-btn.active {
    background: var(--ice-blue);
    color: white;
    box-shadow: var(--shadow-light);
}

.data-mgmt-actions {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    background: var(--glass-white);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    align-items: center;
    flex-wrap: wrap;
}

.data-mgmt-actions .btn-primary {
    min-width: 100px;
    height: 38px;
    font-size: 14px;
}

.data-mgmt-actions .search-container {
    flex: 1;
    min-width: 200px;
}

.data-mgmt-actions .search-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--glass-white);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.data-mgmt-actions .search-input:focus {
    outline: none;
    border-color: var(--ice-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.data-mgmt-actions .filter-select {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--glass-white);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 140px;
}

.data-mgmt-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 数据卡片样式 */
.data-card {
    background: var(--glass-white);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.data-card:hover {
    border-color: var(--ice-blue);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.data-card-info {
    flex: 1;
    min-width: 0;
}

.data-card-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--deep-ice-blue);
    margin: 0 0 4px 0;
    word-break: break-word;
}

.data-card-id {
    font-size: 0.85em;
    color: var(--text-subtle);
    margin: 0 0 8px 0;
}

.data-card-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 4px 12px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.data-card-detail {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.data-card-detail strong {
    color: var(--text-primary);
    font-weight: 600;
    flex-shrink: 0;
}

.data-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 80px;
}

.data-card-actions button {
    padding: 6px 12px;
    font-size: 0.85em;
    height: auto;
    min-width: unset;
}

/* 关系卡片特殊样式 */
.relation-card .data-card-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.relation-path {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.relation-meta {
    display: flex;
    gap: 12px;
    font-size: 0.9em;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.relation-strength-container {
    flex: 1;
    min-width: 150px;
}

.relation-strength-label {
    font-size: 0.85em;
    color: var(--text-subtle);
    margin-bottom: 4px;
}

.relation-strength-bar {
    width: 100%;
    height: 6px;
    background: rgba(111, 181, 255, 0.18);
    border-radius: 3px;
    overflow: hidden;
}

.relation-strength-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f9cff 0%, #6de2ff 100%);
    transition: width 0.3s;
}

/* 响应式布局 */
@media (max-width: 768px) {
    .data-mgmt-categories {
        gap: 6px;
        padding: 10px 16px;
    }
    
    .category-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .data-mgmt-actions {
        padding: 10px 16px;
    }
    
    .data-card {
        flex-direction: column;
    }
    
    .data-card-actions {
        flex-direction: row;
        width: 100%;
        min-width: unset;
    }
    
    .data-card-actions button {
        flex: 1;
    }
}

/* ===== 数据管理页面深色模式 ===== */
@media (prefers-color-scheme: dark) {
    .data-management-page {
        background: linear-gradient(135deg,
            #0F172A 0%,
            #1E293B 25%,
            #0F172A 50%,
            #334155 75%,
            #1E293B 100%);
    }

    .data-mgmt-header {
        background: linear-gradient(135deg, rgba(45, 125, 210, 0.85) 0%, rgba(74, 158, 255, 0.75) 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .close-data-mgmt {
        background: rgba(255, 255, 255, 0.15);
    }

    .close-data-mgmt:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .data-mgmt-categories,
    .data-mgmt-actions {
        background: rgba(30, 41, 59, 0.8);
        border-bottom: 1px solid rgba(100, 116, 139, 0.3);
    }

    .data-mgmt-categories::-webkit-scrollbar-thumb {
        background: rgba(74, 158, 255, 0.5);
    }

    .category-btn {
        border-color: var(--ice-blue);
        color: var(--ice-blue);
    }

    .category-btn:hover {
        background: rgba(74, 158, 255, 0.2);
    }

    .category-btn.active {
        background: var(--ice-blue);
        color: white;
    }

    .data-mgmt-actions .search-input,
    .data-mgmt-actions .filter-select {
        background: rgba(30, 41, 59, 0.6);
        border-color: rgba(100, 116, 139, 0.4);
        color: var(--text-primary);
    }

    .data-mgmt-actions .search-input:focus {
        border-color: var(--ice-blue);
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    }

    .data-card {
        background: rgba(30, 41, 59, 0.7);
        border-color: rgba(100, 116, 139, 0.3);
    }

    .data-card:hover {
        border-color: var(--ice-blue);
        box-shadow: 0 8px 20px rgba(74, 158, 255, 0.3);
    }

    .data-card-title {
        color: var(--ice-blue);
    }

    .relation-strength-bar {
        background: rgba(74, 158, 255, 0.2);
    }

    .relation-strength-fill {
        background: linear-gradient(90deg, var(--ice-blue) 0%, var(--mint-green) 100%);
    }
}

/* ===== 关系弹窗下拉框样式 ===== */
#relation-target-select {
    width: 100%;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--glass-white);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#relation-target-select:focus {
    outline: none;
    border-color: var(--ice-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

#relation-target-select optgroup {
    font-weight: 600;
    color: var(--deep-ice-blue);
    padding: 8px 0;
}

#relation-target-select option {
    padding: 6px 12px;
    color: var(--text-primary);
}

#relation-target-select option:disabled {
    color: var(--text-secondary);
    font-weight: 600;
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    #relation-target-select {
        background: rgba(30, 41, 59, 0.6);
        border-color: rgba(100, 116, 139, 0.4);
    }

    #relation-target-select:focus {
        border-color: var(--ice-blue);
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    }

    #relation-target-select optgroup {
        color: var(--ice-blue);
    }
}

/* ==================== 关系图谱搜索框 ==================== */

/* 搜索容器 - 桌面端定位 */
.graph-search-container {
    position: fixed;
    left: 60px;              /* 工具栏48px + 间距12px */
    top: 16px;
    width: 320px;
    z-index: 200;            /* 高于工具栏(100)，低于详情面板(1000) */
}

/* 搜索框主体 */
.graph-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.graph-search-box:focus-within {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--ice-blue);
    box-shadow: 0 6px 16px rgba(74, 158, 255, 0.15);
}

/* 搜索图标 */
.graph-search-box .search-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.graph-search-box:focus-within .search-icon {
    color: var(--ice-blue);
}

/* 搜索输入框 */
.graph-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
}

.graph-search-input::placeholder {
    color: var(--text-subtle);
}

/* 清除按钮 */
.search-clear-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

.search-clear-btn.hidden {
    display: none;
}

/* 搜索结果下拉列表 */
.graph-search-results {
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.graph-search-results.hidden {
    display: none;
}

/* 结果为空提示 */
.graph-search-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 搜索结果项 */
.graph-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.graph-search-result-item:last-child {
    border-bottom: none;
}

.graph-search-result-item:hover {
    background: rgba(74, 158, 255, 0.1);
}

/* 实体类型图标 */
.search-result-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.search-result-icon.type-person {
    background: rgba(255, 107, 157, 0.15);
    color: #FF6B9D;
}

.search-result-icon.type-organization {
    background: rgba(156, 39, 176, 0.15);
    color: #9C27B0;
}

.search-result-icon.type-project {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.search-result-icon.type-event {
    background: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

.search-result-icon.type-resource {
    background: rgba(96, 125, 139, 0.15);
    color: #607D8B;
}

/* 结果项文本 */
.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 高亮匹配文本 */
.search-highlight {
    background: rgba(255, 235, 59, 0.4);
    font-weight: 600;
    color: var(--text-primary);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .graph-search-container {
        left: 8px;
        top: 56px;           /* 移动端工具栏48px + 间距8px */
        right: 8px;
        width: auto;
    }

    .graph-search-box {
        padding: 8px 12px;
    }

    .graph-search-input {
        font-size: 15px;     /* iOS最佳字号，避免自动缩放 */
    }

    .graph-search-results {
        max-height: 300px;
    }

    .search-result-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
    .graph-search-box {
        background: rgba(30, 30, 30, 0.9);
        border-color: rgba(74, 158, 255, 0.3);
    }

    .graph-search-box:focus-within {
        background: rgba(40, 40, 40, 0.95);
    }

    .graph-search-results {
        background: rgba(30, 30, 30, 0.95);
        border-color: rgba(74, 158, 255, 0.3);
    }

    .graph-search-result-item:hover {
        background: rgba(74, 158, 255, 0.15);
    }
}
