:root {
  --bg-dark: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.15);
  --font-main: 'Inter', sans-serif;
  --user-msg-bg: #3b82f6;
  --ai-msg-bg: rgba(255, 255, 255, 0.1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background animated orbs logic */
.background-orbs {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(59, 130, 246, 0.4);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: rgba(139, 92, 246, 0.3);
  bottom: -150px;
  right: -50px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Layout */
.app-container {
  display: flex;
  width: 95%;
  max-width: 1400px;
  height: 90vh;
  gap: 24px;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

/* Sidebar */
.sidebar {
  width: 340px;
  flex-shrink: 0;
  padding: 24px;
  overflow-y: auto;
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-color);
}

.sidebar-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.control-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

input[type="text"], input[type="url"], input[type="file"], input[type="password"] {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

input[type="file"] {
  padding: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  color: #fff;
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: rgba(255,255,255,0.2);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.divider {
  height: 1px;
  background: var(--panel-border);
  margin: 16px 0 24px 0;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #fff;
}

.upload-box {
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--panel-border);
}

.upload-box h4 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.1s, filter 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.primary-btn {
  background: var(--accent-color);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-msg {
  font-size: 0.85rem;
  margin-top: auto;
  min-height: 40px;
  padding: 12px;
  border-radius: 8px;
  display: none;
  text-align: center;
  word-break: break-word;
}
.status-msg.success { display: block; background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-msg.error { display: block; background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-msg.loading { display: block; background: rgba(59, 130, 246, 0.2); color: #60a5fa; }

/* Chat Main Area */
.chat-area {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.status-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 85%;
  animation: slideUp 0.3s ease-out forwards;
}

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

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-avatar { background: rgba(255,255,255,0.2); }
.ai-avatar { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }

.bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.user-message .bubble {
  background: var(--user-msg-bg);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message .bubble {
  background: var(--ai-msg-bg);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--panel-border);
}

.chat-input-wrapper {
  padding: 20px;
  background: rgba(15, 23, 42, 0.4);
  border-top: 1px solid var(--panel-border);
  display: flex;
  gap: 12px;
}

#chatInput {
  background: rgba(0,0,0,0.3);
  padding: 16px 20px;
  font-size: 1rem;
  border-radius: 14px;
  flex-grow: 1;
}

.send-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.send-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s;
}

.send-btn:hover {
  background: var(--accent-hover);
}

.send-btn:hover svg {
  transform: translate(2px, -2px);
}

.send-btn:active {
  transform: scale(0.95);
}

/* Scrollbar tweaks */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* Authentication Login Modal Styles */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(10px);
  display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.login-box {
  padding: 40px; width: 100%; max-width: 380px; 
  display: flex; flex-direction: column; text-align: center;
}
.login-box h2 {
  font-size: 24px; font-weight: 700; color: #fff; margin-bottom: 5px;
}
.login-box input {
  padding: 12px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.2); color: white; font-size: 15px; outline: none; transition: all 0.2s;
}
.login-box input:focus {
  border-color: #6366f1; background: rgba(255,255,255,0.05);
}

/* Document Polling List Styles */
.doc-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.icon-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; transition: color 0.2s;
}
.icon-btn:hover { color: white; transform: rotate(45deg); }

.doc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.doc-item {
  background: rgba(0,0,0,0.2);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--panel-border);
}
.doc-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px;
  color: var(--text-main);
}
.status-badge {
  padding: 3px 6px; border-radius: 4px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-processing { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.status-completed { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-failed { background: rgba(239, 68, 68, 0.2); color: #f87171; }
