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

:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --background-light: #f5f5f5;
  --text-color: #333;
}

body {
  font-family: 'Arial', sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-light);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: white;
}

.workspace {
  display: flex;
  flex: 1;
  position: relative;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background-color: var(--primary-color);
  color: white;
}

/* Conversations Sidebar */
.conversations-sidebar {
  width: 250px;
  background-color: #f9f9f9;
  border-right: 1px solid #e0e0e0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease-in-out;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
  transition: background-color 0.3s;
}

.conversation-item:hover {
  background-color: #f0f0f0;
}

.conversation-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.conversation-date {
  font-size: 0.8em;
  color: #888;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--primary-color);
  color: white;
  position: relative;
}

main {
  flex: 1;
  display: flex;
}

#chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.message {
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px 16px;
  position: relative;
  max-width: 90%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.user-message {
  background-color: #e1f5fe;
  color: #0d47a1;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.ai-message {
  background-color: #f5f5f5;
  color: #212121;
  align-self: flex-start;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.chat-input-container {
  display: flex;
  padding: 1rem;
  background-color: #f9f9f9;
}

#user-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: none;
  height: 100px;
}

.input-actions {
  display: flex;
  align-items: flex-end;
  margin-left: 1rem;
}

/* Enhanced Typing Indicator */
.typing-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
}

.typing-dots span {
  height: 8px;
  width: 8px;
  margin: 0 2px;
  background-color: #bdbdbd;
  border-radius: 50%;
  display: inline-block;
  animation: typing-dot 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-dot {
  0%, 80%, 100% { 
    transform: scale(0);
  } 40% { 
    transform: scale(1);
  }
}

/* Copy Button */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(255, 255, 255, 0.8);
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  opacity: 1;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.copy-btn.copied {
  background-color: #E8F5E9;
  color: #4CAF50;
  opacity: 1;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

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

.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  gap: 1rem;
}

.error {
  color: #d9534f;
  background-color: #f2dede !important;
}

.btn {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: #2980b9;
}

.conversation-item {
  position: relative;
  padding: 10px;
  display: flex;
  align-items: center;
}

.menu-btn {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.menu-dropdown {
  position: absolute;
  right: 10px;
  top: 100%;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.menu-dropdown.hidden {
  display: none;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background-color: #f0f0f0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }

  .conversations-sidebar {
    position: fixed;
    top: 0;
    left: -250px;
    height: 100vh;
    width: 250px;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }

  .conversations-sidebar.open {
    transform: translateX(250px);
  }

  .workspace {
    position: relative;
  }

  .chat-area {
    width: 100%;
  }

  header {
    padding: 1rem;
  }
}

/* Responsive improvements */
@media (max-width: 768px) {
  .process-status {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .process-step {
    flex-direction: row;
    width: 100%;
    margin-bottom: 10px;
  }
  
  .step-icon {
    margin-right: 10px;
    margin-bottom: 0;
  }
  
  .process-line {
    width: 3px;
    height: 20px;
    margin: 5px 0 5px 18px;
  }
  
  .message {
    max-width: 100%;
  }
}

/* Collapsible bubble for research/analysis phases */
.collapsible-phase {
  border-left: 3px solid #6c6c6c;
  transition: all 0.3s ease;
  margin: 10px 0;
  max-width: 95%;
}

/* The header bar with arrow and title */
.phase-header {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 500;
  background-color: #f9f9f9;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.phase-header:hover {
  background-color: #f1f1f1;
}

.phase-research {
  border-left-color: #2196F3;
}

.phase-analysis {
  border-left-color: #9C27B0;
}

/* Process Indicator */
.process-indicator {
  width: 100%;
  max-width: 95%;
  padding: 16px;
  margin: 16px 0;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.process-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.process-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
}

.step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
  transition: all 0.3s ease;
}

.step-icon.active {
  background-color: #2196F3;
  color: white;
  box-shadow: 0 0 10px rgba(33, 150, 243, 0.6);
  transform: scale(1.1);
}

.step-icon.completed {
  background-color: #4CAF50;
  color: white;
}

.process-line {
  height: 3px;
  background-color: #e0e0e0;
  flex-grow: 1;
  margin: 0 10px;
  position: relative;
  top: -15px;
}

.step-label {
  font-size: 12px;
  color: #757575;
  margin-top: 2px;
}

/* Status Messages */
.status-update {
  background-color: #f5f5f5;
  font-style: italic;
  color: #616161;
  padding: 8px 12px;
  font-size: 13px;
  border-left: 3px solid #9E9E9E;
}

.status-complete {
  background-color: #E8F5E9;
  color: #2E7D32;
  border-left: 3px solid #4CAF50;
  font-weight: 500;
}

/* Multi-agent improvements */
.system-activation {
  background-color: rgba(59, 130, 246, 0.1);
  border-left: 3px solid #3b82f6;
  font-weight: 500;
}

.system-complete {
  background-color: rgba(16, 185, 129, 0.1);
  border-left: 3px solid #10b981;
  font-weight: 500;
}

.research-activation, .analysis-activation {
  background-color: rgba(99, 102, 241, 0.1);
  border-left: 3px solid #6366f1;
}

.research-complete, .analysis-complete {
  background-color: rgba(79, 70, 229, 0.1);
  border-left: 3px solid #4f46e5;
}

.research-phase, .analysis-phase {
  border-left: 3px solid #6366f1;
  margin-bottom: 12px;
}

.research-phase .phase-header, .analysis-phase .phase-header {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background-color: rgba(99, 102, 241, 0.1);
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.research-phase .phase-header:hover, .analysis-phase .phase-header:hover {
  background-color: rgba(99, 102, 241, 0.15);
}

.phase-icon {
  margin-right: 8px;
  font-size: 16px;
}

.phase-arrow {
  margin-left: auto;
  transition: transform 0.3s;
}

.expanded .phase-arrow {
  transform: rotate(180deg);
}

.collapse-content {
  padding: 10px 15px;
  background-color: rgba(99, 102, 241, 0.05);
  border-radius: 0 0 4px 4px;
  max-height: 300px;
  overflow-y: auto;
}

.final-report {
  border-left: 3px solid #10b981;
  margin-top: 24px;
}

.report-header {
  background-color: rgba(16, 185, 129, 0.1);
  padding: 10px 15px;
  border-radius: 4px 4px 0 0;
}

.report-header h3 {
  margin: 0;
  color: #0f766e;
  font-size: 18px;
}

.report-content {
  padding: 15px;
  background-color: rgba(16, 185, 129, 0.05);
  border-radius: 0 0 4px 4px;
}

.progress-container {
  height: 4px;
  background-color: #e5e7eb;
  border-radius: 2px;
  margin: 8px 15px 15px 15px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: #6366f1;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.final-report .progress-bar {
  background-color: #10b981;
}

/* Phase transition animation */
.phase-transition {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent !important;
  border: none !important;
  padding: 15px 0;
  opacity: 1;
  transition: opacity 0.8s;
}

.phase-transition.fade-out {
  opacity: 0;
}

.transition-animation {
  display: flex;
  align-items: center;
  background-color: rgba(99, 102, 241, 0.1);
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.from-phase, .to-phase {
  padding: 5px 10px;
  border-radius: 15px;
  font-weight: 500;
}

.from-phase {
  background-color: rgba(99, 102, 241, 0.2);
  color: #4f46e5;
}

.to-phase {
  background-color: rgba(16, 185, 129, 0.2);
  color: #059669;
}

.transition-arrow {
  margin: 0 10px;
  color: #6b7280;
  font-size: 20px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.7; }
}

/* Typing indicator improvements */
.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 32px;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  float: left;
  margin: 0 1px;
  background-color: #6366f1;
  display: block;
  border-radius: 50%;
  opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
  animation: 1s blink infinite 0.3333s;
}

.typing-indicator span:nth-of-type(2) {
  animation: 1s blink infinite 0.6666s;
}

.typing-indicator span:nth-of-type(3) {
  animation: 1s blink infinite 0.9999s;
}

@keyframes blink {
  50% {
    opacity: 1;
  }
}
