/* === APP SHELL === */
.app-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* === HEADER === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.app-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.app-logo:hover { color: var(--accent); }

/* === MODE TOGGLE === */
.mode-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 100px;
  transition: background 0.15s, color 0.15s;
}
.mode-btn.active {
  background: var(--accent);
  color: white;
}
.mode-btn:not(.active):hover { color: var(--fg); }

/* === MAIN === */
.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* === UPLOAD PANEL === */
.upload-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.upload-panel.hidden { display: none; }
.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 56px 48px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.05);
}
.upload-icon {
  width: 64px;
  height: 64px;
  background: #EFF6FF;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin: 0 auto 20px;
}
.upload-card h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 10px;
}
.upload-card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}
.upload-btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 100px;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 20px;
}
.upload-btn:hover { opacity: 0.88; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  color: var(--muted);
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #EFF6FF;
  color: var(--accent);
}
.upload-status {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 20px;
}
.upload-status.error { color: #EF4444; }
.upload-status.loading { color: var(--accent); }

/* === CHAT LAYOUT === */
.chat-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.chat-layout.hidden { display: none; }

/* === SIDEBAR === */
.chat-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.doc-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: #EFF6FF;
  border-radius: 12px;
}
.doc-info-icon {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}
.doc-info-text { min-width: 0; }
.doc-info-text strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  word-break: break-word;
  line-height: 1.3;
  margin-bottom: 3px;
}
.doc-info-text span {
  font-size: 0.73rem;
  color: var(--muted);
}
.new-doc-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
.new-doc-btn:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-tips { margin-top: 4px; }
.tips-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}
.tip-chip {
  display: block;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--fg);
  cursor: pointer;
  margin-bottom: 6px;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}
.tip-chip:hover {
  border-color: var(--accent);
  background: #EFF6FF;
  color: var(--accent);
}

/* === CHAT MAIN === */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === MESSAGES === */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.message { display: flex; gap: 12px; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.message-bubble {
  max-width: 68%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
}
.message.user .message-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.message.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}
.intro-message .message-bubble {
  background: #F0FDF4;
  border-color: #BBF7D0;
  color: #166534;
}

.message-citation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.73rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.message-citation svg { color: var(--accent); flex-shrink: 0; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* === INPUT BAR === */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--muted); }
.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.4; cursor: default; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .chat-sidebar { display: none; }
  .messages { padding: 16px; }
  .message-bubble { max-width: 86%; }
  .chat-input-bar { padding: 12px 16px; }
  .upload-card { padding: 40px 24px; }
}
