@import "tailwindcss";

@plugin "tailwindcss-animate";
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/typography";

/* v3 darkMode: "class" */
@custom-variant dark (&:where(.dark, .dark *));

/* v3 safelist: { pattern: /max-w-./, variants: "sm" } */
@source inline("{,sm:}max-w-{xs,sm,md,lg,xl,2xl,3xl,4xl,5xl,6xl,7xl,full}");

@theme {
  /* Brand */
  --color-brand: #00e6ca;
  --color-brand-light: #00e6ca;
  --color-brand-dark: #00c4b8;

  /* AI — the mark for generative features. Indigo rather than the brand teal on purpose: AI is a
     distinct modality, not brand chrome, and the brand tokens cannot carry it accessibly
     (brand-dark is 2.19:1 on white, under the 3:1 WCAG 1.4.11 floor for non-text). Indigo also
     already reads as "AI generated" in the auto-mapped pill under unify-feedback.
     Two tokens because one value cannot serve both grounds — pick with AiIcon's `tone`. */
  --color-ai-dark: var(--color-indigo-700); /* on light surfaces — 8.09:1 on white */
  --color-ai: var(--color-indigo-100); /* on dark surfaces — 14.49:1 on slate-900 */
  --color-ai-strong: var(--color-indigo-700); /* filled AI button — white on it is 8.02:1 */
  --color-ai-subtle: var(--color-indigo-100); /* soft AI button — ai-dark on it is 6.57:1 */

  --color-focus: var(--formbricks-focus, #1982fc);
  --color-brandnew: var(--formbricks-brand, #038178);

  --color-primary: #0f172a;
  --color-primary-foreground: #fefefe;

  /* Keyboard focus ring (`ring-ring`). Without it `ring-ring` generated nothing and rings fell back
     to the text colour: white on a primary button, so its focus was invisible on a white page.
     slate-500 is 4.76:1 on white, over the 3:1 WCAG 1.4.11 floor for non-text (slate-400 is not). */
  --color-ring: var(--color-slate-500);

  --color-destructive: #ff6b6b;
  --color-destructive-foreground: #fff5f5;

  --color-secondary: #f1f5f9;
  --color-secondary-foreground: #0f172a;

  --color-accent: #f4f6f8;
  --color-accent-foreground: #0f172a;

  /* info — Tailwind v3 blue palette */
  --color-info: #2563eb;
  --color-info-foreground: #1e3a8a;
  --color-info-muted: #1d4ed8;
  --color-info-background: #eff6ff;
  --color-info-background-muted: #dbeafe;

  /* warning — Tailwind v3 amber palette */
  --color-warning: #f59e0b;
  --color-warning-foreground: #78350f;
  --color-warning-muted: #b45309;
  --color-warning-background: #fffbeb;
  --color-warning-background-muted: #fef3c7;

  /* success — Tailwind v3 green palette */
  --color-success: #16a34a;
  --color-success-foreground: #14532d;
  --color-success-muted: #15803d;
  --color-success-background: #f0fdf4;
  --color-success-background-muted: #dcfce7;

  /* error — Tailwind v3 red palette */
  --color-error: #dc2626;
  --color-error-foreground: #7f1d1d;
  --color-error-muted: #b91c1c;
  --color-error-background: #fef2f2;
  --color-error-background-muted: #fee2e2;

  /* Box shadows */
  --shadow-card-sm: 0px 0.5px 12px -5px rgba(30, 41, 59, 0.2);
  --shadow-card-md: 0px 1px 25px -10px rgba(30, 41, 59, 0.3);
  --shadow-card-lg: 0px 2px 51px -19px rgba(30, 41, 59, 0.4);
  --shadow-card-xl: 0px 20px 25px -5px rgba(0, 0, 0, 0.1), 0px 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Breakpoints */
  --breakpoint-xs: 430px;

  /* max-w-8xl reads from the container scale */
  --container-8xl: 88rem;

  /* Animations */
  --animate-ping-slow: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  --animate-shake: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  --animate-accordion-down: accordion-down 0.2s ease-out;
  --animate-accordion-up: accordion-up 0.2s ease-out;
  --animate-collapsible-down: collapsible-down 0.2s ease-out;
  --animate-collapsible-up: collapsible-up 0.2s ease-out;
  --animate-fadeIn: fadeIn 0.2s ease-out;
  --animate-fadeOut: fadeOut 0.2s ease-out;
  --animate-surveyLoading: surveyLoadingAnimation 0.5s ease-out forwards;
  --animate-surveyExit: surveyExitAnimation 0.5s ease-out forwards;
  --animate-logo-scroll: logo-scroll 20s linear infinite;
  /* AI activity. Both rest at their start/end frame so the prefers-reduced-motion kill-switch below
     — which collapses duration to 0.01ms rather than removing the animation — lands on a correct
     static appearance instead of a stranded mid-animation pose. */
  --animate-ai-twinkle: ai-twinkle 1.1s ease-in-out infinite;
  --animate-ai-sweep: ai-sweep 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  --animate-ai-phase-in: ai-phase-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  --animate-ai-shimmer: ai-shimmer 1.8s linear infinite;

  @keyframes fadeIn {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
  @keyframes fadeOut {
    0% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }
  @keyframes shake {
    10%,
    90% {
      transform: translate3d(-1px, 0, 0);
    }
    20%,
    80% {
      transform: translate3d(2px, 0, 0);
    }
    30%,
    50%,
    70% {
      transform: translate3d(-4px, 0, 0);
    }
    40%,
    60% {
      transform: translate3d(4px, 0, 0);
    }
  }
  @keyframes accordion-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-accordion-content-height);
    }
  }
  @keyframes accordion-up {
    from {
      height: var(--radix-accordion-content-height);
    }
    to {
      height: 0;
    }
  }
  @keyframes collapsible-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-collapsible-content-height);
    }
  }
  @keyframes collapsible-up {
    from {
      height: var(--radix-collapsible-content-height);
    }
    to {
      height: 0;
    }
  }
  @keyframes surveyLoadingAnimation {
    0% {
      transform: translateY(50px);
      opacity: 0;
    }
    100% {
      transform: translateY(0);
      opacity: 1;
    }
  }
  @keyframes surveyExitAnimation {
    0% {
      transform: translateY(0);
      opacity: 1;
    }
    100% {
      transform: translateY(-50px);
      opacity: 0;
    }
  }
  @keyframes logo-scroll {
    0% {
      transform: translateX(0);
    }
    100% {
      transform: translateX(-50%);
    }
  }
  /* Transform-dominant rather than an opacity pulse: the skeleton rows that sit beside this while a
     draft streams are already animate-pulse, and two elements pulsing the same property beat against
     each other. Scaling a 16px svg is GPU-composited and reflows nothing. */
  @keyframes ai-twinkle {
    0%,
    100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.6;
      transform: scale(1.28);
    }
  }
  /* The bar is w-1/3, so -100% puts its right edge at the container's left edge and 300% puts its
     left edge at the right edge — it enters and exits fully. */
  /* Each new status phase arrives with a short fade and a hair of upward travel, so the line reads
     as progressing rather than as text being swapped underneath the reader. */
  @keyframes ai-phase-in {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  /* A light band travelling across the status text. Chosen over an opacity pulse because dimming
     slate-500 puts it under 4.5:1 at the trough; the gradient's lightest stop is slate-500 itself,
     so the text never drops below its normal contrast. */
  @keyframes ai-shimmer {
    from {
      background-position: 200% 0;
    }
    to {
      background-position: -200% 0;
    }
  }
  @keyframes ai-sweep {
    0% {
      transform: translateX(-100%);
    }
    100% {
      transform: translateX(300%);
    }
  }
}

/* AI status text shimmer. The colour is set unconditionally; only where background-clip: text is
   supported does the text become transparent so the moving gradient shows through. */
.ai-shimmer-text {
  color: var(--color-slate-500);
}

@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .ai-shimmer-text {
    background-image: linear-gradient(
      100deg,
      var(--color-slate-500) 0%,
      var(--color-slate-500) 35%,
      var(--color-slate-900) 50%,
      var(--color-slate-500) 65%,
      var(--color-slate-500) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: var(--animate-ai-shimmer);
  }
}

/* Named width utilities (v3 theme.extend.width) */
@utility w-sidebar-expanded {
  width: 4rem;
}
@utility w-sidebar-collapsed {
  width: 14rem;
}

/* v3 backgroundImage.gradient-radial */
@utility bg-gradient-radial {
  background-image: radial-gradient(var(--tw-gradient-stops));
}

/* Backdrop behind the signed-out (auth) screens. Before ENG-2428 this hex was inline on
   login and signup only, while the other auth routes showed a slate gradient. */
@utility bg-auth-backdrop {
  background-color: #d9f6f4;
}

/*
  The default border color has changed to `currentcolor` in Tailwind CSS v4,
  so we've added these compatibility styles to make sure everything still
  looks the same as it did with Tailwind CSS v3.

  If we ever want to remove these styles, we need to add an explicit border
  color utility to any element that depends on these defaults.
*/
@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-gray-200, currentcolor);
  }

  /*
    Tailwind CSS v4 removed the default `cursor: pointer` on buttons from
    Preflight. Restore the v3 behaviour for enabled buttons.
  */
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}

@utility no-scrollbar {
  /* Hide scrollbar for IE, Edge and Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera. Kept as a standalone selector rather than a nested
   `&::-webkit-scrollbar` inside the @utility: the nested form trips SonarCloud's "missing scoping
   root" on the bare `&`, and this is equivalent — both target elements carrying `.no-scrollbar`. */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

@layer utilities {
  :root {
    /* Brand Colors */
    --formbricks-brand: #038178;

    /* Fill Colors */
    --formbricks-fill-primary: #fefefe;
    --formbricks-fill-secondary: #0f172a;
    --formbricks-fill-disabled: #e0e0e0;

    /* Label Colors */
    --formbricks-label-primary: #0f172a;
    --formbricks-label-secondary: #384258;
    --formbricks-label-disabled: #bdbdbd;

    /* Border Colors */
    --formbricks-border-primary: #e0e0e0;
    --formbricks-border-secondary: #0f172a;
    --formbricks-border-disabled: #ececec;

    /* Functional Colors */
    --formbricks-focus: #1982fc;
    --formbricks-error: #d13a3a;
  }

  .dark {
    /* Brand Colors */
    --formbricks-brand: #038178;

    /* Fill Colors */
    --formbricks-fill-primary: #0f172a;
    --formbricks-fill-secondary: #e0e0e0;
    --formbricks-fill-disabled: #394258;

    /* Label Colors */
    --formbricks-label-primary: #fefefe;
    --formbricks-label-secondary: #f2f2f2;
    --formbricks-label-disabled: #bdbdbd;

    /* Border Colors */
    --formbricks-border-primary: #394258;
    --formbricks-border-secondary: #e0e0e0;
    --formbricks-border-disabled: #394258;

    /* Functional Colors */
    --formbricks-focus: #1982fc;
    --formbricks-error: #d13a3a;
  }
}

@layer base {
  [data-nextjs-scroll-focus-boundary] {
    display: contents;
  }
}

@layer utilities {
  /* Chrome, Edge, and Safari */
  *::-webkit-scrollbar {
    width: 7px;
    height: 7px;
  }

  *::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
  }

  *::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
  }

  .filter-scrollbar::-webkit-scrollbar {
    height: 7px;
  }

  .filter-scrollbar::-webkit-scrollbar-thumb {
    border-radius: 8px;
  }

  .filter-scrollbar::-webkit-scrollbar-track {
    border-radius: 8px;
  }

  /* Thin thumb on a transparent track, for scroll areas inside menus and popovers where the
     default grey track reads as a second frame. */
  .subtle-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
  }

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

  input:focus,
  textarea:focus {
    --tw-ring-color: none;
    --tw-ring-offset-color: none;
    --tw-ring-shadow: 0 0 #000 !important;
    box-shadow: none;
  }
}

/* Hide the clear button for input type "search" */
input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

input[type="search"]::-ms-clear {
  display: none;
}

input[type="search"]::-ms-reveal {
  display: none;
}

.surveyFilterDropdown[data-state="open"] {
  background-color: #0f172a;
  color: white;
}
.surveyFilterDropdown:hover * {
  background-color: #0f172a;
  color: white;
}

input[type="range"]::-webkit-slider-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  -webkit-appearance: none;
  background: #0f172a;
}

/* Respect prefers-reduced-motion for all CSS animations and transitions (tailwindcss-animate
   entry/exit classes included). Durations are collapsed to a near-zero value instead of
   `animation: none` so animationend/transitionend still fire; Radix primitives rely on them
   to unmount `animate-out` content. Kept unlayered so it wins over layered utilities. */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after,
  ::backdrop {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
