:root {
  --primary-color: #2196F3;
  --secondary-color: #E3F2FD;
  --text-color: #444444;
  --border-color: #E0E0E0;
  --bg-color: #dadada;
  --chat-bg: #fbfbfb;
  --success-color: #4CAF50;
  --error-color: #F44336;
  --warning-color: #FFC107;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  overflow: hidden;
}

.container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
  width: 350px;
  height: 100vh;
  background: white;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background-color: white;
}

.sidebar-header h2 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.mode-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  background-color: white;
  transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.input-group textarea {
  min-height: 100px;
  resize: vertical;
}

.button-group {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: #1976D2;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

.btn-secondary:hover {
  background-color: #BBDEFB;
}

.btn-warning {
  background-color: var(--warning-color);
  color: #212529;
}

.btn-warning:hover {
  background-color: #e0a800;
}

/* Connection Status Styles */
.connection-status {
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: var(--secondary-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-color);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--error-color);
  transition: background-color 0.3s ease;
}

.status-dot.connected {
  background-color: var(--success-color);
}

/* Main Content Styles */
.main-content {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  overflow: hidden;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: calc(100vh - 180px); /* Adjust based on input container height */
}

.message {
  position: relative;
  max-width: 85%;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
  word-wrap: break-word;
}

.message p {
  margin: 0.5rem 0;
  line-height: 1.5;
}

.message h1, .message h2, .message h3, .message h4, .message h5, .message h6 {
  margin: 1rem 0 0.5rem 0;
  color: var(--text-color);
  font-weight: 600;
}

.message h1 { font-size: 1.5rem; }
.message h2 { font-size: 1.3rem; }
.message h3 { font-size: 1.1rem; }
.message h4 { font-size: 1rem; }
.message h5 { font-size: 0.9rem; }
.message h6 { font-size: 0.8rem; }

.message ul, .message ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message li {
  margin: 0.25rem 0;
}

.message blockquote {
  margin: 0.5rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--primary-color);
  background-color: rgba(0, 0, 0, 0.05);
  font-style: italic;
}

.message code {
  font-family: 'Fira Code', monospace;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
}

.message pre {
  margin: 0.5rem 0;
  padding: 1rem;
  background-color: #889ea4;
  border-radius: 0.5rem;
  overflow-x: auto;
}

.message pre code {
  background-color: transparent;
  padding: 0;
  color: #d4d4d4;
  font-size: 0.9em;
  line-height: 1.5;
}

.message table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  width: 100%;
}

.message th, .message td {
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  text-align: left;
}

.message th {
  background-color: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.message tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

.message a {
  color: var(--primary-color);
  text-decoration: none;
}

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

.message img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  margin: 0.5rem 0;
}

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

/* Code Block Styles */
pre {
  background-color: #D3D3D3;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  position: relative;
  border: 1px solid #BDBDBD;
}

pre code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #424242;
  display: block;
  padding: 0.5rem;
}

/* Syntax Highlighting */
.hljs {
  background: #D3D3D3;
  color: #424242;
  padding: 0.5rem;
  border-radius: 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.hljs-keyword { color: #616161; }
.hljs-string { color: #558B2F; }
.hljs-number { color: #7B1FA2; }
.hljs-comment { color: #757575; }
.hljs-function { color: #C62828; }
.hljs-variable { color: #616161; }
.hljs-operator { color: #424242; }
.hljs-punctuation { color: #424242; }
.hljs-property { color: #616161; }
.hljs-attr { color: #616161; }
.hljs-selector { color: #C62828; }
.hljs-tag { color: #616161; }
.hljs-attribute { color: #616161; }
.hljs-built_in { color: #558B2F; }
.hljs-literal { color: #616161; }
.hljs-regexp { color: #C62828; }
.hljs-title { color: #558B2F; }
.hljs-section { color: #558B2F; }
.hljs-meta { color: #757575; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }

/* Inline code */
.message code:not(pre code) {
  background-color: #D3D3D3;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  color: #616161;
  font-family: 'Consolas', 'Monaco', monospace;
  border: 1px solid #BDBDBD;
}

/* Code block language indicator */
pre::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  right: 0;
  color: #757575;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background-color: #BDBDBD;
  border-radius: 0 8px 0 8px;
  font-family: 'Consolas', 'Monaco', monospace;
}

.user {
  align-self: flex-end;
  background-color: var(--primary-color);
  color: white;
  border-radius: 12px 12px 0 12px;
}

.bot {
  align-self: flex-start;
  background-color: var(--secondary-color);
  color: var(--text-color);
  border-radius: 12px 12px 12px 0;
}

/* Message Actions */
.message-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: none;
  gap: 0.5rem;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 0.25rem;
  border-radius: 0.25rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1;
}

.user .message-actions {
  background-color: rgba(0, 0, 0, 0.1);
}

.message:hover .message-actions {
  display: flex;
}

.action-button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.user .action-button {
  color: rgba(255, 255, 255, 0.8);
}

.bot .action-button {
  color: rgba(0, 0, 0, 0.6);
}

.action-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.user .action-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.bot .action-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
  color: var(--primary-color);
}

.action-button.edit:hover {
  color: #2196F3;
}

.action-button.delete:hover {
  color: #F44336;
}

.action-button.resend:hover {
  color: #4CAF50;
}

/* Edit Form */
.edit-input {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  border: 1px solid var(--primary-color);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background-color: white;
}

.edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.edit-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.save-button,
.cancel-button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.save-button {
  background-color: var(--primary-color);
  color: white;
}

.save-button:hover {
  background-color: #1976D2;
}

.cancel-button {
  background-color: #f5f5f5;
  color: var(--text-color);
  border: 1px solid #ddd;
}

.cancel-button:hover {
  background-color: #e0e0e0;
}

.input-container {
  flex-shrink: 0;
  padding: 1rem;
  background-color: white;
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.quick-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.quick-buttons button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: white !important;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  white-space: nowrap;
  font-weight: normal;
}

.quick-buttons button:hover {
  background-color: var(--secondary-color) !important;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.message-input {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  position: relative;
  width: 100%;
}

.message-input textarea {
  flex: 1;
  padding: 1rem;
  padding-right: 140px; /* Space for both buttons */
  border: 1px solid var(--border-color);
  border-radius: 8px;
  resize: none;
  height: 60px;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
}

.message-input textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.message-input .message-actions {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
}

.message-input #resetChat {
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--warning-color);
  border: none;
  border-radius: 8px;
  color: #212529;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.message-input #resetChat:hover {
  background-color: #e0a800;
}

.message-input #resetChat i {
  font-size: 1.2rem;
}

.send-button {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 8px;
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-button:hover {
  background-color: #1976D2;
}

.send-button:disabled {
  background-color: #BDBDBD;
  cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 40vh;
    min-height: 300px;
  }
  
  .main-content {
    height: 60vh;
  }
  
  .sidebar-content {
    padding-right: 1.5rem;
  }
  
  .message {
    max-width: 90%;
  }
  
  .chat {
    height: calc(60vh - 180px); /* Adjust for mobile view */
  }
}

/* Process Time Indicator */
.process-time {
  display: block;
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.4);
  margin-top: 0.5rem;
  font-style: italic;
  text-align: right;
}

.bot .process-time {
  color: rgba(0, 0, 0, 0.4);
}

.user .process-time {
  color: rgba(255, 255, 255, 0.6);
}

/* Connection Alert */
.connection-alert {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--error-color);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 400px;
}

.connection-alert i {
  font-size: 1.25rem;
}

.connection-alert .message {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

.chat::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

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

.chat::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Mode Toggle Styles */
.mode-toggle {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.mode-toggle label {
  font-size: 0.9rem;
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--success-color);
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  padding-right: calc(1.5rem + 8px); /* Account for scrollbar width */
}

/* Loading Indicator */
.loading-indicator {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background-color: var(--secondary-color);
  border-radius: 12px;
  margin: 1rem 0;
  animation: fadeIn 0.3s ease;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.loading-indicator.show {
  display: flex;
}

.loading-indicator .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--primary-color);
  border-top: 3px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-indicator .text {
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 500;
}

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

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

.metrics-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 12px;
    background-color: var(--secondary-color);
    transition: all 0.3s ease;
}

.metrics-link:hover {
    background-color: var(--primary-color);
    color: white;
}

.metrics-link i {
    font-size: 1.1em;
} 