/* --- Color Theme Variables --- */
:root {
    --primary-color: #3498db;
    --primary-hover-color: #2980b9;
    
    /* Dark Mode (Default) */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --panel-bg: rgba(255, 255, 255, 0.95);
    --panel-text-color: #2c3e50;
    --header-bg: rgba(255, 255, 255, 0.1);
    --header-text-color: #ffffff;
    --control-panel-bg: rgba(255, 255, 255, 0.9);
    --info-content-text: #34495e;
    --molecule-item-bg: rgba(52, 152, 219, 0.1);
    --molecule-item-hover-bg: rgba(52, 152, 219, 0.2);
    --footer-bg: #2c3e50;
    --footer-text: #ecf0f1;
}

body.light-mode {
    /* Light Mode Overrides */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --panel-bg: rgba(255, 255, 255, 0.9);
    --panel-text-color: #1a202c;
    --header-bg: rgba(255, 255, 255, 0.7);
    --header-text-color: #2d3748;
    --control-panel-bg: rgba(248, 250, 252, 0.95);
    --info-content-text: #2d3748;
    --molecule-item-bg: rgba(52, 152, 219, 0.15);
    --molecule-item-hover-bg: rgba(52, 152, 219, 0.25);
    --footer-bg: #e2e8f0;
    --footer-text: #4a5568;
}


/* --- General Styles --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease;
}

.container {
    display: flex;
    flex: 1;
    height: calc(100% - 50px);
    transition: all 0.3s ease;
}

.sidebar {
    width: 280px;
    background: var(--panel-bg);
    color: var(--panel-text-color);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    padding: 20px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.sidebar.collapsed { width: 50px; padding: 10px; }
.sidebar.collapsed .sidebar-content { display: none; }
.sidebar-toggle { position: absolute; top: 10px; right: 10px; background: var(--primary-color); color: white; border: none; padding: 8px; border-radius: 4px; cursor: pointer; z-index: 1000; }
.sidebar-toggle:hover { background: var(--primary-hover-color); }
.panel-title { text-align: center; margin-bottom: 20px; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header { background: var(--header-bg); color: var(--header-text-color); padding: 10px 20px; backdrop-filter: blur(10px); position: relative; display: flex; justify-content: space-between; align-items: center; transition: background 0.3s, color 0.3s; }
.header h1 { font-size: 1.5rem; }
.header p { font-size: 0.9rem; }
.header-controls { display: flex; gap: 10px; }
#theme-toggle-btn, .fullscreen-btn { background: rgba(0, 0, 0, 0.1); color: var(--header-text-color); border: 1px solid var(--header-text-color); padding: 8px 15px; border-radius: 4px; cursor: pointer; transition: background 0.3s; }
#theme-toggle-btn:hover, .fullscreen-btn:hover { background: rgba(0, 0, 0, 0.2); }

.viewer-container { flex: 1; position: relative; background: rgba(0, 0, 0, 0.1); min-height: 200px; }
.loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--header-text-color); font-size: 1.2rem; }

/* --- Zoom Hint --- */
.zoom-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    animation: fadeOutHint 5s ease-in-out forwards;
}
@keyframes fadeOutHint {
    0% { opacity: 0; transform: translate(-50%, 10px); }
    20% { opacity: 1; transform: translate(-50%, 0); }
    80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 10px); }
}

/* --- Info Panel --- */
.info-panel { height: 200px; background: var(--panel-bg); color: var(--panel-text-color); backdrop-filter: blur(10px); border-top: 1px solid rgba(0, 0, 0, 0.1); overflow-y: auto; padding: 20px; position: relative; transition: height 0.3s ease, padding 0.3s ease; flex-shrink: 0; }
.info-panel.collapsed { height: 50px !important; padding: 10px 20px !important; overflow: hidden !important; }
.info-panel.collapsed .info-content-wrapper { display: none !important; }
.info-panel.collapsed .info-panel-header { margin-bottom: 0 !important; }
.info-panel.editing { height: 300px; }
.info-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.info-panel-title { font-weight: bold; }
.info-panel-controls { display: flex; gap: 5px; }
.collapse-btn, .edit-btn, .save-btn, .cancel-btn { background: var(--primary-color); color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.75rem; }
.collapse-btn { background: #95a5a6; } .collapse-btn:hover { background: #7f8c8d; }
.edit-btn:hover, .save-btn:hover, .cancel-btn:hover { background: var(--primary-hover-color); }
.cancel-btn { background: #e74c3c; } .cancel-btn:hover { background: #c0392b; }
.save-btn, .cancel-btn { display: none; }
.info-panel.editing .edit-btn { display: none; }
.info-panel.editing .save-btn, .info-panel.editing .cancel-btn { display: inline-block; }
.info-section { margin-bottom: 15px; }
.info-title { font-weight: bold; margin-bottom: 8px; font-size: 1.1rem; }
.info-content { line-height: 1.6; color: var(--info-content-text); }
.info-content.editable { border: 1px solid #ddd; padding: 10px; border-radius: 4px; min-height: 60px; background: white; }
.info-content.editable:focus { outline: 2px solid var(--primary-color); }
.highlight { color: #e74c3c; font-weight: bold; }

/* --- Molecule List --- */
.molecule-category { margin-bottom: 20px; }
.category-title { font-size: 1rem; font-weight: bold; margin-bottom: 10px; padding: 8px 12px; background: linear-gradient(135deg, #3498db, #2980b9); color: white; border-radius: 6px; cursor: pointer; transition: all 0.3s ease; }
.category-title:hover { transform: translateX(5px); }
.molecule-list { display: none; padding-left: 10px; }
.molecule-list.active { display: block; }
.molecule-item { padding: 8px 12px; margin: 5px 0; background: var(--molecule-item-bg); border-radius: 4px; cursor: pointer; transition: all 0.3s ease; border-left: 3px solid transparent; }
.molecule-item:hover { background: var(--molecule-item-hover-bg); border-left-color: var(--primary-color); transform: translateX(5px); }
.molecule-item.active { background: linear-gradient(135deg, #3498db, #2980b9); color: white; border-left-color: var(--primary-hover-color); }
.molecule-formula { font-size: 0.85rem; color: #7f8c8d; margin-top: 5px; }
.molecule-item.active .molecule-formula { color: #ecf0f1; }

/* --- Controls Panel --- */
.controls { position: absolute; top: 20px; right: 20px; background: var(--control-panel-bg); color: var(--panel-text-color); backdrop-filter: blur(10px); padding: 15px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); cursor: move; user-select: none; z-index: 10; }
.controls.dragging { cursor: grabbing; }
.controls-header { cursor: move; padding-bottom: 10px; border-bottom: 1px solid #eee; margin-bottom: 10px; text-align: center; font-weight: bold; }
.control-group { margin-bottom: 10px; }
.control-group:last-child { margin-bottom: 0; }
button { padding: 8px 15px; margin: 3px; background: linear-gradient(135deg, #3498db, #2980b9); color: white; border: none; border-radius: 4px; cursor: pointer; transition: all 0.3s ease; font-size: 0.8rem; }
button:hover { background: linear-gradient(135deg, #2980b9, #1f4e79); transform: translateY(-2px); }
.model-type-btn { background: linear-gradient(135deg, #27ae60, #229954); }
.model-type-btn.active { background: linear-gradient(135deg, #e74c3c, #c0392b); }

/* --- Footer --- */
.footer { height: 50px; background: var(--footer-bg); color: var(--footer-text); display: flex; justify-content: center; align-items: center; flex-direction: column; font-size: 0.8rem; padding: 5px; flex-shrink: 0; transition: background 0.3s, color 0.3s; }
.footer p { margin: 2px 0; }

/* --- Fullscreen & Responsive --- */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 10px; padding-bottom: 15px; }
    .container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; max-height: 40vh; border-right: none; border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
    .viewer-container { height: 50vh; }
}