@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-dark: #090a0f;
  --bg-card: rgba(18, 22, 36, 0.7);
  --bg-card-hover: rgba(28, 34, 56, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(0, 240, 255, 0.3);
  
  --accent-cyan: #00f0ff;
  --accent-magenta: #ff007f;
  --accent-purple: #7928ca;
  --accent-gold: #ffb300;
  
  --text-main: #f0f4f8;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-heading: 'Outfit', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(121, 40, 202, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(0, 240, 255, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(255, 0, 127, 0.08) 0%, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  height: 64px;
  background: rgba(10, 13, 24, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

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

.logo-badge {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
}

.logo-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border: none;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

/* Main Layout */
.app-container {
  flex: 1;
  display: flex;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Left Panel: 3D Knowledge Graph */
.graph-panel {
  flex: 1.1;
  position: relative;
  border-right: 1px solid var(--border-color);
  background: rgba(5, 7, 13, 0.6);
  display: flex;
  flex-direction: column;
}

.graph-overlay-header {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.graph-title-card {
  pointer-events: auto;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.graph-title-card h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 8px;
}

.graph-title-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.graph-legend {
  pointer-events: auto;
  display: flex;
  gap: 12px;
  background: rgba(10, 13, 24, 0.7);
  backdrop-filter: blur(12px);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

#3d-graph-container {
  width: 100%;
  height: 100%;
}

.node-info-modal {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  padding: 16px;
  border-radius: 12px;
  display: none;
  z-index: 20;
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.2);
  animation: slideUp 0.3s ease;
}

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

/* Right Panel: Hybrid RAG Search & Chatbot */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 28, 0.75);
  backdrop-filter: blur(16px);
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(8, 10, 18, 0.9);
  padding: 0 16px;
}

.tab-btn {
  padding: 14px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab-btn.active {
  color: var(--accent-cyan);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  box-shadow: 0 0 10px var(--accent-cyan);
}

.tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  height: calc(100% - 49px);
  overflow: hidden;
}

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

/* Chat Search Section */
.chat-search-bar {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 20, 35, 0.5);
  display: flex;
  gap: 10px;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(5, 8, 18, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px 12px 40px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 14px;
  line-height: 1.6;
  font-size: 14px;
  animation: fadeIn 0.3s ease;
}

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

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-purple), #4a00e0);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(121, 40, 202, 0.3);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-bubble.assistant h1, .chat-bubble.assistant h2, .chat-bubble.assistant h3 {
  font-family: var(--font-heading);
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--accent-cyan);
}

.chat-bubble.assistant ul, .chat-bubble.assistant ol {
  margin-left: 20px;
  margin-bottom: 8px;
}

.chat-bubble.assistant code {
  background: rgba(0, 240, 255, 0.1);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.retrieved-context-box {
  background: rgba(0, 240, 255, 0.05);
  border-left: 3px solid var(--accent-cyan);
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.retrieved-tag {
  display: inline-block;
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
  margin-right: 6px;
}

/* Chat Input Bar */
.chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(8, 10, 18, 0.9);
  display: flex;
  gap: 10px;
}

.chat-input-container textarea {
  flex: 1;
  background: rgba(18, 22, 38, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  resize: none;
  height: 48px;
  outline: none;
}

.chat-input-container textarea:focus {
  border-color: var(--accent-cyan);
}

/* Search Engine Tab */
.search-results-container {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.search-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  transition: all 0.2s;
}

.search-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.15);
}

.search-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.search-card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--accent-cyan);
}

.search-score-badge {
  background: rgba(0, 240, 255, 0.1);
  color: var(--accent-cyan);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.search-card-snippet {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Data Viewer Tab */
.data-viewer-container {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.code-block-wrapper {
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  color: #c9d1d9;
  white-space: pre-wrap;
  max-height: 500px;
  overflow-y: auto;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: rgba(18, 22, 38, 0.95);
  border: 1px solid var(--accent-cyan);
  border-radius: 16px;
  width: 480px;
  padding: 24px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  color: var(--accent-cyan);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  background: rgba(8, 10, 18, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  outline: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}
