/* Modern Chat Interface Styles for BirbalBot */

/* Chat Container */
.chat-container {
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #004e89 0%, #ff6b35 100%);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="80" r="1" fill="rgba(255,255,255,0.1)"/></svg>');
  opacity: 0.3;
}

.chat-header-content {
  position: relative;
  z-index: 1;
}

.book-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.book-cover-small {
  width: 3rem;
  height: 3.75rem;
  border-radius: 0.5rem;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.book-details h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.book-details p {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0.25rem 0 0 0;
}

/* Quick Actions */
.quick-actions {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-left: 1.5rem;
  padding-bottom: 1rem;
  order: 3;
}

.quick-actions-grid {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-top: 0.25rem;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-action-btn:hover {
  background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.3);
  border-color: #ff6b35;
}

.quick-action-btn svg {
  width: 1rem;
  height: 1rem;
  transition: transform 0.3s ease;
}

.quick-action-btn:hover svg {
  transform: scale(1.1);
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Message Bubbles */
.message {
  display: flex;
  gap: 0.75rem;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  touch-action: pan-y;
  transition: transform 0.2s ease;
}

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

/* Enhanced swipe interactions for mobile */
.message.swipe-left {
  transform: translateX(-20px);
}

.message.swipe-right {
  transform: translateX(20px);
}

/* Message status indicators */
.message-status {
  position: absolute;
  bottom: 0.25rem;
  right: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.message.user .message-status {
  color: rgba(255, 255, 255, 0.8);
}

.message.bot .message-status {
  color: #6b7280;
}

.status-icon {
  width: 0.875rem;
  height: 0.875rem;
  animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
  0%, 100% { 
    opacity: 0.7; 
  }
  50% { 
    opacity: 1; 
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  display: none;
}

.message-content {
  flex: 1;
  width: auto;
  float: left;
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: 1.25rem;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  user-select: text;
}

.message-bubble:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.message-bubble:active {
  transform: scale(0.98);
}

/* Enhanced message reactions */
.message-reactions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.reaction-button {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 1rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.reaction-button:hover {
  background: rgba(255, 107, 53, 0.1);
  border-color: rgba(255, 107, 53, 0.3);
  transform: scale(1.05);
}

.reaction-button.active {
  background: rgba(255, 107, 53, 0.2);
  border-color: rgba(255, 107, 53, 0.5);
  color: #ff6b35;
}

.reaction-emoji {
  font-size: 0.875rem;
}

.reaction-count {
  font-weight: 500;
  min-width: 1rem;
  text-align: center;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
  color: white;
  border-bottom-right-radius: 0.5rem;
  margin-left: 0;
  float: right;
}

.message.bot .message-bubble {
  background: rgba(255, 255, 255, 0.95);
  color: #1f2937;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom-left-radius: 0.5rem;
  margin-right: 0;
  float:left
}

.message-text {
  line-height: 1.6;
  margin: 0;
}

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

.message-text h1 { font-size: 1.5rem; }
.message-text h2 { font-size: 1.25rem; }
.message-text h3 { font-size: 1.125rem; }
.message-text h4 { font-size: 1rem; }

.message-text p {
  margin: 0 0 0.75rem 0;
}

.message-text p:last-child {
  margin-bottom: 0;
}

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

.message-text li {
  margin: 0.25rem 0;
}

.message-text blockquote {
  border-left: 4px solid rgba(0, 0, 0, 0.1);
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  opacity: 0.8;
}

.message.user .message-text blockquote {
  border-left-color: rgba(255, 255, 255, 0.3);
}

/* Enhanced code blocks */
.message-text pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-size: 0.875rem;
  color: #1f2937;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.message.user .message-text pre {
  background: rgba(255, 255, 255, 0.2);
  color: #1f2937;
  border-color: rgba(255, 255, 255, 0.3);
}

.message-text code {
  color: #1f2937;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.message.user .message-text code {
  background: rgba(255, 255, 255, 0.2);
}

/* Enhanced KaTeX mathematical expressions */
.message-text .katex {
  font-size: 1.1em;
  color: inherit;
  line-height: 1.4;
}

.message-text .katex-display {
  margin: 1.5rem 0;
  text-align: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.message.user .message-text .katex-display {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.message-text .katex-html {
  overflow-x: auto;
  overflow-y: hidden;
}

/* Math error handling */
.message-text .katex-error {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
}

/* Chemical formulas and scientific notation */
.message-text .chem-formula {
  font-family: 'Times New Roman', serif;
  font-weight: 500;
}

.message-text .physics-vector {
  font-weight: bold;
  text-decoration: overline;
}

.message-text .unit {
  font-style: italic;
  margin-left: 0.2em;
  color: #6b7280;
}

/* Tables */
.message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.875rem;
}

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

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

.message.user .message-text th,
.message.user .message-text td {
  border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-text th {
  background: rgba(255, 255, 255, 0.2);
}

/* Links */
.message-text a {
  color: #3b82f6;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.message-text a:hover {
  color: #1d4ed8;
}

.message.user .message-text a {
  color: #93c5fd;
}

.message.user .message-text a:hover {
  color: #dbeafe;
}

/* Horizontal rules */
.message-text hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 1rem 0;
}

.message.user .message-text hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

/* Images in messages */
.message-text img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

/* Message Actions - now below message text */
.message-actions {
  gap: 0.5rem;
  margin-top: 0.75rem;
  transition: opacity 0.3s ease;
  justify-content: flex-start; /* Align with message bubble */
}

.message.user .message-actions {
  justify-content: flex-end; /* Align with user message bubble */
}



.message-action {
  padding: 0.375rem;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 0.375rem;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.75rem;
}

.message-action:hover {
  background: #ff6b35;
  color: white;
  transform: scale(1.05);
}

.message.user .message-action {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
}

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

/* Message Timestamp - now below actions */
.message-time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.5rem;
  text-align: left; /* Default alignment */
}

.message.user .message-time {
  text-align: right; /* Right align for user messages */
  color: rgba(255, 255, 255, 0.7);
}

/* Enhanced Chat Input Area */
.chat-input-area {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 1.25rem;
  padding-bottom: 0;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
  position: relative;
  order: 2;
}

.chat-input-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 107, 53, 0.3), transparent);
}

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

.chat-input-wrapper {
  flex: 1;
  position: relative;
  background: white;
  overflow: hidden;
}


.chat-input {
  width: 100%;
  min-height: 3.5rem;
  max-height: 10rem;
  padding: 1rem 4rem 1rem 1.25rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2937;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  border-radius: 0.5rem;
  transition: border-color 0.2s ease;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-input::-webkit-scrollbar {
  display: none;
}

.chat-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

.chat-input:focus {
  border-color: #ff6b35;
  box-shadow: 0 0 0 1px #ff6b35;
}

/* Fixed Input Actions Positioning */
.input-actions {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 0.375rem;
  align-items: center;
  z-index: 10;
}

/* Adjust positioning when textarea expands */
.chat-input-wrapper.expanded .input-actions {
  top: auto;
  bottom: 0.75rem;
  transform: none;
}

.input-action {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.8);
}

.chat-input-wrapper.has-text .input-action {
  opacity: 1;
  transform: scale(1);
}

.input-action:hover {
  background: #ff6b35;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.input-action svg {
  width: 0.875rem;
  height: 0.875rem;
  transition: transform 0.3s ease;
}

.input-action:hover svg {
  transform: rotate(90deg);
}

/* Enhanced Send Button */
.send-button {
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b35 0%, #e55a2b 100%);
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.send-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #e55a2b 0%, #cc4a1f 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.send-button:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 12px 35px rgba(255, 107, 53, 0.5);
}

.send-button:hover:not(:disabled)::before {
  opacity: 1;
}

.send-button:active:not(:disabled) {
  transform: translateY(-1px) scale(1.05);
}

.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

.send-button svg {
  width: 1.375rem;
  height: 1.375rem;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.send-button:hover:not(:disabled) svg {
  transform: translateX(2px) scale(1.1);
}

/* Character Counter Enhancement */
.char-counter {
  position: absolute;
  bottom: -1.25rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: #9ca3af;
  transition: color 0.3s ease;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-5px);
}

.chat-input-wrapper:focus-within .char-counter,
.chat-input-wrapper.has-text .char-counter {
  opacity: 1;
  transform: translateY(0);
}

.char-counter.warning {
  color: #f59e0b;
}

.char-counter.danger {
  color: #ef4444;
}

/* Input Focus Ring Enhancement */
.chat-input-wrapper.focus-ring {
  animation: focusRing 0.6s ease-out;
}

@keyframes focusRing {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 107, 53, 0.1);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
  }
}

/* Typing Indicator Enhancement */
.typing-indicator-input {
  position: absolute;
  bottom: 100%;
  left: 1.25rem;
  background: rgba(255, 107, 53, 0.1);
  color: #ff6b35;
  padding: 0.5rem 1rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.typing-indicator-input.show {
  opacity: 1;
  transform: translateY(-0.5rem);
}

/* Loading States */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 1.25rem;
  border-bottom-left-radius: 0.5rem;
  margin-right: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: auto;
  float: left;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
  80% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
}

.welcome-message h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.welcome-message p {
  margin-bottom: 1.5rem;
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.suggestion-chip {
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  color: #374151;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.suggestion-chip:hover {
  background: #ff6b35;
  color: white;
  border-color: #ff6b35;
  transform: translateY(-1px);
}

/* Error States */
.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 1rem;
  border-radius: 0.75rem;
  margin: 1rem 0;
  text-align: center;
}

.retry-button {
  background: #dc2626;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.3s ease;
}

.retry-button:hover {
  background: #b91c1c;
}

/* Enhanced Input Actions Positioning */
.chat-input-wrapper {
  position: relative;
  min-height: 3.5rem;
}

.chat-input-wrapper:not(.expanded) .input-actions {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}

.chat-input-wrapper.expanded .input-actions {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  top: auto;
  transform: none;
}

/* Enhanced Mobile Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 3rem);
    position: relative;
  }
  
  .chat-header {
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .book-info {
    gap: 0.75rem;
  }
  
  .book-cover-small {
    width: 2.5rem;
    height: 3.125rem;
  }
  
  .book-details h1 {
    font-size: 1rem;
    line-height: 1.25;
  }
  
  .book-details p {
    font-size: 0.75rem;
  }
  
  .quick-actions {
    padding: 0.75rem 1rem;
    order: 3;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
  }
  
  .quick-actions-grid {
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .quick-actions-grid::-webkit-scrollbar {
    display: none;
  }
  
  .quick-action-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 2.5rem;
  }
  
  .chat-messages {
    padding: 1rem;
    gap: 1rem;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .message-bubble {
    padding: 0.75rem 1rem;
    word-break: break-word;
    font-size: 0.875rem;
    line-height: 1.5;
  }
  
  .message.user .message-bubble {
    margin-left: 0;
  }
  
  .message.bot .message-bubble {
    margin-right: 0;
  }
  
  /* Enhanced mobile input area */
  .chat-input-area {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
  }
  
  .chat-input-area.mobile-keyboard-open {
    padding-bottom: env(keyboard-inset-height, 1rem);
  }
  
  .chat-input-wrapper.mobile-focused {
    transform: translateY(-2px);
  }
  
  .chat-input-container {
    gap: 0.75rem;
  }
  
  .chat-input {
    min-height: 2.75rem;
    max-height: 8rem;
    padding: 0.75rem 3rem 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.5rem;
  }
  
  /* Enhanced touch targets */
  .input-actions {
    right: 0.5rem;
    touch-action: manipulation;
  }
  
  .chat-input-wrapper:not(.expanded) .input-actions {
    top: 50%;
    transform: translateY(-50%);
  }
  
  .chat-input-wrapper.expanded .input-actions {
    bottom: 0.5rem;
    transform: none;
  }
  
  .input-action {
    width: 2.25rem;
    height: 2.25rem;
    touch-action: manipulation;
  }
  
  .input-action svg {
    width: 1rem;
    height: 1rem;
  }
  
  .char-counter {
    right: 0.5rem;
    bottom: -1rem;
    font-size: 0.7rem;
  }
  
  .send-button {
    width: 2.75rem;
    height: 2.75rem;
    touch-action: manipulation;
  }
  
  .send-button svg {
    width: 1.375rem;
    height: 1.375rem;
  }
  
  /* Enhanced message interactions */
  .message-actions {
    margin-top: 0.5rem;
    gap: 0.375rem;
  }
  
  .message-action {
    padding: 0.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    touch-action: manipulation;
    font-size: 0.75rem;
  }
  
  .message-time {
    margin-top: 0.375rem;
    font-size: 0.6875rem;
  }
  
  .welcome-suggestions {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  
  .suggestion-chip {
    width: 100%;
    max-width: 16rem;
    text-align: center;
    padding: 0.75rem 1rem;
    touch-action: manipulation;
  }
  
  /* Swipe gesture indicators */
  .swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 107, 53, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
  }
  
  .swipe-hint.left {
    right: 1rem;
  }
  
  .swipe-hint.right {
    left: 1rem;
  }
  
  .swipe-hint.show {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 0.625rem 0.875rem;
  }
  
  .book-details h1 {
    font-size: 0.875rem;
  }
  
  .book-details p {
    font-size: 0.6875rem;
  }
  
  .quick-action-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.6875rem;
    min-height: 2.25rem;
  }
  
  .message-avatar {
    display: none;
  }
  
  .message-bubble {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }
  
  .chat-input-area {
    padding: 0.875rem;
  }
  
  .chat-input {
    min-height: 2.5rem;
    padding: 0.625rem 2.75rem 0.625rem 0.875rem;
    font-size: 1rem;
    border-radius: 0.5rem;
  }
  
  .input-actions {
    right: 0.5rem;
    bottom: 0.5rem;
  }
  
  .input-action {
    width: 1.875rem;
    height: 1.875rem;
  }
  
  .send-button {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Responsive adjustments for math and content */
@media (max-width: 768px) {
  .message-text .katex {
    font-size: 1em;
  }
  
  .message-text .katex-display {
    padding: 0.75rem;
    margin: 1rem 0;
    font-size: 0.9em;
  }
  
  .message-text pre {
    padding: 0.75rem;
    font-size: 0.8125rem;
  }
  
  .message-text table {
    font-size: 0.8125rem;
  }
  
  .message-text th,
  .message-text td {
    padding: 0.375rem;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .message-bubble {
    border: 2px solid;
  }
  
  .chat-input {
    border: 2px solid;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .message,
  .typing-dot,
  .send-button,
  .quick-action-btn {
    animation: none;
    transition: none;
  }
}

/* Enhanced Animation States */
.chat-input-wrapper.sending {
  animation: sendingPulse 1s ease-in-out infinite;
}

@keyframes sendingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 107, 53, 0.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4);
  }
}

/* Input State Indicators */
.chat-input-wrapper.has-text {
  border-color: #e2e8f0;
}

.chat-input-wrapper.has-text .input-actions {
  opacity: 1;
}

.chat-input-wrapper:not(.has-text) .input-actions {
  opacity: 0.6;
}

/* Max Height Indicator */
.chat-input-wrapper.max-height-reached {
  border-color: #fbbf24;
}

.chat-input-wrapper.max-height-reached::after {
  content: 'Max height reached - scroll to see more';
  position: absolute;
  bottom: -1.75rem;
  left: 1rem;
  font-size: 0.75rem;
  color: #f59e0b;
  font-weight: 500;
}

/* Character Counter Positioning */
.char-counter {
  position: absolute;
  bottom: -1.5rem;
  right: 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
  transition: color 0.3s ease;
  font-weight: 500;
}

/* Enhanced Focus States */
.chat-input-wrapper:focus-within .char-counter {
  color: #6b7280;
}

/* Loading State for Input Area */
.chat-input-area.loading {
  opacity: 0.8;
  pointer-events: none;
}

.chat-input-area.loading .chat-input-wrapper {
  animation: loadingShimmer 1.5s ease-in-out infinite;
}

@keyframes loadingShimmer {
  0% {
    background-color: rgba(255, 255, 255, 0.95);
  }
  50% {
    background-color: rgba(255, 255, 255, 1);
  }
  100% {
    background-color: rgba(255, 255, 255, 0.95);
  }
}

/* Smooth Transitions for All States */
.chat-input-wrapper * {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced Hover Effects */
.chat-input-area:hover .send-button:not(:disabled) {
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.45);
}

.chat-input-area:hover .input-action {
  background: #f1f5f9;
}

/* Focus Trap for Accessibility */
.chat-input-area:focus-within {
  background: rgba(255, 255, 255, 1);
}

/* Accessibility Enhancements */
.chat-input:focus {
  box-shadow: none; /* Remove default focus since wrapper handles it */
  background: rgba(255, 107, 53, 0.02);
}

/* Prevent text selection on buttons */
.input-action,
.send-button {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .chat-input-wrapper,
  .send-button,
  .input-action {
    transition: none;
    animation: none;
  }
  
  .send-button:hover:not(:disabled) {
    transform: none;
  }
  
  .input-action:hover {
    transform: none;
  }
}

/* Print styles */
@media print {
  .chat-header,
  .quick-actions,
  .chat-input-area {
    display: none;
  }
  
  .chat-messages {
    height: auto;
    overflow: visible;
  }
  
  .message-bubble {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
