/* ============================================================
   关系图 - 完整样式（含欢迎页）
   ============================================================ */

/* ---------- 容器 ---------- */
#newrenwusd {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    background: #ffffff;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* ---------- 工具栏 ---------- */
.gxt-toolbar {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
    flex-wrap: wrap;
    min-height: 48px;
    z-index: 10;
    position: relative;
}
.gxt-toolbar .divider {
    width: 1px;
    height: 26px;
    background: #d1d5db;
    flex-shrink: 0;
}
.gxt-toolbar .spacer {
    flex: 1;
}

/* ---------- 按钮 ---------- */
.btn-gxt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 16px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}
.btn-gxt:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.btn-gxt:active {
    transform: scale(0.96);
}
.btn-gxt.primary {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
.btn-gxt.primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}
.btn-gxt.danger {
    color: #dc2626;
    border-color: #fca5a5;
}
.btn-gxt.danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}
.btn-gxt.toggle-on {
    background: #dbeafe;
    border-color: #60a5fa;
}
.btn-gxt.toggle-off {
    background: #f1f5f9;
    border-color: #d1d5db;
}
.btn-gxt.close {
    background: #fee2e2;
    border-color: #fca5a5;
}
.btn-gxt.close:hover {
    background: #fecaca;
}
.btn-gxt-lg {
    height: 40px;
    padding: 0 32px;
    font-size: 15px;
}
.btn-gxt-sm {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
}

/* ---------- 主布局 ---------- */
.gxt-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;   /* 让内部绝对定位元素相对此容器定位 */
}

/* ========== 欢迎页 ========== */
.gxt-welcome {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    box-sizing: border-box;
    overflow-y: auto;
    transition: opacity 0.3s ease;
}
.gxt-welcome.hidden {
    display: none;
}
.gxt-welcome .logo-area {
    text-align: center;
    margin-bottom: 32px;
}
.gxt-welcome .logo-area .icon {
    font-size: 64px;
    margin-bottom: 12px;
}
.gxt-welcome .logo-area h1 {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px 0;
}
.gxt-welcome .logo-area p {
    font-size: 15px;
    color: #64748b;
    margin: 0;
}
.gxt-welcome .actions {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    justify-content: center;
}
.gxt-welcome .card-list-section {
    width: 100%;
    max-width: 560px;
}
.gxt-welcome .card-list-section .section-title {
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 12px;
    text-align: center;
}
.gxt-welcome .card-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gxt-welcome .card-grid .welcome-card-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.15s;
    cursor: default;
}
.gxt-welcome .card-grid .welcome-card-item:hover {
    border-color: #93c5fd;
    background: #f1f5f9;
}
.gxt-welcome .card-grid .welcome-card-item .info {
    flex: 1;
    min-width: 0;
}
.gxt-welcome .card-grid .welcome-card-item .name {
    font-weight: 500;
    color: #0f172a;
}
.gxt-welcome .card-grid .welcome-card-item .time {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}
.gxt-welcome .card-grid .welcome-card-item .load-btn {
    padding: 4px 16px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 12px;
}
.gxt-welcome .card-grid .welcome-card-item .load-btn:hover {
    background: #2563eb;
}
.gxt-welcome .empty-tip {
    text-align: center;
    color: #94a3b8;
    padding: 24px 0;
    font-size: 14px;
}

/* ---------- 左侧边栏（浮动层） ---------- */
.gxt-left-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    overflow: hidden;
    background: #f8fafc;
    border-right: 1px solid #e5e7eb;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 15;                  /* 高于 #main，低于欢迎页(20) */
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0,0,0,0.08);
}
.gxt-left-sidebar.open {
    width: 420px;                /* 或 30%，但固定更可控 */
    overflow: visible;
}
.gxt-left-sidebar-inner {
    width: 420px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 左侧标签栏 */
.gxt-left-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}
.gxt-left-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    text-align: center;
}
.gxt-left-tab:hover {
    background: #f1f5f9;
}
.gxt-left-tab.active {
    color: #0f172a;
    font-weight: 600;
    border-bottom-color: #3b82f6;
    background: #eff6ff;
}

/* 左侧内容面板 */
.gxt-left-panel {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #ffffff;
}
.gxt-left-panel .panel-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gxt-left-panel .panel-content.hidden {
    display: none;
}

/* 面板操作栏 */
.gxt-panel-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* 面板表格容器（支持滚动） */
.gxt-panel-table {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: #ffffff;
    height: 100%;
    min-height: 0;
}
.gxt-panel-table table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    font-size: 13px;
    background: #ffffff;
    table-layout: fixed;
}
.gxt-panel-table thead th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 600;
    padding: 6px 6px;
    border: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 5;
    text-align: center;
    font-size: 12px;
}
.gxt-panel-table tbody td {
    padding: 0 !important;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
    text-align: center;
}
.gxt-panel-table tbody tr:hover td {
    background: #f8fafc;
}

/* 表格列宽分配（人物表） */
#test thead th:nth-child(1),
#test tbody td:nth-child(1) { width: 40px; min-width: 40px; }
#test thead th:nth-child(2),
#test tbody td:nth-child(2) { width: 25%; min-width: 140px; }
#test thead th:nth-child(3),
#test tbody td:nth-child(3) { width: 12%; min-width: 60px; }
#test thead th:nth-child(4),
#test tbody td:nth-child(4) { width: 15%; min-width: 80px; }
#test thead th:nth-child(5),
#test tbody td:nth-child(5) { width: 40%; min-width: 200px; }

/* 关系表列宽 */
#test2 thead th:nth-child(1),
#test2 tbody td:nth-child(1) { width: 40px; min-width: 40px; }
#test2 thead th:nth-child(2),
#test2 tbody td:nth-child(2) { width: 18%; min-width: 100px; }
#test2 thead th:nth-child(3),
#test2 tbody td:nth-child(3) { width: 18%; min-width: 100px; }
#test2 thead th:nth-child(4),
#test2 tbody td:nth-child(4) { width: 18%; min-width: 100px; }
#test2 thead th:nth-child(5),
#test2 tbody td:nth-child(5) { width: 15%; min-width: 80px; }
#test2 thead th:nth-child(6),
#test2 tbody td:nth-child(6) { width: 25%; min-width: 140px; }

/* 表格内输入框填满单元格 */
.gxt-panel-table td input,
.gxt-panel-table td select,
.gxt-panel-table td textarea {
    width: 100%;
    height: 100%;
    min-height: 36px;
    box-sizing: border-box;
    padding: 4px 8px;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    transition: background 0.15s;
}
.gxt-panel-table td input:focus,
.gxt-panel-table td select:focus,
.gxt-panel-table td textarea:focus {
    background: #fef9e3;
    outline: 2px solid #facc15;
    outline-offset: -1px;
}
.gxt-panel-table td select {
    appearance: auto;
    -webkit-appearance: auto;
    background: transparent;
    cursor: pointer;
    padding-right: 24px;
}
.gxt-panel-table td input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: auto;
    padding: 0;
    margin: 0 auto;
    display: block;
    cursor: pointer;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
}
.gxt-panel-table td:first-child {
    text-align: center;
    vertical-align: middle;
    padding: 4px 0 !important;
}

/* 头像列特殊样式 */
.gxt-panel-table .name-cell {
    padding: 4px !important;
}
.gxt-panel-table .name-cell .avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
}
.gxt-panel-table .name-cell .avatar-img {
    width: 100%;
    max-width: 80px;
    height: auto;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
}
.gxt-panel-table .name-cell .name-row {
    display: flex;
    gap: 4px;
    width: 100%;
}
.gxt-panel-table .name-cell .name-row .char-name {
    flex: 1;
    height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    background: #fff;
}
.gxt-panel-table .name-cell .name-row .avatar-pick-btn {
    height: 32px;
    padding: 0 8px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}
.gxt-panel-table .name-cell .name-row .avatar-pick-btn:hover {
    background: #2563eb;
}

/* 人物表格行高（带头像） */
#test tr {
    height: auto;
    min-height: 180px;
}
#test td {
    min-height: 180px;
}
#test td textarea {
    min-height: 180px;
    resize: none;
    line-height: 1.5;
}

/* 关系表格行高 */
#test2 tr {
    height: 44px;
}
#test2 td {
    height: 44px;
}

/* ---------- 左侧边栏拖拽手柄 ---------- */
.gxt-resize-handle {
    position: absolute;
    right: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    z-index: 20;
    cursor: col-resize;
    background: transparent;
    border-right: 2px solid transparent;
    transition: background 0.2s;
}
.gxt-resize-handle:hover,
.gxt-resize-handle.active {
    background: rgba(59, 130, 246, 0.15);
    border-right-color: #3b82f6;
}
.gxt-left-sidebar:not(.open) .gxt-resize-handle {
    display: none;
}

/* ---------- 右侧边栏（浮动层） ---------- */
.gxt-right-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 0;
    overflow: hidden;
    background: #f8fafc;
    border-left: 1px solid #e5e7eb;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 15;                  /* 同左侧边栏 */
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}
.gxt-right-sidebar.open {
    width: 340px;
    overflow: visible;
}
.gxt-right-sidebar-inner {
    width: 340px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 右侧边栏头部 */
.gxt-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.gxt-sidebar-header .title {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}
.gxt-sidebar-header .actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.gxt-sidebar-header .count {
    font-size: 12px;
    color: #94a3b8;
}
.gxt-sidebar-header .close-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
}
.gxt-sidebar-header .close-btn:hover {
    color: #475569;
}

/* 右侧卡片列表 */
.gxt-card-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}
.gxt-card-list .empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px 0;
    font-size: 14px;
}

/* 卡片列表项 */
.gxt-card-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.15s ease;
}
.gxt-card-item:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}
.gxt-card-item.active {
    background: #eff6ff;
    border-color: #93c5fd;
}
.gxt-card-item .info {
    flex: 1;
    min-width: 0;
}
.gxt-card-item .name {
    font-weight: 500;
    color: #0f172a;
    font-size: 14px;
}
.gxt-card-item .time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}
.gxt-card-item .badge {
    font-size: 10px;
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0 8px;
    border-radius: 10px;
    margin-left: 6px;
}
.gxt-card-item .actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 10px;
}
.gxt-card-item .actions button {
    padding: 2px 10px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.gxt-card-item .actions .load-btn {
    background: #3b82f6;
    color: #ffffff;
}
.gxt-card-item .actions .load-btn:hover:not(:disabled) {
    background: #2563eb;
}
.gxt-card-item .actions .load-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: default;
}
.gxt-card-item .actions .rename-btn {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #6b7280;
}
.gxt-card-item .actions .rename-btn:hover {
    background: #f1f5f9;
}
.gxt-card-item .actions .delete-btn {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
}
.gxt-card-item .actions .delete-btn:hover:not(:disabled) {
    background: #fef2f2;
}
.gxt-card-item .actions .delete-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 右侧边栏底部 */
.gxt-sidebar-footer {
    padding: 10px 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #64748b;
}
.gxt-sidebar-footer .current {
    font-weight: 600;
    color: #0f172a;
}
.gxt-sidebar-footer .refresh-btn {
    padding: 2px 10px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.gxt-sidebar-footer .refresh-btn:hover {
    background: #f1f5f9;
}

/* ---------- 关系图主区域 ---------- */
#main {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

/* ---------- 滚动条统一样式 ---------- */
.gxt-scroll::-webkit-scrollbar,
.gxt-panel-table::-webkit-scrollbar,
.gxt-card-list::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.gxt-scroll::-webkit-scrollbar-track,
.gxt-panel-table::-webkit-scrollbar-track,
.gxt-card-list::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.gxt-scroll::-webkit-scrollbar-thumb,
.gxt-panel-table::-webkit-scrollbar-thumb,
.gxt-card-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}
.gxt-scroll::-webkit-scrollbar-thumb:hover,
.gxt-panel-table::-webkit-scrollbar-thumb:hover,
.gxt-card-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .gxt-left-sidebar.open {
        width: 360px;
    }
    .gxt-left-sidebar-inner {
        width: 360px;
    }
    .gxt-right-sidebar.open {
        width: 300px;
    }
    .gxt-right-sidebar-inner {
        width: 300px;
    }
}

@media (max-width: 768px) {
    .gxt-left-sidebar.open {
        width: 100%;
        box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    }
    .gxt-left-sidebar-inner {
        width: 100%;
    }
    .gxt-right-sidebar.open {
        width: 100%;
        box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    }
    .gxt-right-sidebar-inner {
        width: 100%;
    }
    .gxt-toolbar {
        padding: 6px 10px;
        gap: 4px;
    }
    .btn-gxt {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
    }
    .gxt-welcome .logo-area h1 {
        font-size: 22px;
    }
    .gxt-welcome .actions {
        flex-direction: column;
        align-items: center;
    }
    /* 小屏下表格列宽适当调整 */
    #test thead th:nth-child(2),
    #test tbody td:nth-child(2) { min-width: 100px; }
    #test2 thead th:nth-child(2),
    #test2 tbody td:nth-child(2),
    #test2 thead th:nth-child(3),
    #test2 tbody td:nth-child(3),
    #test2 thead th:nth-child(4),
    #test2 tbody td:nth-child(4) { min-width: 80px; }
}