/* Molecular Structure Specific Styles */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.element-categories {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.category-tab {
  padding: 6px 12px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.category-tab:hover {
  background: #e9ecef;
  border-color: #667eea;
}

.category-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: #667eea;
}

.elements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.element-item {
  background: rgba(255,255,255,0.9);
  border: 2px solid #dee2e6;
  border-radius: 6px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.element-item:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.element-item.active {
  border-color: #28a745;
  background: rgba(40, 167, 69, 0.1);
}

.element-symbol {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 2px;
}

.element-name {
  font-size: 8px;
  color: #6c757d;
  line-height: 1;
}

.element-number {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8px;
  color: #6c757d;
}

/* 元素颜色 */
.element-item[data-element="H"] { background-color: rgba(255, 255, 255, 0.8); }
.element-item[data-element="C"] { background-color: rgba(64, 64, 64, 0.8); color: white; }
.element-item[data-element="N"] { background-color: rgba(48, 80, 248, 0.8); color: white; }
.element-item[data-element="O"] { background-color: rgba(255, 13, 13, 0.8); color: white; }
.element-item[data-element="F"] { background-color: rgba(144, 224, 80, 0.8); }
.element-item[data-element="P"] { background-color: rgba(255, 128, 0, 0.8); color: white; }
.element-item[data-element="S"] { background-color: rgba(255, 255, 48, 0.8); }
.element-item[data-element="Cl"] { background-color: rgba(31, 240, 31, 0.8); }

.bond-tools {
  margin-top: 16px;
}

.tool-title {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 8px;
}

.bond-types {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.bond-type {
  background: rgba(255,255,255,0.8);
  border: 2px solid #dee2e6;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.bond-type:hover {
  border-color: #667eea;
  transform: translateY(-1px);
}

.bond-type.active {
  border-color: #28a745;
  background: rgba(40, 167, 69, 0.1);
}

.bond-icon {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 2px;
}

.bond-name {
  font-size: 10px;
  color: #6c757d;
}

.molecule-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 12px;
}

.stat-label {
  color: #6c757d;
  font-weight: 500;
}

.stat-value {
  font-family: monospace;
  color: #2c3e50;
  font-weight: 600;
}

.view-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #667eea;
}

.control-group label {
  font-size: 12px;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

.canvas-container {
  position: relative;
  background: #ffffff;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

#moleculeCanvas {
  display: block;
  width: 100%;
  height: 400px;
  background: 
    radial-gradient(circle at 20px 20px, #f8f9fa 1px, transparent 1px),
    radial-gradient(circle at 60px 60px, #f8f9fa 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  cursor: crosshair;
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

.canvas-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.template-item {
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.template-item:hover {
  background: rgba(102, 126, 234, 0.1);
  border-color: #667eea;
  transform: translateY(-1px);
}

.template-name {
  font-size: 12px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.template-formula {
  font-size: 11px;
  color: #6c757d;
  font-family: monospace;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* 分子绘制样式 */
.atom {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  cursor: move;
  transition: all 0.2s ease;
  border: 2px solid rgba(255,255,255,0.3);
}

.atom:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.atom.selected {
  border-color: #ffc107;
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.5);
}

.atom.hydrogen { background: #ffffff; color: #333; width: 20px; height: 20px; font-size: 12px; }
.atom.carbon { background: #404040; width: 24px; height: 24px; font-size: 14px; }
.atom.nitrogen { background: #3050f8; width: 24px; height: 24px; font-size: 14px; }
.atom.oxygen { background: #ff0d0d; width: 24px; height: 24px; font-size: 14px; }
.atom.fluorine { background: #90e050; color: #333; width: 22px; height: 22px; font-size: 13px; }
.atom.phosphorus { background: #ff8000; width: 26px; height: 26px; font-size: 14px; }
.atom.sulfur { background: #ffff30; color: #333; width: 26px; height: 26px; font-size: 14px; }
.atom.chlorine { background: #1ff01f; color: #333; width: 24px; height: 24px; font-size: 13px; }

.bond {
  position: absolute;
  background: #2c3e50;
  transform-origin: left center;
  z-index: 1;
}

.bond.single {
  height: 2px;
}

.bond.double {
  height: 4px;
  background: linear-gradient(to bottom, #2c3e50 0%, #2c3e50 40%, transparent 40%, transparent 60%, #2c3e50 60%, #2c3e50 100%);
}

.bond.triple {
  height: 6px;
  background: linear-gradient(to bottom, 
    #2c3e50 0%, #2c3e50 25%, 
    transparent 25%, transparent 40%, 
    #2c3e50 40%, #2c3e50 60%, 
    transparent 60%, transparent 75%, 
    #2c3e50 75%, #2c3e50 100%);
}

.bond.aromatic {
  height: 2px;
  background: #2c3e50;
  border-top: 1px dashed #2c3e50;
  margin-top: -1px;
}

.bond:hover {
  background: #667eea;
  z-index: 50;
}

@media (max-width: 768px) {
  .elements-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .molecule-stats {
    grid-template-columns: 1fr;
  }
  
  .bond-types {
    grid-template-columns: 1fr;
  }
  
  .templates-grid {
    grid-template-columns: 1fr;
  }
  
  .canvas-controls {
    justify-content: center;
  }
  
  .toolbar {
    justify-content: center;
  }
  
  #moleculeCanvas {
    height: 300px;
  }
}

/* 动画效果 */
.element-item.selected {
  animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.atom.new {
  animation: atomAppear 0.3s ease-out;
}

@keyframes atomAppear {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.bond.new {
  animation: bondGrow 0.3s ease-out;
}

@keyframes bondGrow {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 100%;
    opacity: 1;
  }
}