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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6; color: #333; background: #f5f7fa;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Buttons */
.btn {
  display: inline-block; padding: 10px 20px; border: none; border-radius: 8px;
  text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all 0.2s; text-align: center;
}

.btn-primary { background: #007bff; color: white; }
.btn-primary:hover { background: #0056b3; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #545b62; }
.btn-outline { background: transparent; color: #007bff; border: 1px solid #007bff; }
.btn-outline:hover { background: #007bff; color: white; }
.btn-full { width: 100%; }
.btn-large { padding: 15px 30px; font-size: 16px; }

/* Alerts */
.alert {
  padding: 12px; border-radius: 6px; margin-bottom: 20px;
}
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* Authentication Pages */
.auth-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}

.auth-container { width: 100%; max-width: 400px; padding: 20px; }

.auth-card {
  background: white; padding: 40px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.auth-title { font-size: 24px; text-align: center; margin-bottom: 10px; color: #007bff; }

.auth-form .form-group { margin-bottom: 20px; }

.auth-form label { display: block; margin-bottom: 5px; font-weight: 500; }

.auth-form input {
  width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 14px; transition: border-color 0.2s;
}

.auth-form input:focus { outline: none; border-color: #007bff; }

.auth-links { text-align: center; margin-top: 20px; }
.auth-links a { color: #007bff; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* Chat Page Layout */
.chat-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

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

.chat-header .container { display: flex; justify-content: space-between; align-items: center; }

.logo { font-size: 20px; font-weight: 600; color: #007bff; }

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

.user-info { font-size: 14px; color: #666; }

.logout-form { margin: 0; }

.chat-container { display: flex; flex: 1; overflow: hidden; min-width: 0; }

/* Sidebar */
.sidebar {
  width: 300px; background: white; border-right: 1px solid #eee;
  padding: 20px; overflow-y: auto; flex-shrink: 0;
}

.sidebar-header { margin-bottom: 20px; }

.sessions-list h3 { margin-bottom: 15px; font-size: 16px; color: #666; }

.session-item {
  padding: 12px; border: 1px solid #eee; border-radius: 8px;
  margin-bottom: 10px; cursor: pointer; transition: all 0.2s;
}

.session-item:hover, .session-item.active { background: #f8f9fa; border-color: #007bff; }

.session-title { font-weight: 500; margin-bottom: 5px; }

.session-meta { display: flex; justify-content: space-between; font-size: 12px; color: #666; }

.empty-state { color: #999; font-style: italic; text-align: center; padding: 20px; }

/* Main Chat Area */
.chat-main { flex: 1; display: flex; flex-direction: column; background: white; min-width: 0; overflow: hidden; }

.chat-info {
  padding: 15px 20px; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
}

.model-selector label { margin-right: 10px; font-weight: 500; }

.model-selector select {
  padding: 8px; border: 1px solid #ddd; border-radius: 6px;
  background: white; min-width: 200px;
}

.session-cost-display { font-weight: 500; color: #28a745; }

.messages-container {
  flex: 1; 
  overflow-y: auto; 
  padding: 12px;
  min-width: 0;
  max-height: calc(100vh - 200px);
  scroll-behavior: smooth;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message {
  display: flex; margin-bottom: 12px; min-width: 0;
}

.message.user { justify-content: flex-end; }

.message-content {
  max-width: 40% !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-line;
  line-height: 1.4 !important;
  display: inline-block !important;
  width: fit-content !important;
  min-width: 0 !important;
  padding: 6px 10px !important;
}

.message.user .message-content {
  background: #007bff;
  color: white;
  padding: 6px 10px !important;
  border-radius: 18px;
  max-width: 40% !important;
  display: inline-block !important;
  width: fit-content !important;
  min-width: 0 !important;
  line-height: 1.4 !important;
}

.message.assistant .message-content {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  padding: 6px 10px !important;
  border-radius: 18px;
  font-family: system-ui, -apple-system, sans-serif;
  display: inline-block !important;
  width: fit-content !important;
  max-width: 40% !important;
  min-width: 0 !important;
  line-height: 1.4 !important;
}

.message-text { 
  white-space: pre-wrap;
  line-height: 1.4 !important; 
  word-wrap: break-word; overflow-wrap: break-word; min-width: 0;
  margin: 0 !important; padding: 0 !important;
}

/* МАКСИМАЛЬНО АГРЕССИВНЫЙ сброс всех отступов внутри сообщений */
.message-content *,
.message-content p,
.message-content div,
.message-content span,
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6,
.message-content strong, .message-content em, .message-content b, .message-content i,
.message-content small, .message-content br {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.4 !important;
}

/* Исключения для элементов, которым нужны отступы */
.message-content ul, .message-content ol {
  padding-left: 20px !important; /* Только отступ слева для списков */
}

.message-content ul ul, .message-content ol ul,
.message-content ul ol, .message-content ol ol {
  padding-left: 16px !important; /* Вложенные списки */
}

.message-content blockquote {
  padding: 6px 12px !important; /* Внутренний отступ для цитат */
}

.message-content pre {
  padding: 8px !important; /* Внутренний отступ для кода */
}

.message-content code {
  padding: 2px 4px !important; /* Внутренний отступ для инлайн кода */
}

/* Markdown styles inside messages - minimal margins for compact bubbles */
.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
  margin: 0 !important; font-weight: 600; line-height: 1.3;
  word-wrap: break-word; overflow-wrap: break-word;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.2em; }
.message-content h4 { font-size: 1.1em; }
.message-content h5, .message-content h6 { font-size: 1em; }

.message-content p { margin: 0 !important; word-wrap: break-word; overflow-wrap: break-word; }

.message-content ul, .message-content ol {
  margin: 0 !important; padding-left: 20px; /* Минимальный отступ слева */
}

.message-content ul li { 
  margin: 0 !important; list-style-type: disc; 
  padding-left: 0; /* Убираем дополнительный отступ */
}

.message-content ol li { 
  margin: 0 !important; list-style-type: decimal; 
  padding-left: 0; /* Убираем дополнительный отступ */
}

.message-content ul ul, .message-content ol ul { 
  margin: 0 !important; padding-left: 16px; /* Вложенные списки минимально */
}

.message-content ul ol, .message-content ol ol { 
  margin: 0 !important; padding-left: 16px; /* Вложенные списки минимально */
}

.message-content blockquote {
  margin: 0 !important; padding: 6px 12px; background: rgba(0,0,0,0.05);
  border-left: 3px solid #007bff; font-style: italic;
}

.message-content code {
  padding: 2px 4px; background: rgba(0,0,0,0.1); border-radius: 3px;
  font-family: 'Consolas', 'Monaco', monospace; font-size: 0.9em;
  word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap;
}

.message-content pre {
  margin: 0 !important; padding: 8px; background: rgba(0,0,0,0.05);
  border-radius: 4px; overflow-x: auto; font-family: 'Consolas', 'Monaco', monospace;
  max-width: 100%; word-wrap: break-word; overflow-wrap: break-word;
}

.message-content pre code {
  padding: 0; background: none; font-size: 0.85em;
  word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap;
}

.message-content strong, .message-content b { font-weight: 600; }
.message-content em, .message-content i { font-style: italic; }

.message-content a {
  color: #007bff; text-decoration: none; border-bottom: 1px dotted #007bff;
  word-wrap: break-word; overflow-wrap: break-word; max-width: 100%;
}

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

.message-content hr {
  margin: 0 !important; border: none; border-top: 1px solid #eee;
}

.message-image { max-width: 200px; border-radius: 8px; margin-bottom: 10px; }

.message-cost {
  font-size: 12px; color: #666; margin-top: 3px;
  padding-top: 3px; border-top: 1px solid #eee;
}

.message-time {
  font-size: 11px; color: #999; margin-top: 3px;
  text-align: right; padding: 0 5px;
}

.message.user .message-time { text-align: left; }

.empty-chat {
  text-align: center; color: #666; padding: 50px 20px;
  font-size: 18px;
}

/* Message Input */
.message-input-container {
  padding: 20px; border-top: 1px solid #eee;
}

.input-group { position: relative; }

.image-preview {
  margin-bottom: 10px; position: relative; display: inline-block;
}

.image-preview img { max-width: 100px; border-radius: 8px; }

.remove-btn {
  position: absolute; top: -5px; right: -5px;
  background: #dc3545; color: white; border: none;
  border-radius: 50%; width: 20px; height: 20px;
  cursor: pointer; font-size: 12px;
}

#messageInput {
  width: 100%; min-height: 80px; padding: 15px;
  border: 1px solid #ddd; border-radius: 12px;
  resize: vertical; font-family: inherit;
  font-size: 14px; line-height: 1.5;
}

#messageInput:focus { outline: none; border-color: #007bff; }

.input-actions {
  display: flex; gap: 10px; margin-top: 10px;
  justify-content: flex-end;
}

/* Welcome Screen */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; text-align: center;
  padding: 40px;
}

.welcome-screen h2 { margin-bottom: 10px; color: #333; }
.welcome-screen p { color: #666; margin-bottom: 30px; }

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

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

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

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

/* Error Pages */
.error-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #f8f9fa;
}

.error-container { max-width: 500px; padding: 20px; }

.error-card {
  background: white; padding: 40px; border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center;
}

.error-message { margin: 20px 0; font-size: 16px; color: #666; }

.error-details { margin: 20px 0; text-align: left; }

.error-details summary { cursor: pointer; font-weight: 500; }

.error-details pre {
  background: #f8f9fa; padding: 15px; border-radius: 6px;
  overflow-x: auto; font-size: 12px; margin-top: 10px;
}

.error-actions { display: flex; gap: 15px; justify-content: center; margin-top: 30px; }

/* Ensure tables don't break layout */
.message-content table {
  max-width: 100%; word-wrap: break-word; overflow-wrap: break-word;
  table-layout: fixed; border-collapse: collapse;
}

.message-content th, .message-content td {
  word-wrap: break-word; overflow-wrap: break-word;
  max-width: 200px; padding: 8px; border: 1px solid #ddd;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container { flex-direction: column; }
  
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #eee; flex-shrink: 0; }
  
  .chat-header .container { flex-direction: column; gap: 10px; }
  
  .chat-info { flex-direction: column; gap: 10px; align-items: flex-start; }
  
  .message-content { 
    max-width: 75% !important; 
    width: fit-content !important; 
    display: inline-block !important;
    min-width: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap !important;
    box-sizing: border-box !important;
    padding: 6px 10px !important;
  }
  
  .input-actions { flex-wrap: wrap; }
  
  .error-actions { flex-direction: column; }
}

/* Enhanced File Upload Styles */
.file-upload-hint {
  font-size: 13px;
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: 6px;
  text-align: center;
  line-height: 1.4;
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  color: #777;
}

.file-upload-hint.enabled {
  background-color: #d4edda !important;
  color: #27ae60 !important;
  border: 1px solid #c3e6cb;
}

.file-upload-hint.disabled {
  background-color: #fff3cd !important;
  color: #f39c12 !important;
  border: 1px solid #ffeaa7;
}

.file-upload-hint strong {
  font-weight: 600;
}

.file-upload-hint br {
  line-height: 1.6;
}

.uploaded-files-list {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin: 10px 0;
  max-width: 100%;
}

.uploaded-files-header {
  font-weight: bold;
  margin-bottom: 10px;
  color: #495057;
  font-size: 0.9em;
}

.uploaded-file-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  margin: 5px 0;
  background-color: white;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  gap: 10px;
  transition: all 0.2s ease;
}

.uploaded-file-item:hover {
  background-color: #f8f9fa;
  border-color: #007bff;
}

.file-icon {
  font-size: 1.2em;
  width: 24px;
  text-align: center;
}

.file-name {
  flex: 1;
  font-weight: 500;
  color: #343a40;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 0.8em;
  color: #6c757d;
  min-width: 60px;
}

.file-type {
  font-size: 0.75em;
  background-color: #e9ecef;
  color: #495057;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 500;
  min-width: 50px;
  text-align: center;
}

.file-upload-progress {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 20px 30px;
  border-radius: 8px;
  z-index: 1000;
  display: none;
}

.progress-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.progress-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #ffffff40;
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* File button enhanced styles */
#imageBtn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

#imageBtn:hover {
  background-color: #0056b3;
  transform: scale(1.05);
}

#imageBtn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#imageBtn.disabled:hover {
  background-color: #6c757d;
  transform: none;
}

/* Model-specific file support indicators */
.model-capability-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8em;
  margin-left: 10px;
}

.capability-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.capability-icon.supported {
  background-color: #28a745;
}

.capability-icon.not-supported {
  background-color: #dc3545;
}

/* File type specific colors */
.file-type.image { background-color: #e3f2fd; color: #1976d2; }
.file-type.pdf { background-color: #fff3e0; color: #f57c00; }
.file-type.video { background-color: #f3e5f5; color: #7b1fa2; }
.file-type.audio { background-color: #e8f5e8; color: #388e3c; }
.file-type.text { background-color: #fafafa; color: #424242; }

/* Responsive file list */
@media (max-width: 768px) {
  .uploaded-file-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .file-name {
    width: 100%;
  }
  
  .file-size, .file-type {
    align-self: flex-end;
  }
}

/* Enhanced error/success messages for file operations */
.alert.file-operation {
  border-left: 4px solid;
  padding-left: 15px;
}

.alert.file-operation.success {
  border-left-color: #28a745;
  background-color: #d4edda;
  color: #155724;
}

.alert.file-operation.error {
  border-left-color: #dc3545;
  background-color: #f8d7da;
  color: #721c24;
}

/* Modern file message styles - inspired by ChatGPT/Claude */
.file-message .message-content {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 12px;
}

.file-upload-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 1.5em;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #e3f2fd;
  border-radius: 8px;
}

.file-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.9em;
}

.file-details {
  font-size: 0.75em;
  color: #6c757d;
}

.file-status {
  font-size: 0.8em;
  color: #28a745;
  font-weight: 500;
  padding: 2px 8px;
  background-color: #d4edda;
  border-radius: 12px;
  border: 1px solid #c3e6cb;
}

.file-preview-image {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.file-preview-image:hover {
  transform: scale(1.02);
}

/* File type specific icon colors */
.file-message .file-icon {
  color: white;
  font-weight: bold;
}

.file-message[data-file-type="image"] .file-icon {
  background-color: #4CAF50;
}

.file-message[data-file-type="pdf"] .file-icon {
  background-color: #f44336;
}

.file-message[data-file-type="video"] .file-icon {
  background-color: #9c27b0;
}

.file-message[data-file-type="audio"] .file-icon {
  background-color: #ff9800;
}

.file-message[data-file-type="text"] .file-icon {
  background-color: #607d8b;
}

/* Responsive file messages */
@media (max-width: 768px) {
  .file-header {
    gap: 8px;
  }
  
  .file-icon {
    width: 28px;
    height: 28px;
    font-size: 1.2em;
  }
  
  .file-name {
    font-size: 0.85em;
  }
  
  .file-details {
    font-size: 0.7em;
  }
  
  .file-preview-image {
    max-width: 150px !important;
  }
}

/* Staged Files Container */
.staged-files-container {
    margin-bottom: 15px;
    border: 1px solid #e3e6e8;
    border-radius: 8px;
    background: #f8f9fa;
    padding: 12px;
    display: none;
}

.staged-files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.clear-all-files {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.clear-all-files:hover {
    background: #c82333;
}

.staged-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.staged-file-item {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 80px;
}

.staged-file-item:hover {
    border-color: #adb5bd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.staged-file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 8px;
}

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

.staged-file-name {
    font-weight: 500;
    font-size: 14px;
    color: #495057;
    margin-bottom: 2px;
}

.staged-file-details {
    font-size: 12px;
    color: #6c757d;
}

.remove-staged-file {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background-color 0.2s;
    margin-left: auto;
}

.remove-staged-file:hover {
    background: #c82333;
}

.file-preview-thumb {
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* File Upload Messages in Chat */
.file-upload-message {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

.file-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.file-icon {
    font-size: 18px;
    margin-right: 8px;
}

.file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
    color: #495057;
}

.file-details {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

.file-status {
    color: #28a745;
    font-size: 12px;
    font-weight: 500;
}

.file-preview-image {
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.file-preview-image:hover {
    transform: scale(1.02);
}

.file-message-text {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
    font-size: 14px;
    color: #495057;
}

/* Navigation styles for chat/agent switcher */
.chat-nav {
  background: #2d2d2d;
  border-bottom: 1px solid #444;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: #ccc;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 5px;
  transition: all 0.2s;
}

.nav-link:hover {
  background: #444;
  color: white;
}

.nav-link.active {
  background: #007bff;
  color: white;
}

.nav-user {
  color: #ccc;
  font-size: 0.9em;
}

.nav-user a {
  color: #007bff;
  text-decoration: none;
}

/* Tool indicator improvements */
.tool-indicator {
    background: #e3f2fd;
    color: #1565c0;
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid #2196f3;
    font-size: 14px;
    font-weight: 500;
}

/* Agent session styling */
.agent-session-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* Improved message container for agent */
.messages-container {
    flex: 1; 
    overflow-y: auto; 
    padding: 16px;
    min-width: 0;
    max-height: calc(100vh - 200px);
    scroll-behavior: smooth;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Agent input area */
.agent-input-area {
    border-top: 1px solid #e9ecef;
    padding: 16px;
    background: white;
}

/* Error styling for agent */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    margin-bottom: 12px;
}

/* Long text handling */
.message-content pre {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
}

.message-content code {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* JSON/Tool result formatting */
.message-content .tool-result {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* Responsive improvements for agent */
@media (max-width: 768px) {
    .message.user .message-content {
        max-width: 85%;
    }
    
    .message.assistant .message-content {
        padding: 8px;
        font-size: 14px;
    }
    
    .agent-input-area {
        padding: 12px;
    }
}

/* NUCLEAR OPTION: Maximum aggressive reset for message content */
.message-content *,
.message-content *:before,
.message-content *:after {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    font-size: inherit !important;
    vertical-align: baseline !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Only allow specific padding for essential elements */
.message-content ul, .message-content ol {
    padding-left: 20px !important;
}

.message-content blockquote {
    padding: 6px 12px !important;
    border-left: 3px solid #ccc !important;
}

.message-content pre, .message-content code {
    padding: 4px 8px !important;
    background: rgba(0,0,0,0.05) !important;
}

.message-content table td, .message-content table th {
    padding: 4px 8px !important;
    border: 1px solid #ddd !important;
}