/*-----------------------------------------------
  AI CHAT ASSISTANT STYLES
-----------------------------------------------*/

/* Chat Container */
.ai-chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  font-family: 'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Chat Button */
.ai-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: visible;
}

.ai-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.ai-chat-button.active {
  transform: scale(0.9);
}

.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
  z-index: 1;
}

/* Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 350px;
  max-width: calc(100vw - 40px);
  height: 550px;
  max-height: calc(100vh - 120px);
  min-height: 400px;
  background: var(--info-bg, #ffffff);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  border: none;
  z-index: 10000;
}

.ai-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Expanded Mode */
.ai-chat-window.expanded {
  width: 600px;
  height: 80vh;
  max-height: 800px;
}

/* Fullscreen Mode */
.ai-chat-window.fullscreen {
  width: 90vw;
  height: 90vh;
  max-height: 90vh;
  max-width: 1400px;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.ai-chat-window.fullscreen.open {
  transform: translate(-50%, -50%);
}

/* Chat Header */
.ai-chat-header {
  background: #2d3748;
  color: #f7fafc;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: #f7fafc;
}

.brain-icon-image {
  width: 55px;
  height: 55px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: invert(1) brightness(0.9);
  margin: 0 auto;
}

.brain-icon-header-image {
  width: 40px;
  height: 40px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: invert(1) brightness(0.9);
}

.ai-chat-controls {
  display: flex;
  gap: 8px;
}

.ai-chat-control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e2e8f0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 12px;
}

.ai-chat-control-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  color: #f7fafc;
}

.ai-chat-control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
}

.ai-message {
  display: flex;
  animation: messageSlide 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-message-content {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 13.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

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

.ai-user-message .ai-message-content {
  background: #667eea;
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-assistant-message .ai-message-content {
  background: #f4f6f8;
  color: #2d3748;
  border-bottom-left-radius: 4px;
}

.ai-message-content br {
  line-height: 1.4;
}

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

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

.ai-assistant-message .ai-message-content strong {
  color: #4a5568;
  font-weight: 600;
}

.ai-assistant-message .ai-message-content code {
  background: var(--bg-color, #f5f5f7);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.ai-assistant-message .ai-message-content .ai-heading {
  margin: 20px 0 12px 0;
  font-weight: 600;
  line-height: 1.3;
  color: #667eea;
}

.ai-assistant-message .ai-message-content h1.ai-heading {
  font-size: 18px;
  margin-top: 25px;
  border-bottom: 2px solid #667eea;
  padding-bottom: 8px;
}

.ai-assistant-message .ai-message-content h2.ai-heading {
  font-size: 16px;
  margin-top: 20px;
}

.ai-assistant-message .ai-message-content h3.ai-heading {
  font-size: 14px;
  margin-top: 15px;
}

.ai-assistant-message .ai-message-content h3 {
  margin: 5px 0 10px 0;
  font-size: 14px;
  color: #667eea;
  font-weight: 600;
}

.ai-assistant-message .ai-message-content h4 {
  margin: 15px 0 5px 0;
  font-size: 13px;
  color: #4a5568;
  font-weight: 600;
}

.ai-assistant-message .ai-message-content .ai-hipaa-warning {
  background: #ffebee;
  border: 2px solid #ef5350;
  border-left: 4px solid #d32f2f;
  color: #c62828;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.ai-assistant-message .ai-message-content .ai-hipaa-warning strong {
  color: #d32f2f;
  font-weight: 700;
}

.ai-assistant-message .ai-message-content table {
  font-size: 13px;
  line-height: 1.5;
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-assistant-message .ai-message-content table th {
  font-weight: 600;
  background: #667eea;
  color: white;
  padding: 12px;
  text-align: left;
  border: 1px solid #5568d3;
}

.ai-assistant-message .ai-message-content table td {
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  background: white;
}

.ai-assistant-message .ai-message-content table tr:nth-child(even) td {
  background: #f8f9fa;
}

.ai-assistant-message .ai-message-content table tr:hover td {
  background: #f0f4ff;
}

.ai-assistant-message .ai-message-content table td,
.ai-assistant-message .ai-message-content table th {
  padding: 10px 12px !important;
}

.ai-assistant-message .ai-message-content a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
}

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

.ai-assistant-message .ai-message-content .ai-chat-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(102, 126, 234, 0.3);
  transition: all 0.2s ease;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(102, 126, 234, 0.05);
  display: inline-block;
  margin: 0 2px;
}

.ai-assistant-message .ai-message-content .ai-chat-link:hover {
  color: #5568d3;
  border-bottom-color: #5568d3;
  text-decoration: none;
  background: rgba(102, 126, 234, 0.15);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.ai-assistant-message .ai-message-content .ai-important-text {
  color: #667eea !important;
  font-weight: 600;
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin: 2px 0;
}

.ai-assistant-message .ai-message-content .ai-formatted-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-size: 13px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-assistant-message .ai-message-content .ai-formatted-table th {
  background: #667eea;
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  border: 1px solid #5568d3;
}

.ai-assistant-message .ai-message-content .ai-formatted-table td {
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  background: white;
}

.ai-assistant-message .ai-message-content .ai-formatted-table tr:nth-child(even) td {
  background: #f8f9fa;
}

.ai-assistant-message .ai-message-content .ai-formatted-table tr:hover td {
  background: #f0f4ff;
}

.ai-assistant-message .ai-message-content input[type="text"] {
  background: #fff;
  color: #2d3748;
}

body.dark .ai-assistant-message .ai-message-content input[type="text"] {
  background: #2d3748;
  color: #f7fafc;
  border-color: #4a5568;
}

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

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667eea;
  animation: typing 1.4s infinite;
}

.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: translateY(0);
    opacity: 0.7;
  }

  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Quick Questions */
.ai-chat-quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ai-quick-btn {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  color: #667eea;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-quick-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: translateY(-1px);
}

body.dark .ai-quick-btn {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.3);
  color: #a3bffa;
}

body.dark .ai-quick-btn:hover {
  background: rgba(102, 126, 234, 0.3);
}

/* Input Area */
.ai-chat-input-container {
  display: flex;
  padding: 16px 20px;
  gap: 10px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  /* Slightly reduced radius */
  padding: 10px 16px;
  /* Reduced padding to ensure single line fit */
  font-size: 16px;
  /* 16px minimum to prevent iOS zoom on focus */
  line-height: 20px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  height: 42px;
  /* Explicit single line height (20 text + 20 pad + 2 border) */
  min-height: 42px;
  background: #f8fafc;
  color: #2d3748;
  transition: all 0.2s ease;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  overflow-y: hidden;
}

.ai-chat-input:focus {
  outline: none;
  border-color: #667eea;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-chat-input::placeholder {
  color: #a0aec0;
}

.ai-chat-voice-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  color: #667eea;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 16px;
}

.ai-chat-voice-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: scale(1.05);
}

.ai-chat-voice-btn:active {
  transform: scale(0.95);
}

.ai-chat-voice-btn.listening {
  background: #ef5350;
  border-color: #ef5350;
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.7);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(239, 83, 80, 0);
  }
}


/* Human Verification */
.ai-chat-human-verify {
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 13px;
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-human-verify.hidden {
  display: none;
}

.ai-chat-human-verify label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.ai-chat-human-verify input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #cbd5e0;
  cursor: pointer;
}

body.dark .ai-chat-human-verify {
  background: #1a202c;
  color: #a0aec0;
  border-top-color: rgba(255, 255, 255, 0.05);
}

body.dark .ai-chat-human-verify input[type="checkbox"] {
  background: #2d3748;
  border-color: #4a5568;
}

.ai-chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #667eea;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: none;
}

.ai-chat-send-btn:hover {
  background: #5a67d8;
  transform: scale(1.05);
}

.ai-chat-send-btn:active {
  transform: scale(0.95);
}

/* Footer */
.ai-chat-footer {
  padding: 12px 16px;
  text-align: center;
  background: #2d3748;
  color: #cbd5e0;
  font-size: 10px;
  letter-spacing: 0.5px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-chat-footer .ai-hipaa-warning {
  background: #ffebee;
  border: 2px solid #ef5350;
  border-left: 4px solid #d32f2f;
  color: #c62828;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}

.ai-chat-footer .ai-hipaa-warning strong {
  color: #d32f2f;
  font-weight: 700;
}

/* Dark Mode Support */
body.dark .ai-chat-window {
  background: #1a202c;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

body.dark .ai-chat-header {
  background: #1a202c;
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark .ai-chat-title {
  color: #667eea;
}

body.dark .ai-chat-close-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.dark .ai-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

body.dark .ai-chat-messages {
  background: #1a202c;
}

body.dark .ai-assistant-message .ai-message-content {
  background: #2d3748;
  color: #e2e8f0;
  border: none;
}

body.dark .ai-assistant-message .ai-message-content strong {
  color: #f7fafc;
}

/* Dark mode table overrides - must override inline styles */
body.dark .ai-assistant-message .ai-message-content table {
  background: #2d3748 !important;
  color: #e2e8f0 !important;
}

body.dark .ai-assistant-message .ai-message-content table th {
  background: #667eea !important;
  color: white !important;
  border: 1px solid #5568d3 !important;
}

body.dark .ai-assistant-message .ai-message-content table td {
  background: #2d3748 !important;
  color: #e2e8f0 !important;
  border: 1px solid #4a5568 !important;
}

body.dark .ai-assistant-message .ai-message-content table tr:nth-child(even) td {
  background: #374151 !important;
}

body.dark .ai-assistant-message .ai-message-content table tr:hover td {
  background: #4a5568 !important;
}

body.dark .ai-assistant-message .ai-message-content table thead tr {
  background: #667eea !important;
}

body.dark .ai-assistant-message .ai-message-content table thead tr th {
  background: #667eea !important;
  color: white !important;
  border: 1px solid #5568d3 !important;
}

/* Dark mode for headings and text in table messages */
body.dark .ai-assistant-message .ai-message-content h3,
body.dark .ai-assistant-message .ai-message-content h4 {
  color: #f7fafc !important;
}

body.dark .ai-assistant-message .ai-message-content p {
  color: #e2e8f0 !important;
}

body.dark .ai-assistant-message .ai-message-content a,
body.dark .ai-assistant-message .ai-message-content .ai-chat-link {
  color: #8b9aff !important;
}

body.dark .ai-assistant-message .ai-message-content .ai-chat-link:hover {
  color: #a0b0ff !important;
  border-bottom-color: #a0b0ff !important;
}

body.dark .ai-chat-input-container {
  background: #1a202c;
  border-top-color: rgba(255, 255, 255, 0.05);
}

body.dark .ai-chat-input {
  background: #2d3748;
  border-color: #4a5568;
  color: #f7fafc;
}

body.dark .ai-chat-input:focus {
  background: #2d3748;
  border-color: #667eea;
}

body.dark .ai-chat-footer {
  background: #1a202c;
  color: #4a5568;
  border-top-color: rgba(255, 255, 255, 0.05);
}

body.dark .ai-chat-voice-btn {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.3);
  color: #a3bffa;
}

body.dark .ai-chat-voice-btn:hover {
  background: rgba(102, 126, 234, 0.3);
}

body.dark .ai-chat-voice-btn.listening {
  background: #ef5350;
  border-color: #ef5350;
  color: white;
}

body.dark .ai-chat-footer .ai-hipaa-warning {
  background: rgba(211, 47, 47, 0.15);
  border-color: #ef5350;
  color: #ffcdd2;
}

body.dark .ai-chat-footer .ai-hipaa-warning strong {
  color: #ffcdd2;
}

/* Hide mobile buttons on desktop */
.ai-chat-mobile-control-btn {
  display: none !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .ai-chat-container {
    bottom: 15px;
    right: 15px;
    z-index: 10001;
  }

  .ai-chat-button {
    width: 56px;
    height: 56px;
    font-size: 22px;
    z-index: 10002;
    position: relative;
  }

  /* Hide chat button when chat is open on mobile */
  .ai-chat-button.active {
    display: none !important;
  }

  /* Make badge smaller on mobile */
  .chat-badge {
    font-size: 7px !important;
    padding: 1px 4px !important;
    top: -3px !important;
    right: -3px !important;
    border-radius: 6px !important;
    min-width: 16px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  .ai-chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
  }

  .ai-chat-window.open {
    bottom: 0;
    display: flex;
  }

  /* Mobile Control Buttons - Always visible at top right */
  .ai-chat-mobile-control-btn {
    position: fixed !important;
    top: 12px !important;
    z-index: 99999 !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 50% !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    color: #666 !important;
    font-size: 18px !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: all 0.2s ease !important;
  }

  .ai-chat-window.open .ai-chat-mobile-control-btn {
    display: flex !important;
  }

  /* Reset button on the left */
  .ai-chat-window.open #ai-chat-mobile-reset {
    right: 60px !important;
  }

  /* Close button on the right */
  .ai-chat-window.open #ai-chat-mobile-close {
    right: 12px !important;
  }

  .ai-chat-mobile-control-btn i {
    color: #666 !important;
    font-size: 18px !important;
    display: block !important;
  }

  .ai-chat-mobile-control-btn:active {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(0.95) !important;
  }

  body.dark .ai-chat-mobile-control-btn {
    background: rgba(45, 55, 72, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #e2e8f0 !important;
  }

  body.dark .ai-chat-mobile-control-btn i {
    color: #e2e8f0 !important;
  }

  body.dark .ai-chat-mobile-control-btn:active {
    background: rgba(45, 55, 72, 1) !important;
  }

  /* Fixed close button on top right for mobile - make it very visible */
  .ai-chat-window.open #ai-chat-close {
    position: fixed !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 99999 !important;
    width: 48px !important;
    height: 48px !important;
    background: #ff4757 !important;
    border: 3px solid #ffffff !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    color: #ffffff !important;
    font-size: 20px !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .ai-chat-window.open #ai-chat-close i {
    color: #ffffff !important;
    font-size: 20px !important;
    display: block !important;
  }

  body.dark .ai-chat-window.open #ai-chat-close {
    background: #ff4757 !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
  }

  .ai-chat-window.open #ai-chat-close:hover,
  .ai-chat-window.open #ai-chat-close:active {
    background: #ff3838 !important;
    transform: scale(1.1) !important;
  }

  /* Ensure messages area is scrollable and accounts for fixed header */
  .ai-chat-window.open .ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding: 10px 12px !important;
    padding-top: 70px !important;
    padding-bottom: 10px !important;
  }

  /* Mobile medication search improvements */
  .ai-chat-messages input[type="text"] {
    font-size: 16px !important;
    padding: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .ai-chat-messages .med-autocomplete-suggestions {
    width: 100% !important;
    margin-top: 8px !important;
  }

  /* Mobile message content improvements */
  .ai-chat-messages .ai-message-content {
    max-width: 100% !important;
    padding: 12px !important;
    font-size: 14px !important;
  }

  .ai-chat-messages .ai-message-content h3 {
    font-size: 16px !important;
    margin-bottom: 8px !important;
  }

  .ai-chat-messages .ai-message-content table {
    font-size: 11px !important;
    width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
  }

  /* Ensure input container stays at bottom */
  .ai-chat-window.open .ai-chat-input-container {
    flex-shrink: 0;
    position: relative;
    z-index: 10001;
    background: #ffffff !important;
  }

  body.dark .ai-chat-window.open .ai-chat-input-container {
    background: #1a202c !important;
  }

  /* Prevent zoom on input focus - ensure 16px font-size */
  .ai-chat-input {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Voice button on mobile */
  .ai-chat-voice-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 14px !important;
  }

  /* Ensure footer stays at bottom */
  .ai-chat-footer {
    flex-shrink: 0;
  }

  /* Hide size controls on mobile - always fullscreen */
  #ai-chat-increase,
  #ai-chat-decrease {
    display: none !important;
  }

  /* Ensure close button is always visible and not hidden by parent */
  .ai-chat-window.open .ai-chat-controls {
    display: flex !important;
  }

  .ai-chat-window.open .ai-chat-controls #ai-chat-close {
    position: fixed !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 99999 !important;
    width: 48px !important;
    height: 48px !important;
    background: #ff4757 !important;
    border: 3px solid #ffffff !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    color: #ffffff !important;
    font-size: 20px !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Ensure fullscreen class works on mobile - override desktop styles */
  .ai-chat-window.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    transform: none !important;
    margin: 0 !important;
  }

  .ai-chat-window.fullscreen.open {
    transform: none !important;
  }
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}