/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f5f5f5;
    color: #333;
}

header {
    background-color: #0078d7;
    color: white;
    padding: 0.8rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin-bottom: 0.6rem;
    text-align: center;
    font-size: 1.6rem;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 0.5rem;
}

nav ul li {
    margin: 0 1rem;
}

nav ul li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav ul li a:hover, nav ul li a.active {
    background-color: rgba(255, 255, 255, 0.2);
}

main {
    flex: 1;
    padding: 1rem;
    position: relative;
    height: calc(100vh - 130px);
    overflow: hidden;
}

/* 模块样式 - 默认所有模块隐藏 */
.module {
    display: none;
}

/* 活动模块样式 - 只显示active的模块 */
.module.active {
    display: flex;
}

/* ER图协作白板样式 */
#er-diagram.active {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    height: calc(100vh - 130px);
}

/* 规范化流程向导样式 */
#normalization.active {
    display: flex;
    flex-direction: column;
}

/* 设计反例博物馆样式 */
#anti-patterns {
    display: none;
}

#anti-patterns.active {
    display: flex;
    gap: 1rem;
}

/* 动态规范化工具样式 */
#dynamic-tool {
    display: none;
}

#dynamic-tool.active {
    display: flex;
    flex-direction: column;
}

footer {
    background-color: #f0f0f0;
    padding: 0.3rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #ddd;
}

.help-links a {
    color: #0078d7;
    text-decoration: none;
}

.help-links a:hover {
    text-decoration: underline;
}

/* ER图其他组件样式 */
.sidebar {
    width: 250px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar h3 {
    margin-bottom: 1rem;
    text-align: center;
}

.component-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.component {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    cursor: grab;
    background-color: #f9f9f9;
    transition: transform 0.2s, box-shadow 0.2s;
}

.component:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.entity {
    background-color: #e3f2fd;
    border-color: #90caf9;
}

.relationship {
    background-color: #f3e5f5;
    border-color: #ce93d8;
}

.attribute {
    background-color: #f1f8e9;
    border-color: #aed581;
}

.key-attribute {
    background-color: #fff3e0;
    border-color: #ffcc80;
}

.actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.actions button {
    padding: 0.5rem;
    border: none;
    border-radius: 4px;
    background-color: #0078d7;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.actions button:hover {
    background-color: #005a9e;
}

.workspace {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    min-height: calc(100vh - 150px);
    height: 100%;
}

.drawing-area {
    width: 100%;
    height: 100%;
    position: relative;
    background-image: 
        linear-gradient(#f0f0f0 1px, transparent 1px),
        linear-gradient(90deg, #f0f0f0 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
}

.output-panel {
    width: 250px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.output-panel h3 {
    margin-bottom: 1rem;
    text-align: center;
}

#relation-output {
    font-family: monospace;
    white-space: pre-wrap;
    border: 1px solid #ddd;
    padding: 0.5rem;
    border-radius: 4px;
    background-color: #f9f9f9;
    flex: 1;
    overflow-y: auto;
}

/* ER图实体和关系样式 */
.er-element {
    position: absolute;
    border: 2px solid #ccc;
    border-radius: 4px;
    padding: 0.5rem;
    min-width: 100px;
    min-height: 40px;
    background: white;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s, transform 0.2s;
    user-select: none;
}

.er-element:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.er-entity {
    border-color: #90caf9;
    background-color: #e3f2fd;
    box-shadow: 0 2px 5px rgba(25, 118, 210, 0.2);
}

.er-relationship {
    border-color: #ce93d8;
    background-color: #f3e5f5;
    transform: rotate(45deg);
    width: 80px;
    height: 80px;
    box-shadow: 0 2px 5px rgba(171, 71, 188, 0.2);
}

.er-relationship .element-content {
    transform: rotate(-45deg);
}

.er-attribute {
    border-color: #aed581;
    background-color: #f1f8e9;
    border-radius: 50px;
    box-shadow: 0 2px 5px rgba(104, 159, 56, 0.2);
}

.er-key-attribute {
    border-color: #ffcc80;
    background-color: #fff3e0;
    border-radius: 50px;
    font-weight: bold;
    text-decoration: underline;
    box-shadow: 0 2px 5px rgba(255, 152, 0, 0.2);
}

.element-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.element-name {
    width: 100%;
    min-height: 20px;
    outline: none;
    text-align: center;
    cursor: text;
}

.element-name:focus {
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
    padding: 2px;
}

.delete-element {
    opacity: 0.5;
    transition: opacity 0.3s;
}

.er-element:hover .delete-element {
    opacity: 1;
}

/* 规范化流程向导样式 */
#normalization {
    flex-direction: column;
}

.control-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.control-panel button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #0078d7;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.control-panel button:hover {
    background-color: #005a9e;
}

.control-panel button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.normalization-container {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.step-description {
    width: 30%;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.step-description h3 {
    margin-bottom: 1rem;
    color: #0078d7;
}

.visualization-area {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 设计反例博物馆样式 */
#anti-patterns {
    display: flex;
    gap: 1rem;
}

.cases-list {
    width: 250px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.cases-list h3 {
    margin-bottom: 1rem;
    text-align: center;
}

#case-selector {
    list-style: none;
}

#case-selector li {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#case-selector li:hover {
    background-color: #f0f0f0;
}

#case-selector li.selected {
    background-color: #0078d7;
    color: white;
}

.case-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.case-description {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.case-demo {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    min-height: 300px;
}

.case-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.case-actions button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #0078d7;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.case-actions button:hover {
    background-color: #005a9e;
}

/* 动态规范化工具样式 */
#dynamic-tool {
    flex-direction: column;
}

.instruction-panel {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.instruction-panel h3 {
    margin-bottom: 0.5rem;
    color: #0078d7;
}

.current-status {
    margin: 1rem 0;
    font-weight: bold;
}

.feedback {
    margin-top: 0.5rem;
    color: #d32f2f;
    min-height: 1.5rem;
}

.table-workspace {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex: 1;
}

.original-table, .decomposed-tables {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.original-table {
    width: 40%;
}

.decomposed-tables {
    flex: 1;
}

.original-table h4, .decomposed-tables h4 {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#add-table {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 4px;
    background-color: #0078d7;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.action-buttons button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #0078d7;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

.action-buttons button:hover {
    background-color: #005a9e;
}

/* 数据表格样式 */
.data-table {
    border-collapse: collapse;
    width: 100%;
}

.data-table th, .data-table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
}

.data-table th {
    background-color: #f0f0f0;
    position: relative;
}

.data-table th.primary-key::after {
    content: "🔑";
    position: absolute;
    right: 5px;
}

.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tr:hover {
    background-color: #f0f0f0;
}

/* 对话框样式 */
.dialog {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.dialog-content {
    background-color: white;
    margin: 10% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 70%;
    max-width: 800px;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    cursor: pointer;
    font-size: 1.5rem;
}

/* 拖拽表格字段的样式 */
.field-draggable {
    padding: 0.3rem 0.6rem;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0.3rem;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
}

.field-draggable:hover {
    background-color: #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.field-draggable:active {
    transform: scale(0.98);
}

.remove-field {
    margin-left: 6px;
    font-weight: bold;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.field-draggable:hover .remove-field {
    opacity: 1;
}

/* 字段容器样式增强 */
.field-container {
    min-height: 60px;
    border: 1px dashed #ccc;
    padding: 0.8rem;
    border-radius: 4px;
    margin: 10px 0;
    background-color: #fafafa;
}

/* 表容器样式改进 */
.table-container {
    margin-bottom: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s;
}

.table-container:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.table-container h5 {
    font-size: 16px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

/* 响应式设计 */
@media (max-width: 992px) {
    #er-diagram, .normalization-container, #anti-patterns {
        flex-direction: column;
    }
    
    .sidebar, .output-panel, .cases-list, .step-description {
        width: 100%;
    }
    
    .table-workspace {
        flex-direction: column;
    }
    
    .original-table {
        width: 100%;
    }
}

/* 动画效果 */
@keyframes highlight {
    0% {
        background-color: yellow;
    }
    100% {
        background-color: transparent;
    }
}

.highlight {
    animation: highlight 2s;
}

/* 错误状态 */
.error {
    border-color: #d32f2f !important;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* 辅助元素样式 */
.connector-dot {
    width: 10px;
    height: 10px;
    background-color: #0078d7;
    border-radius: 50%;
    position: absolute;
    z-index: 20;
}

.hidden {
    display: none;
}

/* 拖动中的元素样式 */
.dragging {
    opacity: 0.7;
    z-index: 1000;
}

/* 可放置区域高亮 */
.drop-active {
    border: 2px dashed #0078d7;
}

.drop-target {
    background-color: rgba(0, 120, 215, 0.1);
}

/* 拖拽反馈样式 */
.drag-feedback {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    background-color: #f9f9f9;
    min-width: 100px;
    opacity: 0.8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.drag-feedback.entity {
    background-color: #e3f2fd;
    border-color: #90caf9;
}

.drag-feedback.relationship {
    background-color: #f3e5f5;
    border-color: #ce93d8;
}

.drag-feedback.attribute {
    background-color: #f1f8e9;
    border-color: #aed581;
}

.drag-feedback.key-attribute {
    background-color: #fff3e0;
    border-color: #ffcc80;
}

/* 异常演示强化样式 */
.problem-note {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    background-color: #f8f9fa;
    border-left: 4px solid #0078d7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.problem-note.error {
    border-left: 4px solid #d32f2f;
    background-color: #fff5f5;
}

.note-title {
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.highlight-anomaly {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        background-color: #fff;
    }
    50% {
        background-color: #ffe0e0;
    }
    100% {
        background-color: #fff;
    }
}

/* 拖拽到画布高亮效果 */
.drawing-area.drop-active {
    background-color: rgba(0, 120, 215, 0.05);
    border: 2px dashed #0078d7;
}

/* 插入异常表单样式 */
.insert-form table {
    margin: 0 auto;
}

.insert-form input {
    border: 1px solid #ddd;
    padding: 4px;
    border-radius: 3px;
}

.insert-form input:disabled {
    background-color: #f8f8f8;
}

/* 强化动态规范化工具可视化效果 */
.field-draggable {
    transition: transform 0.2s, box-shadow 0.2s;
}

.field-draggable:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background-color: #e3f2fd;
}

.field-container.drop-target {
    background-color: rgba(0, 120, 215, 0.1);
    border: 2px dashed #0078d7;
}

/* 连接端点样式 */
.jtk-endpoint {
    z-index: 15;
    cursor: pointer;
}

/* 连接线样式 */
.jtk-connector {
    z-index: 5;
}

.jtk-connector:hover {
    cursor: pointer;
}

/* 连接端点和连接线的交互状态 */
.jtk-endpoint.jtk-hover, 
.jtk-source-hover,
.jtk-target-hover {
    cursor: pointer;
}

/* 主键字段样式 */
.field-draggable.primary-key-field {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
    font-weight: bold;
    position: relative;
}

.field-draggable.primary-key-field:hover {
    background-color: #bbdefb;
}

/* 表信息样式 */
.table-info {
    margin: 5px 0;
    color: #666;
    font-style: italic;
}

/* 关系模式表示法 */
.schema-notation {
    margin-top: 15px;
    padding: 8px;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

.schema-notation u {
    text-decoration: underline;
    font-weight: bold;
    color: #0078d7;
}

/* 关系类型选择器样式 */
.relation-type {
    margin-top: 5px;
}

.relation-cardinality {
    background-color: #f8e7fa;
    border: 1px solid #d3a6e0;
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 0.9em;
    cursor: pointer;
} 