/* Mobile-First Study Mode Pro Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Mobile-optimized scrollbars */
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
  -webkit-overflow-scrolling: touch;
}

.overflow-y-auto::-webkit-scrollbar {
  width: 4px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: transparent;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background-color: #cbd5e0;
  border-radius: 2px;
}

/* Bottom sheet animation */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

/* Enhanced markdown styling for mobile */
.prose {
  line-height: 1.6;
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.prose h1 { font-size: 1.5em; }
.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.1em; }
.prose h4, .prose h5, .prose h6 { font-size: 1em; }

.prose p {
  margin-bottom: 1em;
}

.prose strong {
  font-weight: 600;
  color: #1e40af;
}

.dark .prose strong {
  color: #60a5fa;
}

.prose em {
  font-style: italic;
  color: #059669;
}

.dark .prose em {
  color: #34d399;
}

.prose code {
  background: #f1f5f9;
  padding: 0.2em 0.4em;
  border-radius: 0.25em;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.dark .prose code {
  background: #374151;
  color: #e5e7eb;
}

.prose blockquote {
  border-left: 4px solid #2563eb;
  background: #eff6ff;
  margin: 1em 0;
  padding: 0.75em 1em;
  border-radius: 0.5em;
}

.dark .prose blockquote {
  background: #1e3a8a;
  border-color: #60a5fa;
}

.prose ul, .prose ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

.prose li {
  margin-bottom: 0.5em;
}

/* Code blocks with copy functionality */
.code-block-container {
  position: relative;
  margin: 1em 0;
}

.code-block-container pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1em;
  border-radius: 0.5em;
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.4;
}

.copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 0.25em;
  padding: 0.25em 0.5em;
  color: #e2e8f0;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.8em;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive tables */
.table-container {
  overflow-x: auto;
  margin: 1em 0;
  border-radius: 0.5em;
  border: 1px solid #e2e8f0;
}

.dark .table-container {
  border-color: #374151;
}

.mobile-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 300px;
}

.mobile-table th,
.mobile-table td {
  padding: 0.75em;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9em;
}

.dark .mobile-table th,
.dark .mobile-table td {
  border-color: #374151;
}

.mobile-table th {
  background: #f8fafc;
  font-weight: 600;
}

.dark .mobile-table th {
  background: #1f2937;
}

/* Zoomable images */
.zoomable-image {
  max-width: 100%;
  height: auto;
  border-radius: 0.5em;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.zoomable-image:hover {
  transform: scale(1.02);
}

/* Collapsible sections */
.collapsible-header {
  cursor: pointer;
  user-select: none;
  padding: 0.5em 0;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.5em;
}

.dark .collapsible-header {
  border-color: #374151;
}

.collapsible-content {
  display: block;
  margin-left: 1em;
}

/* Touch-optimized interactive elements */
.interactive-element {
  min-height: 44px;
  min-width: 44px;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.interactive-element:active {
  transform: scale(0.98);
  opacity: 0.8;
}

/* Enhanced focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Loading animations optimized for mobile */
@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1.0);
  }
}

.animate-bounce {
  animation: bounce 1.4s ease-in-out infinite both;
}

/* Custom range slider styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  transition: background 0.2s;
}

.dark input[type="range"] {
  background: #374151;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

input[type="range"]::-moz-range-thumb {
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* iOS-style toggle switches */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

/* Voice input active state */
.voice-active {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.2) 0%, transparent 70%);
  animation: pulse-red 1.5s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

/* Connection status indicators */
.status-connected {
  animation: pulse-green 3s ease-in-out infinite;
}

.status-error {
  animation: shake 0.5s ease-in-out;
}

@keyframes pulse-green {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Safe area adjustments for devices with notches */
@supports (padding: env(safe-area-inset-top)) {
  .safe-top {
    padding-top: env(safe-area-inset-top);
  }
  
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Dark mode transitions */
* {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Prevent zoom on input focus (iOS Safari) */
input[type="text"],
input[type="password"],
textarea,
select {
  font-size: 16px !important;
}

/* Enhanced message bubbles for mobile */
.message-bubble {
  word-wrap: break-word;
  line-height: 1.5;
  max-width: none;
}

/* Topic pills horizontal scroll */
.topics-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.topics-scroll::-webkit-scrollbar {
  height: 2px;
}

.topics-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.topics-scroll::-webkit-scrollbar-thumb {
  background-color: #cbd5e0;
  border-radius: 1px;
}

/* Floating input adjustments for keyboard */
.floating-input {
  transition: transform 0.3s ease;
}

/* Quick actions responsive grid */
.quick-actions {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.quick-action-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Settings optimization for mobile */
.settings-content {
  padding: 1rem;
  max-height: 60vh;
  overflow-y: auto;
}

/* Enhanced accessibility for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .prose strong {
    color: #000;
    background: #ff0;
    padding: 0.1em 0.2em;
  }
  
  .dark .prose strong {
    color: #fff;
    background: #0066ff;
  }
}

/* Large text support */
@media (prefers-reduced-data: reduce) {
  .zoomable-image {
    max-width: 200px;
    max-height: 200px;
  }
}