/* iOS WebKit & Mobile Kinetic Smooth Scrolling Optimization */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: auto; /* Preserve native iOS momentum physics on touch */
}

@media (hover: hover) and (pointer: fine) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Enable hardware-accelerated momentum scrolling on all scrollable containers */
.overflow-y-auto,
.overflow-x-auto,
#chatMessages,
#sidebar,
#chatHistoryList {
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: scroll-position;
}

/* Mobile GPU performance acceleration for glass panels and ambient glows */
.glass-panel,
.glass-card,
.glow-purple,
.glow-cyan {
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Custom Scrollbars */
.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
  background: rgba(17, 24, 39, 0.4);
}
.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(75, 85, 99, 0.5);
  border-radius: 9999px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.8);
}

/* Animations */
@keyframes bounceShort {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.animate-bounce-short {
  animation: bounceShort 2.5s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}
.animate-pulse-glow {
  animation: pulseGlow 1.8s infinite ease-in-out;
}

/* Message Markdown Rendering Styles */
.markdown-body {
  font-size: 0.925rem;
  line-height: 1.65;
  color: #e5e7eb;
}

.markdown-body p {
  margin-bottom: 0.75rem;
}
.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-weight: 700;
  color: #ffffff;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}
.markdown-body h1 { font-size: 1.35rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }

.markdown-body ul, 
.markdown-body ol {
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
}
.markdown-body ul { list-style-type: disc; }
.markdown-body ol { list-style-type: decimal; }
.markdown-body li { margin-bottom: 0.25rem; }

.markdown-body code:not(pre code) {
  background-color: rgba(31, 41, 55, 0.8);
  color: #a5b4fc;
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.markdown-body pre {
  margin: 0.75rem 0;
  border-radius: 0.75rem;
  background-color: #0b0f19 !important;
  border: 1px solid #1f2937;
  overflow: hidden;
  position: relative;
}

.markdown-body pre code {
  display: block;
  padding: 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #111827;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid #1f2937;
  font-size: 0.75rem;
  color: #9ca3af;
  font-family: ui-monospace, monospace;
}

.copy-code-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  transition: all 0.2s;
}
.copy-code-btn:hover {
  background-color: #1f2937;
  color: #ffffff;
}

.markdown-body blockquote {
  border-left: 3px solid #6366f1;
  padding-left: 0.75rem;
  margin: 0.75rem 0;
  color: #9ca3af;
  font-style: italic;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid #374151;
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.markdown-body th {
  background-color: #1f2937;
  color: #f3f4f6;
}

/* Typing cursor animation */
.typing-cursor::after {
  content: '▋';
  display: inline-block;
  color: #6366f1;
  margin-left: 2px;
  animation: blink 0.9s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
