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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  height: 100vh;
  display: flex;
  background: #f5f5f5;
}

/* Sidebar Styles */
.sidebar {
  width: 280px;
  background: #2c3e50;
  color: white;
  display: flex;
  flex-direction: column;
  border-right: 3px solid #34495e;
}

.sidebar-header {
  padding: 20px;
  background: #34495e;
  border-bottom: 1px solid #4a6741;
}

.sidebar-header h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.storage-info {
  font-size: 11px;
  color: #bdc3c7;
  margin-bottom: 10px;
}

.storage-info .storage-badge {
  display: inline-block;
  background: #34495e;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 5px;
}

.storage-badge.memory {
  background: #27ae60;
}

.storage-badge.disk {
  background: #f39c12;
}

.new-chat-btn {
  width: 100%;
  padding: 10px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
}

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

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.conversation-item {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid #34495e;
  transition: background 0.2s;
  position: relative;
}

.conversation-item:hover {
  background: #34495e;
}

.conversation-item.active {
  background: #3498db;
}

.conversation-title {
  font-weight: 500;
  margin-bottom: 5px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta {
  font-size: 11px;
  color: #bdc3c7;
}

.conversation-delete {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

/* Main Chat Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.chat-header {
  padding: 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-header h1 {
  font-size: 24px;
  color: #2c3e50;
  margin-bottom: 5px;
}

.session-info {
  font-size: 12px;
  color: #7f8c8d;
}

.chat-container {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages-area {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  overflow-y: auto;
  background: #fafafa;
  margin-bottom: 20px;
  font-family: 'Courier New', monospace;
  white-space: pre-wrap;
  line-height: 1.5;
  position: relative;
}

/* Typing indicator animation */
.typing-indicator {
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Streaming text effect */
.streaming-text {
  animation: fadeIn 0.1s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.prompt-input {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.3s;
}

.prompt-input:focus {
  outline: none;
  border-color: #3498db;
}

.controls {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: #555;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.loading {
  color: #3498db;
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 200px;
  }

  .conversation-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .conversation-item {
    min-width: 200px;
  }

  .chat-header h1 {
    font-size: 20px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls label {
    justify-content: center;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  color: #7f8c8d;
  padding: 40px;
  font-style: italic;
}

/* Scrollbar Styling */
.conversation-list::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
  width: 6px;
}

.conversation-list::-webkit-scrollbar-track {
  background: #34495e;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: #7f8c8d;
  border-radius: 3px;
}

.messages-area::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.messages-area::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

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

.message-fade-in {
  animation: fadeIn 0.3s ease-out;
}