@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
  * {
    @apply border-border;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
  }

  html {
    @apply font-sans antialiased;
    --bc-color-brand: hsl(var(--primary));
    --bc-color-brand-dark: hsl(var(--primary));
    --bc-brand-mix: 100%;
    --bc-color-brand-button-text: hsl(var(--primary-foreground));
    --bc-color-brand-button-text-dark: hsl(var(--primary-foreground));
  }

  input,
  textarea,
  button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  body {
    @apply bg-background text-foreground;
    -webkit-overflow-scrolling: touch;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }

  body,
  html {
    overscroll-behavior-y: none;
  }

  .clickable {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;

    &:active {
      background-color: hsl(var(--muted) / 0.4);
    }
  }

  .tiptap p.is-editor-empty:first-child::before {
    color: hsl(var(--muted-foreground));
    content: attr(data-placeholder);
    float: left;
    height: 0;
    pointer-events: none;
  }

  .scrollbar-hide {
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    scrollbar-width: none; /* Firefox */
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
  }

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

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

  ::-webkit-scrollbar-thumb {
    background: hsl(var(--muted) / 0.5);
    border-radius: 4px;
    transition: background 0.2s ease;
  }

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

  @media (hover: hover) and (pointer: fine) {
    .clickable:hover {
      background-color: hsl(var(--muted) / 0.4);
    }
  }

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

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

  /* Light theme variables */
  :root, .light {
    --chrome-background: 0 0% 100%;
    --surface-background: 0 0% 98%;
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 38 92% 50%;
    --primary-hover: 38 92% 60%;
    --primary-foreground: 0 0% 10%;
    --secondary: 240 4.8% 94%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 94%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 94%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 92%;
    --input: 240 5.9% 90%;
    --ring: 38 92% 50%;
    --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%;
    --radius: 0.75rem;
  }
  /* System dark preference - apply dark theme by default */
  @media (prefers-color-scheme: dark) {
    :root:not(.light) {
      --chrome-background: 0 0% 0%;
      --surface-background: 240 10% 3.9%;
      --background: 0 0% 9%;
      --foreground: 0 0% 98%;
      --card: 0 0% 12%;
      --card-foreground: 0 0% 98%;
      --popover: 0 0% 12%;
      --popover-foreground: 0 0% 98%;
      --primary: 38 92% 50%;
      --primary-hover: 38 92% 60%;
      --primary-foreground: 240 5.9% 10%;
      --secondary: 240 3.7% 15.9%;
      --secondary-foreground: 0 0% 98%;
      --muted: 240 3.7% 15.9%;
      --muted-foreground: 240 5% 64.9%;
      --accent: 240 3.7% 15.9%;
      --accent-foreground: 0 0% 98%;
      --destructive: 0 62.8% 30.6%;
      --destructive-foreground: 0 0% 98%;
      --border: 240 3.7% 18%;
      --input: 240 3.7% 15.9%;
      --ring: 38 92% 50%;
      --chart-1: 220 70% 50%;
      --chart-2: 160 60% 45%;
      --chart-3: 30 80% 55%;
      --chart-4: 280 65% 60%;
      --chart-5: 340 75% 55%;
      --radius: 0.75rem;
    }
  }
  /* Explicit dark class override */
  .dark {
    --chrome-background: 0 0% 0%;
    --surface-background: 240 10% 3.9%;
    --background: 0 0% 9%;
    --foreground: 0 0% 98%;
    --card: 0 0% 12%;
    --card-foreground: 0 0% 98%;
    --popover: 0 0% 12%;
    --popover-foreground: 0 0% 98%;
    --primary: 38 92% 50%;
    --primary-hover: 38 92% 60%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 18%;
    --input: 240 3.7% 15.9%;
    --ring: 38 92% 50%;
    --chart-1: 220 70% 50%;
    --chart-2: 160 60% 45%;
    --chart-3: 30 80% 55%;
    --chart-4: 280 65% 60%;
    --chart-5: 340 75% 55%;
    --radius: 0.75rem;
  }
  .dark.pure-black {
    --surface-background: 0 0% 0%;
    --background: 0 0% 0%;
    --card: 0 0% 5%;
    --popover: 0 0% 5%;
  }

  .dark input[type='datetime-local']::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.5);
  }
}

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

@keyframes shake {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  10% {
    transform: translate(-1px, -1px) rotate(-1deg);
  }
  20% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  30% {
    transform: translate(-1px, 1px) rotate(-1deg);
  }
  40% {
    transform: translate(1px, 1px) rotate(1deg);
  }
  50% {
    transform: translate(-1px, -1px) rotate(-1deg);
  }
  60% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  70% {
    transform: translate(-1px, 1px) rotate(-1deg);
  }
  80% {
    transform: translate(1px, 1px) rotate(1deg);
  }
  90% {
    transform: translate(-1px, -1px) rotate(-1deg);
  }
}
