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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 1600px;
  width: 95%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  height: 90vh;
  max-height: 900px;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 24px;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
}

.status-bar {
  display: flex;
  gap: 10px;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar {
  width: 450px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e5e7eb;
  overflow-y: auto;
  background: #f9fafb;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.server-list::-webkit-scrollbar {
  width: 6px;
}

.server-list::-webkit-scrollbar-track {
  background: #f9fafb;
}

.server-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.server-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-authenticated {
  background: #10b981;
  color: white;
}

.status-unauthenticated {
  background: #f59e0b;
  color: white;
}

.status-connected {
  background: #10b981;
  color: white;
}

.status-disconnected {
  background: #ef4444;
  color: white;
}

.server-panel {
  background: white;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.server-panel h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #374151;
}

.add-server-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.server-url-input {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.2s;
  min-width: 0;
}

.server-url-input:focus {
  outline: none;
  border-color: #667eea;
}

.btn-add {
  padding: 8px 14px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-add:hover {
  background: #5568d3;
}

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

.server-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.server-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  gap: 12px;
}

.server-info {
  flex: 1;
  min-width: 0;
}

.server-url {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-status {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 4px;
}

.server-status.status-connected {
  background: #d1fae5;
  color: #065f46;
}

.server-status.status-connecting {
  background: #fef3c7;
  color: #92400e;
}

.server-status.status-error {
  background: #fee2e2;
  color: #991b1b;
}

.server-error {
  font-size: 11px;
  color: #dc2626;
  margin-top: 4px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-remove {
  padding: 6px 12px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-remove:hover {
  background: #dc2626;
}

.no-servers {
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  font-style: italic;
}

/* Logs panel */
.logs-panel {
  background: #1f2937;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.logs-panel.collapsed {
  flex: 0 0 auto;
  max-height: 40px;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #111827;
  border-bottom: 1px solid #374151;
}

.logs-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: #f3f4f6;
  margin: 0;
}

.logs-controls {
  display: flex;
  gap: 6px;
}

.btn-small {
  padding: 4px 10px;
  background: #374151;
  color: #e5e7eb;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-small:hover {
  background: #4b5563;
}

.logs-filters {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  background: #111827;
  border-bottom: 1px solid #374151;
  align-items: center;
  flex-wrap: wrap;
}

.logs-filters select {
  padding: 4px 8px;
  background: #374151;
  color: #e5e7eb;
  border: 1px solid #4b5563;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.logs-filters label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #9ca3af;
  cursor: pointer;
}

.logs-filters input[type="checkbox"] {
  cursor: pointer;
}

.logs-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.4;
}

.logs-container::-webkit-scrollbar {
  width: 6px;
}

.logs-container::-webkit-scrollbar-track {
  background: #111827;
}

.logs-container::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 3px;
}

.logs-container::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

.log-entry {
  padding: 3px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.log-time {
  color: #6b7280;
  font-weight: 500;
  min-width: 70px;
}

.log-level {
  font-weight: 700;
  min-width: 55px;
}

.log-level-info .log-level {
  color: #60a5fa;
}

.log-level-success .log-level {
  color: #34d399;
}

.log-level-warn .log-level {
  color: #fbbf24;
}

.log-level-error .log-level {
  color: #f87171;
}

.log-category {
  color: #9ca3af;
  font-weight: 500;
  min-width: 60px;
}

.log-message {
  color: #e5e7eb;
  flex: 1;
}

.log-data {
  width: 100%;
  margin: 4px 0 4px 145px;
  padding: 6px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 3px;
  color: #9ca3af;
  font-size: 10px;
  overflow-x: auto;
}

.no-logs {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: slideIn 0.3s ease-out;
}

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

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

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .message-content {
  background: #667eea;
  color: white;
}

.message.assistant .message-content {
  background: #f3f4f6;
  color: #1f2937;
}

.message-content strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  opacity: 0.8;
}

.message-content p {
  margin: 8px 0;
}

.message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.tool-call {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  padding: 12px;
  margin: 8px 0;
  border-radius: 6px;
  font-size: 13px;
}

.tool-call-name {
  font-weight: 600;
  color: #1e40af;
  font-family: 'Courier New', monospace;
  margin-bottom: 6px;
}

.tool-call-result {
  background: white;
  padding: 8px;
  border-radius: 4px;
  margin-top: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
}

.input-container {
  padding: 20px 24px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
}

#user-input {
  flex: 1;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s;
}

#user-input:focus {
  outline: none;
  border-color: #667eea;
}

#send-button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 100px;
}

#send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#send-button:active {
  transform: translateY(0);
}

#send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 2px solid white;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

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

/* Modal styles */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

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

.modal-content {
  background: white;
  padding: 32px;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

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

.modal-content h2 {
  margin-bottom: 16px;
  color: #1f2937;
}

.modal-content p {
  margin-bottom: 24px;
  color: #6b7280;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-secondary:hover {
  background: #d1d5db;
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Markdown content styles */
.markdown-content {
  line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
  color: #1f2937;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }
.markdown-content h4 { font-size: 1em; }

.markdown-content p {
  margin: 8px 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 4px 0;
}

.markdown-content code {
  background: #e5e7eb;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.markdown-content blockquote {
  border-left: 4px solid #667eea;
  margin: 12px 0;
  padding: 8px 16px;
  background: #f9fafb;
  color: #4b5563;
  border-radius: 0 8px 8px 0;
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background: #f3f4f6;
  font-weight: 600;
}

.markdown-content tr:nth-child(even) {
  background: #f9fafb;
}

.markdown-content a {
  color: #667eea;
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 16px 0;
}

.markdown-content strong {
  font-weight: 600;
  display: inline;
  margin: 0;
}

.markdown-content em {
  font-style: italic;
}

/* Responsive design */
@media (max-width: 1200px) {
  .sidebar {
    width: 380px;
  }
}

@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    max-height: 400px;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }
  
  .container {
    max-height: none;
    height: auto;
    min-height: 90vh;
  }
}
