/* CSS Variables for Themes */
:root {
  /* Light Theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent-primary: #3455DB;
  --accent-hover: #253baf;
  --accent-light: rgba(52, 85, 219, 0.1);
  --border-color: #e0e0e0;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.2);
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-primary: #0f1117;
  --bg-secondary: #1c1e24;
  --bg-tertiary: #2a2d35;
  --text-primary: #f2f3f7;
  --text-secondary: #c1c2c5;
  --text-tertiary: #909296;
  --accent-primary: #4a7dfc;
  --accent-hover: #3455db;
  --accent-light: rgba(74, 125, 252, 0.15);
  --border-color: #3a3d45;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.5);
  --success-color: #34d399;
  --error-color: #f87171;
  --warning-color: #fbbf24;
  --info-color: #60a5fa;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.4; /* Reduced from 1.6 for more compact layout */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header Styles */
.header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  height: 70px;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo-section {
  display: flex;
  align-items: center;
  height: 100%;
}

.logo-icon {
  height: 60px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}



.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.theme-toggle:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
}

.auth-section {
  display: flex;
  align-items: center;
}

.auth-button {
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-button:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(52, 85, 219, 0.2);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
}

.logout-button {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.logout-button:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem; /* Reduced from 2rem for more compact layout */
  gap: 1.5rem; /* Reduced from 2rem */
  width: 100%;
  transition: all 0.3s ease;
}

.main-content.markdown-hidden {
  max-width: 800px;
}

/* Chat Container */
.chat-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-header {
  margin-bottom: 1.5rem; /* Reduced from 2rem */
  text-align: center;
}

.chat-header h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.chat-subtitle {
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.chat-messages {
  flex: 0 0 auto; /* Changed from flex: 1 to allow content-based sizing */
  overflow-y: auto;
  margin-bottom: 1.5rem; /* Reduced from 2rem */
  padding: 0.75rem; /* Reduced from 1rem */
  background-color: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  min-height: 120px; /* Significantly reduced to fit just the welcome message content */
  max-height: 600px;
}

.message {
  margin-bottom: 1rem; /* Reduced from 1.5rem */
  animation: fadeIn 0.3s ease-in-out;
}

.message-content {
  background-color: var(--bg-primary);
  border-radius: 12px;
  padding: 0.75rem; /* Reduced from 1rem */
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
}

.assistant-message .message-content {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.message-attachment {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.md-file-btn {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--accent-primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.md-file-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.md-file-icon {
  font-size: 1rem;
  opacity: 0.8;
}

.md-file-name {
  font-weight: 600;
  color: var(--accent-primary);
}

.message-sender {
  font-weight: 600;
  color: var(--text-primary);
}

.message-time {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.message-text {
  color: var(--text-primary);
  line-height: 1.5; /* Reduced from 1.7 for more compact text */
}

.message-text p {
  margin-bottom: 0.5rem; /* Reduced from 0.75rem */
}

/* Two-column layout for "What I can help you with" bulleted list */
.message-text ul {
  margin-left: 1rem; /* Reduced from 1.5rem */
  margin-bottom: 0.5rem; /* Reduced from 0.75rem */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1rem; /* Reduced vertical gap, added horizontal gap */
  list-style-type: none; /* Remove default bullets since we have emojis */
}

.message-text li {
  margin-bottom: 0.125rem; /* Reduced from 0.25rem for tighter spacing */
  break-inside: avoid; /* Prevent breaking list items across columns */
}

.message-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.message-text code {
  background-color: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.875rem;
}

.typing-cursor {
  color: var(--accent-primary);
  font-weight: bold;
  animation: blink 1s infinite;
  margin-left: 2px;
}

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

.analyzing-message {
  opacity: 0.9;
}

/* Enhanced Analyzing Animation */
.analyzing-content {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 20px 0;
}

.analyzing-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(52, 85, 219, 0.2);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: analyzing-spin 1s linear infinite;
  flex-shrink: 0;
  margin-top: 2px;
}

@keyframes analyzing-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.analyzing-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analyzing-text {
  color: var(--text-primary);
  font-style: italic;
  animation: analyzing-pulse 2s ease-in-out infinite;
  font-size: 15px;
}

@keyframes analyzing-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Tool Status Display */
.tool-status-container {
  background: rgba(52, 85, 219, 0.1);
  border-radius: 8px;
  padding: 12px;
  border-left: 3px solid var(--accent-primary);
}

.tools-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.active-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-badge {
  background: var(--accent-primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  animation: tool-fadeInScale 0.3s ease-out;
}

@keyframes tool-fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile optimizations for analyzing */
@media (max-width: 768px) {
  .analyzing-content {
    gap: 12px;
    padding: 15px 0;
  }
  
  .tool-status-container {
    padding: 10px;
  }
  
  .analyzing-text {
    font-size: 14px;
  }
  
  .tools-header {
    font-size: 11px;
  }
  
  .tool-badge {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* Chat Input */
.chat-input-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow-light);
  transition: all 0.2s ease;
}

.chat-input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-medium);
}

.input-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem; /* Reduced padding for more compact layout */
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
}

.active-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-indicator {
  font-size: 1rem;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  cursor: help;
}

.tool-indicator:hover {
  opacity: 1;
}

.tool-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
  font-weight: 500;
}

.input-status {
  display: flex;
  align-items: center;
}

.status-indicator {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  background: var(--success-color);
  color: white;
}

.status-indicator.ready {
  background: var(--success-color);
}

.status-indicator.analyzing {
  background: var(--warning-color);
}

.status-indicator.error {
  background: var(--error-color);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.75rem; /* Reduced from 1rem */
  position: relative;
}

.input-controls {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.attach-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-button:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.attach-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  padding: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  line-height: 1.4; /* Reduced from 1.5 for more compact input */
  min-height: 46px;
  max-height: 200px;
  overflow-y: auto;
  height: 46px; /* Start with fixed height like ChatGPT/Claude */
  transition: height 0.1s ease; /* Smooth height transitions */
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.send-button {
  background: var(--accent-primary);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  margin-bottom: 0.25rem;
}

.send-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.send-button:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  padding: 0.5rem 1rem; /* Reduced from 0.75rem 1rem */
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 0 0 20px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex: 1;
}

.model-info {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Markdown Viewer */
.markdown-viewer {
  flex: 1;
  background-color: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
  min-height: 300px;
  max-height: 90vh;
  overflow: hidden;
  transition: all 0.3s ease;
}

.markdown-viewer.visible {
  display: flex;
}

.markdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  flex-shrink: 0;
}

.markdown-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-button:hover {
  background-color: var(--bg-primary);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.action-button:active {
  transform: translateY(0);
}

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-button:hover {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.markdown-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background-color: var(--bg-primary);
  min-height: 200px;
  max-height: calc(90vh - 100px); /* Account for header height */
}

.markdown-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Markdown Styling */
.markdown-content h1 {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-primary);
}

.markdown-content h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.5rem 0 1rem 0;
}

.markdown-content h3 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem 0;
}

.markdown-content p {
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.markdown-content ul, .markdown-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content li {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.markdown-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.markdown-content code {
  background-color: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.markdown-content pre {
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.markdown-content pre code {
  background: none;
  padding: 0;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.markdown-content th, .markdown-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background-color: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-content td {
  color: var(--text-primary);
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2rem 0;
}

.markdown-content blockquote {
  border-left: 4px solid var(--accent-primary);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Sample Queries */
.sample-queries {
  position: fixed;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-medium);
  z-index: 50;
  max-width: 250px;
}

.sample-queries h4 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.sample-query {
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background-color: var(--bg-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.sample-query:hover {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
}

.sample-query:last-child {
  margin-bottom: 0;
}

/* Footer */
.footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-content p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--accent-primary);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.loading-spinner {
  text-align: center;
  color: white;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-content {
  background-color: var(--bg-primary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-heavy);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

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

.modal-body {
  padding: 1rem;
}

.modal-body p {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

.button-primary {
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.button-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.button-secondary:hover {
  background-color: var(--bg-primary);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

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

/* Chat Panel Styles */
.chat-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-medium);
  overflow: hidden;
}

.chat-panel.open {
  transform: translateX(0);
}

/* Always visible hamburger toggle */
.panel-toggle-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 50px;
  height: 70px;
  background: var(--bg-secondary);
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

/* Panel top bar - fills the space next to hamburger when panel is open */
.chat-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50px;
  right: 0;
  height: 70px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.panel-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.panel-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 16px;
}

.chat-panel-content {
  margin-top: 70px;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}

.new-chat-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.search-container {
  margin-bottom: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-primary);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.search-clear:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.chat-group {
  margin-bottom: 24px;
}

.chat-group-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 8px 16px;
  margin-bottom: 8px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  position: relative;
}

.chat-item:hover {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

.chat-item.active {
  background: var(--accent-light);
  border-color: var(--accent-primary);
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chat-time {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.chat-message-count {
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
}

.chat-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  flex-shrink: 0;
}

/* Chat Options Menu */
.chat-options {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10;
}

.chat-item:hover .chat-options {
  opacity: 1;
  visibility: visible;
}

.chat-options-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
}

.chat-options-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.chat-options-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-medium);
  min-width: 120px;
  z-index: 1000;
  overflow: hidden;
  display: none;
}

.chat-options-menu.show {
  display: block;
}

.chat-options-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  font-size: 13px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.chat-options-menu-item:hover {
  background: var(--bg-secondary);
}

.chat-options-menu-item.danger {
  color: var(--error-color);
}

.chat-options-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Chat Rename Modal */
.chat-rename-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.chat-rename-modal.show {
  display: flex;
}

.chat-rename-modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-large);
}

.chat-rename-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.chat-rename-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 16px;
}

.chat-rename-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.chat-rename-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.chat-rename-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.chat-rename-btn.cancel {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-rename-btn.cancel:hover {
  background: var(--bg-secondary);
}

.chat-rename-btn.save {
  background: var(--accent-primary);
  color: white;
}

.chat-rename-btn.save:hover {
  background: var(--accent-hover);
}

.chat-rename-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Archived Section */
.archived-section {
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
  padding-top: 16px;
}

.archived-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}

.archived-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.archived-toggle-icon {
  transition: transform 0.2s ease;
}

.archived-toggle.expanded .archived-toggle-icon {
  transform: rotate(90deg);
}

.archived-chats {
  display: none;
  margin-top: 8px;
}

.archived-chats.show {
  display: block;
}

.archived-chats .chat-item {
  opacity: 0.7;
}

.archived-chats .chat-item:hover {
  opacity: 1;
}

.search-results {
  margin-bottom: 16px;
}

.search-results-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 8px 16px;
  margin-bottom: 8px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  height: 200px;
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 16px;
}

.empty-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  max-width: 200px;
}

.panel-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.panel-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Main Content Adjustment */
/* Remove main content shifting - panel floats over content */

/* Scrollbar Styling */
.chat-history::-webkit-scrollbar {
  width: 6px;
}

.chat-history::-webkit-scrollbar-track {
  background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Chat Panel Mobile */
  .chat-panel {
    left: 0;
    width: 100%;
    max-width: 320px;
    transform: translateX(-100%);
  }

  .panel-toggle-wrapper {
    left: 0;
    width: 50px;
    height: 65px;
  }

  .chat-panel-content {
    margin-top: 65px;
  }

  .chat-panel::before {
    height: 65px;
  }

  /* Remove mobile main content shifting */

  .main-content {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .main-content.markdown-hidden {
    max-width: 100%;
  }
  
  .header {
    height: 66px;
  }

  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .logo-icon {
    height: 52px;
    width: auto;
  }
  
  .chat-header h2 {
    font-size: 1.5rem;
  }
  
  .markdown-viewer.visible {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    max-height: 100vh;
    border-radius: 0;
  }

  .md-file-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }
  
  .sample-queries {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    margin-top: 1rem;
    max-width: none;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  /* Adjust bulleted list layout for mobile - single column for better readability */
  .message-text ul {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }
}

@media (max-width: 480px) {
  .header {
    height: 60px;
  }

  .header-content {
    padding: 0 0.5rem;
  }

  .logo-icon {
    height: 48px;
    width: auto;
  }
  
  .main-content {
    padding: 0.5rem;
  }
  
  .chat-messages {
    min-height: 300px;
    padding: 0.75rem;
  }
  
  .message-content {
    padding: 0.75rem;
  }
  
  .chat-input-container {
    border-radius: 16px;
  }

  .input-toolbar {
    padding: 0.5rem 0.75rem;
    border-radius: 16px 16px 0 0;
  }

  .tool-text {
    display: none;
  }

  .chat-input-wrapper {
    padding: 0.75rem;
  }

  .input-footer {
    padding: 0.5rem 0.75rem;
    border-radius: 0 0 16px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .model-info {
    font-size: 0.7rem;
  }
  
  .modal-content {
    width: 95%;
  }
} 