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

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;
    --primary-rgb: 59, 130, 246;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --success: 142.1 76.2% 36.3%;
    --success-foreground: 355.7 100% 97.3%;
    --warning: 45.4 93.4% 47.5%;
    --warning-foreground: 26 83.3% 14.1%;
    --info: 199.4 95.5% 53.8%;
    --info-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 221.2 83.2% 53.3%;
    --radius: 0.5rem;

    /* Sidebar colors */
    --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%;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;
    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;
    --primary: 217.2 91.2% 59.8%;
    --primary-foreground: 222.2 47.4% 11.2%;
    --primary-rgb: 59, 130, 246;
    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --success: 142.1 70.6% 45.3%;
    --success-foreground: 144.9 80.4% 10%;
    --warning: 48 96.5% 53%;
    --warning-foreground: 26 83.3% 14.1%;
    --info: 199.4 95.5% 53.8%;
    --info-foreground: 210 40% 98%;
    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 224.3 76.3% 48%;

    /* Sidebar colors - dark */
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  
  body {
    @apply bg-background text-foreground;
    font-feature-settings: "rlig" 1, "calt" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Custom scrollbar */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    @apply bg-muted/50;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb {
    @apply bg-muted-foreground/30 hover:bg-muted-foreground/50;
    border-radius: 4px;
  }

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

  /* Selection styles */
  ::selection {
    @apply bg-primary/20 text-foreground;
  }
}

@layer components {
  /* Glass effect */
  .glass {
    @apply bg-white/80 dark:bg-gray-900/80 backdrop-blur-xl border border-white/20 dark:border-gray-700/30;
  }

  /* Gradient text */
  .gradient-text {
    @apply bg-gradient-to-r from-primary via-blue-500 to-purple-500 bg-clip-text text-transparent;
  }

  /* Card hover effect */
  .card-hover {
    @apply transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5;
  }

  /* Glow effects */
  .glow-primary {
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.3);
  }

  .glow-success {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
  }

  .glow-warning {
    box-shadow: 0 0 20px rgba(234, 179, 8, 0.3);
  }

  .glow-destructive {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
  }

  /* Skeleton loading */
  .skeleton {
    @apply animate-pulse bg-muted rounded;
  }

  /* Data table styles */
  .data-table {
    @apply w-full border-collapse;
  }

  .data-table th {
    @apply px-4 py-3 text-left text-xs font-medium text-muted-foreground uppercase tracking-wider bg-muted/50 border-b;
  }

  .data-table td {
    @apply px-4 py-3 text-sm border-b border-border/50;
  }

  .data-table tr:hover td {
    @apply bg-muted/30;
  }

  /* Status badges */
  .badge {
    @apply inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium;
  }

  .badge-success {
    @apply bg-success/10 text-success;
  }

  .badge-warning {
    @apply bg-warning/10 text-warning;
  }

  .badge-destructive {
    @apply bg-destructive/10 text-destructive;
  }

  .badge-info {
    @apply bg-info/10 text-info;
  }

  .badge-muted {
    @apply bg-muted text-muted-foreground;
  }

  /* Command palette */
  .command-palette {
    @apply fixed inset-0 z-50 flex items-start justify-center pt-[15vh];
  }

  .command-palette-backdrop {
    @apply fixed inset-0 bg-black/50 backdrop-blur-sm;
  }

  /* Sidebar styles */
  .sidebar {
    @apply flex flex-col h-full bg-sidebar border-r border-sidebar-border;
  }

  .sidebar-header {
    @apply flex h-14 items-center border-b border-sidebar-border px-4;
  }

  .sidebar-content {
    @apply flex-1 overflow-auto py-2;
  }

  .sidebar-footer {
    @apply flex h-14 items-center border-t border-sidebar-border px-4;
  }

  .sidebar-group {
    @apply px-2 py-2;
  }

  .sidebar-group-label {
    @apply px-2 mb-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider;
  }

  .sidebar-item {
    @apply flex items-center gap-3 px-3 py-2 text-sm rounded-md transition-colors;
    @apply hover:bg-sidebar-accent hover:text-sidebar-accent-foreground;
  }

  .sidebar-item-active {
    @apply bg-sidebar-accent text-sidebar-accent-foreground;
  }

  /* Dashboard widgets */
  .widget {
    @apply rounded-lg border bg-card text-card-foreground shadow-sm;
  }

  .widget-header {
    @apply flex items-center justify-between p-4 border-b;
  }

  .widget-title {
    @apply text-sm font-medium;
  }

  .widget-content {
    @apply p-4;
  }

  /* Form styles */
  .form-group {
    @apply space-y-2;
  }

  .form-label {
    @apply text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70;
  }

  .form-description {
    @apply text-sm text-muted-foreground;
  }

  .form-error {
    @apply text-sm font-medium text-destructive;
  }

  /* KPI cards */
  .kpi-card {
    @apply relative overflow-hidden rounded-lg border bg-card p-6;
  }

  .kpi-value {
    @apply text-3xl font-bold tracking-tight;
  }

  .kpi-label {
    @apply text-sm text-muted-foreground;
  }

  .kpi-change {
    @apply absolute top-4 right-4 flex items-center gap-1 text-sm;
  }

  .kpi-change-up {
    @apply text-success;
  }

  .kpi-change-down {
    @apply text-destructive;
  }

  /* Timeline */
  .timeline {
    @apply relative pl-6 space-y-4;
  }

  .timeline::before {
    @apply absolute left-2 top-2 bottom-2 w-px bg-border;
    content: '';
  }

  .timeline-item {
    @apply relative;
  }

  .timeline-item::before {
    @apply absolute left-[-18px] top-2 h-2 w-2 rounded-full bg-primary;
    content: '';
  }
}

@layer utilities {
  /* Animation delays */
  .animation-delay-100 {
    animation-delay: 100ms;
  }
  .animation-delay-200 {
    animation-delay: 200ms;
  }
  .animation-delay-300 {
    animation-delay: 300ms;
  }
  .animation-delay-500 {
    animation-delay: 500ms;
  }
  .animation-delay-700 {
    animation-delay: 700ms;
  }
  .animation-delay-1000 {
    animation-delay: 1000ms;
  }

  /* Text utilities */
  .text-balance {
    text-wrap: balance;
  }

  /* Hide scrollbar */
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }

  /* Gradient backgrounds */
  .bg-gradient-subtle {
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(var(--muted)) 100%);
  }

  .bg-gradient-primary {
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--primary) / 0.8) 100%);
  }

  /* Grid pattern background */
  .bg-grid {
    background-image: 
      linear-gradient(to right, hsl(var(--border)) 1px, transparent 1px),
      linear-gradient(to bottom, hsl(var(--border)) 1px, transparent 1px);
    background-size: 40px 40px;
  }

  /* Dot pattern background */
  .bg-dots {
    background-image: radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px);
    background-size: 20px 20px;
  }

  /* Truncate text */
  .truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}