/* 参考 stitch letta / api_letta / xiami_3 的页面功能区样式 */

.xi-page-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.xi-page-hero h2 {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.xi-page-hero .xi-page-desc {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #64748b;
    max-width: 42rem;
}

.xi-page-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.xi-letta-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.xi-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: rgba(248, 250, 252, 0.6);
}

.xi-table-toolbar .agent-batch-bar {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.xi-letta-table-wrap {
    overflow-x: auto;
}

.xi-letta-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.xi-letta-table thead tr {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.xi-letta-table th {
    padding: 14px 20px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.xi-letta-table td {
    padding: 16px 20px;
    font-size: 13px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.xi-letta-table tbody tr:hover {
    background: #f8fafc;
}

.xi-letta-table tbody tr:last-child td {
    border-bottom: none;
}

.xi-letta-table .xi-cell-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.xi-letta-table .xi-cell-sub {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.xi-code-pill {
    display: inline-block;
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #6366f1;
}

.xi-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.xi-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.xi-badge--active {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.xi-badge--active .xi-badge-dot {
    background: #10b981;
}

.xi-badge--revoked {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}

.xi-badge--revoked .xi-badge-dot {
    background: #94a3b8;
}

.xi-btn-text-danger {
    border: none;
    background: none;
    color: #ef4444;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.xi-btn-text-danger:hover {
    text-decoration: underline;
}

.xi-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 24px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    background: #f8fafc;
}

.xi-info-banner .material-symbols-outlined {
    color: #6366f1;
    flex-shrink: 0;
}

.xi-info-banner-title {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 4px;
}

.xi-info-banner-text {
    font-size: 12px;
    line-height: 1.6;
    color: #64748b;
    margin: 0;
}

.xi-perm-panel {
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fafbfc;
}

.xi-perm-panel summary {
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #334155;
}

.xi-perm-panel .xi-perm-body {
    padding: 0 16px 16px;
}

/* 记忆体管理 stats */
.xi-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 24px 0;
}

@media (max-width: 1100px) {
    .xi-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .xi-stats-grid {
        grid-template-columns: 1fr;
    }
}

.xi-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.xi-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.xi-stat-icon .material-symbols-outlined {
    font-size: 22px;
}

.xi-stat-icon--purple {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
}

.xi-stat-icon--blue {
    background: #eff6ff;
    color: #2563eb;
}

.xi-stat-icon--green {
    background: #ecfdf5;
    color: #059669;
}

.xi-stat-icon--amber {
    background: #fffbeb;
    color: #d97706;
}

.xi-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 4px;
}

.xi-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.xi-stat-sub {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    margin-left: 4px;
}

/* 记忆体广场 letta_2 */
.apz-hero-letta {
    margin-bottom: 24px;
}

.apz-hero-letta .apz-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.apz-grid-letta {
    gap: 20px;
}

.apz-card-letta {
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s, box-shadow 0.15s;
}

.apz-card-letta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.08);
}

.apz-cat.is-active {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.25);
    font-weight: 600;
}

/* 记忆可视化 xiami_3 */
.memory-graph-card.xi-graph-ref {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: calc(100vh - 140px);
}

#panel-visual.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
}

#panel-visual.active #timeline {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#panel-visual.active .memory-graph-card.xi-graph-ref {
    flex: 1;
    min-height: calc(100vh - 130px);
}

.xi-graph-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px 20px;
    padding: 16px 24px;
    background: #fff;
    border: 1px solid rgba(204, 195, 216, 0.35);
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(204, 195, 216, 0.2);
}

@media (max-width: 1100px) {
    .xi-graph-filter-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }
}

.xi-graph-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.xi-graph-filter-field--grow {
    flex: 1 1 220px;
    min-width: 200px;
}

.xi-graph-filter-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.xi-graph-filter-select,
.xi-graph-filter-num {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #f1f3ff;
    color: #141b2b;
    font-size: 14px;
    box-sizing: border-box;
}

.xi-graph-filter-select {
    min-width: 160px;
}

.xi-graph-filter-select:focus,
.xi-graph-filter-num:focus {
    outline: none;
    border-color: rgba(99, 14, 212, 0.35);
    box-shadow: 0 0 0 3px rgba(99, 14, 212, 0.12);
}

.xi-graph-filter-node-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.xi-graph-filter-num {
    width: 72px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .xi-graph-ref .xi-graph-filter-num {
        display: none;
    }
}

.xi-graph-cap-inline {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #94a3b8;
    font-size: 10px;
}

.xi-graph-filter-field--token {
    flex: 1 1 180px;
    min-width: 160px;
}

.xi-graph-filter-field--search {
    flex: 1 1 220px;
    min-width: 200px;
}

.xi-graph-inline-search {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.xi-graph-inline-search .xi-graph-search-input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #f1f3ff;
    font-size: 14px;
    box-sizing: border-box;
}

.xi-graph-inline-search .xi-graph-search-input:focus {
    outline: none;
    border-color: rgba(99, 14, 212, 0.35);
    box-shadow: 0 0 0 3px rgba(99, 14, 212, 0.12);
}

.xi-graph-inline-search .btn {
    align-self: stretch;
    white-space: nowrap;
}

.xi-graph-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-left: auto;
    padding-bottom: 2px;
}

.xi-graph-edge-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #4a4455;
    user-select: none;
}

.xi-graph-edge-toggle input {
    width: 18px;
    height: 18px;
    accent-color: #630ed4;
}

.xi-graph-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    background: #630ed4;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(99, 14, 212, 0.25);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.xi-graph-refresh-btn:hover {
    background: #5b21b6;
    box-shadow: 0 6px 20px rgba(99, 14, 212, 0.3);
}

.xi-graph-refresh-btn:active {
    transform: scale(0.98);
}

.xi-graph-refresh-btn .material-symbols-outlined {
    font-size: 18px;
}

.xi-graph-msg {
    margin: 0;
    padding: 8px 24px;
    font-size: 13px;
    background: #fff;
    border-left: 1px solid rgba(204, 195, 216, 0.35);
    border-right: 1px solid rgba(204, 195, 216, 0.35);
}

.xi-graph-stage {
    position: relative;
    flex: 1;
    min-height: calc(100vh - 300px);
    background: #f1f3ff;
    border: 1px solid rgba(204, 195, 216, 0.35);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.graph-mesh {
    background-color: #f9f9ff !important;
    background-image: radial-gradient(circle at 1px 1px, rgba(99, 14, 212, 0.06) 1px, transparent 0) !important;
    background-size: 40px 40px !important;
}

.xi-graph-canvas-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-color: #d8e0f0;
    background-image: url('/media/backgroud/background.png');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0.45;
}

.xi-graph-stage .memory-graph-canvas-wrap {
    position: absolute;
    inset: 0;
    min-height: 0;
    border: none;
    background: transparent !important;
    z-index: 1;
}

.xi-graph-stage .memory-graph-svg {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 300px);
    background: transparent !important;
}

.xi-graph-zoom-controls {
    position: absolute;
    left: 24px;
    bottom: 24px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.xi-graph-zoom-btn {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(204, 195, 216, 0.4);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #141b2b;
    transition: color 0.15s, border-color 0.15s, transform 0.1s;
}

.xi-graph-zoom-btn:hover {
    color: #630ed4;
    border-color: rgba(99, 14, 212, 0.35);
}

.xi-graph-zoom-btn:active {
    transform: scale(0.95);
}

.xi-graph-detail-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: min(380px, calc(100% - 32px));
    max-height: none;
    height: auto;
    display: flex;
    flex-direction: column;
    z-index: 30;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(204, 195, 216, 0.35);
    border-radius: 2rem;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    max-height: none;
    padding: 0;
}

.xi-graph-detail-panel.is-collapsed {
    opacity: 0;
    pointer-events: none;
    transform: translateX(12px);
    transition: opacity 0.2s, transform 0.2s;
}

/* 点击关闭：收起到右下角浮动按钮，再点恢复 */
.xi-graph-stage {
    position: relative;
}

.xi-graph-detail-panel.is-minimized {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: auto;
    width: 52px;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
}

.xi-graph-detail-panel.is-minimized .xi-graph-detail-head {
    padding: 0;
    border: none;
    width: 100%;
    justify-content: center;
}

.xi-graph-detail-panel.is-minimized .xi-graph-detail-head-left {
    display: none;
}

.xi-graph-detail-panel.is-minimized #mgNoEdges,
.xi-graph-detail-panel.is-minimized #mgDetails,
.xi-graph-detail-panel.is-minimized .xi-graph-detail-foot {
    display: none !important;
}

.xi-graph-detail-panel.is-minimized .xi-graph-detail-close {
    width: 44px;
    height: 44px;
}

.xi-graph-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(204, 195, 216, 0.15);
    flex-shrink: 0;
}

.xi-graph-detail-head-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.xi-graph-detail-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: rgba(99, 14, 212, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #630ed4;
}

.xi-graph-detail-icon .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

.xi-graph-detail-panel .mg-side-title {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 17px;
    font-weight: 700;
    color: #141b2b;
}

.xi-graph-detail-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
}

.xi-graph-detail-close:hover {
    background: #f1f3ff;
}

.xi-graph-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.xi-graph-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.xi-graph-detail-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.xi-graph-detail-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.xi-graph-type-badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(99, 14, 212, 0.1);
    color: #630ed4;
    font-size: 13px;
    font-weight: 700;
}

.xi-graph-detail-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #141b2b;
    word-break: break-word;
}

.xi-graph-uuid-box {
    padding: 12px 16px;
    border-radius: 12px;
    background: #f1f3ff;
    border: 1px solid rgba(204, 195, 216, 0.25);
    font-family: ui-monospace, "JetBrains Mono", monospace;
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
}

.xi-graph-detail-time {
    font-size: 14px;
    color: #4a4455;
}

.xi-graph-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.xi-graph-tag {
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(103, 75, 181, 0.1);
    color: #674bb5;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(103, 75, 181, 0.12);
}

.xi-graph-summary-box {
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(241, 243, 255, 0.6);
    border: 1px solid rgba(204, 195, 216, 0.3);
    font-size: 14px;
    line-height: 1.65;
    color: #4a4455;
    white-space: pre-wrap;
    word-break: break-word;
}

.xi-graph-json-pre {
    margin: 0;
    max-height: 200px;
    overflow: auto;
}

.xi-graph-detail-foot {
    padding: 16px 24px;
    border-top: 1px solid rgba(204, 195, 216, 0.15);
    flex-shrink: 0;
}

.xi-graph-json-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 16px;
    background: #e1e8fd;
    color: #141b2b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.xi-graph-json-btn:hover {
    background: rgba(99, 14, 212, 0.12);
    color: #630ed4;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 10px;
}

@media (max-width: 900px) {
    .xi-graph-detail-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        max-height: 360px;
        border-radius: 0 0 12px 12px;
        margin-top: 0;
    }

    .xi-graph-stage {
        display: flex;
        flex-direction: column;
        min-height: 480px;
    }

    .xi-graph-stage .memory-graph-canvas-wrap {
        position: relative;
        flex: 1;
        min-height: 360px;
    }

    .xi-graph-filter-actions {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
}

/* Settings / Usage hub 页头（对齐 agents 功能区） */
.xi-hub-hero {
    margin-bottom: 16px;
}

.xi-hub-hero .page-title {
    margin-bottom: 4px;
}

.xi-hub-hero .xi-page-desc {
    margin: 0;
    max-width: 48rem;
}
