:root {
    --background-color: #f7f9fc;
    --container-bg: #ffffff;
    --text-color: #333;
    --primary-color: #4a90e2;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #0d1117;
        --container-bg: #161b22;
        --text-color: #c9d1d9;
        --primary-color: #58a6ff;
        --border-color: #30363d;
        --shadow-color: rgba(0, 0, 0, 0.3);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll */
}

/* 通用工具类 */
.hidden {
    display: none !important;
}

header {
    text-align: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.title-section {
    flex: 1;
    text-align: left;
}

.auth-section {
    margin-left: 2rem;
}

.auth-btn {
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#welcome-text {
    font-size: 0.9rem;
    color: var(--text-color);
}

.usage-tips {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.9em;
}

.usage-tips p {
    margin: 0;
}

.usage-tips strong {
    color: #fff;
}

.main-container {
    display: flex;
    flex-grow: 1;
    height: calc(100vh - 65px); /* Adjust based on header height */
}

.graph-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

#knowledge-graph {
    flex-grow: 1;
    height: 100%;
    border: none;
    cursor: pointer;
}

#info-sidebar {
    width: 400px; /* Increased width for editor */
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    background-color: var(--container-bg);
}

#node-info .placeholder {
    color: #888;
    font-style: italic;
}

#node-content.hidden, #edit-form-container.hidden {
    display: none;
}

#node-info h2 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

#node-info p {
    margin: 0.25rem 0;
    font-size: 0.9em;
}

#node-group {
    font-style: italic;
    color: #888;
    margin-bottom: 1rem;
}

.resources-panel h3 {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

#resources-list {
    list-style: none;
    padding: 0;
    margin-bottom: 1rem;
}

#resources-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

#resources-list .resource-info { flex-grow: 1; }
#resources-list .resource-actions button { margin-left: 0.5rem; }

button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}
button:hover { opacity: 0.8; }

#edit-form div { margin-bottom: 1rem; }
.form-buttons { display: flex; gap: 1rem; }
.form-buttons button[type="button"] {
    background-color: transparent;
    color: var(--text-color);
    border-color: var(--border-color);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

select, input[type="text"], input[type="url"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
    box-sizing: border-box;
}

/* 改善节点的视觉反馈 */
.vis-network:focus {
    outline: none;
}

/* 为有子节点的节点添加特殊样式提示 */
.expandable-node {
    border: 2px solid var(--primary-color) !important;
    box-shadow: 0 2px 8px var(--shadow-color);
}

/* 展开/折叠信息框样式 */
.expand-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(74, 144, 226, 0.05));
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    font-size: 0.85em;
}

.expand-info strong {
    color: var(--primary-color);
}

.expand-info small {
    color: #666;
    font-style: italic;
}

/* 改善侧边栏滚动条样式 */
#info-sidebar::-webkit-scrollbar {
    width: 8px;
}

#info-sidebar::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 4px;
}

#info-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

#info-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 添加一些动画效果 */
@keyframes nodeExpand {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.node-expanding {
    animation: nodeExpand 0.3s ease-in-out;
}

/* 响应式设计改进 */
@media (max-width: 768px) {
    #info-sidebar {
        width: 100%;
        height: 40%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .main-container {
        flex-direction: column;
    }
    
    #knowledge-graph {
        height: 60%;
    }
}

/* 物理学控制面板样式 */
.physics-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

.control-btn {
    padding: 8px 12px;
    border: 1px solid var(--primary-color);
    background-color: var(--container-bg);
    color: var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: all 0.2s ease;
}

.control-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.control-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 280px;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-top: 5px;
}

.control-panel h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.control-group {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 12px;
    font-weight: 500;
    min-width: 70px;
    color: var(--text-color);
}

.control-group input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    outline: none;
    border-radius: 2px;
    appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.control-group span {
    font-size: 11px;
    color: var(--primary-color);
    font-weight: bold;
    min-width: 35px;
    text-align: right;
}

.control-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.control-actions .control-btn {
    flex: 1;
    font-size: 11px;
    padding: 6px 8px;
}

/* CRUD控制面板样式 */
.crud-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

.crud-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.crud-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.crud-section h5 {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--text-color);
    font-weight: 600;
}

.crud-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crud-btn {
    padding: 6px 10px;
    border: 1px solid var(--primary-color);
    background-color: var(--container-bg);
    color: var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    text-align: center;
}

.crud-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

.crud-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #999;
    border-color: #ccc;
}

.crud-btn.delete-btn {
    border-color: #dc3545;
    color: #dc3545;
}

.crud-btn.delete-btn:hover:not(:disabled) {
    background-color: #dc3545;
    color: white;
}

.crud-info {
    margin-top: 10px;
    padding: 8px;
    background-color: rgba(74, 144, 226, 0.1);
    border-radius: 4px;
    text-align: center;
}

.crud-info small {
    color: #666;
    font-style: italic;
}

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

.modal-content {
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow-color);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 16px;
}

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

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

.crud-form .form-group {
    margin-bottom: 15px;
}

.crud-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 13px;
}

.crud-form input,
.crud-form select,
.crud-form textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-color);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 13px;
}

.crud-form textarea {
    resize: vertical;
    min-height: 60px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}