/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* 应用容器 */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #4a5568;
    font-size: 1.8rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 0.5rem;
    color: #667eea;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* 按钮样式 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-info {
    background: #38b2ac;
    color: white;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-secondary {
    background: #a0aec0;
    color: white;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    gap: 1rem;
}

/* 工具栏 */
.toolbar {
    width: 200px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem;
    height: fit-content;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.tool-group {
    margin-bottom: 1.5rem;
}

.tool-group h3 {
    font-size: 0.9rem;
    color: #4a5568;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-btn {
    width: 100%;
    padding: 0.7rem;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: 8px;
    background: #f7fafc;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    background: #667eea;
    color: white;
    transform: translateX(4px);
}

.tool-btn.active {
    background: #667eea;
    color: white;
}

/* 编辑和分析区域 */
.editor-analysis {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1rem;
}

/* 面板通用样式 */
.editor-panel, .analysis-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.tree-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 故障树画布 */
.tree-canvas {
    height: 84vh;
    padding: 1rem;
    overflow: auto;
    background: #f8f9fa;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    margin: 1rem;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #a0aec0;
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* 节点样式 */
.tree-node {
    position: absolute;
    min-width: 120px;
    min-height: 60px;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: move;
    user-select: none;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid transparent;
    z-index: 10;
}

.tree-node:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.tree-node.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.tree-node.dragging {
    opacity: 0.9;
    transform: scale(1.1);
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transition: none;
}

/* 不同类型节点的颜色 */
.node-TOP_EVENT {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.node-INTERMEDIATE_EVENT {
    background: linear-gradient(135deg, #ed8936, #dd6b20);
    color: white;
}

.node-BASIC_EVENT {
    background: linear-gradient(135deg, #38b2ac, #319795);
    color: white;
}

.node-AND_GATE {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.node-OR_GATE {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.node-XOR_GATE {
    background: linear-gradient(135deg, #9f7aea, #805ad5);
    color: white;
}

.node-NOT_GATE {
    background: linear-gradient(135deg, #a0aec0, #718096);
    color: white;
}

.node-K_N_GATE {
    background: linear-gradient(135deg, #3182ce, #2c5282);
    color: white;
}

.node-name {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.node-probability {
    font-size: 0.75rem;
    opacity: 0.8;
}

.node-icon {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

/* 连接线 */
.connection-line {
    position: absolute;
    background: #4a5568;
    height: 2px;
    transform-origin: left center;
    pointer-events: none;
    z-index: 1;
}

/* 分析面板 */
.analysis-content {
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.analysis-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 1rem;
}

.analysis-section h3 {
    color: #4a5568;
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.probability-display {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 600;
}

.cut-sets {
    max-height: 200px;
    overflow-y: auto;
}

.cut-set {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-family: monospace;
    font-size: 0.85rem;
}

.importance-analysis {
    max-height: 200px;
    overflow-y: auto;
}

.importance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.importance-name {
    font-weight: 500;
}

.importance-value {
    font-family: monospace;
    color: #667eea;
    font-weight: 600;
}

.sensitivity-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sensitivity-controls select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.sensitivity-chart {
    height: 150px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-result {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 2rem;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-col {
    flex: 1;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .editor-analysis {
        grid-template-columns: 1fr 350px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .toolbar {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .editor-analysis {
        grid-template-columns: 1fr;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-actions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
} 