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

/* Prevent zoom on double tap and pinch gestures - PWA requirement */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbar Styles for Sidebar - Visible and Styled */
[data-sidebar="content"] {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--sidebar-border)) transparent;
}

[data-sidebar="content"]::-webkit-scrollbar {
  width: 6px;
}

[data-sidebar="content"]::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

[data-sidebar="content"]::-webkit-scrollbar-thumb {
  background-color: hsl(var(--sidebar-border));
  border-radius: 3px;
  transition: background-color 0.2s;
}

[data-sidebar="content"]::-webkit-scrollbar-thumb:hover {
  background-color: hsl(var(--sidebar-foreground) / 0.3);
}

/* Custom Scrollbar Styles for Sidebar */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

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

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

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

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

.scrollbar-thumb-sidebar-border::-webkit-scrollbar-thumb {
  background-color: hsl(var(--sidebar-border));
}

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

/* Definition of the design system. All colors, gradients, fonts, etc should be defined here. 
All colors MUST be HSL.
Enterprise-grade design system for Oru ERP
*/

@layer base {
  :root {
    /* Light mode – Vercel/Linear inspired sleek neutral palette */
    --background: 0 0% 100%;
    --foreground: 0 0% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 0 0% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 3.9%;

    /* Primary – high contrast for buttons */
    --primary: 0 0% 9%;
    --primary-foreground: 0 0% 98%;

    --secondary: 0 0% 96.1%;
    --secondary-foreground: 0 0% 9%;

    --muted: 0 0% 96.1%;
    --muted-foreground: 0 0% 45.1%;

    --accent: 0 0% 96.1%;
    --accent-foreground: 0 0% 9%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 89.8%;
    --input: 0 0% 89.8%;
    --ring: 0 0% 3.9%;

    /* Semantic */
    --success: 142 76% 36%;
    --success-foreground: 0 0% 100%;
    --success-light: 142 76% 95%;
    --success-dark: 142 76% 25%;

    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 100%;
    --warning-light: 38 92% 95%;
    --warning-dark: 38 92% 35%;

    --error: 0 84.2% 60.2%;
    --error-foreground: 0 0% 100%;
    --error-light: 0 84.2% 95%;
    --error-dark: 0 84.2% 45%;

    --info: 221 83% 53%;
    --info-foreground: 0 0% 100%;
    --info-light: 221 83% 95%;
    --info-dark: 221 83% 40%;

    /* Sidebar */
    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 0 0% 3.9%;
    --sidebar-primary: 0 0% 9%;
    --sidebar-primary-foreground: 0 0% 98%;
    --sidebar-accent: 0 0% 96.1%;
    --sidebar-accent-foreground: 0 0% 9%;
    --sidebar-border: 0 0% 89.8%;
    --sidebar-ring: 0 0% 3.9%;

    /* Border Radius */
    --radius: 0.5rem;

    /* Layout Spacing - 8px Grid System */
    --page-padding-x: 1.5rem;
    --page-padding-y: 1.5rem;
    --section-spacing: 2rem;
    --card-padding: 1.25rem;
    --card-padding-lg: 1.5rem;
    --grid-gap: 1rem;
    --grid-gap-lg: 1.5rem;

    /* Typography Scale - Professional Enterprise Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 0.9375rem; /* 15px for a slightly tighter SaaS feel */
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;
    --text-5xl: 3rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights */
    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Letter Spacing */
    --tracking-normal: 0;
    --tracking-wide: 0.01em;
    --tracking-tighter: -0.02em;
  }

  .dark {
    /* Dark mode - deep charcoal instead of pure black for depth */
    --background: 0 0% 3.9%;
    --foreground: 0 0% 98%;
    --card: 0 0% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 0 0% 3.9%;
    --popover-foreground: 0 0% 98%;

    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 9%;

    --secondary: 0 0% 14.9%;
    --secondary-foreground: 0 0% 98%;

    --muted: 0 0% 14.9%;
    --muted-foreground: 0 0% 63.9%;

    --accent: 0 0% 14.9%;
    --accent-foreground: 0 0% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 14.9%;
    --input: 0 0% 14.9%;
    --ring: 0 0% 83.1%;

    /* Semantic */
    --success: 142 70% 45%;
    --success-foreground: 0 0% 100%;
    --success-light: 142 70% 10%;
    --success-dark: 142 70% 35%;

    --warning: 38 92% 50%;
    --warning-foreground: 0 0% 100%;
    --warning-light: 38 92% 10%;
    --warning-dark: 38 92% 40%;

    --error: 0 84% 60%;
    --error-foreground: 0 0% 100%;
    --error-light: 0 84% 10%;
    --error-dark: 0 84% 50%;

    --info: 221 83% 53%;
    --info-foreground: 0 0% 100%;
    --info-light: 221 83% 10%;
    --info-dark: 221 83% 40%;

    /* Sidebar */
    --sidebar-background: 0 0% 3.9%;
    --sidebar-foreground: 0 0% 98%;
    --sidebar-primary: 0 0% 98%;
    --sidebar-primary-foreground: 0 0% 9%;
    --sidebar-accent: 0 0% 14.9%;
    --sidebar-accent-foreground: 0 0% 98%;
    --sidebar-border: 0 0% 14.9%;
    --sidebar-ring: 0 0% 83.1%;
  }
}

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

  body {
    @apply bg-background text-foreground;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    font-weight: var(--font-normal);
    letter-spacing: var(--tracking-normal);
    /* Improve mobile performance and prevent bounce scrolling */
    -webkit-font-smoothing: antialiased;
    font-smoothing: antialiased;
  }

  /* Typography Hierarchy */
  h1 {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tighter);
    background: linear-gradient(135deg, hsl(var(--foreground)), hsl(var(--foreground) / 0.7));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Removed inline-block which breaks flex layouts */
  }

  h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
  }

  h3 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
  }

  h4 {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    line-height: var(--leading-normal);
  }

  /* Respect reduced motion preference */
  @media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* Touch-friendly interactions */
  button,
  [role="button"],
  a {
    @apply touch-manipulation;
  }

  /* Prevent text selection on interactive elements */
  .sidebar-trigger {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Improve scrolling performance on mobile */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

@layer base {

  /* Hide all scrollbars globally */
  * {
    /* Hide scrollbar for Chrome, Safari, and Opera */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* Internet Explorer 10+ */
  }

  *::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
  }

  html {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* Internet Explorer 10+ */
  }

  html::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
  }

  body {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* Internet Explorer 10+ */
  }

  body::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
  }
}

@layer utilities {

  /* Onboarding Wizard Animations */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(24px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes fadeInDown {
    from {
      opacity: 0;
      transform: translateY(-16px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes scaleIn {
    from {
      opacity: 0;
      transform: scale(0.95);
    }

    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  @keyframes slideInFromRight {
    from {
      opacity: 0;
      transform: translateX(40px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes slideInFromLeft {
    from {
      opacity: 0;
      transform: translateX(-40px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes pulseSubtle {

    0%,
    100% {
      opacity: 1;
    }

    50% {
      opacity: 0.7;
    }
  }

  @keyframes progressFill {
    from {
      width: 0%;
    }
  }

  @keyframes checkmark {
    0% {
      stroke-dashoffset: 100;
    }

    100% {
      stroke-dashoffset: 0;
    }
  }

  @keyframes shimmer {
    0% {
      background-position: -200% 0;
    }

    100% {
      background-position: 200% 0;
    }
  }

  @keyframes float {

    0%,
    100% {
      transform: translateY(0);
    }

    50% {
      transform: translateY(-8px);
    }
  }

  .animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
  }

  .animate-fade-in-down {
    animation: fadeInDown 0.4s ease-out forwards;
  }

  .animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
  }

  .animate-slide-in-right {
    animation: slideInFromRight 0.5s ease-out forwards;
  }

  .animate-slide-in-left {
    animation: slideInFromLeft 0.5s ease-out forwards;
  }

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

  .animate-checkmark {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: checkmark 0.6s ease-out forwards;
  }

  .animate-shimmer {
    background: linear-gradient(90deg, transparent 0%, hsl(var(--primary) / 0.1) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
  }

  .animate-float {
    animation: float 3s ease-in-out infinite;
  }

  /* Premium Glass Effect */
  .glass-panel {
    background: linear-gradient(145deg, hsl(var(--card) / 0.9) 0%, hsl(var(--card) / 0.6) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid hsl(var(--border) / 0.5);
    box-shadow: 0 4px 24px -4px hsl(var(--foreground) / 0.05);
  }

  .dark .glass-panel {
    background: linear-gradient(145deg, hsl(var(--card) / 0.8) 0%, hsl(var(--card) / 0.4) 100%);
    border: 1px solid hsl(var(--border) / 0.3);
    box-shadow: 0 4px 24px -4px hsl(0 0% 0% / 0.5);
  }

  .glass-panel-hover:hover {
    border-color: hsl(var(--primary) / 0.3);
    box-shadow: 0 8px 32px -8px hsl(var(--primary) / 0.15);
    transform: translateY(-2px);
  }

  /* Staggered animation delays */
  .delay-75 {
    animation-delay: 75ms;
  }

  .delay-100 {
    animation-delay: 100ms;
  }

  .delay-150 {
    animation-delay: 150ms;
  }

  .delay-200 {
    animation-delay: 200ms;
  }

  .delay-300 {
    animation-delay: 300ms;
  }

  .delay-400 {
    animation-delay: 400ms;
  }

  .delay-500 {
    animation-delay: 500ms;
  }

  /* Onboarding specific styles */
  .onboarding-bg {
    background:
      radial-gradient(ellipse at 20% 0%, hsl(var(--primary) / 0.03) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 100%, hsl(var(--primary) / 0.02) 0%, transparent 50%),
      hsl(var(--background));
  }

  .dark .onboarding-bg {
    background:
      radial-gradient(ellipse at 20% 0%, hsl(var(--primary) / 0.05) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 100%, hsl(var(--primary) / 0.03) 0%, transparent 50%),
      hsl(var(--background));
  }

  .step-indicator-line {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .input-focus-ring {
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .input-focus-ring:focus-within {
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
  }

  /* Scrollbar utility: hide scrollbar (single definition) */
  .scrollbar-thin,
  .scrollbar-hide {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .scrollbar-thin::-webkit-scrollbar,
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  /* Safe area insets for mobile devices (notches, home indicators) */
  .safe-area-inset-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .safe-area-inset-top {
    padding-top: env(safe-area-inset-top);
  }

  .safe-area-inset-left {
    padding-left: env(safe-area-inset-left);
  }

  .safe-area-inset-right {
    padding-right: env(safe-area-inset-right);
  }

  /* Prevent zoom gestures in PWA - disable pinch zoom */
  html {
    touch-action: pan-x pan-y;
    -ms-touch-action: pan-x pan-y;
  }

  body {
    touch-action: pan-x pan-y;
    -ms-touch-action: pan-x pan-y;
    /* Prevent text selection on double tap (iOS) */
    -webkit-tap-highlight-color: transparent;
  }

  /* Allow text selection in input fields and text areas */
  input,
  textarea,
  [contenteditable="true"],
  [contenteditable="true"] * {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    touch-action: auto;
  }

  /* Prevent double-tap zoom on buttons and interactive elements */
  button,
  a,
  [role="button"],
  .clickable {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
  }

  /* Prevent iOS Safari bounce effect */
  html,
  body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }
}