/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f0f0f0;
    color: #333;
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

/* 主应用容器 */
#app {
    display: flex;
    height: 100vh;
    position: relative;
}

/* 画布容器 */
#canvas-container {
    flex: 1;
    position: relative;
    background: #f8f8f8;
}

#main-canvas {
    width: 100%;
    height: 100%;
    cursor: default;
}

/* 控制面板 */
#control-panel {
    width: 280px;
    background: #fafafa;
    padding: 24px;
    border-left: 1px solid #d0d0d0;
    overflow-y: auto;
    z-index: 100;
}

.panel-header h2 {
    color: #333;
    text-align: center;
    margin-bottom: 32px;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* 输入区域 */
.input-section,
.operators-section,
.actions-section,
.current-expression {
    background: #f5f5f5;
    border: 1px solid #d0d0d0;
    border-radius: 0;
    padding: 20px;
    margin-bottom: 24px;
}

.input-section h3,
.operators-section h3,
.current-expression h3 {
    color: #666;
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#variables-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 0;
    font-size: 14px;
    font-family: monospace;
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
    background: #fafafa;
}

#variables-input:focus {
    outline: none;
    border-color: #333;
    background: white;
}

/* 按钮样式 */
.btn {
    padding: 12px 16px;
    border: 1px solid #333;
    border-radius: 0;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 12px;
    background: white;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.btn:hover {
    background: #333;
    color: white;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-info {
    background: white;
    color: #333;
    border-color: #333;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-success:hover,
.btn-info:hover {
    background: #333;
    color: white;
}

/* 运算符网格 */
.operators-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.operator-btn {
    padding: 16px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 0;
    color: #333;
    font-size: 18px;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.operator-btn:hover {
    background: #f5f5f5;
    border-color: #333;
}

.operator-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #fafafa;
    color: #999;
}

/* 当前表达式显示 */
#expression-display {
    background: #f5f5f5;
    color: #333;
    padding: 16px;
    border-radius: 0;
    font-size: 14px;
    text-align: center;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-all;
    border: 1px solid #e0e0e0;
    font-family: monospace;
}

/* SVG 元素样式 */
.logic-element {
    cursor: pointer;
    transition: all 0.15s ease;
}

.logic-element:hover .element-rect {
    stroke: #333;
    stroke-width: 2;
}

.logic-element.selected .element-rect {
    stroke: #000;
    stroke-width: 2;
    fill: #f5f5f5;
}

.element-rect {
    fill: white;
    stroke: #ccc;
    stroke-width: 1;
    rx: 0;
    ry: 0;
}

.element-text {
    fill: #333;
    font-family: monospace;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.connection-line {
    stroke: #999;
    stroke-width: 1;
    fill: none;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 0;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close {
    font-size: 20px;
    font-weight: normal;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    border: 1px solid #e0e0e0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #333;
    background: #f5f5f5;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* 真值表样式 */
.truth-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    font-family: monospace;
    background: white;
    border: 1px solid #e0e0e0;
}

.truth-table th,
.truth-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid #e0e0e0;
    font-size: 13px;
}

.truth-table th {
    background: #f5f5f5;
    color: #333;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.truth-table tr:nth-child(even) {
    background-color: #fafafa;
}

.truth-table tr:hover {
    background-color: #f0f0f0;
}

/* 答案状态样式 */
.truth-table tr.correct {
    background-color: #f8f9fa !important;
}

.truth-table tr.incorrect {
    background-color: #fff5f5 !important;
}

.truth-table tr.unanswered {
    background-color: #fffbf0 !important;
}

/* 真值表单选按钮 */
.truth-radio-group {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.radio-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.radio-option label {
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    font-size: 12px;
    font-family: monospace;
}

/* 真值表操作区 */
.truth-table-actions {
    text-align: center;
    margin-top: 24px;
    border-top: 1px solid #e0e0e0;
    padding-top: 24px;
}

#result-display {
    margin-top: 16px;
    padding: 16px;
    border-radius: 0;
    font-weight: 500;
    font-size: 13px;
    display: none;
    font-family: monospace;
    text-align: left;
}

.result-correct {
    background-color: #f8f9fa;
    color: #333;
    border: 1px solid #e0e0e0;
}

.result-incorrect {
    background-color: #fff5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

/* 答案统计 */
.answer-statistics {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    font-family: monospace;
    font-size: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.stat-item:last-child {
    margin-bottom: 0;
    font-weight: 600;
    border-top: 1px solid #e0e0e0;
    padding-top: 8px;
    margin-top: 8px;
}

/* 提示工具样式 */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.tooltip.show {
    opacity: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #control-panel {
        width: 100%;
        height: 50vh;
        position: absolute;
        bottom: 0;
        z-index: 100;
    }
    
    #canvas-container {
        height: 50vh;
    }
    
    .operators-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 动画效果 */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 选中状态的高亮效果 */
.highlight-selection {
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.4);
    transform: scale(1.01);
}
