@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 – neutral enterprise palette (SAP/Salesforce/Microsoft style). Clean grays, crisp blue primary */
    /* Main content – subtle off-white for card contrast */
    --background: 220 14% 98%;
    --foreground: 222 47% 11%;

    /* Header & cards – pure white for elevation */
    --card: 0 0% 100%;
    --card-foreground: 222 47% 11%;

    --popover: 0 0% 100%;
    --popover-foreground: 222 47% 11%;

    /* Primary – enterprise blue (#0a6ed1 SAP Fiori style) */
    --primary: 211 100% 43%;
    --primary-foreground: 0 0% 100%;

    --secondary: 220 14% 96%;
    --secondary-foreground: 222 47% 11%;

    --muted: 220 14% 96%;
    --muted-foreground: 220 9% 46%;

    --accent: 220 14% 96%;
    --accent-foreground: 222 47% 11%;

    --destructive: 0 65% 52%;
    --destructive-foreground: 0 0% 100%;

    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 211 100% 43%;

    /* Semantic – clear, professional */
    --success: 152 55% 38%;
    --success-foreground: 0 0% 100%;
    --success-light: 152 45% 94%;
    --success-dark: 152 55% 30%;

    --warning: 38 72% 48%;
    --warning-foreground: 0 0% 100%;
    --warning-light: 38 60% 94%;
    --warning-dark: 38 72% 38%;

    --error: 0 65% 50%;
    --error-foreground: 0 0% 100%;
    --error-light: 0 50% 95%;
    --error-dark: 0 65% 42%;

    --info: 211 100% 43%;
    --info-foreground: 0 0% 100%;
    --info-light: 211 60% 94%;
    --info-dark: 211 100% 36%;

    /* Sidebar – clean, slight tint for separation */
    --sidebar-background: 220 14% 98%;
    --sidebar-foreground: 222 47% 15%;
    --sidebar-primary: 211 100% 43%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 220 14% 94%;
    --sidebar-accent-foreground: 222 47% 11%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 211 100% 43%;

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

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

    /* 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;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 1rem;
    /* 16px */
    --text-lg: 1.125rem;
    /* 18px */
    --text-xl: 1.25rem;
    /* 20px */
    --text-2xl: 1.5rem;
    /* 24px */
    --text-3xl: 1.875rem;
    /* 30px */

    /* 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.025em;
    --tracking-tighter: -0.025em;
  }

  .dark {
    /* Updated dark mode: Neutral premium dark/black palette */
    /* Main surface - deep charcoal/black */
    --background: 0 0% 4%;
    /* Near black */
    --foreground: 0 0% 98%;
    /* Crisp white */

    /* Elevated surfaces - slightly lighter charcoal */
    --card: 0 0% 7%;
    --card-foreground: 0 0% 98%;

    --popover: 0 0% 8%;
    --popover-foreground: 0 0% 98%;

    /* Primary – enterprise blue variant for dark mode */
    --primary: 217 91% 60%;
    --primary-foreground: 0 0% 100%;

    --secondary: 240 5% 12%;
    --secondary-foreground: 0 0% 98%;

    --muted: 240 5% 10%;
    --muted-foreground: 240 5% 65%;

    --accent: 240 5% 15%;
    --accent-foreground: 0 0% 98%;

    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;

    --border: 240 5% 15%;
    --input: 240 5% 15%;
    --ring: 217 91% 60%;

    /* 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: 217 91% 60%;
    --info-foreground: 0 0% 100%;
    --info-light: 217 91% 10%;
    --info-dark: 217 91% 50%;

    /* Sidebar - neutral dark */
    --sidebar-background: 0 0% 6%;
    --sidebar-foreground: 0 0% 95%;
    --sidebar-primary: 217 91% 60%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 5% 12%;
    --sidebar-accent-foreground: 0 0% 98%;
    --sidebar-border: 240 5% 12%;
    --sidebar-ring: 217 91% 60%;
  }
}

@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-2xl);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tighter);
  }

  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;
  }

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