@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    /* Premium Design System - OpenCodeHub Light Theme */
    --background: 0 0% 100%;
    --foreground: 210 11% 15%;
    --card: 0 0% 100%;
    --card-foreground: 210 11% 15%;
    --popover: 0 0% 100%;
    --popover-foreground: 210 11% 15%;
    --primary: 212 100% 37%;
    --primary-foreground: 0 0% 100%;
    --secondary: 210 14% 95%;
    --secondary-foreground: 210 11% 15%;
    --muted: 210 20% 98%;
    --muted-foreground: 210 11% 40%;
    --accent: 210 20% 96%;
    --accent-foreground: 210 11% 15%;
    --destructive: 354 70% 54%;
    --destructive-foreground: 0 0% 100%;
    --border: 210 18% 87%;
    --input: 210 18% 87%;
    --ring: 212 100% 37%;
    --radius: 0.5rem;
    
    --success: 142 70% 45%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(210 20% 98%) 0%, hsl(0 0% 100%) 60%);
    --glass-blur: 20px;
    --glass-bg: rgba(255, 255, 255, 0.7);

    /* Sidebar Tokens */
    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 240 5.9% 10%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217.2 91.2% 59.8%;

    /* Chart Tokens */
    --chart-1: 12 76% 61%;
    --chart-2: 173 58% 39%;
    --chart-3: 197 37% 24%;
    --chart-4: 43 74% 66%;
    --chart-5: 27 87% 67%;
  }

  .dark {
    /* Ryoku Minimalist High-Contrast Black & White Theme */
    --background: 0 0% 4%;
    --foreground: 0 0% 98%;
    --card: 0 0% 7%;
    --card-foreground: 0 0% 98%;
    --popover: 0 0% 7%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 9%;
    --secondary: 0 0% 12%;
    --secondary-foreground: 0 0% 98%;
    --muted: 0 0% 12%;
    --muted-foreground: 0 0% 65%;
    --accent: 0 0% 14%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 50.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 0 0% 18%;
    --input: 0 0% 18%;
    --ring: 0 0% 98%;
    --radius: 0.375rem;
    --success: 142 70% 58%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(0 0% 10%) 0%, hsl(0 0% 4%) 60%);
    --glass-blur: 20px;
    --glass-bg: rgba(10, 10, 12, 0.75);

    /* Chart Tokens */
    --chart-1: 0 0% 80%;
    --chart-2: 0 0% 60%;
    --chart-3: 0 0% 40%;
    --chart-4: 0 0% 70%;
    --chart-5: 0 0% 50%;

    /* Sidebar Tokens */
    --sidebar-background: 0 0% 6%;
    --sidebar-foreground: 0 0% 98%;
    --sidebar-primary: 0 0% 98%;
    --sidebar-primary-foreground: 0 0% 9%;
    --sidebar-accent: 0 0% 12%;
    --sidebar-accent-foreground: 0 0% 98%;
    --sidebar-border: 0 0% 18%;
    --sidebar-ring: 0 0% 98%;
  }

  /* GitHub Dark Theme */
  [data-theme="github-dark"] {
    --background: 216 28% 7%;
    --foreground: 210 17% 92%;
    --card: 215 22% 10%;
    --card-foreground: 210 17% 92%;
    --popover: 215 22% 10%;
    --popover-foreground: 210 17% 92%;
    --primary: 212 92% 63%;
    --primary-foreground: 0 0% 100%;
    --secondary: 215 16% 18%;
    --secondary-foreground: 210 17% 92%;
    --muted: 215 22% 14%;
    --muted-foreground: 212 9% 60%;
    --accent: 215 16% 18%;
    --accent-foreground: 210 17% 92%;
    --destructive: 354 70% 54%;
    --destructive-foreground: 0 0% 100%;
    --border: 215 14% 28%;
    --input: 215 14% 28%;
    --ring: 212 92% 63%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(215 22% 14%) 0%, hsl(216 28% 7%) 60%);
    --glass-bg: rgba(13, 17, 23, 0.75);

    /* Chart Tokens */
    --chart-1: 212 92% 63%;
    --chart-2: 216 78% 42%;
    --chart-3: 0 70% 54%;
    --chart-4: 111 72% 45%;
    --chart-5: 20 100% 58%;

    /* Sidebar Tokens */
    --sidebar-background: 215 22% 10%;
    --sidebar-foreground: 210 17% 92%;
    --sidebar-primary: 212 92% 63%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 215 22% 14%;
    --sidebar-accent-foreground: 210 17% 92%;
    --sidebar-border: 215 14% 28%;
    --sidebar-ring: 212 92% 63%;
  }

  /* Dracula Theme */
  [data-theme="dracula"] {
    --background: 231 15% 18%;
    --foreground: 60 30% 96%;
    --card: 231 15% 20%;
    --card-foreground: 60 30% 96%;
    --popover: 231 15% 20%;
    --popover-foreground: 60 30% 96%;
    --primary: 326 100% 74%;
    --primary-foreground: 231 15% 18%;
    --secondary: 231 15% 25%;
    --secondary-foreground: 60 30% 96%;
    --muted: 231 15% 25%;
    --muted-foreground: 225 27% 51%;
    --accent: 231 15% 25%;
    --accent-foreground: 60 30% 96%;
    --destructive: 0 100% 67%;
    --destructive-foreground: 60 30% 96%;
    --border: 231 15% 25%;
    --input: 231 15% 25%;
    --ring: 326 100% 74%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(231 15% 25%) 0%, hsl(231 15% 18%) 60%);
    --glass-bg: rgba(40, 42, 54, 0.6);

    /* Chart Tokens */
    --chart-1: 326 100% 74%;
    --chart-2: 265 89% 78%;
    --chart-3: 135 94% 65%;
    --chart-4: 31 100% 71%;
    --chart-5: 0 100% 67%;

    /* Sidebar Tokens */
    --sidebar-background: 231 15% 20%;
    --sidebar-foreground: 60 30% 96%;
    --sidebar-primary: 326 100% 74%;
    --sidebar-primary-foreground: 231 15% 18%;
    --sidebar-accent: 231 15% 25%;
    --sidebar-accent-foreground: 60 30% 96%;
    --sidebar-border: 231 15% 25%;
    --sidebar-ring: 326 100% 74%;
  }

  /* Rose Pine Theme */
  [data-theme="rose-pine"] {
    --background: 249 22% 12%;
    --foreground: 248 19% 89%;
    --card: 247 23% 15%;
    --card-foreground: 248 19% 89%;
    --popover: 247 23% 15%;
    --popover-foreground: 248 19% 89%;
    --primary: 343 35% 65%;
    --primary-foreground: 249 22% 12%;
    --secondary: 248 20% 20%;
    --secondary-foreground: 248 19% 89%;
    --muted: 248 25% 18%;
    --muted-foreground: 248 12% 52%;
    --accent: 248 25% 18%;
    --accent-foreground: 248 19% 89%;
    --destructive: 343 35% 65%;
    --destructive-foreground: 249 22% 12%;
    --border: 248 25% 18%;
    --input: 248 25% 18%;
    --ring: 343 35% 65%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(247 23% 15%) 0%, hsl(249 22% 12%) 60%);
    --glass-bg: rgba(25, 23, 36, 0.6);

    /* Chart Tokens */
    --chart-1: 343 35% 65%;
    --chart-2: 198 80% 60%;
    --chart-3: 114 50% 58%;
    --chart-4: 34 100% 73%;
    --chart-5: 247 70% 70%;

    /* Sidebar Tokens */
    --sidebar-background: 247 23% 15%;
    --sidebar-foreground: 248 19% 89%;
    --sidebar-primary: 343 35% 65%;
    --sidebar-primary-foreground: 249 22% 12%;
    --sidebar-accent: 248 25% 18%;
    --sidebar-accent-foreground: 248 19% 89%;
    --sidebar-border: 248 25% 18%;
    --sidebar-ring: 343 35% 65%;
  }

  /* Tokyo Night Theme */
  [data-theme="tokyo-night"] {
    --background: 235 18% 14%;
    --foreground: 227 70% 87%;
    --card: 235 18% 16%;
    --card-foreground: 227 70% 87%;
    --popover: 235 18% 16%;
    --popover-foreground: 227 70% 87%;
    --primary: 263 70% 74%;
    --primary-foreground: 235 18% 14%;
    --secondary: 235 15% 22%;
    --secondary-foreground: 227 70% 87%;
    --muted: 235 18% 20%;
    --muted-foreground: 228 17% 41%;
    --accent: 235 18% 20%;
    --accent-foreground: 227 70% 87%;
    --destructive: 354 87% 68%;
    --destructive-foreground: 235 18% 14%;
    --border: 235 18% 20%;
    --input: 235 18% 20%;
    --ring: 263 70% 74%;
    --hero-gradient: radial-gradient(ellipse at top center, hsl(235 18% 20%) 0%, hsl(235 18% 14%) 60%);
    --glass-bg: rgba(26, 27, 38, 0.6);

    /* Chart Tokens */
    --chart-1: 263 70% 74%;
    --chart-2: 219 73% 68%;
    --chart-3: 168 85% 62%;
    --chart-4: 44 91% 68%;
    --chart-5: 347 70% 68%;

    /* Sidebar Tokens */
    --sidebar-background: 235 18% 16%;
    --sidebar-foreground: 227 70% 87%;
    --sidebar-primary: 263 70% 74%;
    --sidebar-primary-foreground: 235 18% 14%;
    --sidebar-accent: 235 18% 20%;
    --sidebar-accent-foreground: 227 70% 87%;
    --sidebar-border: 235 18% 20%;
    --sidebar-ring: 263 70% 74%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply bg-background text-foreground transition-colors duration-300;
    font-family: "Inter", system-ui, sans-serif;
  }

  code,
  pre,
  .font-mono {
    font-family: "JetBrains Mono", monospace;
  }

  html {
    scroll-behavior: smooth;
  }
}

/* ==========================================================================
   Base Elements & Globals
   ========================================================================== */

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground));
}

/* Code syntax highlighting base */
.hljs {
  display: block;
  overflow-x: auto;
  padding: 1em;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

/* Monaco Editor customizations */
.monaco-editor {
  border-radius: var(--radius);
}

/* Git diff styles */
.diff-add {
  background-color: rgba(46, 160, 67, 0.15);
}

.diff-remove {
  background-color: rgba(248, 81, 73, 0.15);
}

.diff-add-line {
  @apply bg-green-50/50 dark:bg-green-900/20 border-l-4 border-green-500;
}

.diff-remove-line {
  @apply bg-red-50/50 dark:bg-red-900/20 border-l-4 border-red-500;
}

.diff-context-line {
  @apply bg-gray-50 dark:bg-gray-800/50 border-l-4 border-gray-300;
}

/* File tree styles */
.file-tree-item {
  @apply flex items-center gap-2 px-2 py-1 rounded cursor-pointer hover:bg-accent hover:text-accent-foreground transition-colors;
}

.file-tree-item.selected {
  @apply bg-accent text-accent-foreground font-medium;
}

/* Commit graph styles */
.commit-graph-line {
  stroke-width: 2;
  fill: none;
}

.commit-graph-node {
  stroke-width: 2;
}

/* Pipeline status colors */
.pipeline-success {
  @apply text-green-600 dark:text-green-400;
}

.pipeline-failed {
  @apply text-red-600 dark:text-red-400;
}

.pipeline-pending {
  @apply text-yellow-600 dark:text-yellow-400;
}

.pipeline-running {
  @apply text-blue-600 dark:text-blue-400;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

/* ==========================================================================
   Markdown Elements
   ========================================================================== */

.markdown-body {
  @apply text-foreground;
}

.markdown-body h1 {
  @apply text-3xl font-bold mb-4 pb-2 border-b;
}

.markdown-body h2 {
  @apply text-2xl font-bold mb-3 pb-2 border-b;
}

.markdown-body h3 {
  @apply text-xl font-bold mb-2;
}

.markdown-body p {
  @apply mb-4;
}

.markdown-body ul {
  @apply list-disc list-inside mb-4;
}

.markdown-body ol {
  @apply list-decimal list-inside mb-4;
}

.markdown-body code {
  @apply bg-muted px-1.5 py-0.5 rounded text-sm font-mono border border-border;
}

.markdown-body pre {
  @apply bg-muted p-4 rounded-lg overflow-x-auto mb-4 border border-border;
}

.markdown-body pre code {
  @apply bg-transparent p-0 border-none;
}

.markdown-body blockquote {
  @apply border-l-4 border-muted-foreground pl-4 italic my-4 text-muted-foreground;
}

.markdown-body table {
  @apply w-full border-collapse mb-4;
}

.markdown-body th,
.markdown-body td {
  @apply border px-4 py-2 text-left;
}

.markdown-body th {
  @apply bg-muted font-semibold;
}

.markdown-body a {
  @apply text-primary hover:underline font-medium;
}

.markdown-body img {
  @apply max-w-full rounded-lg border border-border;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.skeleton {
  @apply animate-pulse bg-muted rounded;
}

/* Focus ring utility */
.focus-ring {
  @apply focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background;
}

.text-balance {
  text-wrap: balance;
}

/* ==========================================================================
   Premium Landing Page Animations
   ========================================================================== */

@keyframes text-reveal {
  0% {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.animate-text-reveal {
  animation: text-reveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.animate-shimmer {
  animation: shimmer 3s infinite linear;
}

@keyframes slide-fade-up {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slide-up {
  animation: slide-fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes soft-pulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

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

/* CTA Button Styles */
.btn-primary-glow {
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, color-mix(in srgb, hsl(var(--primary)) 80%, white) 100%);
  color: hsl(var(--primary-foreground));
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 4px 20px color-mix(in srgb, hsl(var(--primary)) 30%, transparent);
}

.btn-primary-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px color-mix(in srgb, hsl(var(--primary)) 50%, transparent);
}

.hero-gradient {
  background: var(--hero-gradient);
}

/* ==========================================================================
   Glass & Dashboard HUD
   ========================================================================== */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-card:hover {
  background: color-mix(in srgb, var(--glass-bg) 90%, black);
  border-color: color-mix(in srgb, currentColor 20%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Glass panel for admin dashboard / HUD */
.glass-panel {
  background: color-mix(in srgb, var(--glass-bg) 80%, transparent);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

/* Custom thin scrollbar for panels */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, currentColor 15%, transparent);
  border-radius: 2px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, currentColor 25%, transparent);
}

/* ==========================================================================
   Aceternity UI Styles
   ========================================================================== */

@keyframes spotlight {
  0% {
    opacity: 0;
    transform: translate(-72%, -62%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -40%) scale(1);
  }
}

.animate-spotlight {
  animation: spotlight 2s ease 0.75s 1 forwards;
}

.bg-dot-thick-neutral-800 {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 16px 16px;
}

.bg-dot-thick-primary {
  background-image: radial-gradient(circle, hsl(var(--primary)) 1px, transparent 1px);
  background-size: 16px 16px;
}

.bg-grid-white\/\[0\.02\] {
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

.bg-clip-text {
  -webkit-background-clip: text;
  background-clip: text;
}

@layer utilities {
  .transition-smooth {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes gradient-x {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animate-gradient-x {
  animation: gradient-x 3s ease infinite;
}

/* ==========================================================================
   Responsive & Accessibility Utilities
   ========================================================================== */

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

@media (max-width: 640px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

@media (min-width: 640px) and (max-width: 1024px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  button, a, input, textarea, select {
    min-height: 44px;
    min-width: 44px;
  }
  .hover\:-translate-y-1:hover,
  .hover\:scale-105:hover {
    transform: none;
  }
}

@media print {
  .no-print { display: none !important; }
  body {
    background: white !important;
    color: black !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-text-reveal,
  .animate-shimmer,
  .animate-slide-up,
  .animate-soft-pulse {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 2px);
}

img {
  max-width: 100%;
  height: auto;
}

.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

/* Code block scrollbar */
.blob-scrollbar::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.blob-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.blob-scrollbar::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, currentColor 15%, transparent);
  border-radius: 5px;
  border: 2px solid var(--background);
}
.blob-scrollbar::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, currentColor 25%, transparent);
}

/* Shiki code highlighting overrides */
.shiki {
  background-color: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
}
.shiki code {
  display: flex;
  flex-direction: column;
}
.shiki .line {
  height: 1.5rem;
  display: block;
}