/* Three.js 关系图谱测试页 */

#three-graph-page {
    display: flex;
    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: linear-gradient(135deg,
        var(--ice-crystal) 0%,
        #F0F9FF 25%,
        var(--ice-crystal) 50%,
        #E0F2FE 75%,
        var(--ice-crystal) 100%);
    background-attachment: fixed;
}

#three-graph-page::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(74, 158, 255, 0.03) 10px,
            rgba(74, 158, 255, 0.03) 20px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 15px,
            rgba(0, 212, 170, 0.02) 15px,
            rgba(0, 212, 170, 0.02) 30px
        );
    z-index: 0;
}

.app-page-disabled {
    display: none !important;
}

.three-main-content {
    position: relative;
    z-index: 1;
}

.three-canvas-wrapper {
    position: relative;
    overflow: hidden;
    background: transparent;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.three-canvas-wrapper canvas {
    position: relative;
    display: block;
    width: 100% !important;
    height: 100% !important;
    outline: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.three-graph-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 15px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.28);
    pointer-events: none;
    z-index: 3;
}

.three-graph-status.hidden {
    display: none;
}

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

.three-detail-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.three-detail-row {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    font-size: 14px;
}

.three-detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.three-detail-value {
    color: var(--text-primary);
    word-break: break-word;
}

.three-related-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.three-related-item {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(74, 158, 255, 0.08);
    border: 1px solid rgba(74, 158, 255, 0.18);
    color: var(--text-primary);
    font-size: 13px;
}

.three-detail-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.three-detail-fields .input-group {
    margin: 0;
}

.three-detail-fields input,
.three-detail-fields textarea {
    width: 100%;
}

.three-detail-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 2px;
}

.three-icon-select {
    width: 100%;
    min-height: 36px;
    padding: 7px 9px;
    border: 1px solid rgba(148, 163, 184, 0.38);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    font: inherit;
}

.three-node-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.three-node-label {
    position: absolute;
    transform: translate(-50%, -50%);
    color: #1F2937;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.95);
    z-index: 1;
}

.three-node-label.is-hidden {
    display: none;
}

.three-force2d-view {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
}

.three-force2d-view.hidden {
    display: none;
}

#three-force2d-graph {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.three-force2d-link {
    stroke-linecap: round;
}

.three-force2d-node circle {
    stroke-width: 3px;
    transition: stroke-width 0.2s, filter 0.2s;
    filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.14));
}

.three-force2d-node:hover circle {
    stroke-width: 4px;
    filter: brightness(1.15) drop-shadow(0 3px 7px rgba(15, 23, 42, 0.18));
}

.three-force2d-node text {
    fill: #333333;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: middle;
    user-select: none;
}

.three-force2d-node.is-selected circle {
    stroke: #FF6B00;
    stroke-width: 4px;
    filter: brightness(1.25) drop-shadow(0 0 8px rgba(255, 107, 0, 0.55));
}

.three-data-table-view {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    background: #F8FAFC;
    color: var(--text-primary);
}

.three-data-table-view.hidden {
    display: none;
}

.three-data-table-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 8px rgba(15, 23, 42, 0.04);
}

.three-table-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 180px;
}

.three-table-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748B;
}

.three-table-search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border: 1px solid rgba(148, 163, 184, 0.38);
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--text-primary);
    font: inherit;
}

.three-table-type-tabs,
.three-table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.three-table-type-btn {
    height: 34px;
    padding: 0 11px;
    border: 1px solid rgba(148, 163, 184, 0.34);
    border-radius: 8px;
    background: #FFFFFF;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}

.three-table-type-btn.active {
    border-color: rgba(59, 130, 246, 0.55);
    background: #EAF3FF;
    color: #1D4ED8;
}

.three-data-table-meta {
    min-height: 32px;
    padding: 8px 16px;
    color: #64748B;
    font-size: 13px;
    background: #F8FAFC;
}

.three-data-table-wrap {
    flex: 1;
    overflow: auto;
    padding: 0 14px 14px;
}

.three-data-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    background: #FFFFFF;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.three-data-table th,
.three-data-table td {
    padding: 9px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.20);
    border-right: 1px solid rgba(148, 163, 184, 0.14);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
    line-height: 1.35;
}

.three-data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #F1F5F9;
    color: #334155;
    font-weight: 700;
    white-space: nowrap;
}

.three-data-table td {
    color: #1F2937;
    max-width: 260px;
}

.three-table-empty {
    padding: 36px;
    text-align: center;
    color: #64748B;
}

.three-table-row-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.three-table-row-actions button {
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.32);
    background: #FFFFFF;
    color: #334155;
    font-size: 12px;
}

.three-table-row-actions button.danger {
    color: #DC2626;
    border-color: rgba(220, 38, 38, 0.28);
}

.three-table-row-actions button.status {
    color: #2563EB;
    border-color: rgba(37, 99, 235, 0.28);
}

.three-table-edit-modal {
    max-width: 760px;
}

.three-table-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.three-table-fields .input-group {
    margin: 0;
}

.three-table-fields input,
.three-table-fields textarea,
#three-table-edit-status,
#three-table-edit-summary {
    width: 100%;
}

@media (prefers-color-scheme: dark) {
    #three-graph-page {
        background: radial-gradient(circle at 35% 25%, rgba(74, 158, 255, 0.12), transparent 35%),
            linear-gradient(135deg, #0F172A 0%, #111827 48%, #10251F 100%);
    }

    .three-graph-status {
        background: rgba(15, 23, 42, 0.78);
        border-color: rgba(148, 163, 184, 0.25);
        color: var(--text-primary);
    }

    .three-node-label {
        color: #F8FAFC;
        text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
    }

    .three-canvas-wrapper {
        background: transparent;
    }
}

@media (max-width: 768px) {
    #three-graph-page {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 80px !important;
        height: auto !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .three-graph-sidebar {
        display: none !important;
    }

    .three-graph-mobile-toolbar {
        display: flex !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000;
    }

    .three-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;
        padding: 0 !important;
    }

    .three-canvas-wrapper {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }

    .three-search-container {
        top: 56px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
    }

    .three-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;
        min-width: 0 !important;
        max-width: 100% !important;
        max-height: min(calc(var(--app-vh, 1vh) * 48), calc(var(--app-viewport-height, 100vh) - var(--bottom-nav-height) - env(safe-area-inset-bottom) - 16px)) !important;
        border-radius: 16px 16px 0 0;
    }

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

    .three-data-table-view {
        top: 48px;
    }

    .three-data-table-topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 10px;
    }

    .three-table-search {
        flex-basis: auto;
    }

    .three-table-type-tabs,
    .three-table-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .three-table-type-btn,
    .three-table-actions button {
        flex: 0 0 auto;
    }

    .three-data-table-wrap {
        padding: 0 10px 10px;
    }

    .three-table-fields {
        grid-template-columns: 1fr;
    }
}
