/* Enhanced styles for Study Mode Pro with comprehensive markdown support */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

/* Enhanced Markdown Content Styling */
.markdown-content {
  line-height: 1.6;
  color: #334155;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 1.5em 0 0.5em 0;
  font-weight: 600;
  line-height: 1.3;
  color: #1e293b;
}

.markdown-content h1 {
  font-size: 1.875rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.markdown-content h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.25rem;
}

.markdown-content h3 {
  font-size: 1.25rem;
}

.markdown-content h4 {
  font-size: 1.125rem;
}

.markdown-content h5,
.markdown-content h6 {
  font-size: 1rem;
}

.markdown-content p {
  margin: 0.75em 0;
}

.markdown-content strong {
  font-weight: 600;
  color: #1e293b;
}

.markdown-content em {
  font-style: italic;
  color: #475569;
}

.markdown-content del {
  text-decoration: line-through;
  color: #94a3b8;
}

/* Enhanced Code Block Styling */
.code-block-container {
  margin: 1em 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.75rem;
}

.code-language {
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.copy-code-btn {
  padding: 0.25rem 0.5rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'JetBrains Mono', monospace;
}

.copy-code-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.markdown-content pre {
  margin: 0;
  padding: 1rem;
  background: #1e293b;
  color: #f1f5f9;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

.markdown-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
}

.markdown-content p code,
.markdown-content li code {
  background: #f1f5f9;
  color: #e11d48;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
  font-weight: 500;
}

/* Enhanced List Styling */
.markdown-list {
  margin: 0.75em 0;
  padding-left: 1.5rem;
}

.markdown-list li {
  margin: 0.25em 0;
}

.markdown-ol {
  list-style: decimal;
}

.markdown-ul {
  list-style: disc;
}

.markdown-list li::marker {
  color: #3b82f6;
  font-weight: 600;
}

/* Enhanced Table Styling */
.table-responsive {
  overflow-x: auto;
  margin: 1em 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.markdown-table th,
.markdown-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.markdown-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #d1d5db;
}

.markdown-table tr:hover {
  background: #f9fafb;
}

.markdown-table tr:last-child td {
  border-bottom: none;
}

/* Enhanced Link Styling */
.markdown-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

.markdown-link:hover {
  color: #2563eb;
  border-bottom-color: #3b82f6;
}

.markdown-link:visited {
  color: #7c3aed;
}

/* Enhanced Blockquote Styling */
.markdown-blockquote {
  margin: 1em 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid #3b82f6;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #475569;
}

.markdown-blockquote p {
  margin: 0;
}

.markdown-blockquote p:first-child {
  font-weight: 500;
}

/* Math Expression Styling with KaTeX */
.markdown-content .katex {
  font-size: 1em !important;
}

.markdown-content .katex-display {
  margin: 1em 0 !important;
  text-align: center;
}

.math-error {
  color: #dc2626;
  background: #fef2f2;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-size: 0.875em;
  border: 1px solid #fecaca;
}

/* Image Styling */
.markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  margin: 1em 0;
}

/* Horizontal Rule Styling */
.markdown-content hr {
  margin: 2em 0;
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
}

/* Original App Styles Enhanced */
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 #f7fafc;
}

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

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

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

/* Animation for loading dots */
@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

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

/* Textarea auto-resize */
textarea {
  resize: none;
  overflow-y: auto;
  min-height: 44px;
  max-height: 120px;
}

/* Focus states */
input:focus, 
select:focus, 
textarea:focus {
  outline: none;
  ring: 2px;
  ring-color: #3b82f6;
  border-color: #3b82f6;
}

/* Button hover effects */
button {
  transition: all 0.2s ease-in-out;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

/* Settings panel slide animation */
.settings-panel {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Enhanced message bubble styling */
.message-bubble {
  word-wrap: break-word;
  line-height: 1.5;
}

/* Topic pills animation */
.topic-pill {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Enhanced model indicator styling */
.model-indicator {
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
  animation: slideIn 0.3s ease-out;
}

/* Connection status indicators */
.connection-status {
  animation: pulse 2s ease-in-out infinite;
}

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

/* Tier badge animations */
.tier-badge {
  animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
  }
}

/* Model selection dropdown enhancements */
.model-selector {
  background: linear-gradient(45deg, #f8fafc 0%, #e2e8f0 100%);
  border: 2px solid #e2e8f0;
  transition: all 0.3s ease;
}

.model-selector:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: white;
}

/* Enhanced loading state */
.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #94a3b8;
  animation: loadingBounce 1.4s ease-in-out infinite both;
}

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

@keyframes loadingBounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: 100%;
    height: 100vh;
    border-left: none;
  }
  
  .markdown-content {
    font-size: 0.875rem;
  }
  
  .markdown-content h1 {
    font-size: 1.5rem;
  }
  
  .markdown-content h2 {
    font-size: 1.25rem;
  }
  
  .markdown-content h3 {
    font-size: 1.125rem;
  }
  
  .code-block-container {
    margin: 0.5em 0;
  }
  
  .markdown-content pre {
    padding: 0.75rem;
    font-size: 0.75rem;
  }
  
  .markdown-table {
    font-size: 0.75rem;
  }
  
  .markdown-table th,
  .markdown-table td {
    padding: 0.5rem;
  }
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Checkbox styling */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
}

/* Error state styling */
.error-state {
  border-color: #ef4444;
  background-color: #fef2f2;
  color: #dc2626;
}

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

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

/* Success state styling */
.success-state {
  border-color: #10b981;
  background-color: #f0fdf4;
  color: #059669;
}

/* Enhanced visual feedback */
.interactive-element {
  transition: all 0.2s ease;
}

.interactive-element:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.interactive-element:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for model list */
.model-list {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

.model-list::-webkit-scrollbar {
  width: 4px;
}

.model-list::-webkit-scrollbar-track {
  background: transparent;
}

.model-list::-webkit-scrollbar-thumb {
  background-color: #cbd5e0;
  border-radius: 2px;
}

/* Syntax highlighting overrides for better readability */
.markdown-content pre[class*="language-"] {
  background: #1e293b;
  color: #f1f5f9;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #94a3b8;
}

.token.punctuation {
  color: #f1f5f9;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #f87171;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #34d399;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #fbbf24;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #60a5fa;
}

.token.function,
.token.class-name {
  color: #a78bfa;
}

.token.regex,
.token.important,
.token.variable {
  color: #fb7185;
}

/* Print styles for markdown export */
@media print {
  .markdown-content {
    color: #000;
    background: #fff;
  }
  
  .code-block-container {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  
  .markdown-content pre {
    background: #f5f5f5;
    color: #000;
  }
  
  .copy-code-btn {
    display: none;
  }
}