/* ========================================
   知识图谱前端展示样式
   包含：浮层弹窗、独立页面、AI对话嵌入式
   ======================================== */

/* 知识图谱图标按钮 */
.kg-icon-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    margin-left: 8px;
}

.kg-icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 知识图谱术语链接 */
.kg-term-link {
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s;
}

.kg-term-link:hover {
    color: #764ba2;
}

/* ========== 方案A：浮层弹窗式 ========== */
.kg-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.kg-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.kg-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.kg-modal-overlay.active .kg-modal-content {
    transform: scale(1);
}

.kg-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kg-modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kg-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kg-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.kg-modal-body {
    padding: 25px;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
}

/* 节点信息卡片 */
.kg-node-info {
    margin-bottom: 25px;
}

.kg-node-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.kg-node-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.kg-node-title {
    flex: 1;
}

.kg-node-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.kg-node-category {
    display: inline-block;
    padding: 4px 12px;
    background: #e8f4f8;
    color: #2c7a7b;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.kg-node-description {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.8;
    color: #555;
    border-left: 4px solid #667eea;
}

/* 关系展示 */
.kg-relations-section {
    margin-bottom: 25px;
}

.kg-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kg-relations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.kg-relation-item {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 12px;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.kg-relation-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.kg-relation-type {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kg-relation-name {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.kg-relation-desc {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
}

/* 推荐产品 */
.kg-products-section {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.kg-product-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    gap: 15px;
    transition: all 0.3s;
    cursor: pointer;
}

.kg-product-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kg-product-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
}

.kg-product-info {
    flex: 1;
}

.kg-product-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.kg-product-desc {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.5;
}

.kg-product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e53e3e;
}

.kg-product-price .original {
    font-size: 0.85rem;
    color: #999;
    text-decoration: line-through;
    margin-left: 8px;
}

/* 底部操作 */
.kg-modal-footer {
    padding: 15px 25px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #e9ecef;
}

.kg-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.kg-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.kg-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.kg-btn-outline {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
}

.kg-btn-outline:hover {
    background: #667eea;
    color: white;
}

/* ========== 方案B：独立页面式 ========== */
.kg-page-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
}

.kg-page-header {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kg-page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.kg-page-subtitle {
    color: #666;
    font-size: 1.05rem;
}

.kg-search-bar {
    margin-top: 20px;
    position: relative;
}

.kg-search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s;
}

.kg-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.kg-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.kg-categories {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.kg-category-tag {
    padding: 8px 16px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 600;
}

.kg-category-tag:hover,
.kg-category-tag.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.kg-graph-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-height: 600px;
}

.kg-graph-canvas {
    width: 100%;
    height: 600px;
    border: 1px solid #e9ecef;
    border-radius: 12px;
}

/* 节点卡片列表 */
.kg-nodes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.kg-node-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.kg-node-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

/* ========== 方案C：AI对话嵌入式 ========== */
.kg-inline-widget {
    background: linear-gradient(135deg, #fff5eb 0%, #ffe8d6 100%);
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    border-left: 4px solid #f59e0b;
}

.kg-inline-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.kg-inline-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.kg-inline-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.kg-inline-content {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.kg-inline-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.kg-inline-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* 空状态 */
.kg-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.kg-empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.kg-empty-text {
    color: #999;
    font-size: 1.1rem;
}

/* 加载动画 */
.kg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.kg-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: kg-spin 1s linear infinite;
}

@keyframes kg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .kg-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .kg-relations-grid {
        grid-template-columns: 1fr;
    }

    .kg-nodes-list {
        grid-template-columns: 1fr;
    }

    .kg-page-title {
        font-size: 1.5rem;
    }
}

/* 滚动条美化 */
.kg-modal-body::-webkit-scrollbar {
    width: 8px;
}

.kg-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.kg-modal-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.kg-modal-body::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
