* {
    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%);
    background-repeat: no-repeat;
    background-attachment: fixed; /* 可选，使背景固定不随内容滚动，拉伸感更强 */
    background-position: center;
    background-size: cover;
    min-height: 100vh;
    min-width: 1100px;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

.main-content {
    display: flex;
    min-height: 700px;
}

.sidebar {
    width: 340px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.panel h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.molecule-list,
.reaction-list {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.molecule-item {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
}

.molecule-item:hover {
    background: #f0f4ff;
    border-color: #667eea;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.molecule-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.molecule-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.molecule-item-name {
    font-weight: 600;
    color: #333;
}

.molecule-item-id {
    font-size: 11px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.molecule-item-structure {
    width: 100%;
    height: 80px;
    /* background: #f8f9fa; */
    background: transparent;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    overflow: hidden;
}

.molecule-item-structure img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: transparent;
}

.molecule-svg-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.molecule-svg-preview svg {
    max-width: 100%;
    max-height: 100%;
    background: transparent;
}

.molecule-svg-preview svg * {
    background: transparent;
}

.molecule-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.molecule-type-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.molecule-type-badge.type-2d {
    background: #d4edda;
    color: #155724;
}

.molecule-type-badge.type-3d {
    background: #fff3cd;
    color: #856404;
}

.molecule-item .molecule-actions {
    display: flex;
    gap: 5px;
}

.molecule-item .edit-btn,
.molecule-item .delete-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.molecule-item .edit-btn:hover {
    background: #5568d3;
}

.molecule-item .delete-btn {
    background: #dc3545;
}

.molecule-item .delete-btn:hover {
    background: #c82333;
}

.molecule-buttons {
    display: flex;
    gap: 10px;
}

.molecule-buttons .btn {
    flex: 1;
}

.reaction-item {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reaction-item:hover {
    background: #f0f4ff;
    border-color: #667eea;
    transform: translateX(5px);
}

.reaction-item-id {
    font-size: 10px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
}

.reaction-item-buttons {
    display: flex;
    gap: 6px;
}

.reaction-item .edit-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.reaction-item .edit-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.reaction-item .delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.reaction-item .delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.reaction-item-with-structures .reaction-item-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.reaction-item-with-structures .edit-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.reaction-item-with-structures .edit-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.reaction-item-with-structures .delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.reaction-item-with-structures .delete-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.main-panel {
    flex: 1;
    padding: 20px;
}

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
}

.tab-btn {
    padding: 12px 24px;
    background: #f8f9fa;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.network-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    height: 500px;
    position: relative;
    overflow: hidden;
}



/* 纯HTML网络视图样式 */
.network-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.network-svg path {
    pointer-events: auto;
    cursor: pointer;
}

.network-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.network-node {
    position: absolute;
    cursor: grab;
    user-select: none;
    transition: transform 0.1s, box-shadow 0.2s;
    z-index: 10;
}

.network-node:active {
    cursor: grabbing;
}

.network-node.dragging {
    z-index: 100;
    transform: scale(1.05);
}

/* 分子节点样式 */
.molecule-node {
    width: 100px;
    height: 100px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.molecule-node:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transform: scale(1.02);
}

.molecule-node .node-structure {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.molecule-node .node-structure svg {
    max-width: 100%;
    max-height: 100%;
}

.molecule-node .node-label {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    text-align: center;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 4px;
}

.molecule-node .node-id {
    font-size: 9px;
    color: #666;
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
    margin-top: 2px;
}

/* 反应节点样式 */
.reaction-node {
    width: 60px;
    height: 30px;
    background: #e3f2fd;
    border: 1px solid #667eea;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.reaction-node:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.reaction-node .node-label {
    font-size: 10px;
    font-weight: 600;
    color: #667eea;
    text-align: center;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reaction-node .node-rate {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

/* 空状态提示 */
.network-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #6c757d;
    font-size: 16px;
}

/* 网络提示框 */
.network-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.1s ease;
    white-space: nowrap;
}

.network-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.molecule-editor {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.molecule-info {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.molecule-id-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.molecule-id-display span {
    font-size: 14px;
    color: #666;
}

.molecule-id-display strong {
    color: #333;
    font-family: monospace;
}

.drop-zone {
    position: relative;
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: all 0.3s;
}

.drop-zone.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.drop-hint {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.drop-zone.drag-over .drop-hint {
    opacity: 1;
}

#ketcherFrame {
    width: 100%;
    height: 450px;
    border: none;
    border-radius: 6px;
    background: white;
}

.molecule-controls,
.reaction-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.molecule-controls input,
.reaction-info input {
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
}

.reaction-id-display {
    padding: 8px 12px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
}

.reaction-id-display strong {
    color: #333;
    font-family: monospace;
}

.reaction-builder {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    gap: 20px;
}

.reaction-section {
    flex: 1;
    text-align: center;
}

.reaction-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
}

.molecule-selector {
    min-height: 100px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    transition: all 0.3s;
}

.molecule-selector.drop-target {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.molecule-selector.drag-over {
    background: rgba(102, 126, 234, 0.2);
    border-style: solid;
}

.selected-molecule {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-molecule .remove-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.reaction-arrow {
    font-size: 48px;
    color: #667eea;
    font-weight: bold;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #4a5568;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #2d3748;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 85, 104, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-info {
    background: #17a2b8;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-success {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.molecule-buttons .btn-secondary {
    flex: 1;
    text-align: center;
    padding: 10px 15px;
    font-size: 13px;
}

.network-controls .btn-secondary,
.network-controls .btn-danger,
.network-controls .btn-info,
.network-controls .btn-success {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    min-width: 120px;
}

.network-controls .btn-danger:hover {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.network-controls .btn-info:hover {
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.network-controls .btn-success:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-secondary:active,
.btn-danger:active,
.btn-info:active,
.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: #28a745;
    color: white;
}

.btn-small:hover {
    background: #218838;
}

.molecule-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 150px;
}

.molecule-dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.molecule-dropdown-item:hover {
    background: #f0f4ff;
}

.empty-state {
    text-align: center;
    color: #6c757d;
    padding: 20px;
    font-style: italic;
}

/* Toast 提示样式 */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.info {
    border-left-color: #17a2b8;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast-icon {
    font-size: 20px;
}

.toast.success .toast-icon {
    color: #28a745;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast.info .toast-icon {
    color: #17a2b8;
}

.toast.warning .toast-icon {
    color: #ffc107;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: #666;
}

.toast-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
}

/* 反应列表结构展示样式 */
.reaction-list-with-structures {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.reaction-item-with-structures {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 12px;
}

.reaction-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.reaction-structures {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.reactants-structures, .products-structures {
    flex: 1;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.reaction-structures .reaction-arrow {
    margin: 0 20px;
    font-size: 24px;
}

.molecule-structure-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.molecule-structure-preview small {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
}

.molecule-structure-preview .molecule-svg-preview {
    width: 100px;
    height: 60px;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header.warning {
    background: #fff3cd;
    border-bottom-color: #ffc107;
}

.modal-header h3 {
    font-size: 18px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

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

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 导入模态框特定样式 */
.import-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
}

.import-tab-btn {
    padding: 10px 20px;
    background: #f8f9fa;
    border: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s ease;
}

.import-tab-btn:hover {
    background: #e9ecef;
}

.import-tab-btn.active {
    background: #667eea;
    color: white;
}

.import-tab-content {
    display: none;
}

.import-tab-content.active {
    display: block;
}

.import-formats {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.format-tag {
    background: #e9ecef;
    color: #495057;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.warning-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    color: #856404;
    font-size: 13px;
}

.modal textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
    resize: vertical;
    margin-bottom: 10px;
}

.import-options {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.import-options input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
