/* ============================================================
   关系图 - 完整样式（精简去重版，表头继承全局 th）
   ============================================================ */

/* ---------- 容器 ---------- */
#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: nowrap;
    min-height: 48px;
    z-index: 10;
    position: relative;
}
.gxt-toolbar .spacer {
    flex: 1;
}
.gxt-toolbar .divider {
    width: 1px;
    height: 26px;
    background: #d1d5db;
    flex-shrink: 0;
}

/* ---------- 按钮 ---------- */
.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%;
    overflow: hidden;
    background: #f8fafc;
    border-right: 1px solid #e5e7eb;
    transition: none;
    z-index: 15;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.08);
    width: 0 !important;
}
.gxt-left-sidebar.open {
    width: 950px !important;
    max-width: 100vw !important;
}
.gxt-left-sidebar-inner {
    width: 950px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gxt-left-sidebar:not(.open) .gxt-resize-handle {
    display: none;
}

/* 左侧标签栏 */
.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;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: #ffffff;
    min-height: 0;
    height: 100%;
}
.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;
    min-height: 0;
    height: 100%;
    position: relative;
}
.gxt-panel-table table {
    width: 100%;
    border-collapse: collapse !important;
    font-size: 13px;
    background: #ffffff;
    table-layout: fixed !important;
    height: 100%;
}

/* ----- 表头（继承全局 th 样式，仅保留 sticky 等布局属性） ----- */
.gxt-panel-table thead th {
    /* 背景色和文字颜色由全局 th 决定，不在此覆盖 */
    font-weight: 600;
    padding: 6px 8px !important;
    border: 1px solid #e5e7eb !important;
    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 !important;
    vertical-align: middle;
    text-align: center;
}
.gxt-panel-table tbody tr:hover td {
    background: #f8fafc;
}

/* ========== 人物表 #test 列宽 ========== */
#test thead th:nth-child(1),
#test tbody td:nth-child(1) {
    width: 10%;
    min-width: 50px;
}
#test thead th:nth-child(2),
#test tbody td:nth-child(2) {
    width: 30%;
    min-width: 180px;
}
#test thead th:nth-child(3),
#test tbody td:nth-child(3) {
    width: 10%;
    min-width: 80px;
}
#test thead th:nth-child(4),
#test tbody td:nth-child(4) {
    width: 10%;
    min-width: 80px;
}
#test thead th:nth-child(5),
#test tbody td:nth-child(5) {
    width: 40%;
    min-width: 150px;
}

/* ========== 关系表 #test2 列宽 ========== */
#test2 thead th:nth-child(1),
#test2 tbody td:nth-child(1) {
    width: 10%;
    min-width: 50px;
}
#test2 thead th:nth-child(2),
#test2 tbody td:nth-child(2) {
    width: 20%;
    min-width: 180px;
}
#test2 thead th:nth-child(3),
#test2 tbody td:nth-child(3) {
    width: 20%;
    min-width: 180px;
}
#test2 thead th:nth-child(4),
#test2 tbody td:nth-child(4) {
    width: 10%;
    min-width: 80px;
}
#test2 thead th:nth-child(5),
#test2 tbody td:nth-child(5) {
    width: 10%;
    min-width: 80px;
}
#test2 thead th:nth-child(6),
#test2 tbody td:nth-child(6) {
    width: 30%;
    min-width: 150px;
}

/* ========== 表格内输入元素：无边框，透明背景 ========== */
.gxt-panel-table td input,
.gxt-panel-table td select,
.gxt-panel-table td textarea {
    width: 100% !important;
    height: 100% !important;
    min-height: 36px;
    box-sizing: border-box !important;
    padding: 4px 8px;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    outline: none !important;
    box-shadow: none !important;
    transition: background 0.15s;
    margin: 0;
    display: block;
}
.gxt-panel-table td select {
    appearance: none;
    -webkit-appearance: none;
    background-image: none;
    padding-right: 4px;
    cursor: pointer;
}
.gxt-panel-table td textarea {
    resize: none;
    overflow: hidden;
    min-height: 60px;
}
.gxt-panel-table td input:focus,
.gxt-panel-table td select:focus,
.gxt-panel-table td textarea:focus {
    background: #fef9e3 !important;
    outline: none !important;
}

/* 复选框 */
.gxt-panel-table td:first-child input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    padding: 0;
    margin: 0 auto;
    display: block;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
}
.gxt-panel-table td:first-child {
    text-align: center;
    vertical-align: middle;
}

/* ========== 头像列（名称列） ========== */
.gxt-panel-table .name-cell {
    padding: 4px !important;
}
.gxt-panel-table .name-cell .avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 4px;
    box-sizing: border-box;
    gap: 4px;
    justify-content: center;
}
.gxt-panel-table .name-cell .avatar-img {
    width: 100% !important;
    max-width: none !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    display: block;
    margin-bottom: 4px;
}
.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;
}

/* ========== 关系表头像 ========== */
#test2 td div[style*="display:flex"] {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    height: 100%;
}
#test2 td .jia-avatar,
#test2 td .yi-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
#test2 td select {
    flex: 1;
    min-width: 60px;
    height: 32px;
}

/* ========== 行高 ========== */
#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-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 !important;
    }
    .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% !important;
        max-width: 100% !important;
        max-height: 100vh;
        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;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .gxt-toolbar::-webkit-scrollbar {
        display: none;
    }
    .btn-gxt {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
        flex-shrink: 0;
    }

    /* 欢迎页 */
    .gxt-welcome .logo-area h1 {
        font-size: 22px;
    }
    .gxt-welcome .actions {
        flex-direction: column;
        align-items: center;
    }

    /* 左侧面板高度自适应 */
    .gxt-left-panel {
        flex: 1;
        min-height: 0;
        height: 100%;
    }
    .gxt-panel-table {
        flex: 1;
        min-height: 0;
        height: 100%;
        overflow: auto;
    }
    #test,
    #test2 {
        height: auto;
        min-height: 100%;
        width: 100%;
        min-width: 600px;
    }
    #test tbody tr,
    #test2 tbody tr {
        height: auto;
        min-height: 44px;
    }

    /* 移动端输入元素 */
    #test td input,
    #test td select,
    #test td textarea,
    #test2 td input,
    #test2 td select,
    #test2 td textarea {
        min-height: 40px;
        font-size: 14px;
    }

    /* 头像在移动端缩小 */
    .gxt-panel-table .name-cell .avatar-img {
        max-width: 60px !important;
        margin: 0 auto 4px;
    }
    .gxt-panel-table .name-cell .name-row input {
        font-size: 12px;
        min-height: 30px;
    }
    #test2 td .jia-avatar,
    #test2 td .yi-avatar {
        width: 28px;
        height: 28px;
    }
    #test2 td select {
        height: 36px;
        font-size: 14px;
    }

    /* 列最小宽度在移动端调整 */
    #test thead th:nth-child(2),
    #test tbody td:nth-child(2) {
        min-width: 120px;
    }
    #test2 thead th:nth-child(2),
    #test2 tbody td:nth-child(2),
    #test2 thead th:nth-child(3),
    #test2 tbody td:nth-child(3) {
        min-width: 120px;
    }
}