@import "tailwindcss";

@theme {
  --color-background: #0a0a0a;
  --color-foreground: #fafafa;
  --color-card: #141414;
  --color-card-hover: #1a1a1a;
  --color-border: #2a2a2a;
  --color-primary: #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-primary-foreground: #fafafa;
  --color-muted-foreground: #d4d4d8;
  --color-accent: #27272a;
  --color-input: #27272a;
  --color-muted: #18181b;
  --color-popover: #18181b;
  --color-destructive: #dc2626;
  --color-secondary: #27272a;
  --color-secondary-foreground: #fafafa;
  --color-accent-foreground: #fafafa;
}

:root:not(.dark) {
  --color-background: #ffffff;
  --color-foreground: #111827;
  --color-card: #f9fafb;
  --color-card-hover: #f3f4f6;
  --color-border: #e5e7eb;
  --color-primary: #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-primary-foreground: #ffffff;
  --color-muted-foreground: #6b7280;
  --color-accent: #f3f4f6;
  --color-input: #e5e7eb;
  --color-muted: #f4f4f5;
  --color-popover: #ffffff;
  --color-destructive: #dc2626;
  --color-secondary: #f4f4f5;
  --color-secondary-foreground: #111827;
  --color-accent-foreground: #111827;
}

html {
  background-color: #0a0a0a;
  min-height: calc(100% + env(safe-area-inset-top));
  overscroll-behavior-x: none;
}

:root:not(.dark) html {
  background-color: #ffffff;
}

body {
  background: linear-gradient(to bottom right, #0a0a0a, #0d0d0d, #0a0a0a);
  color: var(--color-foreground);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
  overscroll-behavior-x: none;
}

#root {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

:root:not(.dark) body {
  background: linear-gradient(to bottom right, #ffffff, #f0f0f0, #ffffff);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Custom animations */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Loading states */
.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.95; }
}

.animate-pulse-subtle {
  animation: pulse-subtle 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes page-slide-in-from-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes page-slide-in-from-left {
  from { transform: translateX(-30%); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

.page-slide-in-push {
  animation: page-slide-in-from-right 300ms cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.page-slide-in-pop {
  animation: page-slide-in-from-left 300ms cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes shine-loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shine-loading {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.2) 40%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0.6) 60%,
    rgba(255, 255, 255, 0.8) 70%,
    rgba(255, 255, 255, 1) 80%,
    rgba(255, 255, 255, 0.2) 100%
  );
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  animation: shine-loading 3s linear infinite;
}

.prose-enhanced {
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
}

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

.prose-enhanced h1,
.prose-enhanced h2,
.prose-enhanced h3,
.prose-enhanced h4,
.prose-enhanced h5,
.prose-enhanced h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
  line-height: 1.3;
}

.prose-enhanced h1 { font-size: 1.5em; }
.prose-enhanced h2 { font-size: 1.3em; }
.prose-enhanced h3 { font-size: 1.15em; }

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

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

.prose-enhanced strong {
  font-weight: 600;
  color: var(--color-foreground);
}

.prose-enhanced a {
  color: #60a5fa;
  text-decoration: none;
}

.dark .prose-enhanced a {
  color: #60a5fa;
}

.prose-enhanced a:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.prose-enhanced hr {
  margin-top: 2em;
  margin-bottom: 2em;
  border-color: #d0d0d0;
}

.dark .prose-enhanced hr {
  border-color: #3f3f46;
}

.prose-enhanced blockquote {
  margin-top: 1em;
  margin-bottom: 1em;
  padding-left: 1em;
  border-left: 3px solid #d0d0d0;
  color: #6b7280;
}

.dark .prose-enhanced blockquote {
  border-left: 3px solid #3f3f46;
  color: #a1a1aa;
}

.prose-enhanced pre {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  white-space: pre-wrap;
  word-break: break-word;
}

.prose-enhanced code {
  word-break: break-all;
}

.prose-enhanced .table-wrapper {
  overflow-x: auto;
  margin: 1em 0;
  -webkit-overflow-scrolling: touch;
}

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

.prose-enhanced th,
.prose-enhanced td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

.prose-enhanced th {
  background-color: var(--color-accent);
  font-weight: 600;
}

.prose-enhanced tr:nth-child(even) {
  background-color: var(--color-accent);
}

@media (max-width: 640px) {
  .prose-enhanced pre {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
  
  .prose-enhanced code {
    font-size: 0.75rem;
  }

  .prose-enhanced th,
  .prose-enhanced td {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
}

.prose-enhanced :first-child {
  margin-top: 0;
}

.prose-enhanced :last-child {
  margin-bottom: 0;
}

@utility pt-safe {
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}

@utility pb-safe {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Prevent iOS zoom on all input elements */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
  }
  
  /* ContentEditable elements */
  [contenteditable="true"] {
    font-size: 16px !important;
  }
}

/* Normalize autofill backgrounds in dark mode */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: inherit !important;
  -webkit-box-shadow: 0 0 0px 1000px transparent inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Syntax highlighting for markdown code blocks */
@import 'highlight.js/styles/github.css' layer(highlight-light);
@import 'highlight.js/styles/github-dark.css' layer(highlight-dark);

@layer highlight-light {
  :root:not(.dark) .hljs {
    display: block;
    overflow-x: auto;
    padding: 0.5em;
    background: var(--color-accent);
    color: var(--color-foreground);
  }
}

@layer highlight-dark {
  .dark .hljs {
    display: block;
    overflow-x: auto;
    padding: 0.5em;
    background: var(--color-accent);
    color: var(--color-foreground);
}
 }

/* Custom scrollbar styling */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-muted-foreground);
}

/* Progress bar animation for download dialog */
@keyframes progress {
  0% {
    width: 0%;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

.animate-progress {
  animation: progress 2s ease-in-out infinite;
}

/* Error line highlighting - red-orange selection color */
.error-highlight::selection {
  background-color: #fecaca;
  color: #991b1b;
}

.dark .error-highlight::selection {
  background-color: #7f1d1d;
  color: #fecaca;
}

.error-highlight::-moz-selection {
  background-color: #fecaca;
  color: #991b1b;
}

.dark .error-highlight::-moz-selection {
  background-color: #7f1d1d;
  color: #fecaca;
}
