/* Modern Premium Dark CSS Design System */

:root {
  --bg-primary: #090c15;
  --bg-secondary: rgba(17, 22, 39, 0.7);
  --bg-card: rgba(26, 32, 53, 0.45);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --gradient-glow: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Background Glowing Orbs */
.glow-orb-1 {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, rgba(0,0,0,0) 70%);
  top: -100px;
  right: -50px;
  z-index: -1;
  pointer-events: none;
}

.glow-orb-2 {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, rgba(0,0,0,0) 70%);
  bottom: -150px;
  left: -100px;
  z-index: -1;
  pointer-events: none;
}

/* App Container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex-grow: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2rem;
  position: relative;
  z-index: 1;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
}

.logo-section h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.025em;
  margin-bottom: 0.25rem;
}

.logo-section p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
}

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

.status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content Grid */
.main-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}

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

/* Sidebar Components */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Model Configurations list */
.model-info-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.model-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-left: 2px solid var(--accent-indigo);
  padding-left: 0.75rem;
}

.model-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.model-value {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-family: monospace;
  word-break: break-all;
}

/* File Upload Area */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition-smooth);
  position: relative;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.03);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.05);
}

.upload-icon {
  font-size: 2.25rem;
  margin-bottom: 1rem;
  color: var(--accent-indigo);
  transition: var(--transition-smooth);
}

.upload-zone:hover .upload-icon {
  transform: translateY(-4px);
}

.upload-zone p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.upload-zone .file-limit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.file-input {
  display: none;
}

/* Upload Status list */
.upload-status-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.upload-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  color: var(--text-secondary);
}

.upload-status {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.upload-status.uploading {
  color: var(--accent-indigo);
  animation: pulse-opacity 1.5s infinite;
}

.upload-status.success {
  color: var(--accent-emerald);
}

.upload-status.error {
  color: var(--accent-rose);
}

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

/* Chat/Query Dashboard Area */
.query-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.input-container {
  display: flex;
  position: relative;
  width: 100%;
}

.query-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.15rem 4rem 1.15rem 1.25rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  backdrop-filter: blur(16px);
  outline: none;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-sm);
}

.query-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  background: rgba(26, 32, 53, 0.65);
}

.send-button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gradient-primary);
  border: none;
  color: white;
  padding: 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-button:hover {
  opacity: 0.95;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.send-button:active {
  transform: translateY(-50%) scale(0.95);
}

/* Results Display */
.result-card {
  display: none; /* Shown dynamically when there are results */
  flex-direction: column;
  gap: 1.5rem;
}

.result-card.visible {
  display: flex;
}

.answer-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.answer-header::after {
  content: "";
  height: 1px;
  flex-grow: 1;
  background-color: var(--border-color);
}

.answer-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Sources section */
.sources-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sources-title {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.source-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  transition: var(--transition-smooth);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.source-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.source-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.score-badge {
  font-size: 0.6875rem;
  font-family: monospace;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-indigo);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.source-content {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal configuration */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 12, 21, 0.8);
  backdrop-filter: blur(12px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.visible {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: #111625;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 700px;
  width: 90%;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal.visible .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Loading skeleton */
.skeleton-loader {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.skeleton-loader.visible {
  display: flex;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: loading-shimmer 1.5s infinite;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 75%; }
.skeleton-line.long { width: 100%; }

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Helper Utilities */
.text-indigo { color: var(--accent-indigo); }
.text-emerald { color: var(--accent-emerald); }
.text-rose { color: var(--accent-rose); }
