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

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

@layer base {
  :root {
    /* Core colors - Futuristic dark theme */
    --background: 222 47% 6%;
    --foreground: 210 40% 98%;
    
    /* Card/Panel surfaces with depth */
    --card: 222 47% 8%;
    --card-foreground: 210 40% 98%;
    
    /* Popover/Dropdown */
    --popover: 222 47% 10%;
    --popover-foreground: 210 40% 98%;
    
    /* Primary - Cyan/Teal neon accent */
    --primary: 187 92% 50%;
    --primary-foreground: 222 47% 6%;
    
    /* Secondary - Muted blue-gray */
    --secondary: 217 33% 17%;
    --secondary-foreground: 210 40% 98%;
    
    /* Muted surfaces */
    --muted: 217 33% 12%;
    --muted-foreground: 215 20% 55%;
    
    /* Accent - Purple glow */
    --accent: 262 83% 58%;
    --accent-foreground: 210 40% 98%;
    
    /* Destructive */
    --destructive: 0 84% 60%;
    --destructive-foreground: 210 40% 98%;
    
    /* Borders */
    --border: 217 33% 17%;
    --input: 217 33% 17%;
    --ring: 187 92% 50%;
    
    /* Sidebar - Slightly darker */
    --sidebar: 222 47% 5%;
    --sidebar-foreground: 210 40% 98%;
    --sidebar-border: 217 33% 12%;
    --sidebar-accent: 217 33% 10%;
    --sidebar-accent-foreground: 210 40% 98%;
    --sidebar-primary: 187 92% 50%;
    --sidebar-primary-foreground: 222 47% 6%;
    --sidebar-ring: 187 92% 50%;
    
    /* Editor specific */
    --editor-bg: 222 47% 7%;
    --editor-gutter: 222 47% 5%;
    --editor-line-highlight: 217 33% 10%;
    --editor-selection: 187 92% 50% / 0.35;
    
    /* Tabs */
    --tab-active: 222 47% 10%;
    --tab-inactive: 222 47% 6%;
    --tab-border: 217 33% 15%;
    
    /* Status bar */
    --statusbar: 222 47% 5%;
    --statusbar-foreground: 215 20% 55%;
    
    /* Activity bar */
    --activitybar: 222 47% 4%;
    --activitybar-foreground: 215 20% 55%;
    --activitybar-active: 187 92% 50%;
    
    /* Glassmorphism */
    --glass-bg: 222 47% 8% / 0.8;
    --glass-border: 217 33% 20% / 0.5;
    
    /* Glow effects */
    --glow-primary: 187 92% 50% / 0.3;
    --glow-accent: 262 83% 58% / 0.3;
    
    /* Success/Warning/Info */
    --success: 142 71% 45%;
    --warning: 38 92% 50%;
    --info: 199 89% 48%;
    
    --radius: 0.5rem;
    
    /* Chart colors */
    --chart-1: 187 92% 50%;
    --chart-2: 262 83% 58%;
    --chart-3: 142 71% 45%;
    --chart-4: 38 92% 50%;
    --chart-5: 0 84% 60%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  
  body {
    @apply bg-background text-foreground font-sans antialiased;
    font-feature-settings: "rlig" 1, "calt" 1;
  }
  
  /* Apple-style smooth scrolling */
  * {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Custom scrollbar - Apple style */
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  
  ::-webkit-scrollbar-track {
    @apply bg-sidebar;
    border-radius: 5px;
  }
  
  ::-webkit-scrollbar-thumb {
    @apply bg-muted-foreground/40 rounded-full;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background-color 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  
  ::-webkit-scrollbar-thumb:hover {
    @apply bg-muted-foreground/60;
  }
  
  ::-webkit-scrollbar-corner {
    @apply bg-transparent;
  }
  
  /* Ensure scrollbars are visible in file explorer */
  .apple-scroll {
    overflow-y: scroll !important;
    overflow-x: auto !important;
  }
  
  /* Apple-style transitions for interactive elements */
  button, a, [role="button"] {
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  
  /* Apple-style focus ring */
  *:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
    border-radius: 4px;
    transition: outline-offset 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
}

@layer components {
  /* Glassmorphism panels */
  .glass-panel {
    @apply backdrop-blur-xl border border-white/10;
    background: hsl(var(--glass-bg));
  }
  
  /* Neon glow effect */
  .neon-glow {
    box-shadow: 0 0 20px hsl(var(--glow-primary)),
                0 0 40px hsl(var(--glow-primary)),
                inset 0 0 20px hsl(var(--glow-primary));
  }
  
  .neon-glow-subtle {
    box-shadow: 0 0 10px hsl(var(--glow-primary));
  }
  
  /* Activity indicator */
  .activity-indicator {
    @apply relative;
  }
  
  .activity-indicator::after {
    content: '';
    @apply absolute left-0 top-0 bottom-0 w-0.5 bg-primary;
    box-shadow: 0 0 8px hsl(var(--primary));
  }
  
  /* Editor cursor blink */
  .cm-cursor {
    animation: cursor-blink 1s ease-in-out infinite;
  }
  
  @keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
  }
  
  /* Tab styling - Apple style smooth transitions */
  .editor-tab {
    @apply relative px-3 py-1.5 text-sm flex items-center gap-2 border-r border-tab-border;
    background: hsl(var(--tab-inactive));
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  
  .editor-tab.active {
    background: hsl(var(--tab-active));
  }
  
  .editor-tab.active::after {
    content: '';
    @apply absolute bottom-0 left-0 right-0 h-0.5 bg-primary;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  
  /* Command palette */
  .command-palette {
    @apply glass-panel rounded-lg overflow-hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
                0 0 0 1px hsl(var(--border));
  }
  
  /* File tree item - Apple style smooth interactions */
  .file-tree-item {
    @apply flex items-center gap-2 px-2 py-1 rounded-sm cursor-pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  
  .file-tree-item:hover {
    @apply bg-sidebar-accent;
    transform: translateX(2px);
  }
  
  .file-tree-item.selected {
    @apply bg-primary/10 text-primary;
  }
  
  /* Minimap */
  .minimap {
    @apply absolute right-0 top-0 bottom-0 w-20 opacity-50;
    background: linear-gradient(to left, hsl(var(--editor-bg)), transparent);
  }
  
  /* Status bar item */
  .statusbar-item {
    @apply px-2 py-0.5 text-xs transition-colors cursor-pointer;
  }
  
  .statusbar-item:hover {
    @apply bg-white/5;
  }
  
  /* Smooth focus ring */
  .focus-ring {
    @apply outline-none ring-2 ring-primary/50 ring-offset-2 ring-offset-background;
  }
}

@layer utilities {
  /* Animation utilities */
  .animate-in {
    animation: animate-in 0.2s ease-out;
  }
  
  @keyframes animate-in {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .animate-slide-in {
    animation: slide-in 0.2s ease-out;
  }
  
  @keyframes slide-in {
    from {
      opacity: 0;
      transform: translateX(-10px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
  
  /* Pulse glow */
  .pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
  }
  
  @keyframes pulse-glow {
    0%, 100% {
      box-shadow: 0 0 5px hsl(var(--primary) / 0.5);
    }
    50% {
      box-shadow: 0 0 20px hsl(var(--primary) / 0.8);
    }
  }
  
  /* Gradient text */
  .gradient-text {
    @apply bg-clip-text text-transparent;
    background-image: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
  }
}

/* CodeMirror: fill container so .cm-scroller can scroll */
.cm-editor {
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 13px;
  line-height: 1.6;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Vertical scroll: scrollbar always visible, mouse wheel works here */
.cm-editor .cm-scroller {
  font-family: 'JetBrains Mono', monospace !important;
  overflow-y: scroll !important;
  overflow-x: auto !important;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  max-height: 100% !important;
}
.cm-editor .cm-scroller::-webkit-scrollbar {
  width: 10px;
}
.cm-editor .cm-scroller::-webkit-scrollbar-track {
  background: hsl(var(--editor-gutter));
}
.cm-editor .cm-scroller::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.4);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.cm-editor .cm-scroller::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.55);
}

/* Editor wrapper: flex chain so CodeMirror gets a fixed height and can scroll */
.editor-scroll-container {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.editor-scroll-container .editor-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-scroll-container .editor-inner > div {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cm-editor .cm-content {
  padding: 8px 0;
}

.cm-editor .cm-gutters {
  background: hsl(var(--editor-gutter));
  border-right: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

.cm-editor .cm-activeLineGutter {
  background: hsl(var(--editor-line-highlight));
  color: hsl(var(--foreground));
}

.cm-editor .cm-activeLine {
  background: hsl(var(--editor-line-highlight));
}

/* Selected text highlight - visible in code/content workspace */
.cm-editor .cm-selectionBackground,
.cm-editor .cm-content ::selection {
  background: hsl(var(--editor-selection)) !important;
}

.cm-editor.cm-focused .cm-selectionBackground,
.cm-editor.cm-focused .cm-content ::selection {
  background: hsl(var(--editor-selection)) !important;
}

.cm-editor .cm-cursor {
  border-left-color: hsl(var(--primary));
  border-left-width: 2px;
}

.cm-editor .cm-matchingBracket {
  background: hsl(var(--primary) / 0.2);
  outline: 1px solid hsl(var(--primary) / 0.5);
}

/* Bookmark marker */
.cm-bookmark-marker {
  @apply w-3 h-3 rounded-full bg-accent cursor-pointer;
  box-shadow: 0 0 8px hsl(var(--accent));
}
