/* Core Design System & Tokens */
:root {
  --bg-primary: #080b11;
  --bg-secondary: #0f1420;
  --bg-glass: rgba(15, 20, 32, 0.6);
  --bg-glass-active: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-glow: rgba(0, 242, 254, 0.3);
  
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #9b51e0;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 20px rgba(0, 242, 254, 0.15);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(155, 81, 224, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.08) 0%, transparent 40%);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Layout Utilities */
.app-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
  }
}

/* Sidebar / RAG Controls Panel */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-glass);
    max-height: 300px;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  box-shadow: var(--shadow-glow);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.panel-section {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Form elements & Settings */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

select, input, button {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-smooth);
}

select:focus, input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

/* Status Indicators */
.status-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  margin-right: 0.5rem;
}

.status-dot.active {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.loading {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.5s infinite;
}

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

/* Progress bar */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.progress-bar-bg {
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 3px;
  transition: width 0.2s ease;
}

/* Retrieved chunks view */
.chunk-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.50rem;
  font-size: 0.75rem;
  line-height: 1.4;
  transition: var(--transition-smooth);
}

.chunk-card:hover {
  border-color: rgba(0, 242, 254, 0.2);
}

.chunk-header {
  display: flex;
  justify-content: space-between;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.chunk-score {
  background: rgba(0, 242, 254, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.chunk-text {
  color: var(--text-muted);
}

/* Chat Area Layout */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-primary) 0%, rgba(11, 16, 28, 0.8) 100%);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(8, 11, 17, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Chat Messages View */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out;
}

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

.message.user {
  align-self: flex-end;
}

.message.system {
  align-self: center;
  max-width: 90%;
}

.message-avatar {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.message.user .message-avatar {
  text-align: right;
  color: var(--accent-cyan);
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.15) 0%, rgba(0, 242, 254, 0.15) 100%);
  border: 1px solid rgba(0, 242, 254, 0.25);
  border-top-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-top-left-radius: 4px;
  backdrop-filter: blur(8px);
  white-space: normal;
}

.message.system .message-bubble {
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border-glass);
  color: var(--text-muted);
  font-size: 0.8rem;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  white-space: normal;
}

/* Markdown formatting inside chat bubbles */
.message-bubble p {
  margin-bottom: 0.75rem;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}
.message-bubble ul, .message-bubble ol {
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
}
.message-bubble li {
  margin-bottom: 0.25rem;
}
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  color: var(--accent-cyan);
}
.message-bubble code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--accent-blue);
}
.message-bubble pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-glass);
}
.message-bubble pre code {
  background: none;
  padding: 0;
  color: var(--text-main);
  font-size: 0.85em;
}

/* Streaming Text Generation cursor */
.typing-cursor::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-cyan);
  animation: blink 0.8s infinite;
}

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

/* Chat Input Bar */
.chat-input-container {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-glass);
  background: rgba(8, 11, 17, 0.9);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 0.5rem;
  transition: var(--transition-smooth);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  resize: none;
  height: 72px;
  max-height: 250px;
  font-family: var(--font-sans);
}

.send-btn {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border: none;
  color: #000;
  font-weight: 700;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-glow);
}

.send-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn:disabled {
  background: var(--border-glass);
  color: var(--text-dim);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Suggestions Cards */
.suggestions-container {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.suggestion-chip {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.suggestion-chip:hover {
  background: var(--bg-glass-active);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* System metrics & stats */
.metrics {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-row {
  display: flex;
  justify-content: space-between;
}

.metric-value {
  font-family: monospace;
  color: var(--text-main);
}

/* Modal Popup Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-icon {
  font-size: 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-body strong {
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-btn {
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-smooth);
}

.modal-btn.cancel {
  background: transparent;
  color: var(--text-muted);
}

.modal-btn.cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.modal-btn.ok {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
  border: none;
  box-shadow: var(--shadow-glow);
}

.modal-btn.ok:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.modal-btn.ok:active {
  transform: translateY(0);
}

/* Related Project Hover Styles */
.dev-card:hover {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.15) !important;
  background: linear-gradient(135deg, rgba(15, 20, 32, 0.75) 0%, rgba(0, 242, 254, 0.08) 100%) !important;
}

/* Developer Profile styling */
.developer-profile {
  margin-top: 0;
  margin-bottom: 1rem;
  border: 1px solid rgba(0, 242, 254, 0.25);
  background: linear-gradient(135deg, rgba(15, 20, 32, 0.6) 0%, rgba(0, 242, 254, 0.04) 100%);
  transition: var(--transition-smooth);
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  line-height: 1.4;
}

.developer-profile:hover {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.15) !important;
  background: linear-gradient(135deg, rgba(15, 20, 32, 0.75) 0%, rgba(0, 242, 254, 0.08) 100%) !important;
}

.dev-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.dev-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dev-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--text-dim);
  flex-wrap: wrap;
  margin-top: 0.1rem;
  font-weight: 500;
  font-size: 0.75rem;
}

.dev-meta a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.2s ease;
}

.dev-meta a:hover {
  color: var(--accent-cyan);
}
