/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-tertiary: #242938;
  --text-primary: #e7e9ea;
  --text-secondary: #8b98a5;
  --accent-blue: #1d9bf0;
  --accent-green: #00ba7c;
  --accent-yellow: #ffd93d;
  --accent-red: #f4212e;
  --accent-purple: #7856ff;
  --border-color: #2f3542;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px;
  gap: 16px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.status-dot.running {
  background: var(--accent-green);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress-container {
  width: 200px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 80px;
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

/* Panels */
.panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Molecule Panel */
.molecule-panel {
  display: flex;
  flex-direction: column;
}

.molecule-select {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.molecule-viewer {
  flex: 1;
  min-height: 250px;
  background: var(--bg-primary);
  position: relative;
}

.molecule-info {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.info-label {
  color: var(--text-secondary);
}

.info-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Chart Panel */
.chart-panel {
  display: flex;
  flex-direction: column;
}

.chart-legend {
  display: flex;
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.low { background: #ff6b6b; }
.dot.standard { background: #ffd93d; }
.dot.high { background: #6bcb77; }
.dot.star { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }

.chart-container {
  flex: 1;
  padding: 16px;
  min-height: 0;
}

.chart-controls {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon {
  font-size: 12px;
}

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

.btn-primary:hover {
  background: #1a8cd8;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-success {
  background: var(--accent-green);
  color: white;
}

.btn-success:hover {
  background: #00a36c;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background: #d91c28;
}

/* Compound Panel */
.compound-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.compound-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.compound-item:hover {
  border-color: var(--accent-blue);
}

.compound-item.optimal {
  border-color: var(--accent-green);
  background: rgba(0, 186, 124, 0.1);
}

.compound-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 12px;
}

.compound-item.optimal .compound-rank {
  background: var(--accent-green);
  color: white;
}

.compound-details {
  flex: 1;
}

.compound-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.compound-stats {
  font-size: 11px;
  color: var(--text-secondary);
}

.compound-star {
  font-size: 18px;
}

/* Chat Panel */
.chat-panel {
  height: 200px;
}

.agent-badge {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--accent-purple);
  border-radius: 4px;
  color: white;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message-avatar.agent {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

.message-avatar.alert {
  background: var(--accent-yellow);
}

.message-avatar.success {
  background: var(--accent-green);
}

.message-content {
  flex: 1;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-type {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message-type.hypothesis { background: rgba(120, 86, 255, 0.2); color: var(--accent-purple); }
.message-type.literature { background: rgba(29, 155, 240, 0.2); color: var(--accent-blue); }
.message-type.alert { background: rgba(255, 217, 61, 0.2); color: var(--accent-yellow); }
.message-type.result { background: rgba(0, 186, 124, 0.2); color: var(--accent-green); }

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.message-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}

.message-reference {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 12px;
  border-left: 3px solid var(--accent-blue);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-icon {
  font-size: 28px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-reference {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  border-left: 3px solid var(--accent-blue);
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 1fr;
  }

  .compound-panel {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .compound-panel {
    grid-column: span 1;
  }

  .header {
    flex-direction: column;
    gap: 16px;
  }
}
