/* Floating chat button */
.chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #007bff, #0056b3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 123, 255, 0.3);
  transition: all 0.3s ease;
  z-index: 1000;
  color: white;
  font-size: 24px;
}

.chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(0, 123, 255, 0.4);
}

.chat-button.open {
  background: #dc3545;
  font-size: 18px;
}

/* Chat window */
.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 400px;
  height: 600px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 999;
  animation: slideUp 0.3s ease;
}

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

/* Chat header */
.chat-header {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  padding: 20px;
  border-radius: 15px 15px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.chat-icon {
  font-size: 20px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: #28a745;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* Messages container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.message {
  margin-bottom: 15px;
  display: flex;
  align-items: flex-end;
}

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

.message.bot {
  justify-content: flex-start;
}

.message-content {
  max-width: 80%;
}

.message-text {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.4;
  word-wrap: break-word;
  font-size: 14px;
}

.message.user .message-text {
  background: #007bff;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.bot .message-text {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  border: 1px solid #e9ecef;
}

.message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

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

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Input container */
.chat-input-container {
  border-top: 1px solid #e9ecef;
  background: white;
  border-radius: 0 0 15px 15px;
}

.quick-suggestions {
  padding: 15px 15px 0 15px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-btn {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 15px;
  padding: 6px 12px;
  font-size: 12px;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.chat-input {
  display: flex;
  align-items: flex-end;
  padding: 15px;
  gap: 10px;
}

.chat-input textarea {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  padding: 10px 15px;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  background: #f8f9fa;
  transition: all 0.2s ease;
}

.chat-input textarea:focus {
  border-color: #007bff;
  background: white;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.send-button {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: #0056b3;
  transform: scale(1.05);
}

.send-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
}

.send-button span {
  font-size: 16px;
  margin-left: 2px;
}

.chat-footer {
  padding: 8px 15px;
  text-align: center;
  color: #6c757d;
  border-top: 1px solid #f1f3f4;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* Mobile responsiveness */
@media (max-width: 768px) {
  .chat-window {
    width: calc(100vw - 20px);
    height: 70vh;
    bottom: 80px;
    right: 10px;
    left: 10px;
  }
  
  .chat-button {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .quick-suggestions {
    display: none; /* Hide on mobile to save space */
  }
}

/* Enhanced Message Formatting Styles */

/* Code blocks and inline code */
.code-block {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin: 8px 0;
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  padding: 12px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #333;
}

.inline-code {
  background: #f1f3f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  color: #d73a49;
  border: 1px solid #e1e4e8;
}

/* Medical Record Headers */
.record-header {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  border: 1px solid #2196f3;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0 8px 0;
  font-weight: 600;
  color: #1565c0;
  font-size: 15px;
}

/* Medication Items */
.medication-item {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  padding: 10px 12px;
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
}

.medication-number {
  font-weight: 600;
  color: #f57c00;
}

.medication-name {
  font-weight: 600;
  color: #e65100;
  margin-left: 8px;
}

.medication-detail {
  margin-left: 20px;
  padding: 4px 0;
  border-bottom: 1px solid #ffe0b2;
}

.medication-detail:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #bf360c;
  min-width: 80px;
  display: inline-block;
}

.detail-value {
  color: #5d4037;
}

/* Field Items (General key-value pairs) */
.field-item {
  padding: 6px 0;
  margin: 4px 0;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  flex-wrap: wrap;
}

.field-label {
  font-weight: 600;
  color: #424242;
  min-width: 120px;
  margin-right: 8px;
}

.field-value {
  color: #616161;
  flex: 1;
}

/* Numbered Lists */
.numbered-item {
  display: flex;
  align-items: flex-start;
  margin: 8px 0;
  padding: 8px 0;
}

.number-badge {
  background: #2196f3;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.item-content {
  flex: 1;
  padding-top: 2px;
  line-height: 1.5;
}

/* Bullet Points */
.bullet-item {
  display: flex;
  align-items: flex-start;
  margin: 6px 0;
  padding: 4px 0;
}

.bullet {
  color: #2196f3;
  font-weight: bold;
  margin-right: 12px;
  margin-top: 2px;
  flex-shrink: 0;
}

.bullet-content {
  flex: 1;
  line-height: 1.5;
}

/* Section Headers */
.section-header {
  background: linear-gradient(135deg, #f3e5f5, #e1bee7);
  border: 1px solid #9c27b0;
  border-radius: 6px;
  padding: 10px 16px;
  margin: 16px 0 12px 0;
  font-weight: 600;
  color: #6a1b9a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 13px;
}

/* Service Items */
.service-item {
  background: #f0f7ff;
  border-left: 4px solid #2196f3;
  padding: 12px;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
}

.service-number {
  background: #2196f3;
  color: white;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 10px;
}

.service-title {
  font-weight: 600;
  color: #1565c0;
  margin-right: 8px;
}

.service-description {
  color: #424242;
  display: block;
  margin-top: 6px;
  line-height: 1.4;
}

/* Q&A Formatting */
.question {
  background: #e8f5e8;
  border-left: 4px solid #4caf50;
  padding: 10px 12px;
  margin: 8px 0 4px 0;
  border-radius: 0 6px 6px 0;
}

.q-label {
  font-weight: 700;
  color: #2e7d32;
  margin-right: 8px;
}

.answer {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  padding: 10px 12px;
  margin: 4px 0 8px 0;
  border-radius: 0 6px 6px 0;
}

.a-label {
  font-weight: 700;
  color: #f57c00;
  margin-right: 8px;
}

/* Error Messages */
.error-message {
  background: #ffebee;
  border: 1px solid #f44336;
  border-radius: 6px;
  padding: 12px;
  margin: 10px 0;
  color: #c62828;
}

.error-label {
  font-weight: 600;
  color: #d32f2f;
  display: block;
  margin-bottom: 6px;
}

.error-code {
  background: #fff;
  border: 1px solid #ffcdd2;
  border-radius: 4px;
  padding: 8px;
  font-family: monospace;
  font-size: 13px;
  color: #b71c1c;
  display: block;
  margin-top: 6px;
  word-break: break-all;
}

/* Query Display */
.query-display {
  background: #f3e5f5;
  border: 1px solid #9c27b0;
  border-radius: 6px;
  padding: 12px;
  margin: 10px 0;
}

.query-label {
  font-weight: 600;
  color: #6a1b9a;
  display: block;
  margin-bottom: 6px;
}

.sql-query {
  background: #fff;
  border: 1px solid #ce93d8;
  border-radius: 4px;
  padding: 8px;
  font-family: monospace;
  font-size: 13px;
  color: #4a148c;
  display: block;
  margin-top: 6px;
  word-break: break-all;
  overflow-x: auto;
}

/* Status Messages */
.success-message {
  background: #e8f5e8;
  border: 1px solid #4caf50;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  color: #2e7d32;
  font-weight: 500;
}

.warning-message {
  background: #fff8e1;
  border: 1px solid #ff9800;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  color: #f57c00;
  font-weight: 500;
}

.info-message {
  background: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  color: #1565c0;
  font-weight: 500;
}

/* Results Header */
.results-header {
  background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
  border: 2px solid #4caf50;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0 12px 0;
  font-weight: 600;
  color: #2e7d32;
  font-size: 16px;
  text-align: center;
}

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

/* Typography improvements for bot messages */
.message.bot .message-text {
  line-height: 1.6;
  font-size: 14px;
}

.message.bot .message-text strong {
  color: #1565c0;
  font-weight: 600;
}

.message.bot .message-text em {
  color: #5d4037;
  font-style: italic;
}

.message.bot .message-text u {
  text-decoration: underline;
  color: #7b1fa2;
}

.message.bot .message-text del {
  text-decoration: line-through;
  color: #757575;
} 