@layer theme, base, components, utilities;

/* HeroUI v3 Styles - Layered Theme Architecture */

/* Base layer - Tailwind CSS v4 */
@import "tailwindcss";
/* Not used by HeroUI overlays anymore (see base/overlay-motion.css); kept for consumers that rely on its utilities. */
@import "tw-animate-css";

/* Base styles */
@import "./base/base.css" layer(base);
@import "./base/scrollbar.css" layer(base);

/* Base component structures (unstyled) */
@import "./components/index.css" layer(components);

/* Default theme (variables + component customizations) */
@import "./themes/default/index.css" layer(theme);

/* Utilities */
@import "./utilities/index.css";

/* Variants */
@import "./variants/index.css";

@layer base {
  /* HeroUI Default Theme */

  /*
   * == Common Variables ==
   * Identical in every theme, so they are also declared on `:host`: `:root` matches
   * nothing inside a shadow tree, and the theme blocks below never re-declare these.
   */
  :root,
  :host {
    /* Primitive Colors (Do not change between light and dark) */
    --white: oklch(100% 0 0);
    --black: oklch(0% 0 0);
    --snow: oklch(0.9911 0 0);
    --eclipse: oklch(0.2103 0.0059 285.89);

    /* Spacing scale */
    --spacing: 0.25rem;

    /* Border */
    --border-width: 1px;
    --field-border-width: 0px;
    --disabled-opacity: 0.5;

    /* Ring offset - Used for focus ring */
    --ring-offset-width: 2px;

    /* Cursor */
    --cursor-interactive: pointer;
    --cursor-disabled: not-allowed;

    /* Radius */
    --radius: 0.5rem;
    --field-radius: calc(var(--radius) * 1.5);

    /* Accent and status hues (shared with the dark theme) */
    --accent: oklch(0.6204 0.195 253.83);
    --accent-foreground: var(--snow);

    --success: oklch(0.7329 0.1935 150.81);
    --success-foreground: var(--eclipse);

    /* no border by default on form fields */
    --field-border: transparent;

    /* Skeleton Default Global Animation */
    --skeleton-animation: shimmer; /* shimmer, pulse, none */

    /* Tooltip Default Delays */
    --tooltip-delay: 1500ms;
    --tooltip-close-delay: 500ms;
  }

  :root,
  .light,
  .default,
  [data-theme="light"],
  [data-theme="default"],
  :host(.light),
  :host(.default),
  :host([data-theme="light"]),
  :host([data-theme="default"]) {
    color-scheme: light;

    /* == Light Theme Variables == */

    /* Base Colors */
    --background: oklch(0.9702 0 0);
    --foreground: var(--eclipse);

    /* Surface: Used for non-overlay components (cards, accordions, disclosure groups) */
    --surface: var(--white);
    --surface-foreground: var(--foreground);

    --surface-secondary: oklch(0.9524 0.0013 286.37);
    --surface-secondary-foreground: var(--foreground);

    --surface-tertiary: oklch(0.9373 0.0013 286.37);
    --surface-tertiary-foreground: var(--foreground);

    /* Overlay: Used for floating/overlay components (tooltips, popovers, modals, menus) */
    --overlay: var(--white);
    --overlay-foreground: var(--foreground);

    --muted: oklch(0.5517 0.0138 285.94);

    --scrollbar: var(--scrollbar-thumb);
    --scrollbar-thumb: color-mix(in oklch, var(--foreground) 15%, transparent);
    --scrollbar-track: transparent;
    --scrollbar-gutter: auto;
    --scrollbar-width: thin;
    --scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);

    --default: oklch(94% 0.001 286.375);
    --default-foreground: var(--eclipse);

    /* Form Fields */
    --field-background: var(--white);
    --field-foreground: oklch(0.2103 0.0059 285.89);
    --field-placeholder: var(--muted);

    /* Status Colors */
    --warning: oklch(0.7819 0.1585 72.33);
    --warning-foreground: var(--eclipse);

    --danger: oklch(0.6532 0.2328 25.74);
    --danger-foreground: var(--snow);

    /* Component Colors */
    --segment: var(--white);
    --segment-foreground: var(--eclipse);

    /* Misc Colors */
    --border: oklch(90% 0.004 286.32);
    --separator: oklch(92% 0.004 286.32);
    --focus: var(--accent);
    --link: var(--foreground);

    /* Backdrop */
    --backdrop: rgba(0, 0, 0, 0.5);

    /* Calculated Colors */
    --surface-hover: color-mix(in oklab, var(--surface) 92%, var(--surface-foreground) 8%);

    --background-secondary: color-mix(in oklab, var(--background) 96%, var(--foreground) 4%);
    --background-tertiary: color-mix(in oklab, var(--background) 92%, var(--foreground) 8%);
    --background-inverse: var(--foreground);

    --default-hover: color-mix(in oklab, var(--default) 96%, var(--default-foreground) 4%);
    --accent-hover: color-mix(in oklab, var(--accent) 90%, var(--accent-foreground) 10%);
    --success-hover: color-mix(in oklab, var(--success) 90%, var(--success-foreground) 10%);
    --warning-hover: color-mix(in oklab, var(--warning) 90%, var(--warning-foreground) 10%);
    --danger-hover: color-mix(in oklab, var(--danger) 90%, var(--danger-foreground) 10%);

    --field-hover: color-mix(
      in oklab,
      var(--field-background, var(--default)) 90%,
      var(--field-foreground, var(--foreground)) 2%
    );
    --field-focus: var(--field-background, var(--default));
    --field-border-hover: color-mix(
      in oklab,
      var(--field-border, var(--border)) 88%,
      var(--field-foreground, var(--foreground)) 10%
    );
    --field-border-focus: color-mix(
      in oklab,
      var(--field-border, var(--border)) 74%,
      var(--field-foreground, var(--foreground)) 22%
    );

    --default-soft: color-mix(in oklab, var(--default) 50%, transparent);
    --default-soft-foreground: var(--default-foreground);
    --default-soft-hover: color-mix(in oklab, var(--default) 60%, transparent);

    --accent-soft: color-mix(in oklab, var(--accent) 15%, transparent);
    --accent-soft-foreground: color-mix(in oklab, var(--accent) 70%, var(--foreground) 30%);
    --accent-soft-hover: color-mix(in oklab, var(--accent) 20%, transparent);

    --danger-soft: color-mix(in oklab, var(--danger) 15%, transparent);
    --danger-soft-foreground: color-mix(in oklab, var(--danger) 70%, var(--foreground) 40%);
    --danger-soft-hover: color-mix(in oklab, var(--danger) 20%, transparent);

    --warning-soft: color-mix(in oklab, var(--warning) 15%, transparent);
    --warning-soft-foreground: color-mix(in oklab, var(--warning) 80%, var(--foreground) 70%);
    --warning-soft-hover: color-mix(in oklab, var(--warning) 20%, transparent);

    --success-soft: color-mix(in oklab, var(--success) 15%, transparent);
    --success-soft-foreground: color-mix(in oklab, var(--success) 80%, var(--foreground) 60%);
    --success-soft-hover: color-mix(in oklab, var(--success) 20%, transparent);

    --separator-secondary: color-mix(in oklab, var(--surface) 85%, var(--surface-foreground) 15%);
    --separator-tertiary: color-mix(in oklab, var(--surface) 81%, var(--surface-foreground) 19%);

    --border-secondary: color-mix(in oklab, var(--surface) 78%, var(--surface-foreground) 22%);
    --border-tertiary: color-mix(in oklab, var(--surface) 66%, var(--surface-foreground) 34%);

    /* Shadows */
    /* --surface-shadow: 0 0px 0px 0 rgba(24, 24, 27, 0.03), 0 2px 10px 0 rgba(24, 24, 27, 0.08); */
    --surface-shadow:
      0 2px 4px 0 rgba(0, 0, 0, 0.04), 0 1px 2px 0 rgba(0, 0, 0, 0.06),
      0 0 1px 0 rgba(0, 0, 0, 0.06);
    /* Overlay shadow */
    --overlay-shadow:
      0 2px 8px 0 rgba(0, 0, 0, 0.06), 0 -6px 12px 0 rgba(0, 0, 0, 0.03),
      0 14px 28px 0 rgba(0, 0, 0, 0.08);
    --field-shadow:
      0 2px 4px 0 rgba(0, 0, 0, 0.04), 0 1px 2px 0 rgba(0, 0, 0, 0.06),
      0 0 1px 0 rgba(0, 0, 0, 0.06);
  }

  .dark,
  [data-theme="dark"],
  :host(.dark),
  :host([data-theme="dark"]) {
    color-scheme: dark;
    /* == Dark Theme Variables == */

    /* Base Colors */
    --background: oklch(12% 0.005 285.823);
    --foreground: var(--snow);

    /* Surface: Used for non-overlay components (cards, accordions, disclosure groups) */
    --surface: oklch(0.2103 0.0059 285.89);
    --surface-foreground: var(--foreground);

    --surface-secondary: oklch(0.257 0.0037 286.14);
    --surface-secondary-foreground: var(--foreground);

    --surface-tertiary: oklch(0.2721 0.0024 247.91);
    --surface-tertiary-foreground: var(--foreground);

    /* Overlay: Used for floating/overlay components (tooltips, popovers, modals, menus) - lighter for contrast */
    --overlay: oklch(0.2103 0.0059 285.89);
    --overlay-foreground: var(--foreground);

    --muted: oklch(70.5% 0.015 286.067);

    --scrollbar: var(--scrollbar-thumb);
    --scrollbar-thumb: color-mix(in oklch, var(--foreground) 15%, transparent);
    --scrollbar-track: transparent;
    --scrollbar-gutter: auto;
    --scrollbar-width: thin;
    --scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);

    --default: oklch(27.4% 0.006 286.033);
    --default-foreground: var(--snow);

    /* Form Fields */
    --field-background: oklch(0.2103 0.0059 285.89);
    --field-foreground: var(--foreground);
    --field-placeholder: var(--muted);

    /* Status Colors */
    --warning: oklch(0.8203 0.1388 76.34);
    --warning-foreground: var(--eclipse);

    --danger: oklch(0.594 0.1967 24.63);
    --danger-foreground: var(--snow);

    /* Component Colors */
    --segment: oklch(0.3964 0.01 285.93);
    --segment-foreground: var(--foreground);

    /* Misc Colors */
    --border: oklch(28% 0.006 286.033);
    --separator: oklch(25% 0.006 286.033);
    --focus: var(--accent);
    --link: var(--foreground);

    /* Backdrop */
    --backdrop: rgba(0, 0, 0, 0.6);

    /* Shadows */
    --surface-shadow: 0 0 0 0 transparent inset; /* No shadow on dark mode */
    --overlay-shadow: 0 0 1px 0 rgba(255, 255, 255, 0.3) inset;
    --field-shadow: 0 0 0 0 transparent inset; /* Transparent shadow to allow ring utilities to work */

    /* Calculated Colors */
    --surface-hover: color-mix(in oklab, var(--surface) 92%, var(--surface-foreground) 8%);

    --background-secondary: color-mix(in oklab, var(--background) 96%, var(--foreground) 4%);
    --background-tertiary: color-mix(in oklab, var(--background) 92%, var(--foreground) 8%);
    --background-inverse: var(--foreground);

    --default-hover: color-mix(in oklab, var(--default) 96%, var(--default-foreground) 4%);
    --accent-hover: color-mix(in oklab, var(--accent) 90%, var(--accent-foreground) 10%);
    --success-hover: color-mix(in oklab, var(--success) 90%, var(--success-foreground) 10%);
    --warning-hover: color-mix(in oklab, var(--warning) 90%, var(--warning-foreground) 10%);
    --danger-hover: color-mix(in oklab, var(--danger) 90%, var(--danger-foreground) 10%);

    --field-hover: color-mix(
      in oklab,
      var(--field-background, var(--default)) 90%,
      var(--field-foreground, var(--foreground)) 2%
    );
    --field-focus: var(--field-background, var(--default));
    --field-border-hover: color-mix(
      in oklab,
      var(--field-border, var(--border)) 88%,
      var(--field-foreground, var(--foreground)) 10%
    );
    --field-border-focus: color-mix(
      in oklab,
      var(--field-border, var(--border)) 74%,
      var(--field-foreground, var(--foreground)) 22%
    );

    --default-soft: color-mix(in oklab, var(--default) 50%, transparent);
    --default-soft-foreground: var(--default-foreground);
    --default-soft-hover: color-mix(in oklab, var(--default) 60%, transparent);

    --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
    --accent-soft-foreground: color-mix(in oklab, var(--accent) 80%, var(--foreground) 30%);
    --accent-soft-hover: color-mix(in oklab, var(--accent) 16%, transparent);

    --danger-soft: color-mix(in oklab, var(--danger) 15%, transparent);
    --danger-soft-foreground: color-mix(in oklab, var(--danger) 80%, var(--foreground) 30%);
    --danger-soft-hover: color-mix(in oklab, var(--danger) 20%, transparent);

    --warning-soft: color-mix(in oklab, var(--warning) 12%, transparent);
    --warning-soft-foreground: color-mix(in oklab, var(--warning) 80%, var(--foreground) 30%);
    --warning-soft-hover: color-mix(in oklab, var(--warning) 16%, transparent);

    --success-soft: color-mix(in oklab, var(--success) 12%, transparent);
    --success-soft-foreground: color-mix(in oklab, var(--success) 80%, var(--foreground) 30%);
    --success-soft-hover: color-mix(in oklab, var(--success) 16%, transparent);

    --separator-secondary: color-mix(in oklab, var(--surface) 85%, var(--surface-foreground) 15%);
    --separator-tertiary: color-mix(in oklab, var(--surface) 81%, var(--surface-foreground) 19%);

    --border-secondary: color-mix(in oklab, var(--surface) 78%, var(--surface-foreground) 22%);
    --border-tertiary: color-mix(in oklab, var(--surface) 66%, var(--surface-foreground) 34%);
  }

  /* Vibrant palette - more saturated soft foregrounds, less contrast */
  [data-vibrant-palette="true"]:not(.dark):not([data-theme="dark"]) {
    --accent-soft-foreground: color-mix(in oklab, var(--accent) 92%, var(--foreground) 8%);
    --danger-soft-foreground: color-mix(in oklab, var(--danger) 92%, var(--foreground) 8%);
    --warning-soft-foreground: color-mix(in oklab, var(--warning) 92%, var(--foreground) 8%);
    --success-soft-foreground: color-mix(in oklab, var(--success) 92%, var(--foreground) 8%);
  }

  [data-vibrant-palette="true"].dark,
  [data-vibrant-palette="true"][data-theme="dark"] {
    --accent-soft-foreground: color-mix(in oklab, var(--accent) 92%, var(--foreground) 8%);
    --danger-soft-foreground: color-mix(in oklab, var(--danger) 92%, var(--foreground) 8%);
    --warning-soft-foreground: color-mix(in oklab, var(--warning) 92%, var(--foreground) 8%);
    --success-soft-foreground: color-mix(in oklab, var(--success) 92%, var(--foreground) 8%);
  }
}

/* Declares the theme variables - @see https://tailwindcss.com/docs/theme */
@import "../shared/theme.css";

/* Default Theme */
@import "./variables.css" layer(theme);

/* Component customizations for default theme */
@import "./components/index.css" layer(components);

/* ------------------------------------------------------------------------------------------------
 * Component Styles
 * ------------------------------------------------------------------------------------------------
 * CRITICAL: Import order matters for CSS specificity and style overrides.
 *
 * General Rule: Shared/primitive components MUST be imported FIRST, before components that use them.
 * This ensures that parent component styles can properly override shared component defaults.
 *
 * Organization: Components are grouped by their Storybook categories (Components/Category/Name)
 * to maintain consistency between documentation and implementation.
 * ------------------------------------------------------------------------------------------------ */

/* ------------------------------------------------------------------------------------------------
 * Shared Components - MUST Import FIRST
 * ------------------------------------------------------------------------------------------------
 * These are used by multiple components and must be imported early to allow proper overrides.
 * ------------------------------------------------------------------------------------------------ */
@import "./close-button.css";
@import "./description.css";
@import "./error-message.css";
@import "./field-error.css";
@import "./label.css";

/* ------------------------------------------------------------------------------------------------
 * Navigation
 * ------------------------------------------------------------------------------------------------ */
@import "./accordion.css";
@import "./breadcrumbs.css";
@import "./disclosure-group.css";
@import "./disclosure.css";
@import "./link.css";
@import "./pagination.css";
@import "./tabs.css";

/* ------------------------------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------------------------------ */
@import "./button.css";
@import "./button-group.css";
@import "./toggle-button.css";
@import "./toggle-button-group.css";
@import "./toolbar.css";

/* ------------------------------------------------------------------------------------------------
 * Collections
 * ------------------------------------------------------------------------------------------------ */
@import "./dropdown.css";
@import "./list-box-item.css";
@import "./list-box-section.css";
@import "./list-box.css";
@import "./menu-item.css";
@import "./menu-section.css";
@import "./menu.css";
@import "./tag-group.css";
@import "./tag.css";

/* ------------------------------------------------------------------------------------------------
 * Colors
 * ------------------------------------------------------------------------------------------------ */
@import "./color-area.css";
@import "./color-picker.css";
@import "./color-slider.css";
@import "./color-swatch.css";
@import "./color-swatch-picker.css";
@import "./color-input-group.css";
@import "./color-field.css";

/* ------------------------------------------------------------------------------------------------
 * Controls
 * ------------------------------------------------------------------------------------------------ */
@import "./slider.css";
@import "./switch.css";
@import "./switch-group.css";

/* ------------------------------------------------------------------------------------------------
 * DataDisplay
 * ------------------------------------------------------------------------------------------------ */
@import "./badge.css";
@import "./chip.css";
@import "./table.css";

/* ------------------------------------------------------------------------------------------------
 * Feedback
 * ------------------------------------------------------------------------------------------------ */
@import "./alert.css";
@import "./empty-state.css";
@import "./skeleton.css";
@import "./meter.css";
@import "./progress-bar.css";
@import "./progress-circle.css";
@import "./spinner.css";
@import "./toast.css";

/* ------------------------------------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------------------------------------ */
@import "./checkbox-group.css";
@import "./checkbox.css";
@import "./fieldset.css";
@import "./input-otp.css";
@import "./input.css";
@import "./input-group.css";
@import "./number-field.css";
@import "./radio-group.css";
@import "./radio.css";
@import "./textfield.css";
@import "./search-field.css";
@import "./textarea.css";

/* ------------------------------------------------------------------------------------------------
* Date & Time
* ------------------------------------------------------------------------------------------------ */
@import "./calendar.css";
@import "./range-calendar.css";
@import "./calendar-year-picker.css";
@import "./date-field.css";
@import "./time-field.css";
@import "./date-input-group.css";
@import "./date-picker.css";
@import "./date-range-picker.css";

/* ------------------------------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------------------------------ */
@import "./card.css";
@import "./header.css";
@import "./separator.css";
@import "./surface.css";

/* ------------------------------------------------------------------------------------------------
 * Media
 * ------------------------------------------------------------------------------------------------ */
@import "./avatar.css";
@import "./avatar-group.css";

/* ------------------------------------------------------------------------------------------------
 * Overlays
 * ------------------------------------------------------------------------------------------------ */
@import "./alert-dialog.css";
@import "./drawer.css";
@import "./sheet.css";
@import "./modal.css";
@import "./popover.css";
@import "./tooltip.css";

/* ------------------------------------------------------------------------------------------------
 * Pickers
 * ------------------------------------------------------------------------------------------------ */
@import "./combo-box.css";
@import "./select.css";
@import "./autocomplete.css";

/* ------------------------------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------------------------------ */
@import "./kbd.css";
@import "./typography.css";

/* ------------------------------------------------------------------------------------------------
 * Utilities
 * ------------------------------------------------------------------------------------------------ */
@import "./scroll-shadow.css";

/* Base accordion styles */
.accordion {
  @apply w-full;

  /* Performance optimization - contain layout changes */
  contain: layout style;
}

/* Accordion elements */
.accordion__body {
  @apply text-sm;
}

.accordion__body-inner {
  @apply px-4 pt-0 pb-4 text-muted;
}

.accordion__heading {
  @apply flex;
}

.accordion__indicator {
  @apply ms-auto size-4 shrink-0 text-muted;

  /**
   * Transitions
   */
  @apply transition duration-250 motion-reduce:transition-none;

  /* Expanded state for indicator rotation */
  &[data-expanded="true"] {
    @apply -rotate-180;
  }
}

/* Accordion Item - Separator styles */
.accordion__item {
  @apply relative border-none;
}

.accordion__item::after {
  content: "";
  @apply absolute start-0 bottom-0 h-px w-full rounded-xs bg-separator;
}

.accordion__item:last-child::after {
  content: none;
}

/* Hide separator when hideSeparator prop is set */
.accordion__item[data-hide-separator="true"]::after {
  display: none;
}
/* ------------------------------------ */

.accordion__trigger {
  cursor: var(--cursor-interactive);

  /* Base Styles */
  @apply flex flex-1 items-center justify-between px-4 py-4 text-start text-sm font-medium no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    opacity 150ms var(--ease-out),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /**
   * Hover state
   * CRITICAL: inside `@media (hover: hover)` this keys off `:hover` alone. React Aria writes
   * `data-hovered` on a render tick, so on pointer leave the attribute outlives the native
   * `:hover` by at least a frame; including it here keeps this background painted for that frame,
   * after a custom `hover:bg-*` override has already stopped matching, and the default color
   * flashes on top. `:hover` is the same signal Tailwind's `hover:` variant compiles to, so the
   * default and any override switch in lockstep. `data-hovered` is still on the element for
   * consumers who want to key their own styles off it.
   */
  @media (hover: hover) {
    &:hover:not([aria-expanded="true"]) {
      background-color: color-mix(in oklab, var(--foreground) 3%, transparent 90%);
    }
  }

  /* Pressed state */
  &[data-pressed="true"]:not([aria-expanded="true"]) {
  }

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled State */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.accordion__panel {
  opacity: 0;
  height: var(--disclosure-panel-height);
  overflow: clip;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    height 200ms var(--ease-out-quad),
    opacity 200ms var(--ease-out);
  @apply motion-reduce:transition-none;

  &[data-expanded="true"] {
    will-change: height, opacity;
    opacity: 1;
  }
}

/* Surface variant */
.accordion--surface {
  @apply bg-surface;
  border-radius: min(32px, var(--radius-3xl));

  .accordion__trigger {
    /* See the base trigger hover state for why `data-hovered` is left out here. */
    @media (hover: hover) {
      &:hover:not([aria-expanded="true"]) {
        @apply bg-default;
      }
    }
  }

  .accordion__item::after {
    @apply bg-surface-foreground/6;
  }
}

.accordion--surface .accordion__item {
  /* Surface variant separator styling */
  &::after {
    @apply start-[3%] w-[94%];
  }

  /* Special rounding for first and last items in surface variant */
  &:first-child [data-slot="accordion-trigger"] {
    border-start-start-radius: min(32px, var(--radius-3xl));
    border-start-end-radius: min(32px, var(--radius-3xl));
  }

  &:last-child:not(:has([data-slot="accordion-trigger"][aria-expanded="true"]))
    [data-slot="accordion-trigger"] {
    border-end-start-radius: min(32px, var(--radius-3xl));
    border-end-end-radius: min(32px, var(--radius-3xl));
  }
}

/* -------------------------------------------------------------------------------------------------
 * AlertDialog Component Styles
 * Block: alert-dialog
 * -----------------------------------------------------------------------------------------------*/

/**
 * Element: trigger - the element that opens the modal
 */
.alert-dialog__trigger {
  @apply inline-block;
  @apply cursor-(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Active/pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.97);
  }
}

/**
 * Element: backdrop - the overlay behind the dialog
 */
.alert-dialog__backdrop {
  @apply fixed inset-0 z-(--z-index-overlay);
  @apply flex flex-row items-center justify-center;
  @apply h-(--visual-viewport-height) w-full;

  /* Entering animation */
  &[data-entering="true"] {
    animation: heroui-overlay-fade-in 150ms var(--ease-out);
  }

  /* Exiting animation */
  &[data-exiting="true"] {
    animation: heroui-overlay-fade-out 100ms var(--ease-out);
  }

  /**
   * Reduce Animation
   * CRITICAL: motion-reduce must be AFTER animate for correct override specificity
   */
  &[data-exiting="true"],
  &[data-entering="true"] {
    @apply motion-reduce:animate-none;
  }
}

/**
 * Modifier: backdrop--transparent
 */
.alert-dialog__backdrop--transparent {
  @apply bg-transparent;
}

/**
 * Modifier: backdrop--opaque
 */
.alert-dialog__backdrop--opaque {
  @apply bg-backdrop;
}

/**
 * Modifier: backdrop--blur
 */
.alert-dialog__backdrop--blur {
  @apply bg-backdrop backdrop-blur-md;

  /*
   * A full-viewport backdrop-filter stalls mid-range mobile GPUs long enough
   * that the open animation is skipped. On touch devices, only skip the blur
   * while the backdrop is animating so the dim scrim fades on its own, then
   * apply the blur once the overlay has settled.
   */
  @media (hover: none) and (pointer: coarse) {
    &[data-entering="true"],
    &[data-exiting="true"] {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

/**
 * Element: container - the positioning wrapper for the modal
 */
.alert-dialog__container {
  @apply flex flex-col items-center;
  @apply h-(--visual-viewport-height) w-full min-w-0 flex-1;
  @apply p-4;
  @apply sm:w-fit sm:p-10;
  @apply pointer-events-none;

  /* Entering animation */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-105 250ms var(--ease-out-quad);

    &[data-placement="auto"] {
      animation-name: heroui-overlay-enter-105-y;

      @variant sm {
        animation-name: heroui-overlay-enter-105;
      }
    }

    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-105-ny;
    }

    &[data-placement="center"] {
      animation-name: heroui-overlay-enter-105;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-105-y;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-out-quad);
  }

  /**
   * Reduce Animation
   * CRITICAL: motion-reduce must be AFTER animate for correct override specificity
   */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement],
  &[data-entering="true"],
  &[data-entering="true"][data-placement] {
    @apply motion-reduce:animate-none;
  }
}

/**
 * Element: dialog - the content container for the modal
 */
.alert-dialog__dialog {
  @apply relative;
  @apply flex min-h-0 w-full flex-col;
  @apply max-h-full;
  @apply bg-overlay shadow-overlay outline-none;
  border-radius: min(32px, var(--radius-3xl));
  @apply p-6;
  @apply overflow-clip;
  @apply pointer-events-auto;

  &[data-placement="auto"] {
    @apply mt-auto;
    @apply sm:my-auto;
  }

  &[data-placement="center"] {
    @apply my-auto;
  }

  &[data-placement="bottom"] {
    @apply mt-auto;
  }

  &[data-placement="top"] {
    @apply mt-0;
  }
}

/**
 * Modifier: dialog--xs
 */
.alert-dialog__dialog--xs {
  @apply max-w-xs;
}

/**
 * Modifier: dialog--sm
 */
.alert-dialog__dialog--sm {
  @apply max-w-sm;
}

/**
 * Modifier: dialog--md
 */
.alert-dialog__dialog--md {
  @apply max-w-md;
}

/**
 * Modifier: dialog--lg
 */
.alert-dialog__dialog--lg {
  @apply max-w-lg;
}

/**
 * Modifier: dialog--cover
 */
.alert-dialog__dialog--cover {
  @apply h-full min-h-full w-full;
}

/**
 * Element: header - the top section with the title
 */
.alert-dialog__header {
  @apply flex flex-col gap-3;
  @apply mb-0;

  /* When header contains icon, use flex-col layout with gap */
  & > .modal__icon {
    @apply mb-0;
  }
}

/**
 * Element: heading - the main title text
 */
.alert-dialog__heading {
  @apply align-middle;
  @apply text-base font-medium text-foreground;
}

/**
 * Element: icon - the optional icon indicator
 */
.alert-dialog__icon {
  @apply flex items-center justify-center;
  @apply size-10 shrink-0;
  @apply rounded-3xl select-none;

  [data-slot="alert-dialog-default-icon"] {
    @apply box-content size-5;
  }
}

/**
 * Modifier: icon--default
 */
.alert-dialog__icon--default {
  @apply bg-default text-foreground;
}

/**
 * Modifier: icon--accent
 */
.alert-dialog__icon--accent {
  @apply bg-accent-soft text-accent-soft-foreground;
}

/**
 * Modifier: icon--success
 */
.alert-dialog__icon--success {
  @apply bg-success-soft text-success-soft-foreground;
}

/**
 * Modifier: icon--warning
 */
.alert-dialog__icon--warning {
  @apply bg-warning-soft text-warning-soft-foreground;
}

/**
 * Modifier: icon--danger
 */
.alert-dialog__icon--danger {
  @apply bg-danger-soft text-danger-soft-foreground;
}

/**
 * Element: body - the main content area
 */
.alert-dialog__body {
  @apply min-h-0 flex-1 scrollbar;
  @apply text-sm leading-[1.43] text-muted;
  @apply -m-[3px] my-0 p-[3px];
  @apply overflow-y-auto overscroll-contain;
  -webkit-overflow-scrolling: touch;
}

/**
 * Element: footer - the bottom action section
 */
.alert-dialog__footer {
  @apply flex flex-row flex-wrap items-center justify-end gap-2;
  @apply mt-0;
}

/**
 * Element: close-trigger - the optional x icon button to close the modal
 */
.alert-dialog__close-trigger {
  @apply absolute end-4 top-4;
}

/**
 * Elements Spacing
 */
.alert-dialog__header + .alert-dialog__body {
  @apply mt-2;
}

.alert-dialog__header + .alert-dialog__footer {
  @apply mt-5;
}

.alert-dialog__body + .alert-dialog__footer {
  @apply mt-5;
}

/* Alert component styles */

/* Base alert styles */
.alert {
  @apply flex w-full flex-row items-start justify-start gap-4 bg-surface px-4 py-3 shadow-surface;
  border-radius: min(32px, var(--radius-3xl));
}

/* Alert elements */
.alert__content {
  @apply flex h-full grow flex-col items-start;
}

.alert__indicator {
  @apply flex items-center justify-center p-1 select-none;

  [data-slot="alert-default-icon"] {
    @apply box-content size-4;
  }
}

.alert__title {
  @apply text-sm leading-6 font-medium;
}

.alert__description {
  @apply text-sm text-muted;
}

/* Variant modifiers */
.alert--default .alert__indicator {
  @apply text-foreground;
}

.alert--default .alert__title {
  @apply text-foreground;
}

.alert--accent .alert__indicator {
  @apply text-accent-soft-foreground;
}

.alert--accent .alert__title {
  @apply text-accent-soft-foreground;
}

.alert--success .alert__indicator {
  @apply text-success-soft-foreground;
}

.alert--success .alert__title {
  @apply text-success-soft-foreground;
}

.alert--warning .alert__indicator {
  @apply text-warning-soft-foreground;
}

.alert--warning .alert__title {
  @apply text-warning-soft-foreground;
}

.alert--danger .alert__indicator {
  @apply text-danger-soft-foreground;
}

.alert--danger .alert__title {
  @apply text-danger-soft-foreground;
}

/* Autocomplete styles */
.autocomplete {
  @apply flex flex-col gap-1;
}

.autocomplete__trigger {
  @apply relative isolate inline-flex min-h-9 rounded-field border bg-field px-3 py-2 text-sm text-field-foreground shadow-field outline-none select-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Add inline-end padding when indicator is present */
  &:has(.autocomplete__indicator) {
    @apply pe-7;
  }

  /* Hover state - exclude when clear button is hovered to prevent double hover effect */
  @media (hover: hover) {
    &:hover:not(:has(.autocomplete__clear-button:hover)),
    &[data-hovered="true"]:not(:has(.autocomplete__clear-button:hover)) {
      @apply bg-field-hover;
      border-color: var(--field-border-hover);
    }
  }

  /* Focus visible state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
    border-color: var(--field-border-focus);
    background-color: var(--field-focus);
  }

  /* Focus state */
  &:focus,
  &[data-focus="true"] {
  }

  /* Invalid state */
  .autocomplete[data-invalid="true"] &,
  .autocomplete[aria-invalid="true"] & {
    @apply status-invalid-field;
    background-color: var(--field-focus);
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* Variant property definitions */
.autocomplete--primary {
  /* Default styles */
}

.autocomplete--secondary .autocomplete__trigger {
  @apply shadow-none;
  background-color: var(--autocomplete-trigger-bg);

  --autocomplete-trigger-bg: var(--default);
  --autocomplete-trigger-bg-hover: var(--default-hover);
  --autocomplete-trigger-bg-focus: var(--default);

  /* Exclude when clear button is hovered to prevent double hover effect */
  @media (hover: hover) {
    &:hover:not(:has(.autocomplete__clear-button:hover)),
    &[data-hovered="true"]:not(:has(.autocomplete__clear-button:hover)) {
      background-color: var(--autocomplete-trigger-bg-hover);
    }
  }

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    background-color: var(--autocomplete-trigger-bg-focus);
  }

  &:focus,
  &[data-focus="true"] {
  }

  .autocomplete[data-invalid="true"] &,
  .autocomplete[aria-invalid="true"] & {
    background-color: var(--autocomplete-trigger-bg-focus);
  }
}

.autocomplete__value {
  @apply flex-1 text-start text-base wrap-break-word text-current sm:text-sm;

  &[data-placeholder="true"] {
    @apply text-field-placeholder;
  }

  /* Removes the list-box-item indicator element from the autocomplete value*/
  [data-slot="list-box-item-indicator"] {
    @apply hidden;
  }
}

.autocomplete__indicator {
  @apply absolute inset-y-0 end-2 my-auto flex shrink-0 items-center justify-center text-field-placeholder transition duration-150;

  /* Cursor */
  cursor: var(--cursor-interactive);

  &[data-open="true"] {
    @apply rotate-180;
  }

  &[data-slot="autocomplete-default-indicator"] {
    @apply size-4;
  }
}

/* Similar to popover content styles */
.autocomplete__popover {
  @apply flex w-(--trigger-width) max-w-(--trigger-width) origin-(--trigger-anchor-point) scroll-py-1 flex-col overflow-hidden overscroll-contain bg-overlay p-0 pt-2 text-sm outline-none;
  border-radius: min(32px, calc(var(--radius-2xl) + var(--spacing) * 1.5));
  box-shadow: var(--overlay-shadow);

  &:focus,
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 250ms var(--ease-out-fluid);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-out-quad);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /* Arrow styling */
  & [data-slot="popover-overlay-arrow"] {
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="popover-overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="popover-overlay-arrow"] {
    rotate: 90deg;
  }

  /* Listbox styles.
   * `min-h-0` + the popover's flex column let the list shrink below 320px when the
   * popover itself is constrained (e.g. inside a Modal, or a short viewport). Without
   * it the list keeps its full 320px and its overflow is clipped by the popover, making
   * the last options unreachable. */
  [data-slot="list-box"] {
    @apply max-h-[320px] min-h-0 scrollbar overflow-y-auto p-1.5 outline-none;
  }

  [data-slot="list-box-item"] {
    @apply px-2.5;

    /* list-box-item.css is imported earlier and at equal specificity, so the shorthand above
       would otherwise reset the room it reserves for the absolutely positioned indicator */
    &:has(.list-box-item__indicator) {
      @apply pe-7;
    }
  }

  /* Virtualized rows: react-aria's Virtualizer wraps each row in an absolutely-positioned
   * [role="presentation"] element whose width equals the scroll container's clientWidth
   * (which includes the list-box horizontal padding) while sitting inside the padded content
   * box. Without this, rows overflow the right padding and the hover background reaches the
   * popover edge. Subtract the horizontal padding (2 × p-1.5 = 12px) to keep rows aligned. */
  [role="presentation"] > [data-slot="list-box-item"] {
    width: calc(100% - var(--spacing) * 3);
  }

  /* As the popover closes fast in single-select mode, the default item indicator transition is not even visible - so we disable it only for single-select */
  [data-slot="list-box"]:not([aria-multiselectable="true"]) [data-slot="list-box-item-indicator"],
  [data-slot="list-box"]:not([aria-multiselectable="true"])
    [data-slot="list-box-item-indicator"]
    [data-slot="list-box-item-indicator--checkmark"] {
    @apply transition-none;
  }

  /* Search Field styles */
  [data-slot="search-field"] {
    @apply shrink-0 px-3 py-1 outline-none;
  }

  /* Empty State */
  [data-slot="empty-state"] {
    @apply text-center text-sm text-overlay-foreground/60;
  }
}

/* Full width modifier */
.autocomplete--full-width {
  @apply w-full;
}

.autocomplete__trigger--full-width {
  @apply w-full;
}

/* Clear Button styles */
.autocomplete__clear-button {
  @apply relative isolate inline-flex h-6 w-6 shrink-0 origin-center items-center justify-center rounded-xl p-1 text-muted select-none no-highlight;
  @apply me-0 size-5 shrink-0 self-center bg-transparent;

  /* Cursor */
  cursor: var(--cursor-interactive);

  @apply transform-gpu;

  /* Transition only when visible - disappears immediately when cleared */
  &:not([data-empty="true"]) {
    transition: opacity 150ms var(--ease-smooth);
    @apply motion-reduce:transition-none;
  }

  &[data-empty="true"] {
    @apply pointer-events-none opacity-0;
  }

  [data-slot="autocomplete-clear-button-icon"] {
    @apply size-3.5;
  }

  &:active,
  &[data-pressed="true"] {
  }

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default-hover;
    }
  }

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.93);
  }
}

/* ==========================================================================
   AvatarGroup - Stacked or grid layout for multiple avatars
   ========================================================================== */

.avatar-group {
  --avatar-group-overlap: 0.5rem;
  --avatar-group-seam: 2px;

  @apply inline-flex items-center;
}

/* Grid */
.avatar-group--grid {
  @apply flex-wrap gap-3;
}

.avatar-group:not(.avatar-group--grid) > .avatar + .avatar,
.avatar-group:not(.avatar-group--grid) > .avatar + .avatar-group__count {
  margin-inline-start: calc(-1 * var(--avatar-group-overlap, 0.5rem));
}

.avatar-group__count {
  @apply shrink-0;
}

/* --------------------------------------------------------------------------
   Overlap: ring
   -------------------------------------------------------------------------- */
.avatar-group--ring:not(.avatar-group--grid) > .avatar,
.avatar-group--ring:not(.avatar-group--grid) > .avatar-group__count {
  position: relative;
  box-shadow: 0 0 0 var(--avatar-group-seam, 2px) var(--background);
}

/* --------------------------------------------------------------------------
   Overlap: clip
   The seam traces the next avatar's own outline — its `--avatar-radius` grown
   by the seam width — so a themed `--radius` reshapes avatars and seams
   together. CSS has no rounded-rect mask image, so that outline is assembled
   from a tall bar, a wide bar and four corner arcs, then XOR-ed out of a fully
   opaque layer.
   Cut sits on the inline-end edge (LTR: right / RTL: left). Optical nudge uses
   padding-inline-end so fallback glyphs stay logical in both directions.
   -------------------------------------------------------------------------- */
.avatar-group--clip:not(.avatar-group--grid) > .avatar:not(:last-child) {
  --avatar-group-cut-size: calc(var(--avatar-size, 2.5rem) + 2 * var(--avatar-group-seam, 2px));
  /* Browsers clamp a border-radius at half the box, so clamp here too — a
     themed radius above that ceiling paints a circle, not an overshooting arc. */
  --avatar-group-cut-radius: calc(
    min(
        var(--avatar-radius, calc(var(--avatar-size, 2.5rem) / 2)),
        calc(var(--avatar-size, 2.5rem) / 2)
      ) +
      var(--avatar-group-seam, 2px)
  );
  --avatar-group-cut-diameter: calc(2 * var(--avatar-group-cut-radius));
  /* Length of the straight run between two corner arcs. Collapses to 0 on a
     circular avatar, which leaves the four arcs forming one circle. */
  --avatar-group-cut-span: calc(var(--avatar-group-cut-size) - var(--avatar-group-cut-diameter));
  --avatar-group-cut-x: calc(
    var(--avatar-size, 2.5rem) - var(--avatar-group-overlap, 0.5rem) - var(--avatar-group-seam, 2px)
  );
  --avatar-group-cut-y: calc(-1 * var(--avatar-group-seam, 2px));
  --avatar-group-cut-x2: calc(var(--avatar-group-cut-x) + var(--avatar-group-cut-span));
  --avatar-group-cut-y2: calc(var(--avatar-group-cut-y) + var(--avatar-group-cut-span));
  --avatar-group-cut-fill: linear-gradient(#000 0 0);
  --avatar-group-cut-arc: radial-gradient(circle closest-side, #000 99%, #0000);

  mask:
    var(--avatar-group-cut-fill) 0 0 / 100% 100% no-repeat exclude,
    var(--avatar-group-cut-fill) calc(var(--avatar-group-cut-x) + var(--avatar-group-cut-radius))
      var(--avatar-group-cut-y) / var(--avatar-group-cut-span) var(--avatar-group-cut-size)
      no-repeat add,
    var(--avatar-group-cut-fill) var(--avatar-group-cut-x)
      calc(var(--avatar-group-cut-y) + var(--avatar-group-cut-radius)) /
      var(--avatar-group-cut-size) var(--avatar-group-cut-span) no-repeat add,
    var(--avatar-group-cut-arc) var(--avatar-group-cut-x) var(--avatar-group-cut-y) /
      var(--avatar-group-cut-diameter) var(--avatar-group-cut-diameter) no-repeat add,
    var(--avatar-group-cut-arc) var(--avatar-group-cut-x2) var(--avatar-group-cut-y) /
      var(--avatar-group-cut-diameter) var(--avatar-group-cut-diameter) no-repeat add,
    var(--avatar-group-cut-arc) var(--avatar-group-cut-x) var(--avatar-group-cut-y2) /
      var(--avatar-group-cut-diameter) var(--avatar-group-cut-diameter) no-repeat add,
    var(--avatar-group-cut-arc) var(--avatar-group-cut-x2) var(--avatar-group-cut-y2) /
      var(--avatar-group-cut-diameter) var(--avatar-group-cut-diameter) no-repeat add;
}

.avatar-group--clip:not(.avatar-group--grid):dir(rtl) > .avatar:not(:last-child),
:dir(rtl) .avatar-group--clip:not(.avatar-group--grid) > .avatar:not(:last-child) {
  --avatar-group-cut-x: calc(
    var(--avatar-group-overlap, 0.5rem) - var(--avatar-size, 2.5rem) - var(--avatar-group-seam, 2px)
  );
}

.avatar-group--clip:not(.avatar-group--grid) > .avatar:not(:last-child) .avatar__fallback {
  box-sizing: border-box;
  padding-inline-end: calc(var(--avatar-group-overlap, 0.5rem) * 0.35);
}

/* Base avatar styles */
.avatar {
  /* Shape tokens. AvatarGroup's clip seam traces `--avatar-radius`, so the
     radius has to live in a custom property rather than a `rounded-*` utility.
     The steps are spelled out instead of read from `--radius-3xl` /
     `--radius-2xl`, which resolve once at `:root` and would ignore a scoped
     `--radius`. */
  --avatar-size: 2.5rem; /* size-10 — same as --md */
  --avatar-radius: calc(var(--radius) * 3); /* rounded-3xl */

  @apply relative flex size-10 shrink-0 items-center justify-center overflow-hidden bg-default;

  border-radius: var(--avatar-radius);
}

/* Avatar fallback element */
.avatar__fallback {
  @apply flex size-full items-center justify-center bg-default text-sm font-medium;
}

/* Avatar image element */
.avatar__image {
  @apply absolute inset-0 aspect-square size-full;

  /**
   * Transitions
   */
  @apply transition-opacity duration-250 motion-reduce:transition-none;
}

/* Size modifiers */
.avatar--sm {
  --avatar-size: 2rem; /* size-8 */
  --avatar-radius: calc(var(--radius) * 2); /* rounded-2xl */

  @apply size-8;

  .avatar__fallback {
    @apply text-xs;
  }
}

.avatar--md {
  /* No layout styles as this is the default size */
}

.avatar--lg {
  --avatar-size: 3rem; /* size-12 */

  @apply size-12;

  .avatar__fallback {
    @apply text-base;
  }
}

/* Color modifiers for fallback */
.avatar__fallback--accent {
  @apply text-accent-soft-foreground;
}

.avatar__fallback--default {
  @apply text-default-soft-foreground;
}

.avatar__fallback--success {
  @apply text-success-soft-foreground;
}

.avatar__fallback--warning {
  @apply text-warning-soft-foreground;
}

.avatar__fallback--danger {
  @apply text-danger-soft-foreground;
}

/* Variant modifiers */
.avatar--soft {
  @apply bg-transparent;
}

.avatar--soft .avatar__fallback--accent {
  @apply bg-accent-soft text-accent-soft-foreground;
}

.avatar--soft .avatar__fallback--success {
  @apply bg-success-soft text-success-soft-foreground;
}

.avatar--soft .avatar__fallback--warning {
  @apply bg-warning-soft text-warning-soft-foreground;
}

.avatar--soft .avatar__fallback--default {
  @apply bg-default-soft text-default-soft-foreground;
}

.avatar--soft .avatar__fallback--danger {
  @apply bg-danger-soft text-danger-soft-foreground;
}

/* ==========================================================================
   Badge - Small informational badges for displaying labels, statuses, and categories.
   ========================================================================== */

/* Base styles */
.badge {
  @apply inline-flex shrink-0 items-center justify-center gap-0.5 font-medium;

  /* Default size (matches --md) */
  @apply min-h-7 min-w-7 rounded-3xl text-xs leading-[1.34];

  /* Default tokens */
  --badge-bg: var(--default);
  --badge-fg: var(--default-foreground);
  --badge-border: var(--background);

  background-color: var(--badge-bg);
  color: var(--badge-fg);
  border: 1px solid var(--badge-border);
  background-clip: padding-box;
}

.badge__label {
  @apply px-0.5;
}

.badge-anchor {
  @apply relative inline-flex shrink-0;
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.badge--lg {
  @apply min-h-8 min-w-8 rounded-2xl text-sm leading-[1.43];
}

.badge--md {
  /* No styles as this is the default size */
}

.badge--sm {
  @apply min-h-4 min-w-4 rounded-xl text-[10px] leading-[1.34];
}

/* ==========================================================================
   Color variants - set foreground color
   ========================================================================== */

.badge--accent {
  --badge-fg: var(--accent-soft-foreground);
}

.badge--default {
  --badge-fg: var(--default-foreground);
}

.badge--success {
  --badge-fg: var(--success-soft-foreground);
}

.badge--warning {
  --badge-fg: var(--warning-soft-foreground);
}

.badge--danger {
  --badge-fg: var(--danger-soft-foreground);
}

/* ==========================================================================
   Variant styles
   ========================================================================== */

.badge--primary {
  /* Solid background - compound variants below handle bg/fg per color */
}

.badge--secondary {
  /* Default background with colored text - base behavior */
}

.badge--soft {
  /* Soft/muted background - compound variants below handle bg/fg per color */
}

/* ==========================================================================
   Placement variants
   ========================================================================== */

.badge--top-right {
  @apply absolute top-0 right-0;
  transform: translate(25%, -25%);
}

.badge--top-left {
  @apply absolute top-0 left-0;
  transform: translate(-25%, -25%);
}

.badge--bottom-right {
  @apply absolute right-0 bottom-0;
  transform: translate(25%, 25%);
}

.badge--bottom-left {
  @apply absolute bottom-0 left-0;
  transform: translate(-25%, 25%);
}

/* ==========================================================================
   Compound variants - Primary (solid background)
   ========================================================================== */

.badge--primary.badge--accent {
  --badge-bg: var(--accent);
  --badge-fg: var(--accent-foreground);
}

.badge--primary.badge--default {
  --badge-bg: var(--default);
  --badge-fg: var(--default-foreground);
}

.badge--primary.badge--success {
  --badge-bg: var(--success);
  --badge-fg: var(--success-foreground);
}

.badge--primary.badge--warning {
  --badge-bg: var(--warning);
  --badge-fg: var(--warning-foreground);
}

.badge--primary.badge--danger {
  --badge-bg: var(--danger);
  --badge-fg: var(--danger-foreground);
}

/* ==========================================================================
   Compound variants - Soft (muted background)
   ========================================================================== */

.badge--soft.badge--accent {
  --badge-bg: var(--accent-soft);
  --badge-fg: var(--accent-soft-foreground);
}

.badge--soft.badge--default {
  --badge-bg: var(--default-soft);
  --badge-fg: var(--default-soft-foreground);
}

.badge--soft.badge--success {
  --badge-bg: var(--success-soft);
  --badge-fg: var(--success-soft-foreground);
}

.badge--soft.badge--warning {
  --badge-bg: var(--warning-soft);
  --badge-fg: var(--warning-soft-foreground);
}

.badge--soft.badge--danger {
  --badge-bg: var(--danger-soft);
  --badge-fg: var(--danger-soft-foreground);
}

/* Base breadcrumbs container */
.breadcrumbs {
  @apply flex items-center gap-1.5;

  /* Breadcrumb link */
  .breadcrumbs__link {
    @apply relative text-sm leading-5 font-medium text-muted no-underline opacity-100;

    &:hover,
    &[data-hovered="true"] {
      @apply underline;
    }

    &[data-current="true"] {
      @apply text-link opacity-100;
    }
  }

  /* Breadcrumb item wrapper */
  .breadcrumbs__item {
    @apply flex shrink-0 items-center justify-center gap-1;
  }

  /* Separator icon */
  .breadcrumbs__separator {
    @apply size-3 text-muted rtl:rotate-180;
  }
}

/* ==========================================================================
   ButtonGroup - Groups related buttons together
   ========================================================================== */

/* Base button group styles */
.button-group {
  @apply inline-flex h-auto items-center justify-center gap-0;
}

/* ==========================================================================
   Orientation variants
   ========================================================================== */

.button-group--horizontal {
  @apply flex-row;
}

.button-group--vertical {
  @apply flex-col;
}

/* Remove border radius from all buttons in group */
.button-group .button {
  @apply rounded-none;
}

/* Apply border radius to first button (start edge) */
.button-group--horizontal .button:first-child {
  @apply rounded-s-3xl;
}

/* Apply border radius to last button (end edge) */
.button-group--horizontal .button:last-child {
  @apply rounded-e-3xl;
}

/* If only one button, apply both rounded edges */
.button-group--horizontal .button:first-child:last-child {
  @apply rounded-3xl;
}

/* Apply border radius to first button (top edge) in vertical */
.button-group--vertical .button:first-child {
  @apply rounded-t-3xl;
}

/* Apply border radius to last button (bottom edge) in vertical */
.button-group--vertical .button:last-child {
  @apply rounded-b-3xl;
}

/* If only one button in vertical, apply all rounded edges */
.button-group--vertical .button:first-child:last-child {
  @apply rounded-3xl;
}

/* Remove scale transform on active/pressed state for buttons in group */
.button-group .button:active,
.button-group .button[data-pressed="true"] {
  transform: none;
}

/* Raise focused button so its outward focus ring + gap shows above adjacent buttons */
.button-group .button:focus-visible:not([data-focused]),
.button-group .button[data-focus-visible="true"] {
  @apply z-10;
}

/* ==========================================================================
   Separator (compound component)
   ========================================================================== */

.button-group__separator {
  @apply rounded-sm bg-current opacity-15;
  position: absolute;
  pointer-events: none;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: opacity 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  /* Horizontal orientation - vertical divider */
  .button-group--horizontal & {
    inset-inline-start: -1px;
    top: 25%;
    width: 1px;
    height: 50%;
  }

  /* Vertical orientation - horizontal divider */
  .button-group--vertical & {
    inset-inline-start: 25%;
    top: -1px;
    width: 50%;
    height: 1px;
  }
}

/* ==========================================================================
   Outline button border handling
   ========================================================================== */

/* Remove adjacent borders from outline buttons in horizontal group */
/* First button: remove end border (right in LTR, left in RTL) */
.button-group--horizontal .button--outline:first-child {
  @apply border-e-0;
}

/* Last button: remove start border (left in LTR, right in RTL) */
.button-group--horizontal .button--outline:last-child {
  @apply border-s-0;
}

/* Middle buttons: remove both inline borders */
.button-group--horizontal .button--outline:not(:first-child):not(:last-child) {
  @apply border-x-0;
}

/* Remove adjacent borders from outline buttons in vertical group */
/* First button: remove bottom border */
.button-group--vertical .button--outline:first-child {
  @apply border-b-0;
}

/* Last button: remove top border */
.button-group--vertical .button--outline:last-child {
  @apply border-t-0;
}

/* Middle buttons: remove both block borders */
.button-group--vertical .button--outline:not(:first-child):not(:last-child) {
  @apply border-y-0;
}

/* ==========================================================================
   Full width modifier
   ========================================================================== */

.button-group--full-width {
  @apply w-full;
}

/* Button component styles */

/* Base button styles */
.button {
  @apply relative isolate inline-flex h-10 w-fit origin-center items-center justify-center gap-2 rounded-3xl px-4 text-sm font-medium whitespace-nowrap outline-none select-none no-highlight md:h-9;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-smooth),
    background-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Default tokens (fallback behavior) */
  --button-bg: transparent;
  --button-bg-hover: var(--button-bg);
  --button-bg-pressed: var(--button-bg-hover);
  --button-fg: currentColor;

  background-color: var(--button-bg);
  color: var(--button-fg);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Pending state */
  &[data-pending="true"] {
    @apply status-pending;
  }

  /* Active / pressed */
  &:active,
  &[data-pressed="true"] {
    @apply will-change-transform;
    background-color: var(--button-bg-pressed);
    transform: scale(0.97);
  }

  /* Hover */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      background-color: var(--button-bg-hover);
    }
  }

  /* SVG icon styling - exclude spinner and link-icon svgs */
  & svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
    @apply pointer-events-none -mx-0.5 my-0.5 size-5 shrink-0 self-center sm:my-1 sm:size-4;
  }
}

/* Size variants */
.button--sm {
  @apply h-9 px-3 md:h-8;

  & svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
    @apply size-4;
  }

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.98);
  }
}

.button--md {
  /* No styles as this is the default size */
}

.button--lg {
  @apply h-11 text-base md:h-10;

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.96);
  }
}

/* Color variants - only set custom property values */
.button--primary {
  --button-bg: var(--accent);
  --button-bg-hover: var(--accent-hover);
  --button-bg-pressed: var(--accent-hover);
  --button-fg: var(--accent-foreground);
}

.button--secondary {
  --button-bg: var(--default);
  --button-bg-hover: var(--default-hover);
  --button-bg-pressed: var(--default-hover);
  --button-fg: var(--accent-soft-foreground);
}

.button--tertiary {
  --button-bg: var(--default);
  --button-bg-hover: var(--default-hover);
  --button-bg-pressed: var(--default-hover);
}

.button--ghost,
.button--outline {
  --button-bg: transparent;
  --button-bg-hover: var(--default);
  --button-bg-pressed: var(--default);
  --button-fg: var(--default-foreground);
}

.button--outline {
  @apply border border-border;
  --button-bg-hover: color-mix(in srgb, var(--default) 60%, transparent);
}

.button--danger {
  --button-bg: var(--danger);
  --button-bg-hover: var(--danger-hover);
  --button-bg-pressed: var(--danger-hover);
  --button-fg: var(--danger-foreground);
}

.button--danger-soft {
  --button-bg: var(--danger-soft);
  --button-bg-hover: var(--danger-soft-hover);
  --button-bg-pressed: var(--danger-soft-hover);
  --button-fg: var(--danger-soft-foreground);
}

/* Icon-only modifier */
.button--icon-only {
  @apply w-10 p-0 md:w-9;
}

.button--icon-only.button--sm {
  @apply w-9 md:w-8;
}

.button--icon-only.button--lg {
  @apply w-11 md:w-10;
}

/* Full width modifier */
.button--full-width {
  @apply w-full;
}

/* =============================================================================
 * Calendar Year Picker Component Styles
 *
 * Internal component used inside Calendar / RangeCalendar to provide a
 * toggleable year selector. Uses CSS :has() on the parent .calendar to
 * drive crossfade transitions.
 *
 * The year grid is absolutely positioned and sized via JS to match the
 * day grid's exact area. This keeps the calendar's original block layout
 * completely untouched.
 *
 * BEM naming: calendar-year-picker__element, calendar-year-picker--modifier
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * Positioning Context
 * -------------------------------------------------------------------------- */
.calendar:has(.calendar-year-picker__year-grid),
.range-calendar:has(.calendar-year-picker__year-grid) {
  position: relative;
}

/* -----------------------------------------------------------------------------
 * Crossfade + Blur Transitions
 *
 * The crossfade is staggered to avoid both grids being semi-transparent at
 * the same time (ghosting). When opening, the day grid fades out first,
 * then the year grid fades in. When closing, the year grid fades out first,
 * then the day grid fades in (via transition-delay).
 *
 * -------------------------------------------------------------------------- */

/* Day grid – default visible */
.calendar:has(.calendar-year-picker__year-grid) > [data-slot="calendar-grid"],
.range-calendar:has(.calendar-year-picker__year-grid) > [data-slot="range-calendar-grid"] {
  will-change: opacity;
  transition:
    opacity 150ms var(--ease-out),
    visibility 0ms linear;
  @apply motion-reduce:transition-none;
}

/* Day grid – hidden when year picker is open (fade + blur out) */
.calendar:has(.calendar-year-picker__year-grid[data-open="true"]) > [data-slot="calendar-grid"],
.range-calendar:has(.calendar-year-picker__year-grid[data-open="true"])
  > [data-slot="range-calendar-grid"] {
  @apply pointer-events-none opacity-0;
  visibility: hidden;
  transition:
    opacity 150ms var(--ease-out),
    visibility 0ms linear 150ms;
  @apply motion-reduce:transition-none;
}

/* -----------------------------------------------------------------------------
 * Trigger Button
 * -------------------------------------------------------------------------- */
.calendar-year-picker__trigger {
  @apply flex flex-1 items-center justify-start gap-1 rounded-lg outline-none;

  cursor: var(--cursor-interactive);
  touch-action: manipulation;

  /* Focus state */
  &:focus-visible {
    @apply status-focused;
  }
}

.calendar-year-picker__trigger-heading {
  @apply text-sm font-medium;

  transition: color 150ms var(--ease-out);
  @apply motion-reduce:transition-none;
}

.calendar-year-picker__trigger-indicator {
  @apply text-xs text-accent-soft-foreground rtl:[transform:rotate(180deg)];

  transition: transform 150ms var(--ease-out);
  @apply motion-reduce:transition-none;
}

/* Rotate chevron when open */
.calendar-year-picker__trigger[data-open="true"] .calendar-year-picker__trigger-indicator {
  transform: rotate(90deg);
}

.calendar-year-picker__trigger[data-open="true"] .calendar-year-picker__trigger-heading {
  @apply text-accent-soft-foreground;
}

/* -----------------------------------------------------------------------------
 * Year Grid Container
 *
 * Absolutely positioned over the day grid area. The exact `top` and `height`
 * are set via JS to match the sibling day grid element.
 * -------------------------------------------------------------------------- */
.calendar-year-picker__year-grid {
  @apply pointer-events-none absolute start-0 end-0 grid scrollbar content-start gap-1 overflow-y-auto p-1 opacity-0;
  grid-template-columns: repeat(3, 1fr);

  /* When closing: instant (no transition) */
  will-change: opacity;
}

.calendar-year-picker__year-grid[data-open="true"] {
  @apply pointer-events-auto opacity-100;

  /* When opening: slight delay so the day grid starts fading out first */
  transition: opacity 200ms var(--ease-out) 50ms;
  @apply motion-reduce:transition-none;
}

/* -----------------------------------------------------------------------------
 * Year Cell
 * -------------------------------------------------------------------------- */
.calendar-year-picker__year-cell {
  @apply relative inline-flex h-8 items-center justify-center rounded-3xl px-2.5 text-sm font-medium outline-none select-none no-highlight;
  touch-action: manipulation;

  /**
   * Transitions – same as .tag
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 100ms var(--ease-smooth),
    scale 100ms var(--ease-smooth),
    opacity 100ms var(--ease-smooth),
    background-color 100ms var(--ease-smooth),
    box-shadow 100ms var(--ease-out);
  @apply origin-center transform-gpu motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Hover state (when not selected) – only on devices that support hover */
  @media (hover: hover) and (pointer: fine) {
    &:is(:hover, [data-hovered="true"]):not([data-selected="true"]) {
      @apply bg-default text-default-foreground;
    }
  }

  /* Selected state (current year) – same as .tag[data-selected] */
  &[data-selected="true"],
  &[aria-selected="true"] {
    @apply bg-accent text-accent-foreground;

    @media (hover: hover) and (pointer: fine) {
      &:is(:hover, [data-hovered="true"]) {
        @apply bg-accent-hover;
      }
    }
  }

  /* Focus state */
  &:focus-visible {
    @apply status-focused;
  }
}

/* =============================================================================
 * Calendar Component Styles
 *
 * A compound component for date selection.
 * Uses BEM naming convention: calendar, calendar__element, calendar--modifier
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * Base Calendar Styles
 * -------------------------------------------------------------------------- */
.calendar {
  @apply w-63 max-w-63;

  container-type: inline-size;
}

/* Week view – visibleDuration={{ weeks: n }} */
.calendar--week-view {
  .calendar__cell {
    /* Keep cells circular on the 7-column grid; only filled cells take space. */
    @apply aspect-square size-auto w-full place-self-center;
  }
}

/* Day view – visibleDuration={{ days: n }} */
.calendar--day-view {
  .calendar__cell {
    @apply aspect-square size-auto w-full place-self-center;
  }

  /*
   * Isolate header and body into separate 7-column grids. With display:contents
   * on the root grid, fewer than 7 weekday headers flow into the same row as dates.
   */
  .calendar__grid {
    display: flex;
    flex-direction: column;
  }

  .calendar__grid-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    @apply w-full;

    & > tr {
      display: contents;
    }
  }

  .calendar__grid-body {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    @apply mt-1 w-full;

    & > tr {
      display: contents;
    }

    & > tr:first-child > td {
      @apply mt-0;
    }
  }
}

/* -----------------------------------------------------------------------------
 * Calendar Header
 * -------------------------------------------------------------------------- */
.calendar__header {
  @apply flex items-center justify-between px-0.5 pb-4;

  &:has(.calendar-year-picker__trigger[data-open="true"]) {
    .calendar__nav-button {
      @apply pointer-events-none opacity-0;
    }
  }
}

.calendar__heading {
  @apply flex-1 text-sm font-medium;
}

.calendar__nav-button {
  @apply flex size-6 items-center justify-center rounded-2xl text-accent-soft-foreground;

  will-change: scale;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out),
    background-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out),
    opacity 150ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Hover state – only on devices that support hover (avoids false triggers on touch) */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default text-accent-soft-foreground;
    }
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.95);
  }

  /* Focus state */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

.calendar__nav-button-icon {
  @apply size-4 rtl:rotate-180;
}

/* -----------------------------------------------------------------------------
 * Calendar Grid
 * -------------------------------------------------------------------------- */
.calendar__grid {
  /* Override table display with CSS Grid for easier customization */
  display: grid;
  /*
   * `minmax(0, 1fr)` instead of `1fr` so columns stay equal and never grow to fit
   * their content. `1fr` alone is `minmax(auto, 1fr)`, which lets long weekday labels
   * (e.g. pt-PT "domingo", "segunda") widen their column past the fixed calendar width.
   */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  @apply w-full;

  &[aria-readonly="true"] {
    .calendar__cell {
      @apply pointer-events-none;
    }
  }
}

.calendar__grid-header {
  /* Grid header (thead) styles */
  display: contents;

  & > tr {
    display: contents;
  }
}

.calendar__grid-body {
  /* Grid body (tbody) styles */
  display: contents;

  & > tr {
    display: contents;
  }

  /* Add top spacing between header and first body row */
  & > tr:first-child > td {
    @apply mt-1;
  }
}

.calendar__grid-row {
  /* Use 'contents' so cells participate directly in grid */
  /* Note: This class can be used for custom row styling if needed */
  display: contents;
}

.calendar__header-cell {
  /* Header cell (th - weekday names) styles */
  /*
   * Block (not flex) so `truncate` can apply an ellipsis to the label text when a
   * locale's weekday name is wider than the column, instead of letting labels overflow
   * and run into each other.
   */
  @apply block min-w-0 truncate pb-2 text-center text-xs font-medium text-muted;
}

/* -----------------------------------------------------------------------------
 * Calendar Cells
 * -------------------------------------------------------------------------- */
.calendar__cell {
  /* Cell (td) wrapper styles - margins now work with grid layout */
  @apply relative flex aspect-square size-full items-center justify-center rounded-3xl text-center text-sm font-medium outline-none no-highlight;

  will-change: scale;
  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Today indicator */
  &[data-today="true"] {
    @apply bg-accent-soft text-accent-soft-foreground;

    @media (hover: hover) {
      &:hover:not([data-selected="true"]),
      &[data-hovered="true"]:not([data-selected="true"]) {
        @apply bg-accent-soft-hover;
      }
    }
  }

  /* Selected state */
  &[data-selected="true"] {
    @apply bg-accent text-accent-foreground;
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    @apply bg-default;
    transform: scale(0.95);

    &[data-selected="true"] {
      @apply bg-accent-hover;
    }
  }

  /* Hover state – only on devices that support hover (avoids false triggers on touch) */
  @media (hover: hover) {
    &:hover:not([data-selected="true"]),
    &[data-hovered="true"]:not([data-selected="true"]) {
      @apply bg-default;
    }
  }

  /* Outside month (previous/next month days) */
  &[data-outside-month="true"] {
    @apply text-muted opacity-50;
  }

  &[data-selected="true"][data-outside-month="true"] {
    @apply bg-default;
  }

  /* Unavailable dates */
  &[data-unavailable="true"] {
    @apply status-disabled;
  }

  /* Disabled state */
  &:disabled:not([data-outside-month="true"]),
  &[data-disabled="true"]:not([data-outside-month="true"]) {
    @apply status-disabled;

    text-decoration: line-through;
  }
}

/* Cell indicator - small dot at bottom center of cell */
.calendar__cell-indicator {
  @apply absolute bottom-1 left-1/2 size-[3px] -translate-x-1/2 rounded-xs bg-muted;

  /* Indicator color changes when cell is selected */
  [data-selected="true"] > & {
    @apply bg-accent-foreground;
  }
}

/* Card component styles */

/* Block */
.card {
  @apply relative flex flex-col gap-3 overflow-visible p-4;
  @apply shadow-surface;
  border-radius: min(32px, var(--radius-3xl));
}

/* Element - header */
.card__header {
  @apply flex flex-col;
}

/* Element - title */
.card__title {
  @apply text-sm leading-6 font-medium text-foreground;
}

/* Element - description */
.card__description {
  @apply text-sm leading-5 text-muted;
}

/* Element - content */
.card__content {
  @apply flex flex-1 flex-col gap-1;
}

/* Element - footer */
.card__footer {
  @apply flex flex-row items-center;
}

/* Modifier - variant */

.card--transparent {
  @apply border-none bg-transparent shadow-none;
}

.card--default {
  @apply bg-surface;
}

.card--secondary {
  @apply bg-surface-secondary;
}

.card--tertiary {
  @apply bg-surface-tertiary;
}

.checkbox-group {
  @apply flex flex-col;

  [data-slot="checkbox"] {
    @apply mt-4;
  }
}

/* ==========================================================================
   Base checkbox styles
   ========================================================================== */

.checkbox {
  @apply flex flex-col items-start gap-1 outline-none no-highlight;

  cursor: var(--cursor-interactive);

  /* Field-level help text (siblings of the button), indented to align under the label */
  & > [data-slot="description"],
  & > [data-slot="field-error"] {
    @apply w-full min-w-0 cursor-default ps-7 text-xs text-wrap wrap-break-word text-muted select-none;
  }

  [data-slot="label"] {
    @apply select-none;
  }

  .checkbox__content [data-slot="label"] {
    cursor: var(--cursor-interactive);
  }

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;

    [data-slot="description"],
    [data-slot="field-error"] {
      @apply status-disabled;
    }
  }

  /* Indicator styles */
  &[data-selected="true"],
  &[data-indeterminate="true"] {
    .checkbox__indicator {
      border-color: var(--accent-foreground);
    }
  }

  /* Checkmark SVG indicator */
  [data-slot="checkbox-default-indicator--checkmark"] {
    @apply size-2.5 stroke-[2.5px] text-accent-foreground;

    /**
     * Transitions
     */
    @apply transition-all duration-200 motion-reduce:transition-none;
  }

  &[data-selected="true"] [data-slot="checkbox-default-indicator--checkmark"] {
    transition: stroke-dashoffset 150ms linear 15ms;
  }

  /* Invalid + Selected: checkmark icon color */
  &[data-invalid="true"][data-selected="true"] [data-slot="checkbox-default-indicator--checkmark"],
  &[data-invalid="true"][aria-checked="true"] [data-slot="checkbox-default-indicator--checkmark"],
  &[aria-invalid="true"][data-selected="true"] [data-slot="checkbox-default-indicator--checkmark"],
  &[aria-invalid="true"][aria-checked="true"] [data-slot="checkbox-default-indicator--checkmark"] {
    @apply text-danger-foreground;
  }

  /* Indeterminate line indicator */
  [data-slot="checkbox-default-indicator--indeterminate"] {
    @apply absolute size-3 text-accent-foreground opacity-0;

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: opacity 200ms var(--ease-linear);
    @apply motion-reduce:transition-none;
  }

  &[data-indeterminate="true"] [data-slot="checkbox-default-indicator--indeterminate"] {
    @apply opacity-100;
  }

  /* Invalid + Indeterminate: indeterminate icon color */
  &[data-indeterminate="true"][data-invalid="true"]
    [data-slot="checkbox-default-indicator--indeterminate"],
  &[data-indeterminate="true"][aria-invalid="true"]
    [data-slot="checkbox-default-indicator--indeterminate"] {
    @apply text-danger-foreground;
  }
}

/* ==========================================================================
   Checkbox control (the square button)
   ========================================================================== */

.checkbox__control {
  @apply relative inline-flex size-4 shrink-0 items-center justify-center overflow-hidden rounded-md border [border-width:var(--border-width-field)] border-field-border bg-field shadow-field outline-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    transform 100ms var(--ease-out);
  @apply motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Background indicator pseudo-element */
  &::before {
    @apply pointer-events-none absolute inset-0 z-0 origin-center scale-70 rounded-md bg-accent opacity-0 content-[''];

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition:
      scale 100ms var(--ease-linear),
      opacity 200ms var(--ease-linear),
      background-color 200ms var(--ease-out);
    @apply motion-reduce:transition-none;
  }

  /* Interactive states */
  /* Focus */
  .checkbox:focus-visible &,
  .checkbox:has([data-slot="checkbox-content"][data-focus-visible="true"]) &,
  .checkbox [data-slot="checkbox-content"][data-focus-visible="true"] & {
    @apply status-focused;
  }

  /* Hover */
  .checkbox:hover &,
  .checkbox:has([data-slot="checkbox-content"][data-hovered="true"]) &,
  .checkbox [data-slot="checkbox-content"][data-hovered="true"] & {
    @apply border-field-border-hover;

    &::before {
      @apply bg-accent-hover;
    }
  }

  /* Pressed */
  .checkbox:active &,
  .checkbox:has([data-slot="checkbox-content"][data-pressed="true"]) &,
  .checkbox [data-slot="checkbox-content"][data-pressed="true"] & {
  }

  /* Selection states */
  /* Selected */
  .checkbox[aria-checked="true"] &,
  .checkbox[data-selected="true"] & {
    @apply border-transparent text-accent-foreground;

    &::before {
      @apply scale-100 opacity-100;
    }
  }

  /* Indeterminate */
  .checkbox[data-indeterminate="true"] & {
    @apply text-accent-foreground;

    &::before {
      @apply scale-100 opacity-100;
    }
  }

  /* Indeterminate + Pressed */
  .checkbox:active[data-indeterminate="true"] &,
  .checkbox[data-pressed="true"][data-indeterminate="true"] &,
  .checkbox:has([data-slot="checkbox-content"][data-pressed="true"])[data-indeterminate="true"] & {
    &::before {
      @apply bg-accent-hover;
    }
  }

  /* Validation states */
  /* Invalid (only when not selected/indeterminate) */
  .checkbox[data-invalid="true"]:not([aria-checked="true"]):not([data-selected="true"]):not(
      [data-indeterminate="true"]
    )
    &,
  .checkbox[aria-invalid="true"]:not([aria-checked="true"]):not([data-selected="true"]):not(
      [data-indeterminate="true"]
    )
    & {
    @apply status-invalid-field;
  }

  /* Invalid + Selected */
  .checkbox[data-invalid="true"][aria-checked="true"] &,
  .checkbox[data-invalid="true"][data-selected="true"] &,
  .checkbox[aria-invalid="true"][aria-checked="true"] &,
  .checkbox[aria-invalid="true"][data-selected="true"] & {
    @apply border-transparent bg-danger text-danger-foreground;

    &::before {
      @apply scale-100 bg-danger opacity-100;
    }
  }

  /* Invalid + Indeterminate */
  .checkbox[data-indeterminate="true"][aria-invalid="true"] &,
  .checkbox[data-indeterminate="true"][data-invalid="true"] & {
    @apply text-danger-foreground;

    &::before {
      @apply bg-danger;
    }
  }
}

/* ==========================================================================
   Checkbox indicator
   ========================================================================== */

.checkbox__indicator {
  @apply relative z-10 flex size-3 items-center justify-center;

  & svg {
    @apply size-full transform-gpu;
  }
}

/* ==========================================================================
   Variant property definitions
   ========================================================================== */

.checkbox--primary {
  /* Default styles */
}

.checkbox--secondary .checkbox__control {
  @apply shadow-none;
  background-color: var(--checkbox-control-bg);

  --checkbox-control-bg: var(--default);

  /* Hover state */
  .checkbox:hover &,
  .checkbox:has([data-slot="checkbox-content"][data-hovered="true"]) &,
  .checkbox [data-slot="checkbox-content"][data-hovered="true"] & {
    @apply border-field-border-hover;
  }
}

/* Checkbox content — the clickable label (control + label text) */
.checkbox__content {
  @apply relative inline-flex cursor-[inherit] items-center gap-3 text-sm font-medium text-foreground outline-none select-none no-highlight;
}

/* Unselected state background for secondary variant */
.checkbox--secondary:not([aria-checked="true"]):not([data-selected="true"]):not(
    [data-indeterminate="true"]
  )
  .checkbox__control {
  background-color: var(--checkbox-control-bg);
}

/* Selected or indeterminate state on secondary variant */
.checkbox--secondary[aria-checked="true"] .checkbox__control,
.checkbox--secondary[data-selected="true"] .checkbox__control,
.checkbox--secondary[data-indeterminate="true"] .checkbox__control {
  &::before {
    @apply bg-accent;
  }
}

/* Base styles */
.chip {
  @apply inline-flex w-fit shrink-0 items-center gap-0.5 rounded-2xl px-2 py-0.5 text-xs leading-5 font-medium;

  /* Default tokens */
  --chip-bg: var(--default);
  --chip-fg: currentColor;

  background-color: var(--chip-bg);
  color: var(--chip-fg);
}

.chip__label {
  @apply px-0.5;
}

/* Color variants - set foreground color */
.chip--accent {
  --chip-fg: var(--accent-soft-foreground);
}

.chip--danger {
  --chip-fg: var(--danger-soft-foreground);
}

.chip--default {
  --chip-fg: var(--default-foreground);
}

.chip--success {
  --chip-fg: var(--success-soft-foreground);
}

.chip--warning {
  --chip-fg: var(--warning-soft-foreground);
}

/* Variant styles */
.chip--primary {
}

.chip--secondary {
  /* No additional styles for secondary variant */
}

.chip--tertiary {
  --chip-bg: transparent;
}

/* Size variants */
.chip--sm {
  @apply px-1 py-0 text-xs;
}

.chip--md {
  /* No styles as this is the default size */
}

.chip--lg {
  @apply px-3 py-1 text-sm font-medium;
}

/* ====================== */
/* = Compound variants = */
/* ====================== */

/* Primary variants - solid backgrounds */
.chip--primary.chip--accent {
  --chip-bg: var(--accent);
  --chip-fg: var(--accent-foreground);
}

.chip--primary.chip--success {
  --chip-bg: var(--success);
  --chip-fg: var(--success-foreground);
}

.chip--primary.chip--warning {
  --chip-bg: var(--warning);
  --chip-fg: var(--warning-foreground);
}

.chip--primary.chip--danger {
  --chip-bg: var(--danger);
  --chip-fg: var(--danger-foreground);
}

/* Soft variants - muted backgrounds */
.chip--accent.chip--soft {
  --chip-bg: var(--accent-soft);
  --chip-fg: var(--accent-soft-foreground);
}

.chip--success.chip--soft {
  --chip-bg: var(--success-soft);
  --chip-fg: var(--success-soft-foreground);
}

.chip--warning.chip--soft {
  --chip-bg: var(--warning-soft);
  --chip-fg: var(--warning-soft-foreground);
}

.chip--danger.chip--soft {
  --chip-bg: var(--danger-soft);
  --chip-fg: var(--danger-soft-foreground);
}

.chip--default.chip--soft {
  --chip-bg: var(--default-soft);
  --chip-fg: var(--default-soft-foreground);
}

/* Close Button component styles */

/* Base close button styles */
.close-button {
  @apply relative isolate inline-flex h-6 w-6 shrink-0 origin-center items-center justify-center rounded-xl p-1 select-none no-highlight;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    color 150ms var(--ease-out),
    background-color 100ms var(--ease-out),
    box-shadow 150ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Focus visible state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Pending state */
  &[data-pending="true"] {
    @apply status-pending;
  }

  /* SVG icon styling*/
  & svg {
    @apply pointer-events-none;
    @apply size-4 shrink-0 self-center;
    @apply -mx-0.5 my-0.5;
  }
}

/* Variants */
.close-button--default {
  @apply bg-default text-muted;

  &:active,
  &[data-pressed="true"] {
  }

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default-hover;
    }
  }

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.93);
  }
}

/* ==========================================================================
   ColorArea - 2D color picker for selecting colors from a gradient area
   ========================================================================== */

/* Base styles */
.color-area {
  @apply relative w-full max-w-56 shrink-0 rounded-2xl no-highlight;

  /* Square aspect ratio */
  aspect-ratio: 1 / 1;

  /* Color gradient background from React Aria */
  background: var(--color-area-background);

  /* Inner shadow for depth */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   Dots overlay variant
   ========================================================================== */

.color-area--show-dots {
  /* Dot pattern overlay using radial gradient */
  &::after {
    content: "";
    @apply pointer-events-none absolute inset-0 rounded-[inherit];

    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 8px 8px;
  }
}

/* ==========================================================================
   Thumb element
   ========================================================================== */

.color-area__thumb {
  @apply size-4 rounded-xl will-change-[width,height];

  /* Current color from React Aria */
  background-color: var(--color-area-thumb-color);

  /* White border for visibility */
  border: 3px solid white;

  /* Inner shadow for depth */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    width 150ms var(--ease-out),
    height 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Focus state */
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Dragging state */
  &[data-dragging="true"] {
    @apply size-5;
  }

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   ColorField - Form field for editing hex colors or individual color channels
   ========================================================================== */

/* Base styles */
.color-field {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }
}

/* Full width modifier */
.color-field--full-width {
  @apply w-full;
}

/* ==========================================================================
   ColorInputGroup - Input group for color field with prefix/suffix support
   ========================================================================== */

/* Base styles */
.color-input-group {
  @apply inline-flex h-9 items-center overflow-hidden rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--color-input-group-bg`; variants override the three tokens. */
  --color-input-group-bg: var(--color-field);
  --color-input-group-bg-hover: var(--color-field-hover);
  --color-input-group-bg-focus: var(--field-focus);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      @apply bg-field-hover;
      --color-input-group-bg: var(--color-input-group-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus within state */
  &[data-focus-within="true"],
  &:focus-within {
    @apply status-focused-field;
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --color-input-group-bg: var(--color-input-group-bg-focus);
    background-color: var(--color-input-group-bg);
    border-color: var(--color-field-border-invalid);
  }

  /* Disabled state */
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   Elements
   ========================================================================== */

.color-input-group__input {
  @apply flex h-full flex-1 cursor-text items-center rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none sm:text-sm;

  /* Placeholder styling */
  &::placeholder {
    @apply text-field-placeholder;
  }

  /* Remove border radius on left side when prefix is present */
  .color-input-group:has([data-slot="color-input-group-prefix"]) & {
    @apply rounded-s-none ps-2;
  }

  /* Remove border radius on right side when suffix is present */
  .color-input-group:has([data-slot="color-input-group-suffix"]) & {
    @apply rounded-e-none pe-2;
  }

  /* Focus state - handled by group */
  &:focus,
  &:focus-visible {
    @apply outline-none;
  }

  /**
   * Cover the UA autofill paint with the group's own fill. The inner control
   * is transparent, so without this the browser background replaces the
   * secondary fill. `--color-input-group-bg` is inherited and tracks the variant.
   * box-shadow is not transitioned: the 1000px inset must appear at once.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--color-input-group-bg) inset;
    box-shadow: 0 0 0 1000px var(--color-input-group-bg) inset;
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition: background-color 9999s ease-in-out 0s;

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

.color-input-group__prefix {
  @apply shrink-0 text-field-placeholder;
  @apply ms-3 me-0 flex items-center;
}

.color-input-group__suffix {
  @apply shrink-0 text-field-placeholder;
  @apply me-3 flex items-center;
}

/* ==========================================================================
   Variant modifiers
   ========================================================================== */

.color-input-group--primary {
  /* Default styles - primary variant uses the base field styling */
}

.color-input-group--secondary {
  @apply shadow-none;
  background-color: var(--color-input-group-bg);

  --color-input-group-bg: var(--default);
  --color-input-group-bg-hover: var(--default-hover);
  --color-input-group-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      --color-input-group-bg: var(--color-input-group-bg-hover);
      background-color: var(--color-input-group-bg);
    }
  }

  &:focus-within,
  &[data-focus-within="true"] {
    --color-input-group-bg: var(--color-input-group-bg-focus);
    background-color: var(--color-input-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    border-color: var(--color-field-border-invalid);
    --color-input-group-bg: var(--color-input-group-bg-focus);
    background-color: var(--color-input-group-bg);
  }

  [data-slot="color-input-group-input"] {
    @apply bg-transparent;
  }
}

/* ==========================================================================
   Full width modifier
   ========================================================================== */

.color-input-group--full-width {
  @apply w-full;
}

/* ==========================================================================
   ColorPicker - Color selection component with popover
   ========================================================================== */

/* Base color-picker styles */
.color-picker {
  @apply inline-flex;
}

/* ==========================================================================
   Trigger
   ========================================================================== */

.color-picker__trigger {
  @apply inline-flex items-center gap-3 rounded-sm text-sm no-highlight;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  [data-slot="label"] {
    cursor: var(--cursor-interactive);
  }

  /* Focus visible state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   Popover
   ========================================================================== */

.color-picker__popover {
  @apply min-w-62 origin-(--trigger-anchor-point) scrollbar-none overflow-x-hidden overflow-y-auto overscroll-contain bg-overlay px-2 pt-2 pb-3;
  box-shadow: var(--overlay-shadow);
  border-radius: min(32px, calc(var(--radius) * 2.5));
  /* Content layout */
  @apply flex flex-col gap-3;

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement^="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement^="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement^="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement^="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }
}

/* ==========================================================================
   ColorSlider - A slider for adjusting individual color channel values
   ========================================================================== */

/* Base styles */
.color-slider {
  @apply grid w-full gap-1;

  grid-template-areas:
    "label output"
    "track track";
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;

  /* When neither label nor output exist, collapse to single row */
  &:not(:has([data-slot="label"])):not(:has(.color-slider__output)) {
    grid-template-areas: "track";
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 0;
  }

  /* When only label exists (no output) */
  &:has([data-slot="label"]):not(:has(.color-slider__output)) {
    grid-template-areas:
      "label"
      "track";
    grid-template-columns: 1fr;
  }

  /* When only output exists (no label) */
  &:not(:has([data-slot="label"])):has(.color-slider__output) {
    grid-template-areas:
      "output"
      "track";
    grid-template-columns: 1fr;

    .color-slider__output {
      justify-self: end;
    }
  }

  [data-slot="label"] {
    @apply w-fit text-sm font-medium;

    grid-area: label;
  }

  .color-slider__output {
    @apply text-sm font-medium tabular-nums;

    grid-area: output;
  }

  .color-slider__track {
    @apply relative rounded-2xl;

    grid-area: track;
    /* Edge cap pseudo-elements */
    &::before,
    &::after {
      content: "";
      position: absolute;
      z-index: 0;
      pointer-events: none;
    }
  }

  .color-slider__thumb {
    /* Flex container for centering */
    @apply absolute flex cursor-grab items-center justify-center rounded-2xl no-highlight;

    /* Border to create white ring around the thumb */
    @apply border-3 border-white shadow-overlay;

    /* Ensure thumb is above edge caps */
    z-index: 1;

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition:
      transform 250ms var(--ease-out),
      box-shadow 150ms var(--ease-out);
    @apply motion-reduce:transition-none;

    /* Dragging state - cursor changes and thumb scales down */
    &[data-dragging="true"] {
      @apply cursor-grabbing;
    }

    /* Focus state - show focus ring */
    &[data-focus-visible="true"] {
      @apply z-10 status-focused;
    }

    /* Disabled state */
    &[data-disabled="true"] {
      @apply cursor-default bg-default;
    }
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;

    [data-slot="label"] {
      @apply opacity-100;
    }
  }

  /* Horizontal orientation */
  &[data-orientation="horizontal"] {
    flex-direction: column;

    .color-slider__track {
      @apply h-5 justify-self-center rounded-none;
      width: calc(100% - 1.25rem);

      /* Default border for visibility against similar backgrounds */
      box-shadow:
        inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
        inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);

      /* Edge caps for horizontal orientation */
      &::before,
      &::after {
        @apply top-0 h-full;
        width: 0.625rem; /* Half thumb width + 2px gap */
      }

      &::before {
        @apply rounded-ss-2xl rounded-es-2xl;
        inset-inline-start: -0.625rem;
        box-shadow:
          inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
          inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
        background:
          linear-gradient(var(--track-start-color, transparent)),
          repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px 16px;
      }

      &::after {
        @apply rounded-se-2xl rounded-ee-2xl;
        inset-inline-end: -0.625rem;
        box-shadow:
          inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
          inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
        background-color: var(--track-end-color, transparent);
      }
    }

    .color-slider__thumb {
      @apply top-1/2 size-4;
    }
  }

  /* Vertical orientation */
  &[data-orientation="vertical"] {
    @apply h-full gap-2;

    flex-direction: row;
    grid-template-areas:
      "output"
      "track"
      "label";
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: center;

    /* When neither label nor output exist in vertical, just show track */
    &:not(:has([data-slot="label"])):not(:has(.color-slider__output)) {
      grid-template-areas: "track";
      grid-template-rows: 1fr;
      gap: 0;
    }

    /* When only label exists in vertical (no output) */
    &:has([data-slot="label"]):not(:has(.color-slider__output)) {
      grid-template-areas:
        "track"
        "label";
      grid-template-rows: 1fr auto;
    }

    /* When only output exists in vertical (no label) */
    &:not(:has([data-slot="label"])):has(.color-slider__output) {
      grid-template-areas:
        "output"
        "track";
      grid-template-rows: auto 1fr;
    }

    .color-slider__output {
      text-align: center;
    }

    [data-slot="label"] {
      text-align: center;
    }

    .color-slider__track {
      @apply w-5 justify-self-center rounded-none;
      height: calc(100% - 1.25rem);

      /* Left and right borders for vertical track */
      box-shadow:
        inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
        inset -1px 0 0 0 rgba(0, 0, 0, 0.1);

      /* Edge caps for vertical orientation */
      &::before,
      &::after {
        @apply start-0 w-full;
        height: 0.625rem; /* Half thumb height + 2px gap */
      }

      &::before {
        bottom: -0.625rem;
        border-end-start-radius: 999px;
        border-end-end-radius: 999px;
        /* Left, right, and bottom borders for bottom cap */
        box-shadow:
          inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
        background:
          linear-gradient(var(--track-start-color, transparent)),
          repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px 16px;
      }

      &::after {
        top: -0.625rem;
        border-start-start-radius: 999px;
        border-start-end-radius: 999px;
        /* Left, right, and top borders for top cap */
        box-shadow:
          inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
          inset 0 1px 0 0 rgba(0, 0, 0, 0.1);
        background-color: var(--track-end-color, transparent);
      }
    }

    .color-slider__thumb {
      /* Cross-axis centering; React Aria applies a physical translateX(-50%), so keep left-1/2 for RTL correctness */
      @apply left-1/2 size-4;
    }
  }
}

/* ==========================================================================
   ColorSwatchPicker - A list of color swatches for selection
   ========================================================================== */

/* Base styles */
.color-swatch-picker {
  @apply flex flex-wrap items-center gap-2;
}

/* ==========================================================================
   Item - Individual swatch picker item
   ========================================================================== */

.color-swatch-picker__item {
  @apply relative flex size-8 items-center justify-center rounded-2xl border-2 border-transparent outline-none no-highlight;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    border-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Focus state */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;
  }

  /* Selected state */
  &[data-selected="true"] {
    border-color: var(--color-swatch-current);
    box-shadow: var(--field-shadow);
    /* Shrink the swatch to reveal the white gap */
    .color-swatch-picker__swatch {
      transform: scale(0.77);
    }
  }
}

/* ==========================================================================
   Swatch - The color swatch visual
   ========================================================================== */

.color-swatch-picker__swatch {
  @apply block size-full;

  /* Inherit border-radius from item */
  border-radius: inherit;
  /**
  * Transitions
  * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
  */
  transition: transform 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  @media (hover: hover) {
    &:hover {
      transform: scale(1.1);
    }
  }
}

/* ==========================================================================
   Indicator - Checkmark indicator for selected state
   ========================================================================== */

.color-swatch-picker__indicator {
  @apply pointer-events-none absolute inset-0 z-10 flex items-center justify-center;

  /* Checkmark SVG styles - default to white for dark backgrounds */
  & > * {
    @apply size-1/3 text-white;

    /* Start scaled down - use translateZ(0) for GPU acceleration */
    transform: scale(0) translateZ(0);

    /**
     * Transitions
     */
    transition: transform 150ms var(--ease-out);
    @apply motion-reduce:transition-none;
  }

  /* Use black checkmark on light backgrounds */
  &[data-light-color="true"] & > * {
    @apply text-black;
  }

  /* Scale up when parent item is selected */
  .color-swatch-picker__item[data-selected="true"] & > * {
    transform: scale(1) translateZ(0);
  }
}

/* ==========================================================================
   Layout variants
   ========================================================================== */

.color-swatch-picker--grid {
  /* Default is already grid (flex-wrap) - no additional styles needed */
}

.color-swatch-picker--stack {
  @apply flex-col;
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.color-swatch-picker--xs {
  .color-swatch-picker__item {
    @apply size-4 rounded-lg border;
  }
}

.color-swatch-picker--sm {
  .color-swatch-picker__item {
    @apply size-6 rounded-xl border-2;
  }
}

.color-swatch-picker--md {
  .color-swatch-picker__item {
    /* No styles as this is the default size */
  }
}

.color-swatch-picker--lg {
  .color-swatch-picker__item {
    @apply size-9 rounded-3xl border-3;
  }
}

.color-swatch-picker--xl {
  .color-swatch-picker__item {
    @apply size-10 rounded-3xl border-3;
  }
}

/* ==========================================================================
   Shape variants
   ========================================================================== */

/* Circle variant (default) - no additional styles needed */
.color-swatch-picker--circle .color-swatch-picker__item {
  /* Default is already circle - radius set per size */
}

/* Square variant */
.color-swatch-picker--square {
  .color-swatch-picker__item {
    @apply rounded-xl;
    .color-swatch-picker__swatch {
      @apply rounded-lg;
    }
    &[data-selected="true"] {
      .color-swatch-picker__swatch {
        @apply rounded-lg;
      }
    }
  }
}

/* Square variant - item radius for xs */
.color-swatch-picker--square.color-swatch-picker--xs {
  .color-swatch-picker__item {
    @apply rounded-md;
    .color-swatch-picker__swatch {
      @apply rounded-md;
    }
    &[data-selected="true"] {
      .color-swatch-picker__swatch {
        @apply rounded-md;
      }
    }
  }
}

/* Square variant - item radius for sm */
.color-swatch-picker--square.color-swatch-picker--sm {
  .color-swatch-picker__item {
    @apply rounded-lg;
    .color-swatch-picker__swatch {
      @apply rounded-lg;
    }
    &[data-selected="true"] {
      .color-swatch-picker__swatch {
        @apply rounded-md;
      }
    }
  }
}

/* Square variant - item radius for md (default) */
.color-swatch-picker--square.color-swatch-picker--md {
  /* No styles as this is the default size */
}

/* Square variant - item radius for lg */
.color-swatch-picker--square.color-swatch-picker--lg {
  .color-swatch-picker__item {
    @apply rounded-xl;
    .color-swatch-picker__swatch {
      @apply rounded-lg;
    }
    &[data-selected="true"] {
      .color-swatch-picker__swatch {
        @apply rounded-lg;
      }
    }
  }
}

/* Square variant - item radius for xl */
.color-swatch-picker--square.color-swatch-picker--xl {
  .color-swatch-picker__item {
    @apply rounded-xl;
    .color-swatch-picker__swatch {
      @apply rounded-lg;
    }
    &[data-selected="true"] {
      .color-swatch-picker__swatch {
        @apply rounded-lg;
      }
    }
  }
}

/* Base color-swatch styles */
.color-swatch {
  @apply relative box-border size-8 shrink-0;

  /* Checkered background pattern for transparency */
  background:
    linear-gradient(var(--color-swatch-current), var(--color-swatch-current)),
    repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px 16px;

  /* Default border for visibility against similar backgrounds */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Shape variants */
.color-swatch--circle {
  @apply rounded-2xl;
}

.color-swatch--square {
  @apply rounded-md;
}

/* Size variants */
.color-swatch--xs {
  @apply size-4;

  &.color-swatch--circle {
    @apply rounded-lg;
  }
}

.color-swatch--sm {
  @apply size-6;

  &.color-swatch--circle {
    @apply rounded-xl;
  }
}

.color-swatch--md {
  /* No additional styles — default size (32px) uses circle's base rounded-2xl */
}

.color-swatch--lg {
  @apply size-9;

  &.color-swatch--circle {
    @apply rounded-3xl;
  }
}

.color-swatch--xl {
  @apply size-10;

  &.color-swatch--circle {
    @apply rounded-3xl;
  }
}

/* ComboBox styles */
.combo-box {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }

  [data-slot="input"] {
    @apply min-w-0 flex-1;

    /* Add inline-end padding when trigger is present */
    &:has(+ .combo-box__trigger) {
      @apply pe-7;
    }

    /* This rule is imported after `.input` and replaces its box-shadow with the focus ring.
       Reassign the input fill so `[data-focus]` tracks the variant, not the primary field. */
    &:focus,
    &[data-focus] {
      @apply status-focused-field;
      border-color: var(--field-border-focus);
      --input-bg: var(--input-bg-focus);
      background-color: var(--input-bg);
    }

    /**
     * Re-apply the input's autofill cover (variant fill + ring + field shadow) or
     * the focus ring above drops it and the UA highlight shows through.
     * box-shadow is not transitioned: the 1000px inset must appear at once.
     */
    &:-webkit-autofill,
    &:-webkit-autofill:hover,
    &:-webkit-autofill:focus,
    &:-webkit-autofill:active,
    &:autofill,
    &:autofill:hover,
    &:autofill:focus,
    &:autofill:active {
      background-color: var(--input-bg);
      box-shadow: var(--input-autofill-shadow);
      -webkit-box-shadow: var(--input-autofill-shadow);
      -webkit-text-fill-color: var(--field-foreground);
      caret-color: var(--field-foreground);
      transition:
        background-color 9999s ease-in-out 0s,
        border-color 150ms var(--ease-smooth);

      @media (prefers-reduced-motion: reduce) {
        transition: background-color 9999s ease-in-out 0s;
      }
    }

    /* Disabled state */
    &:disabled,
    &[data-disabled],
    &[aria-disabled="true"] {
      @apply status-disabled;
    }
  }
}

.combo-box__input-group {
  @apply relative isolate inline-flex items-center;
}

.combo-box__value {
  @apply text-sm wrap-break-word text-field-foreground empty:hidden;

  &[data-placeholder="true"] {
    @apply text-field-placeholder;
  }

  /* Removes the list-box-item indicator element from the combo-box value */
  [data-slot="list-box-item-indicator"] {
    @apply hidden;
  }
}

.combo-box__trigger {
  @apply absolute end-0 top-1/2 flex h-full shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center pe-2 text-field-placeholder transition duration-150 no-highlight;

  /* Remove default button styles */
  @apply border-none bg-transparent outline-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply text-field-foreground;
    }
  }

  /* Focus visible state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply rounded ring-2 ring-focus ring-offset-2 ring-offset-background outline-none;
  }

  /* Pressed state */
  &[data-pressed="true"] {
    @apply opacity-70;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled],
  &[aria-disabled="true"] {
    @apply cursor-not-allowed opacity-50;
  }

  [data-slot="combo-box-trigger-default-icon"] {
    @apply size-4 transition-transform duration-150 motion-reduce:transition-none;
  }

  /* Rotate icon when trigger is open */
  &[data-open="true"] [data-slot="combo-box-trigger-default-icon"] {
    @apply rotate-180;
  }
}

/* Similar to popover content styles */
.combo-box__popover {
  @apply flex min-w-(--trigger-width) origin-(--trigger-anchor-point) flex-col overflow-hidden bg-overlay p-0 text-sm;
  border-radius: min(32px, calc(var(--radius-2xl) + var(--spacing) * 1.5));
  box-shadow: var(--overlay-shadow);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /* Arrow styling */
  & [data-slot="popover-overlay-arrow"] {
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="popover-overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="popover-overlay-arrow"] {
    rotate: 90deg;
  }

  /* Keep scrolling on the input-controlled listbox so virtual focus can reveal options. */
  [data-slot="list-box"] {
    @apply min-h-0 scroll-py-1 scrollbar overflow-y-auto overscroll-contain p-1.5 outline-none;
  }

  [data-slot="list-box-item"] {
    @apply px-2.5;

    /* list-box-item.css is imported earlier and at equal specificity, so the shorthand above
       would otherwise reset the room it reserves for the absolutely positioned indicator */
    &:has(.list-box-item__indicator) {
      @apply pe-7;
    }

    /* As the combo-box is single-select, we don't need to animate the checkmark */
    [data-slot="list-box-item-indicator--checkmark"] {
      @apply transition-none;
    }
  }
}

/* Full width modifier */
.combo-box--full-width {
  @apply w-full;
}

.combo-box__input-group--full-width {
  @apply w-full;
}

/* Date field styles */
.date-field {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }
}

/* Full width modifier */
.date-field--full-width {
  @apply w-full;
}

/* Date input group styles */
.date-input-group {
  @apply inline-flex h-9 items-center overflow-hidden rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      @apply bg-field-hover;
      border-color: var(--field-border-hover);
    }
  }

  /* Focus within state */
  &[data-focus-within="true"]:not(
      :has(
        [data-slot="date-picker-trigger"]:focus,
        [data-slot="date-picker-trigger"][data-focused="true"],
        [data-slot="date-range-picker-trigger"]:focus,
        [data-slot="date-range-picker-trigger"][data-focused="true"]
      )
    ),
  &:focus-within:not(
      :has(
        [data-slot="date-picker-trigger"]:focus,
        [data-slot="date-picker-trigger"][data-focused="true"],
        [data-slot="date-range-picker-trigger"]:focus,
        [data-slot="date-range-picker-trigger"][data-focused="true"]
      )
    ) {
    @apply status-focused-field;
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    background-color: var(--field-focus);
    border-color: var(--color-field-border-invalid);
  }

  /* Disabled state */
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.date-input-group__input {
  @apply flex flex-1 cursor-text items-center gap-px rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none sm:text-sm;

  /* Remove border radius on left side when prefix is present */
  .date-input-group:has([data-slot="date-input-group-prefix"]) & {
    @apply rounded-s-none ps-2;
  }

  /* Remove border radius on right side when suffix is present */
  .date-input-group:has([data-slot="date-input-group-suffix"]) & {
    @apply rounded-e-none pe-2;
  }

  .date-input-group:has(.date-range-picker__range-separator) & {
    &[slot="start"] {
      @apply flex-none pe-0;
    }
    &[slot="end"] {
      @apply ps-0;
    }
  }

  /* Focus state - handled by group */
  &:focus,
  &:focus-visible {
    @apply outline-none;
  }
}

.date-input-group__input-container {
  @apply flex flex-1 scrollbar-none items-center;
  width: fit-content;
  overflow-x: auto;
  overflow-y: clip;
}

.date-input-group__segment {
  @apply inline-block rounded-md px-0.5 text-end text-nowrap outline-none;

  /* Segment separators styling "/" */
  &[data-type="literal"] {
    @apply p-0 text-muted;
  }

  /* Placeholder styling */
  &[data-placeholder="true"] {
    @apply text-field-placeholder;
  }

  /* Focused segment */
  &:focus,
  &[data-focused="true"] {
    @apply bg-accent-soft text-accent-soft-foreground;
  }

  /* Disabled segment */
  &[data-disabled="true"] {
    @apply opacity-50;
  }

  /* Invalid segment */
  &[data-invalid="true"] {
    @apply text-danger;

    /* Focused segment */
    &:focus,
    &[data-focused="true"] {
      @apply bg-danger-soft text-danger-soft-foreground;
    }
  }
}

.date-input-group__prefix {
  @apply pointer-events-none shrink-0 text-field-placeholder;
  @apply ms-3 me-0 flex items-center;
}

.date-input-group__suffix {
  @apply pointer-events-none shrink-0 text-field-placeholder;
  @apply me-3 flex items-center;
}

/* Variant property definitions */
.date-input-group--primary {
  /* Default styles */
}

.date-input-group--secondary {
  @apply shadow-none;
  background-color: var(--date-input-group-bg);

  --date-input-group-bg: var(--default);
  --date-input-group-bg-hover: var(--default-hover);
  --date-input-group-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      background-color: var(--date-input-group-bg-hover);
    }
  }

  &:focus-within,
  &[data-focus-within="true"] {
    background-color: var(--date-input-group-bg-focus);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    border-color: var(--color-field-border-invalid);
    background-color: var(--date-input-group-bg-focus);
  }

  [data-slot="date-input-group-input"] {
    @apply bg-transparent;
  }
}

/* Full width modifier */
.date-input-group--full-width {
  @apply w-full;
}

/* ==========================================================================
   DatePicker - Date selection trigger and popover container
   ========================================================================== */

.date-picker {
  @apply inline-flex flex-col gap-1;

  .date-input-group__suffix,
  .date-input-group__prefix {
    @apply pointer-events-auto;
  }
}

.date-picker__trigger {
  @apply inline-flex w-full items-center rounded-field p-1 text-sm no-highlight;

  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.date-picker__trigger-indicator {
  @apply inline-flex size-4 items-center justify-center text-field-placeholder;
}

.date-picker__popover {
  @apply w-fit origin-(--trigger-anchor-point) scrollbar-none overflow-y-auto overscroll-contain bg-overlay p-3;
  @apply motion-reduce:transition-none;

  box-shadow: var(--overlay-shadow);
  border-radius: min(32px, calc(var(--radius) * 2.5));

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 150ms var(--ease-smooth);

    &[data-placement^="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement^="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement^="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement^="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }
}

.date-picker__popover .calendar__nav-button-icon,
.date-picker__popover .range-calendar__nav-button-icon {
  @apply rotate-0;
}

/* ==========================================================================
   DateRangePicker - Date range selection trigger and popover container
   ========================================================================== */

.date-range-picker {
  @apply inline-flex flex-col gap-1;

  .date-input-group__suffix,
  .date-input-group__prefix {
    @apply pointer-events-auto;
  }
}

.date-range-picker__trigger {
  @apply inline-flex w-full items-center rounded-field p-1 text-sm no-highlight;

  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.date-range-picker__trigger-indicator {
  @apply inline-flex size-4 items-center justify-center text-field-placeholder;
}

.date-range-picker__range-separator {
  @apply px-1 text-field-placeholder select-none;
}

.date-range-picker__popover {
  @apply w-fit origin-(--trigger-anchor-point) scrollbar-none overflow-y-auto overscroll-contain bg-overlay p-3;
  @apply motion-reduce:transition-none;

  box-shadow: var(--overlay-shadow);
  border-radius: min(32px, calc(var(--radius) * 2.5));

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 150ms var(--ease-smooth);

    &[data-placement^="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement^="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement^="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement^="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }
}

.date-range-picker__popover .range-calendar__nav-button-icon,
.date-range-picker__popover .calendar__nav-button-icon {
  @apply rotate-0;
}

/* Base description styles */
.description {
  @apply text-xs text-wrap wrap-break-word text-muted;
}

/* Base disclosure-group styles */
.disclosure-group {
  @apply w-full;

  /* Performance optimization - contain layout changes */
  contain: layout style;
}

/* Base disclosure styles */
.disclosure {
  @apply relative;
}

.disclosure__trigger {
  cursor: var(--cursor-interactive);
  @apply inline-block no-highlight;

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.disclosure__indicator {
  @apply ms-auto size-4 shrink-0 text-inherit;

  /**
   * Transitions
   */
  @apply transition duration-250 motion-reduce:transition-none;

  /* Expanded state for indicator rotation */
  &[data-expanded="true"] {
    @apply -rotate-180;
  }
}

.disclosure__content {
  opacity: 0;
  height: var(--disclosure-panel-height);
  overflow: clip;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    height 200ms var(--ease-out-quad),
    opacity 200ms var(--ease-out);
  @apply motion-reduce:transition-none;

  &[data-expanded="true"] {
    will-change: height, opacity;
    opacity: 1;
  }
}

.disclosure__body {
  @apply p-2;
}

/* -------------------------------------------------------------------------------------------------
 * Drawer Component Styles
 * Block: drawer
 * -----------------------------------------------------------------------------------------------*/

/**
 * Element: trigger - the element that opens the drawer
 */
.drawer__trigger {
  @apply inline-block cursor-(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Active/pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.97);
  }
}

/**
 * Element: backdrop - the overlay behind the drawer
 */
.drawer__backdrop {
  @apply fixed inset-0 z-(--z-index-overlay);
  @apply h-(--visual-viewport-height) w-full;
  opacity: 1;
  transition: opacity 250ms cubic-bezier(0.32, 0.72, 0, 1);

  &[data-entering="true"] {
    opacity: 0;
  }

  &[data-exiting="true"] {
    opacity: 0;
    transition-duration: 200ms;
    transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
  }

  &[data-exiting="true"],
  &[data-entering="true"] {
    will-change: opacity;
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

/**
 * Modifier: backdrop--transparent
 */
.drawer__backdrop--transparent {
  @apply bg-transparent;
}

/**
 * Modifier: backdrop--opaque
 */
.drawer__backdrop--opaque {
  @apply bg-backdrop;
}

/**
 * Modifier: backdrop--blur
 */
.drawer__backdrop--blur {
  @apply bg-backdrop backdrop-blur-md;

  /*
   * A full-viewport backdrop-filter stalls mid-range mobile GPUs long enough
   * that the open animation is skipped. On touch devices, only skip the blur
   * while the backdrop is animating so the dim scrim fades on its own, then
   * apply the blur once the overlay has settled.
   */
  @media (hover: none) and (pointer: coarse) {
    &[data-entering="true"],
    &[data-exiting="true"] {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

/**
 * Element: content - the positioning wrapper for the drawer panel
 */
.drawer__content {
  @apply pointer-events-none;
  @apply fixed inset-0 z-(--z-index-overlay) flex;
  @apply h-(--visual-viewport-height) w-full min-w-0;

  --drawer-enter-duration: 250ms;
  --drawer-exit-duration: 200ms;
  --drawer-enter-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --drawer-exit-ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/**
 * Modifier: content--bottom (default)
 * Slides up from the bottom edge
 */
.drawer__content--bottom {
  @apply items-end;
}

/**
 * Modifier: content--top
 * Slides down from the top edge
 */
.drawer__content--top {
  @apply items-start;
}

/**
 * Modifier: content--left
 * Slides in from the left edge
 */
.drawer__content--left {
  @apply justify-start;
}

/**
 * Modifier: content--right
 * Slides in from the right edge
 */
.drawer__content--right {
  @apply justify-end;
}

/*
 * Enter animation lives on the content. That is the element React Aria watches:
 * a transition on the dialog is cancelled and data-entering is cleared before paint,
 * so the open slide never runs. Exit stays a translate on the dialog so a drag
 * transform can compound with it.
 */
.drawer__content--bottom[data-entering="true"] {
  animation: heroui-drawer-enter-bottom var(--drawer-enter-duration) var(--drawer-enter-ease);
}

.drawer__content--top[data-entering="true"] {
  animation: heroui-drawer-enter-top var(--drawer-enter-duration) var(--drawer-enter-ease);
}

.drawer__content--left[data-entering="true"] {
  animation: heroui-drawer-enter-left var(--drawer-enter-duration) var(--drawer-enter-ease);
}

.drawer__content--right[data-entering="true"] {
  animation: heroui-drawer-enter-right var(--drawer-enter-duration) var(--drawer-enter-ease);
}

.drawer__content[data-entering="true"] {
  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}

@keyframes heroui-drawer-enter-bottom {
  from {
    translate: 0 100%;
  }
}

@keyframes heroui-drawer-enter-top {
  from {
    translate: 0 -100%;
  }
}

@keyframes heroui-drawer-enter-left {
  from {
    translate: -100% 0;
  }
}

@keyframes heroui-drawer-enter-right {
  from {
    translate: 100% 0;
  }
}

/**
 * Element: dialog - the drawer panel itself
 */
.drawer__dialog {
  @apply relative;
  @apply flex flex-col;
  @apply bg-overlay shadow-overlay outline-none;
  @apply p-6;
  @apply pointer-events-auto;

  will-change: translate;
  transition: translate var(--drawer-enter-duration) var(--drawer-enter-ease);

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }

  /* Bottom/top placement: full width, auto height */
  &[data-placement="bottom"] {
    @apply w-full;
    @apply max-h-[85vh];
    border-start-start-radius: min(32px, var(--radius-2xl));
    border-start-end-radius: min(32px, var(--radius-2xl));
  }

  &[data-placement="top"] {
    @apply w-full;
    @apply max-h-[85vh];
    border-end-start-radius: min(32px, var(--radius-2xl));
    border-end-end-radius: min(32px, var(--radius-2xl));
  }

  /* Left/right placement: auto width, full height */
  &[data-placement="left"] {
    @apply h-full rounded-none;
    @apply w-80 max-w-[85vw] sm:w-96;
  }

  &[data-placement="right"] {
    @apply h-full rounded-none;
    @apply w-80 max-w-[85vw] sm:w-96;
  }
}

[data-exiting="true"] .drawer__dialog {
  transition-duration: var(--drawer-exit-duration);
  transition-timing-function: var(--drawer-exit-ease);
}

.drawer__content--left .drawer__dialog,
.drawer__content--right .drawer__dialog,
.drawer__content--top .drawer__dialog,
.drawer__content--bottom .drawer__dialog {
  translate: 0 0;
}

.drawer__content--left[data-exiting="true"] .drawer__dialog {
  translate: -100% 0;
}

.drawer__content--right[data-exiting="true"] .drawer__dialog {
  translate: 100% 0;
}

.drawer__content--top[data-exiting="true"] .drawer__dialog {
  translate: 0 -100%;
}

.drawer__content--bottom[data-exiting="true"] .drawer__dialog {
  translate: 0 100%;
}

.drawer__dialog--top {
  @apply pb-2;
  .drawer__handle {
    @apply pb-0;
  }
}

/**
 * Element: header - the top section with the title
 */
.drawer__header {
  @apply flex flex-col gap-3;
  @apply mb-0;
}

/**
 * Element: heading - the main title text
 */
.drawer__heading {
  @apply align-middle;
  @apply text-base font-medium text-foreground;
}

/**
 * Element: body - the main content area
 * touch-action: pan-y allows vertical scrolling while the dialog captures drag gestures
 */
.drawer__body {
  @apply min-h-0 flex-1 scrollbar;
  @apply text-sm leading-[1.43] text-muted;
  @apply -m-[3px] my-0 p-[3px];
  @apply overflow-y-auto overscroll-contain;
  -webkit-overflow-scrolling: touch;
}

/**
 * Element: footer - the bottom action section
 */
.drawer__footer {
  @apply flex flex-row flex-wrap items-center justify-end gap-2;
  @apply mt-0;
}

/**
 * Element: handle - visual drag handle indicator
 */
.drawer__handle {
  @apply flex items-center justify-center;
  @apply pb-2;

  /* The handle bar */
  & > [data-slot="drawer-handle-bar"] {
    @apply h-1 w-9 rounded-xs;
    @apply bg-separator;
  }
}

/**
 * Element: close-trigger - the close button
 */
.drawer__close-trigger {
  @apply absolute end-4 top-4;
}

/**
 * Elements Spacing
 */
.drawer__header + .drawer__body {
  @apply mt-2;
}

.drawer__header + .drawer__footer {
  @apply mt-5;
}

.drawer__body + .drawer__footer {
  @apply mt-5;
}

.drawer__handle + .drawer__header {
  @apply mt-0;
}

.drawer__handle + .drawer__body {
  @apply mt-0;
}

/* ==========================================================================
   Base dropdown styles
   ========================================================================== */

.dropdown {
  @apply flex flex-col gap-1;
}

.dropdown__trigger {
  @apply inline-block;
  /* Only visible when using a custom trigger  - not passing "Button" as a child - hence we use some button styles (custom trigger) */
  @apply outline-none;
  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Pending state */
  &[data-pending="true"] {
    @apply status-pending;
  }

  /* Default active/pressed state - scale transform */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.97);
  }
}

/* Similar to select popover styles */
.dropdown__popover {
  @apply origin-(--trigger-anchor-point) scroll-py-1 scrollbar overflow-y-auto overscroll-contain bg-overlay p-0 text-sm;
  /*
   * Same floor as min-w-55 on every viewport, capped to the screen minus a 2rem
   * inset. 48svw was narrower than that floor on a phone and collapsed row icons.
   */
  min-width: min(calc(var(--spacing) * 55), 100%, calc(100svw - 2rem));
  max-width: min(100%, calc(100svw - 2rem));
  border-radius: min(32px, calc(var(--radius-2xl) + var(--spacing) * 1.5));
  box-shadow: var(--overlay-shadow);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-90 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-90-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-90-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-90-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-90-nx;
    }
  }

  /* Exiting animations.
     The placement `animation-name` above is more specific than this shorthand, so repeat
     the name for an exiting popover that still has `data-placement`.
     Leave the fill mode at `none`. `forwards` / `both` make WebKit skip this animation
     and jump to the last keyframe, so the menu disappears instead of closing. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /*
   * Touch devices hide this popover (inline opacity, clip, clip-path, mask) until
   * React Aria decides a software keyboard is not opening. That wait is ~800ms, so
   * a second tap closes the menu before it is ever shown. Once it has a placement,
   * show it. The enter animation is skipped on these devices so the late callback
   * cannot hide it again. The close animation still owns opacity while exiting.
   */
  @media (hover: none) and (pointer: coarse) {
    &[data-placement]:not([data-exiting="true"]) {
      opacity: 1 !important;
      clip: auto !important;
      clip-path: none !important;
      mask-image: none !important;
    }
  }

  /* Arrow styling */
  & [data-slot="popover-overlay-arrow"] {
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="popover-overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="popover-overlay-arrow"] {
    rotate: 90deg;
  }

  /* Menu styles */
  [data-slot="dropdown-menu"] {
    @apply p-1.5 outline-none;
  }

  [data-slot="menu-item"] {
    @apply px-2.5;
  }
}

.dropdown__menu {
  @apply relative flex w-full flex-col gap-0.5 overflow-clip p-1;

  /* This makes the separator take up 94% of the width and be centered */
  [data-slot="separator"] {
    @apply ms-[3%] w-[94%];
  }
}

/* Base empty-state styles */
.empty-state {
  @apply p-2 text-sm text-muted;
}

/* Base error message styles */
.error-message {
  @apply h-auto text-xs wrap-break-word text-danger;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    opacity 150ms var(--ease-out),
    height 350ms var(--ease-smooth);
  @apply motion-reduce:transition-none;
}

/* Field error styles */
.field-error {
  @apply h-0 px-1 text-xs wrap-break-word text-danger opacity-0 data-visible:h-auto data-visible:opacity-100;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    opacity 150ms var(--ease-out),
    height 350ms var(--ease-smooth);
  @apply motion-reduce:transition-none;
}

/*
 * Toggle fields (checkbox/switch): stack below the label like description.
 * Disable collapsible height/opacity — those styles break flex-col content layout.
 */
.checkbox > .field-error,
.checkbox > [data-slot="field-error"],
.switch > .field-error,
.switch > [data-slot="field-error"],
.radio > .field-error,
.radio > [data-slot="field-error"] {
  @apply m-0 h-auto min-h-0 p-0 text-muted opacity-100;
  transition: none;
}

/* Base component styles */
.fieldset {
  @apply flex flex-col gap-6;
  /* fix flexbox issue in Safari when fieldset with legend is inside a flexbox */
  @apply shrink grow basis-0;
}

.fieldset__legend {
  @apply text-base font-medium text-foreground;
}

.fieldset__field-group {
  @apply w-full space-y-4;
}

.fieldset__actions {
  @apply flex items-center gap-2 pt-1;
}

/* ==========================================================================
   Base header styles
   ========================================================================== */

.header {
  @apply w-full px-2 pt-1.5 pb-1 text-start text-xs font-medium text-muted;
}

/* ------------------------------------------------------------------------------------------------
 * Component Styles
 * ------------------------------------------------------------------------------------------------
 * CRITICAL: Import order matters for CSS specificity and style overrides.
 *
 * General Rule: Shared/primitive components MUST be imported FIRST, before components that use them.
 * This ensures that parent component styles can properly override shared component defaults.
 *
 * Organization: Components are grouped by their Storybook categories (Components/Category/Name)
 * to maintain consistency between documentation and implementation.
 * ------------------------------------------------------------------------------------------------ */

/* ------------------------------------------------------------------------------------------------
 * Shared Components - MUST Import FIRST
 * ------------------------------------------------------------------------------------------------
 * These are used by multiple components and must be imported early to allow proper overrides.
 * ------------------------------------------------------------------------------------------------ */
@import "./close-button.css";
@import "./description.css";
@import "./error-message.css";
@import "./field-error.css";
@import "./label.css";

/* ------------------------------------------------------------------------------------------------
 * Navigation
 * ------------------------------------------------------------------------------------------------ */
@import "./accordion.css";
@import "./breadcrumbs.css";
@import "./disclosure-group.css";
@import "./disclosure.css";
@import "./link.css";
@import "./pagination.css";
@import "./tabs.css";

/* ------------------------------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------------------------------ */
@import "./button.css";
@import "./button-group.css";
@import "./toggle-button.css";
@import "./toggle-button-group.css";
@import "./toolbar.css";

/* ------------------------------------------------------------------------------------------------
 * Collections
 * ------------------------------------------------------------------------------------------------ */
@import "./dropdown.css";
@import "./list-box-item.css";
@import "./list-box-section.css";
@import "./list-box.css";
@import "./menu-item.css";
@import "./menu-section.css";
@import "./menu.css";
@import "./tag-group.css";
@import "./tag.css";

/* ------------------------------------------------------------------------------------------------
 * Colors
 * ------------------------------------------------------------------------------------------------ */
@import "./color-area.css";
@import "./color-picker.css";
@import "./color-slider.css";
@import "./color-swatch.css";
@import "./color-swatch-picker.css";
@import "./color-input-group.css";
@import "./color-field.css";

/* ------------------------------------------------------------------------------------------------
 * Controls
 * ------------------------------------------------------------------------------------------------ */
@import "./slider.css";
@import "./switch.css";
@import "./switch-group.css";

/* ------------------------------------------------------------------------------------------------
 * DataDisplay
 * ------------------------------------------------------------------------------------------------ */
@import "./badge.css";
@import "./chip.css";
@import "./table.css";

/* ------------------------------------------------------------------------------------------------
 * Feedback
 * ------------------------------------------------------------------------------------------------ */
@import "./alert.css";
@import "./empty-state.css";
@import "./skeleton.css";
@import "./meter.css";
@import "./progress-bar.css";
@import "./progress-circle.css";
@import "./spinner.css";
@import "./toast.css";

/* ------------------------------------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------------------------------------ */
@import "./checkbox-group.css";
@import "./checkbox.css";
@import "./fieldset.css";
@import "./input-otp.css";
@import "./input.css";
@import "./input-group.css";
@import "./number-field.css";
@import "./radio-group.css";
@import "./radio.css";
@import "./textfield.css";
@import "./search-field.css";
@import "./textarea.css";

/* ------------------------------------------------------------------------------------------------
* Date & Time
* ------------------------------------------------------------------------------------------------ */
@import "./calendar.css";
@import "./range-calendar.css";
@import "./calendar-year-picker.css";
@import "./date-field.css";
@import "./time-field.css";
@import "./date-input-group.css";
@import "./date-picker.css";
@import "./date-range-picker.css";

/* ------------------------------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------------------------------ */
@import "./card.css";
@import "./header.css";
@import "./separator.css";
@import "./surface.css";

/* ------------------------------------------------------------------------------------------------
 * Media
 * ------------------------------------------------------------------------------------------------ */
@import "./avatar.css";
@import "./avatar-group.css";

/* ------------------------------------------------------------------------------------------------
 * Overlays
 * ------------------------------------------------------------------------------------------------ */
@import "./alert-dialog.css";
@import "./drawer.css";
@import "./sheet.css";
@import "./modal.css";
@import "./popover.css";
@import "./tooltip.css";

/* ------------------------------------------------------------------------------------------------
 * Pickers
 * ------------------------------------------------------------------------------------------------ */
@import "./combo-box.css";
@import "./select.css";
@import "./autocomplete.css";

/* ------------------------------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------------------------------ */
@import "./kbd.css";
@import "./typography.css";

/* ------------------------------------------------------------------------------------------------
 * Utilities
 * ------------------------------------------------------------------------------------------------ */
@import "./scroll-shadow.css";

/* Input group styles */
.input-group {
  @apply inline-flex min-h-9 items-center rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--input-group-bg`; variants override the three tokens. */
  --input-group-bg: var(--color-field);
  --input-group-bg-hover: var(--color-field-hover);
  --input-group-bg-focus: var(--field-focus);

  /* When textarea is present, align items to start and allow height to grow */
  &:has([data-slot="input-group-textarea"]) {
    @apply items-start;
    height: auto;
  }

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      @apply bg-field-hover;
      --input-group-bg: var(--input-group-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus within state - only when input/textarea is focused */
  &:has([data-slot="input-group-input"]:focus),
  &:has([data-slot="input-group-textarea"]:focus) {
    @apply status-focused-field;
    border-color: var(--field-border-focus);
    --input-group-bg: var(--input-group-bg-focus);
    background-color: var(--input-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --input-group-bg: var(--input-group-bg-focus);
    background-color: var(--input-group-bg);
    border-color: var(--color-field-border-invalid);
  }

  /* Disabled state */
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.input-group__input {
  /* Rounded on every side, then squared where a prefix or suffix touches it (below). The group
     does not clip, so a square outer corner would poke past the shell under the autofill cover. */
  @apply flex-1 rounded-field border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none placeholder:text-field-placeholder sm:text-sm;

  /* Remove border radius on left side when prefix is present */
  .input-group:has([data-slot="input-group-prefix"]) & {
    @apply rounded-s-none ps-0;
  }

  /* Remove border radius on right side when suffix is present */
  .input-group:has([data-slot="input-group-suffix"]) & {
    @apply rounded-e-none pe-0;
  }

  /* Focus state - handled by group */
  &:focus,
  &:focus-visible {
    @apply outline-none;
  }

  /**
   * Browser autofill paints only the inner control. A transparent inset shadow
   * lets that paint through, and a group-level `--field-focus` highlight
   * replaces the secondary fill with the primary field. Cover the UA paint
   * with the group's own fill (`--input-group-bg`, inherited) so prefix,
   * suffix, and input stay one color. The inner control is rounded on its outer
   * sides to match the shell (see above). Border stays on `.input-group`.
   * box-shadow is not transitioned: the 1000px inset must appear at once.
   *
   * Some browsers (Edge on Windows) paint an autofilled control with a native, square text
   * field that ignores `border-radius`, covering the shell's rounded corners and focus ring.
   * `appearance: none` drops the native paint, and `clip-path` keeps whatever is painted
   * inside the shell's rounded shape. Rounding the inner corners next to a prefix/suffix is
   * invisible because the cover and the group share one fill.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    -webkit-appearance: none;
    appearance: none;
    clip-path: inset(0 round var(--radius-field));
    -webkit-box-shadow: 0 0 0 1000px var(--input-group-bg) inset;
    box-shadow: 0 0 0 1000px var(--input-group-bg) inset;
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition: background-color 9999s ease-in-out 0s;

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

/* TextArea within InputGroup - uses same base class as input but with textarea-specific styles */
.input-group__input[data-slot="input-group-textarea"] {
  min-height: 38px;
  resize: vertical;
}

.input-group__prefix {
  @apply flex h-full items-center justify-center rounded-s-field rounded-e-none bg-transparent px-3 text-field-placeholder;
  border-width: var(--border-width-field);
  border-color: var(--field-border);
  border-style: solid;
  border-inline-end-color: var(--field-border);
  border-inline-start: none;
  border-top: none;
  border-bottom: none;

  /* Align to top when textarea is present */
  .input-group:has([data-slot="input-group-textarea"]) & {
    @apply items-start;
    padding-top: 0.5rem;
  }

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;
}

.input-group__suffix {
  @apply flex h-full items-center justify-center rounded-s-none rounded-e-field bg-transparent px-3 text-field-placeholder;
  border-width: var(--border-width-field);
  border-color: var(--field-border);
  border-style: solid;
  border-inline-start-color: var(--field-border);
  border-inline-end: none;
  border-top: none;
  border-bottom: none;

  /* Align to top when textarea is present */
  .input-group:has([data-slot="input-group-textarea"]) & {
    @apply items-start;
    padding-top: 0.5rem;
  }

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;
}

/* Variant property definitions */
.input-group--primary {
  /* Default styles */
}

.input-group--secondary {
  @apply shadow-none;
  background-color: var(--input-group-bg);

  --input-group-bg: var(--default);
  --input-group-bg-hover: var(--default-hover);
  --input-group-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      --input-group-bg: var(--input-group-bg-hover);
      background-color: var(--input-group-bg);
    }
  }

  &:has([data-slot="input-group-input"]:focus),
  &:has([data-slot="input-group-textarea"]:focus) {
    --input-group-bg: var(--input-group-bg-focus);
    background-color: var(--input-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    border-color: var(--color-field-border-invalid);
    --input-group-bg: var(--input-group-bg-focus);
    background-color: var(--input-group-bg);
  }

  [data-slot="input-group-input"],
  [data-slot="input-group-textarea"] {
    @apply bg-transparent;
  }
}

/* Full width modifier */
.input-group--full-width {
  @apply w-full;
}

/* Base container */
.input-otp {
  @apply relative flex w-full items-center gap-2;

  &[data-disabled="true"] {
    @apply cursor-not-allowed opacity-50;
  }
}

/* Group - slots separated with gap */
.input-otp__group {
  @apply flex min-w-0 items-center gap-2;
}

/* Individual slot box - fully rounded, standalone */
.input-otp__slot {
  @apply relative flex h-10 w-9.5 min-w-0 flex-1 items-center justify-center;
  @apply border bg-field text-field-foreground shadow-field;
  @apply rounded-field text-sm font-semibold outline-none;

  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-field-hover;
      border-color: var(--field-border-hover);
    }
  }

  /* Active/Focus */
  &[data-active="true"] {
    @apply z-10 bg-field-focus status-focused-field;
  }

  /* Filled */
  &[data-filled="true"] {
    @apply bg-field-focus;
  }

  /* Disabled */
  &[data-disabled="true"] {
    @apply status-disabled;
  }

  /* Invalid */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    background-color: var(--field-focus);
  }
}

/* Slot value */
.input-otp__slot-value {
  @apply text-lg leading-6 tracking-[-0.27px];

  /**
   * Animations
   * CRITICAL: motion-reduce must be AFTER animation for correct override specificity
   */
  animation: slot-value-in 250ms var(--ease-smooth) both;
  transform-origin: bottom center;
  @apply motion-reduce:animate-none;
}

/* Caret */
.input-otp__caret {
  @apply absolute h-4 w-[2px] animate-caret-blink rounded-sm bg-field-placeholder;
}

/* Separator */
.input-otp__separator {
  @apply h-[2px] w-[6px] shrink-0 rounded-sm bg-separator;
}

/* Variant property definitions */
.input-otp--primary {
  /* Default styles */
}

.input-otp--secondary .input-otp__slot {
  @apply shadow-none;
  background-color: var(--input-otp-slot-bg);

  --input-otp-slot-bg: var(--default);
  --input-otp-slot-bg-hover: var(--default-hover);
  --input-otp-slot-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      background-color: var(--input-otp-slot-bg-hover);
    }
  }

  &[data-active="true"],
  &[data-filled="true"] {
    background-color: var(--input-otp-slot-bg-focus);
  }
}

/* Animations */
@keyframes slot-value-in {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.input {
  @apply rounded-field border bg-field px-3 py-2 text-base text-field-foreground shadow-field outline-none placeholder:text-field-placeholder sm:text-sm;

  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--input-bg`; variants override the three tokens. */
  --input-bg: var(--color-field);
  --input-bg-hover: var(--color-field-hover);
  --input-bg-focus: var(--field-focus);
  /* Inset layer covers the UA autofill paint. The rest keeps shadow-field and the focus ring. */
  --input-autofill-shadow:
    0 0 0 1000px var(--input-bg) inset, var(--tw-inset-shadow, 0 0 #0000),
    var(--tw-inset-ring-shadow, 0 0 #0000), var(--tw-ring-offset-shadow, 0 0 #0000),
    var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow, 0 0 #0000);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  @media (hover: hover) {
    &:hover:not(:focus):not(:focus-visible),
    &[data-hovered="true"]:not([data-focused="true"]):not([data-focus-visible="true"]) {
      @apply bg-field-hover;
      --input-bg: var(--input-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus state */
  &:focus,
  &[data-focused="true"] {
    @apply status-focused-field;
    border-color: var(--field-border-focus);
    --input-bg: var(--input-bg-focus);
    background-color: var(--input-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --input-bg: var(--input-bg-focus);
    background-color: var(--input-bg);
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /**
   * Browser autofill (`:-webkit-autofill` in Chromium, `:autofill` in Firefox).
   * The user agent paints its own background over the author background, which
   * drops `.input--secondary`'s fill and reads as the primary field. Cover that
   * paint with `--input-bg` (the variant's current fill) and keep the field
   * foreground. Border stays on the rules above — autofill is not focus.
   * The long background-color transition stops Chromium's highlight from fading in.
   * box-shadow is not transitioned: the 1000px inset must appear at once, or the
   * highlight shows while that cover grows in from 0.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    background-color: var(--input-bg);
    box-shadow: var(--input-autofill-shadow);
    -webkit-box-shadow: var(--input-autofill-shadow);
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition:
      background-color 9999s ease-in-out 0s,
      border-color 150ms var(--ease-smooth);

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

/* Variant property definitions */
.input--primary {
  /* Default styles */
}

.input--secondary {
  @apply shadow-none;
  background-color: var(--input-bg);

  --input-bg: var(--default);
  --input-bg-hover: var(--default-hover);
  --input-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus):not(:focus-visible),
    &[data-hovered="true"]:not([data-focus-visible="true"]):not([data-focused="true"]) {
      --input-bg: var(--input-bg-hover);
      background-color: var(--input-bg);
    }
  }

  &:focus,
  &[data-focused="true"] {
    --input-bg: var(--input-bg-focus);
    background-color: var(--input-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --input-bg: var(--input-bg-focus);
    background-color: var(--input-bg);
  }
}

/* Full width modifier */
.input--full-width {
  @apply w-full;
}

/* Base styles */
.kbd {
  @apply inline-flex h-6 items-center space-x-0.5 rounded-lg bg-default px-2 text-center font-sans text-sm font-medium whitespace-nowrap text-muted rtl:space-x-reverse;
  word-spacing: -0.25rem;
}

/* Key abbreviation styles */
.kbd__abbr {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

/* Content wrapper */
.kbd__content {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Variant styles */
.kbd--light {
  @apply bg-transparent;
}

/* Base label styles */
.label {
  /* Base styling */
  @apply text-sm font-medium text-foreground;
}

/*
 * Exclude group-level components (RadioGroup, CheckboxGroup) and radio/checkbox items
 * to ensure asterisks only appear on atomic form field labels and group labels,
 * not on individual options within those groups
 */
.label--required,
[data-required="true"]:not([role="group"]):not([role="radiogroup"]):not([role="checkboxgroup"])
  > .label,
[data-required="true"]:not([data-slot="radio"]):not([data-slot="checkbox"]) > .label {
  @apply after:ms-0.5 after:text-danger after:content-['*'];
}

.label--disabled,
[data-disabled="true"] .label {
  @apply status-disabled;
}

.label--invalid,
[data-invalid="true"] .label,
[aria-invalid="true"] .label {
  @apply text-danger;
}

/* Base link styles */
.link {
  @apply relative inline-flex h-fit w-fit items-center rounded-xl font-medium text-link no-underline decoration-separator-tertiary decoration-[1.5px] underline-offset-4 no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 100ms var(--ease-smooth),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out),
    opacity 100ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Hover state */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply underline decoration-muted/50;

      .link__icon {
        @apply opacity-100;
      }
    }
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    @apply underline decoration-muted;

    .link__icon {
      @apply opacity-100;
    }
  }

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;

    .link__icon {
      @apply opacity-100;
    }
  }

  /* Disabled state */
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  .link__icon {
    @apply pointer-events-none inline-flex size-[0.75em] shrink-0 items-center justify-center text-current opacity-60;

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: opacity 150ms var(--ease-out);
    @apply motion-reduce:transition-none;

    & svg {
      @apply transform-gpu;
    }
  }

  .link__icon[data-default-icon="true"] {
    @apply ms-1 pb-1.5;
  }

  /* Handle Link with Button Variants */
  &.button {
    @apply gap-0 no-underline;
  }
}

/* ==========================================================================
   Base list-box item styles
   ========================================================================== */

.list-box-item {
  @apply relative flex min-h-9 w-full items-center justify-start gap-3 rounded-2xl px-2 py-1.5 outline-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    box-shadow 150ms var(--ease-out);

  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  [data-slot="label"] {
    @apply pointer-events-none w-fit max-w-full min-w-0 select-none;
    /* Let a long unbroken word wrap inside the item instead of overflowing it */
    overflow-wrap: break-word;
  }

  [data-slot="description"] {
    @apply pointer-events-none text-wrap select-none;
  }

  /* Keep icons placed directly in the item at their natural size when the label wraps */
  > svg {
    @apply shrink-0;
  }

  /* Let a wrapper around the label (e.g. label + description column) shrink so the label can wrap */
  > :has([data-slot="label"]) {
    @apply min-w-0;
  }

  /* Add inline-end padding when indicator is present */
  &:has(.list-box-item__indicator) {
    @apply pe-7;
  }

  /* Focus visible state (keyboard focus only).
     React Aria always sets data-focused when it owns the item, so the native
     fallback is scoped to consumers rendering this class outside React Aria. */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Focus state */
  &:focus,
  &[data-focus="true"] {
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.98);
  }

  /* Hover state */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default;
    }
  }

  /* Selected state */
  &[aria-selected="true"],
  &[data-selected="true"] {
  }

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   List-box item indicator
   ========================================================================== */

.list-box-item__indicator {
  @apply absolute end-2 top-1/2 flex size-4 shrink-0 -translate-y-1/2 items-center justify-center text-default-foreground;

  /**
   * Transitions
   */
  @apply transition duration-250 motion-reduce:transition-none;

  /* Checkmark SVG indicator */
  [data-slot="list-box-item-indicator--checkmark"] {
    @apply size-2.5;

    /**
     * Transitions
     */
    @apply transition-all duration-300 motion-reduce:transition-none;
  }

  .list-box-item[aria-selected="true"] [data-slot="list-box-item-indicator--checkmark"],
  .list-box-item[data-selected="true"] [data-slot="list-box-item-indicator--checkmark"] {
    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: stroke-dashoffset 250ms linear;
    @apply motion-reduce:transition-none;
  }
}

/* Default variant */
.list-box-item--default {
}

/* Danger variant */
.list-box-item--danger {
  .list-box-item__indicator {
    @apply text-danger;
  }

  [data-slot="label"] {
    @apply text-danger;
  }
}

/* ==========================================================================
   Base list-box section styles
   ========================================================================== */

.list-box-section {
  @apply flex flex-col items-start gap-0;
}

/* ==========================================================================
   Base list-box styles
   ========================================================================== */

.list-box {
  @apply relative w-full overflow-clip p-1;

  /**
   * Spacing between direct children.
   *
   * NOTE: We intentionally avoid `display: flex` + `gap` here because
   * react-aria's Virtualizer renders a `position: relative` content
   * div with an explicit large height (e.g. 50000px) as the only child
   * of the ListBox. Flex shrinking would collapse that height and break
   * scrollbar sizing during virtualized scroll.
   */
  & > * + * {
    @apply mt-1;
  }

  /* This makes the horizontal separator take up 94% of the width and be centered */
  [data-slot="separator"][data-orientation="horizontal"] {
    @apply ms-[3%] w-[94%];
  }
}

/* ==========================================================================
   Base menu item styles
   ========================================================================== */

.menu-item {
  @apply relative flex min-h-9 w-full items-center justify-start gap-3 rounded-2xl px-2 py-1.5 outline-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    box-shadow 150ms var(--ease-out);

  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  [data-slot="label"] {
    @apply pointer-events-none w-fit max-w-full min-w-0 select-none;
    /* Let a long unbroken word wrap inside the item instead of overflowing it */
    overflow-wrap: break-word;
  }

  [data-slot="description"] {
    @apply pointer-events-none text-wrap select-none;
  }

  /* Keep icons placed directly in the item at their natural size when the label wraps */
  > svg {
    @apply shrink-0;
  }

  /* Let a wrapper around the label (e.g. label + description column) shrink so the label can wrap */
  > :has([data-slot="label"]) {
    @apply min-w-0;
  }

  [data-slot="submenu-indicator"] svg {
    @apply size-3.5;
  }

  /* Inline-start room for a start-side selection indicator.
     The submenu chevron uses `.menu-item__indicator` too, but it sits on the
     inline-end, so it must not take this padding. Excluding every submenu row
     would also drop the room a checkmark needs when the row has both. */
  &:has(.menu-item__indicator:not(.menu-item__indicator--submenu)) {
    @apply ps-7;
  }

  /* Inline-end room for the submenu chevron.
     Start padding is left to context (base `.menu-item` `px-2`, or a parent override). */
  &[data-has-submenu="true"]:has(.menu-item__indicator--submenu) {
    @apply pe-7;
  }

  /* Focus visible state (keyboard focus only).
     React Aria always sets data-focused when it owns the item, so the native
     fallback is scoped to consumers rendering this class outside React Aria. */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Focus state */
  &:focus,
  &[data-focus="true"] {
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    @apply will-change-transform;
    transform: scale(0.98);
  }

  /* Hover state */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default;
    }
  }

  /* Selected state */
  &[aria-checked="true"],
  &[aria-selected="true"],
  &[data-selected="true"] {
    [data-slot="menu-item-indicator--checkmark"] {
      /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
      transition: stroke-dashoffset 100ms linear;
      @apply motion-reduce:transition-none;
    }

    [data-slot="menu-item-indicator--dot"] {
      /**
       * Selected state: visible and scaled up
       */
      @apply scale-100 opacity-100;
    }
  }

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   Menu item indicator
   ========================================================================== */

.menu-item__indicator {
  @apply absolute start-2 top-1/2 flex size-4 shrink-0 -translate-y-1/2 items-center justify-center text-muted;

  /**
   * Transitions
   */
  @apply transition duration-250 motion-reduce:transition-none;

  /* Checkmark SVG indicator */
  [data-slot="menu-item-indicator--checkmark"] {
    @apply size-2.5;

    .menu-item[data-selection-mode="multiple"] & {
      /**
       * Transitions
       */
      @apply transition-all duration-300 motion-reduce:transition-none;
    }
  }

  /* Dot SVG indicator */
  [data-slot="menu-item-indicator--dot"] {
    @apply size-2;

    .menu-item[data-selection-mode="multiple"] & {
      /**
     * Transitions
     */
      @apply transition-all duration-250 motion-reduce:transition-none;
    }
    /**
     * Default state: hidden and scaled down
     */
    @apply scale-70 opacity-0;
  }
}

/* Submenu indicator (chevron-right).
   Only the chevron moves to the inline-end. A selection indicator on the same
   row keeps the start position from `.menu-item__indicator`. */
.menu-item__indicator--submenu {
  @apply text-muted;

  .menu-item[data-has-submenu="true"] & {
    @apply start-auto end-2;
  }

  svg {
    @apply size-3;
  }
}

/* Default variant */
.menu-item--default {
}

/* Danger variant */
.menu-item--danger {
  .menu-item__indicator {
    @apply text-danger;
  }

  [data-slot="label"] {
    @apply text-danger;
  }
}

/* ==========================================================================
   Base menu section styles
   ========================================================================== */

.menu-section {
  @apply flex flex-col items-start gap-0;
}

/* ==========================================================================
   Base menu styles
   ========================================================================== */

.menu {
  @apply relative flex w-full flex-col gap-1 overflow-clip p-1;

  /* This makes the separator take up 94% of the width and be centered */
  [data-slot="separator"] {
    @apply ms-[3%] w-[94%];
  }
}

/* ==========================================================================
   Meter - A quantity indicator within a known range
   ========================================================================== */

/* Base styles */
.meter {
  @apply grid w-full gap-1;
  grid-template-areas:
    "label output"
    "track track";
  grid-template-columns: 1fr auto;

  /* Default color tokens (accent) */
  --meter-fill: var(--accent);

  [data-slot="label"] {
    @apply w-fit text-sm font-medium;

    grid-area: label;
  }

  .meter__output {
    @apply text-sm font-medium tabular-nums;

    grid-area: output;
  }

  .meter__track {
    @apply relative overflow-hidden rounded-sm bg-default;

    grid-area: track;

    /* Default height (matches --md) */
    @apply h-2;
  }

  .meter__fill {
    @apply absolute start-0 top-0 h-full rounded-sm;

    background-color: var(--meter-fill);

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: width 300ms var(--ease-out);
    @apply motion-reduce:transition-none;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;

    [data-slot="label"] {
      @apply opacity-100;
    }
  }
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.meter--sm {
  .meter__track {
    @apply h-1 rounded-xs;
  }

  .meter__fill {
    @apply rounded-xs;
  }
}

.meter--md {
  /* No styles as this is the default size */
}

.meter--lg {
  .meter__track {
    @apply h-3 rounded-md;
  }

  .meter__fill {
    @apply rounded-md;
  }
}

/* ==========================================================================
   Color variants
   ========================================================================== */

.meter--default {
  --meter-fill: var(--default-foreground);
}

.meter--accent {
  --meter-fill: var(--accent);
}

.meter--success {
  --meter-fill: var(--success);
}

.meter--warning {
  --meter-fill: var(--warning);
}

.meter--danger {
  --meter-fill: var(--danger);
}

/* -------------------------------------------------------------------------------------------------
 * Modal Component Styles
 * Block: modal
 * -----------------------------------------------------------------------------------------------*/

/**
 * Element: trigger - the element that opens the modal
 */
.modal__trigger {
  @apply inline-block cursor-(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out-quart),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Active/pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.97);
  }
}

/**
 * Element: backdrop - the overlay behind the dialog
 */
.modal__backdrop {
  @apply fixed inset-0 z-(--z-index-overlay);
  @apply flex flex-row items-center justify-center;
  @apply h-(--visual-viewport-height) w-full;

  /* Entering animation */
  &[data-entering="true"] {
    animation: heroui-overlay-fade-in 150ms var(--ease-out);
  }

  /* Exiting animation */
  &[data-exiting="true"] {
    animation: heroui-overlay-fade-out 100ms var(--ease-out);
  }

  /**
   * Reduce Animation
   * CRITICAL: motion-reduce must be AFTER animate for correct override specificity
   */
  &[data-exiting="true"],
  &[data-entering="true"] {
    @apply motion-reduce:animate-none;
  }
}

/**
 * Modifier: backdrop--transparent
 */
.modal__backdrop--transparent {
  @apply bg-transparent;
}

/**
 * Modifier: backdrop--opaque
 */
.modal__backdrop--opaque {
  @apply bg-backdrop;
}

/**
 * Modifier: backdrop--blur
 */
.modal__backdrop--blur {
  @apply bg-backdrop backdrop-blur-md;

  /*
   * A full-viewport backdrop-filter stalls mid-range mobile GPUs long enough
   * that the open animation is skipped. On touch devices, only skip the blur
   * while the backdrop is animating so the dim scrim fades on its own, then
   * apply the blur once the overlay has settled.
   */
  @media (hover: none) and (pointer: coarse) {
    &[data-entering="true"],
    &[data-exiting="true"] {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}

/**
 * Element: container - the positioning wrapper for the modal
 */
.modal__container {
  @apply flex flex-col items-center;
  @apply h-(--visual-viewport-height) w-full min-w-0 flex-1;
  @apply p-4;
  @apply sm:w-fit sm:p-10;
  @apply pointer-events-none;

  /* Entering animation */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-105 250ms var(--ease-out-quad);

    &[data-placement="auto"] {
      animation-name: heroui-overlay-enter-105-y;

      @variant sm {
        animation-name: heroui-overlay-enter-105;
      }
    }

    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-105-ny;
    }

    &[data-placement="center"] {
      animation-name: heroui-overlay-enter-105;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-105-y;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-out-quad);
  }

  /**
   * Reduce Animation
   * CRITICAL: motion-reduce must be AFTER animate for correct override specificity
   */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement],
  &[data-entering="true"],
  &[data-entering="true"][data-placement] {
    @apply motion-reduce:animate-none;
  }
}

/**
 * Modifier: container--scroll-outside
 *
 * The container is React Aria's modal ref, so it must stay `pointer-events: none`,
 * otherwise clicks around the dialog count as inside the modal and never dismiss it.
 * The backdrop owns the scrolling instead.
 */
.modal__container--scroll-outside {
  @apply h-auto min-h-(--visual-viewport-height) overflow-y-visible;
}

.modal__backdrop:has(.modal__container--scroll-outside) {
  @apply scrollbar items-start overflow-y-auto;
  -webkit-overflow-scrolling: touch;
}

/**
 * Modifier: container--full
 */
.modal__container--full {
  @apply p-0 sm:p-0;

  /* Entering animation */
  &[data-entering="true"] {
    animation-name: heroui-overlay-enter-100;

    /* Same placement offsets as the base container, with no scale. */
    &[data-placement="auto"] {
      animation-name: heroui-overlay-enter-100-y;

      @variant sm {
        animation-name: heroui-overlay-enter-100;
      }
    }

    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-100-ny;
    }

    &[data-placement="center"] {
      animation-name: heroui-overlay-enter-100;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-100-y;
    }
  }

  /* Same specificity as the base exit, so the fade still replaces the scale. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation-name: heroui-overlay-fade-out;
  }

  /* The name overrides above outrank the base reduced-motion rule, so repeat it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement],
  &[data-entering="true"],
  &[data-entering="true"][data-placement] {
    @apply motion-reduce:animate-none;
  }
}

/**
 * Element: dialog - the content container for the modal
 */
.modal__dialog {
  @apply relative;
  @apply flex w-full flex-col;
  @apply bg-overlay shadow-overlay outline-none;
  border-radius: min(32px, var(--radius-3xl));
  @apply p-6;
  @apply pointer-events-auto;

  &[data-placement="auto"] {
    @apply mt-auto;
    @apply sm:my-auto;
  }

  &[data-placement="center"] {
    @apply my-auto;
  }

  &[data-placement="bottom"] {
    @apply mt-auto;
  }

  &[data-placement="top"] {
    @apply mt-0;
  }
}

/**
 * Modifier: dialog--scroll-inside
 */
.modal__dialog--scroll-inside {
  @apply max-h-full min-h-0 overflow-clip;
}

/**
 * Modifier: dialog--scroll-outside
 */
.modal__dialog--scroll-outside {
  @apply h-auto;
  @apply min-h-0 shrink-0;
}

/**
 * Modifier: dialog--xs
 */
.modal__dialog--xs {
  @apply max-w-xs;
}

/**
 * Modifier: dialog--sm
 */
.modal__dialog--sm {
  @apply max-w-sm;
}

/**
 * Modifier: dialog--md
 */
.modal__dialog--md {
  @apply max-w-md;
}

/**
 * Modifier: dialog--lg
 */
.modal__dialog--lg {
  @apply max-w-lg;
}

/**
 * Modifier: dialog--cover
 */
.modal__dialog--cover {
  @apply h-full min-h-full w-full;
}

/**
 * Modifier: dialog--full
 */
.modal__dialog--full {
  @apply h-full min-h-full w-full;
  @apply rounded-none shadow-none;
}

/**
 * Element: header - the top section with the title
 */
.modal__header {
  @apply flex flex-col gap-3;
  @apply mb-0;

  /* When header contains icon, use flex-col layout with gap */
  & > .modal__icon {
    @apply mb-0;
  }
}

/**
 * Element: heading - the main title text
 */
.modal__heading {
  @apply align-middle;
  @apply text-base font-medium text-foreground;
}

/**
 * Element: icon - the optional icon indicator
 */
.modal__icon {
  @apply flex items-center justify-center;
  @apply size-10 shrink-0;
  @apply rounded-3xl select-none;
}

/**
 * Element: body - the main content area
 */
.modal__body {
  @apply min-h-0 flex-1;
  @apply text-sm leading-[1.43] text-muted;
  @apply -m-[3px] my-0 overflow-visible p-[3px];
}

/**
 * Modifier: body--scroll-inside
 */
.modal__body--scroll-inside {
  @apply scrollbar overflow-y-auto overscroll-contain;
  -webkit-overflow-scrolling: touch;
}

/**
 * Modifier: body--scroll-outside
 */
.modal__body--scroll-outside {
  @apply overflow-y-visible;
}

/**
 * Element: footer - the bottom action section
 */
.modal__footer {
  @apply flex flex-row flex-wrap items-center justify-end gap-2;
  @apply mt-0;
}

/**
 * Element: close-trigger - the optional x icon button to close the modal
 */
.modal__close-trigger {
  @apply absolute end-4 top-4;
}

/**
 * Elements Spacing
 */
.modal__header + .modal__body {
  @apply mt-2;
}

.modal__header + .modal__footer {
  @apply mt-5;
}

.modal__body + .modal__footer {
  @apply mt-5;
}

/* Number field styles */
.number-field {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }
}

.number-field__group {
  @apply grid h-9 items-center overflow-hidden rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--number-field-group-bg`; variants override the three tokens. */
  --number-field-group-bg: var(--color-field);
  --number-field-group-bg-hover: var(--color-field-hover);
  --number-field-group-bg-focus: var(--field-focus);
  grid-template-columns: 1fr;

  &:has([slot="decrement"]) {
    grid-template-columns: 40px 1fr;
  }

  &:has([slot="increment"]) {
    grid-template-columns: 1fr 40px;
  }

  &:has([slot="decrement"]):has([slot="increment"]) {
    grid-template-columns: 40px 1fr 40px;
  }

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      @apply bg-field-hover;
      --number-field-group-bg: var(--number-field-group-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus within state */
  &[data-focus-within="true"],
  &:focus-within {
    @apply status-focused-field;
    border-color: var(--field-border-focus);
    --number-field-group-bg: var(--number-field-group-bg-focus);
    background-color: var(--number-field-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --number-field-group-bg: var(--number-field-group-bg-focus);
    background-color: var(--number-field-group-bg);
    border-color: var(--color-field-border-invalid);
  }

  /* Disabled state */
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.number-field__input {
  @apply min-w-0 rounded-none border-0 bg-transparent px-3 py-2 text-base tabular-nums shadow-none outline-none sm:text-sm;

  /* Remove border radius on left side when decrement button is present */
  .number-field__group:has([slot="decrement"]) & {
    @apply rounded-s-none;
  }

  /* Remove border radius on right side when increment button is present */
  .number-field__group:has([slot="increment"]) & {
    @apply rounded-e-none;
  }

  /* Focus state - handled by group */
  &:focus,
  &:focus-visible {
    @apply outline-none;
  }

  /**
   * Cover the UA autofill paint with the group's own fill so the stepper
   * buttons and the input stay one color. `--number-field-group-bg` is
   * inherited from `.number-field__group` and already tracks the variant.
   * box-shadow is not transitioned: the 1000px inset must appear at once.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--number-field-group-bg) inset;
    box-shadow: 0 0 0 1000px var(--number-field-group-bg) inset;
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition: background-color 9999s ease-in-out 0s;

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

.number-field__increment-button,
.number-field__decrement-button {
  @apply flex h-full w-10 items-center justify-center rounded-none bg-transparent text-field-foreground outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);
  border-style: solid;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    @apply bg-field-foreground/10;
    transform: scale(0.97);
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Icon styling */
  [data-slot="number-field-increment-button-icon"],
  [data-slot="number-field-decrement-button-icon"] {
    @apply size-4;
  }
}

.number-field__increment-button {
  @apply rounded-s-none rounded-e-field border-s border-field-placeholder/15;
}

.number-field__decrement-button {
  @apply rounded-s-field rounded-e-none border-e border-field-placeholder/15;
}

/* Variant property definitions */
.number-field--primary {
  /* Default styles */
}

.number-field--secondary .number-field__group {
  @apply shadow-none;
  background-color: var(--number-field-group-bg);

  --number-field-group-bg: var(--default);
  --number-field-group-bg-hover: var(--default-hover);
  --number-field-group-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      --number-field-group-bg: var(--number-field-group-bg-hover);
      background-color: var(--number-field-group-bg);
    }
  }

  &:focus-within,
  &[data-focus-within="true"] {
    --number-field-group-bg: var(--number-field-group-bg-focus);
    background-color: var(--number-field-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    border-color: var(--color-field-border-invalid);
    --number-field-group-bg: var(--number-field-group-bg-focus);
    background-color: var(--number-field-group-bg);
  }

  [data-slot="number-field-input"] {
    @apply bg-transparent;
  }
}

/* Full width modifier */
.number-field--full-width {
  @apply w-full;
}

.number-field__group--full-width {
  @apply w-full;
}

/* ==========================================================================
   Pagination - Page navigation component
   ========================================================================== */

/* Base styles */
.pagination {
  @apply flex w-full flex-col items-center justify-between gap-4 sm:flex-row;
}

/* Summary - left side info container */
.pagination__summary {
  @apply flex items-center gap-2 self-start text-sm text-muted sm:self-center;
}

/* Content - container for pagination items */
.pagination__content {
  @apply flex items-center gap-1 self-start sm:self-center;
}

/* Item - list item wrapper */
.pagination__item {
  @apply inline-flex;
}

/* Link - page number button (ghost button style) */
.pagination__link {
  @apply relative isolate inline-flex size-9 origin-center items-center justify-center rounded-3xl text-sm font-medium whitespace-nowrap outline-none select-none no-highlight md:size-8;

  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-smooth),
    background-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Ghost button tokens */
  --pagination-link-bg: transparent;
  --pagination-link-bg-hover: var(--default-hover);
  --pagination-link-bg-pressed: var(--default-hover);
  --pagination-link-fg: var(--default-foreground);

  background-color: var(--pagination-link-bg);
  color: var(--pagination-link-fg);

  /* Focus state */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Hover state */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      background-color: var(--pagination-link-bg-hover);
    }
  }

  /* Active / pressed */
  &:active,
  &[data-pressed="true"] {
    background-color: var(--pagination-link-bg-pressed);
    transform: scale(0.97);
  }

  /* Active page - tertiary button style */
  &[data-active="true"] {
    --pagination-link-bg: var(--default);
    --pagination-link-bg-hover: var(--default-hover);
    --pagination-link-bg-pressed: var(--default-hover);
  }
}

/* Ellipsis */
.pagination__ellipsis {
  @apply inline-flex size-9 items-center justify-center text-sm text-muted select-none md:size-8;
}

/* Navigation buttons (Previous / Next) */
.pagination__link--nav {
  @apply w-auto gap-1.5 px-2.5;

  & [data-slot="pagination-previous-icon"],
  & [data-slot="pagination-next-icon"] {
    @apply rtl:rotate-180;
  }
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.pagination--sm {
  .pagination__link {
    @apply size-8 text-xs md:size-7;

    &:active,
    &[data-pressed="true"] {
      transform: scale(0.98);
    }
  }

  .pagination__link--nav {
    @apply w-auto px-2;
  }

  .pagination__ellipsis {
    @apply size-8 text-xs md:size-7;
  }

  .pagination__summary {
    @apply text-xs;
  }
}

.pagination--md {
  /* No styles as this is the default size */
}

.pagination--lg {
  .pagination__link {
    @apply size-10 text-base md:size-9;

    &:active,
    &[data-pressed="true"] {
      transform: scale(0.96);
    }
  }

  .pagination__link--nav {
    @apply w-auto px-3;
  }

  .pagination__ellipsis {
    @apply size-10 text-base md:size-9;
  }

  .pagination__summary {
    @apply text-base;
  }
}

/* Popover component styles */

/* Base popover styles */
.popover {
  @apply origin-(--trigger-anchor-point) bg-overlay p-0 text-sm;
  border-radius: min(32px, var(--radius-3xl));
  box-shadow: var(--overlay-shadow);

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-90 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-90-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-90-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-90-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-90-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /* Arrow styling */
  & [data-slot="popover-overlay-arrow"] {
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="popover-overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="popover-overlay-arrow"] {
    rotate: 90deg;
  }
}

/* Popover dialog */
.popover__dialog {
  @apply p-4 outline-none;
}

/* Popover heading */
.popover__heading {
  @apply font-medium;
}

/* Popover trigger */
.popover__trigger {
  @apply inline-block;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 150ms var(--ease-smooth),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   ProgressBar - Shows determinate or indeterminate progress
   ========================================================================== */

/* Base styles */
.progress-bar {
  @apply grid w-full gap-1;
  grid-template-areas:
    "label output"
    "track track";
  grid-template-columns: 1fr auto;

  /* Default color token (accent) */
  --progress-bar-fill: var(--accent);

  [data-slot="label"] {
    @apply w-fit text-sm font-medium;

    grid-area: label;
  }

  .progress-bar__output {
    @apply text-sm font-medium tabular-nums;

    grid-area: output;
  }

  .progress-bar__track {
    @apply relative overflow-hidden rounded-sm bg-default;

    grid-area: track;

    /* Default height (matches --md) */
    @apply h-2;
  }

  .progress-bar__fill {
    @apply absolute start-0 top-0 h-full rounded-sm;

    background-color: var(--progress-bar-fill);

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: width 300ms var(--ease-out);
    @apply motion-reduce:transition-none;
  }

  /* Indeterminate state - when no aria-valuenow is set */
  &:not([aria-valuenow]) {
    .progress-bar__fill {
      @apply w-2/5;

      /* The fill is anchored at inline-start (the right edge in RTL), so the sweep must run
         toward inline-end. The keyframes scale their physical offsets by this sign. `:dir(rtl)`
         resolves the element's own direction, so a nested `dir="ltr"` subtree keeps the LTR sign
         (Tailwind's `rtl` variant would still match it through `[dir="rtl"] *`). */
      --progress-bar-sweep-direction: 1;

      &:dir(rtl) {
        --progress-bar-sweep-direction: -1;
      }

      animation: progress-bar-indeterminate 1.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;

      @apply motion-reduce:animate-none;
    }
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;

    [data-slot="label"] {
      @apply opacity-100;
    }
  }
}

/* ==========================================================================
   Indeterminate animation
   ========================================================================== */

@keyframes progress-bar-indeterminate {
  0% {
    transform: translateX(calc(var(--progress-bar-sweep-direction, 1) * -100%));
  }
  100% {
    transform: translateX(calc(var(--progress-bar-sweep-direction, 1) * 350%));
  }
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.progress-bar--sm {
  .progress-bar__track {
    @apply h-1 rounded-xs;
  }

  .progress-bar__fill {
    @apply rounded-xs;
  }
}

.progress-bar--md {
  /* No styles as this is the default size */
}

.progress-bar--lg {
  .progress-bar__track {
    @apply h-3 rounded-md;
  }

  .progress-bar__fill {
    @apply rounded-md;
  }
}

/* ==========================================================================
   Color variants
   ========================================================================== */

.progress-bar--default {
  --progress-bar-fill: var(--default-foreground);
}

.progress-bar--accent {
  --progress-bar-fill: var(--accent);
}

.progress-bar--success {
  --progress-bar-fill: var(--success);
}

.progress-bar--warning {
  --progress-bar-fill: var(--warning);
}

.progress-bar--danger {
  --progress-bar-fill: var(--danger);
}

/* ==========================================================================
   ProgressCircle - Circular progress indicator
   ========================================================================== */

/* Base styles */
.progress-circle {
  @apply inline-flex items-center justify-center;

  /* Default color token (accent) */
  --progress-circle-stroke: var(--accent);
  --progress-circle-track-stroke: var(--default);

  .progress-circle__track {
    /* Default size (matches --md) */
    @apply size-7;
  }

  .progress-circle__track-circle {
    stroke: var(--progress-circle-track-stroke);
  }

  .progress-circle__fill-circle {
    stroke: var(--progress-circle-stroke);

    /**
     * Transitions
     * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
     */
    transition: stroke-dashoffset 300ms var(--ease-out);
    @apply motion-reduce:transition-none;
  }

  /* Indeterminate state - when no aria-valuenow is set */
  &:not([aria-valuenow]) {
    .progress-circle__track {
      animation: progress-circle-spin 1s linear infinite;

      @apply motion-reduce:animate-none;
    }
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* ==========================================================================
   Indeterminate animation
   ========================================================================== */

@keyframes progress-circle-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.progress-circle--sm {
  .progress-circle__track {
    @apply size-5;
  }
}

.progress-circle--md {
  /* No styles as this is the default size */
}

.progress-circle--lg {
  .progress-circle__track {
    @apply size-9;
  }
}

/* ==========================================================================
   Color variants
   ========================================================================== */

.progress-circle--default {
  --progress-circle-stroke: var(--default-foreground);
}

.progress-circle--accent {
  --progress-circle-stroke: var(--accent);
}

.progress-circle--success {
  --progress-circle-stroke: var(--success);
}

.progress-circle--warning {
  --progress-circle-stroke: var(--warning);
}

.progress-circle--danger {
  --progress-circle-stroke: var(--danger);
}

/* Radio Group base styles */
.radio-group {
  @apply flex flex-col;

  /* Default orientation */
  &[data-orientation="vertical"] {
    [data-slot="radio"] {
      @apply mt-4;
    }
  }

  &[data-orientation="horizontal"] {
    @apply flex-row flex-wrap gap-4;
  }
}

/* Variant property definitions */
.radio-group--primary {
  /* Default styles */
}

.radio-group--secondary .radio__control {
  @apply shadow-none;
  background-color: var(--radio-control-bg);

  --radio-control-bg: var(--default);
  --radio-control-bg-hover: var(--default-hover);

  /* Hover state */
  .radio:has([data-slot="radio-content"][data-hovered="true"]) &,
  .radio [data-slot="radio-content"][data-hovered="true"] & {
    @apply border-field-border-hover;
  }

  /* Default indicator color (unselected) */
  .radio:not([data-selected]):not(:has(input:checked)) & .radio__indicator:empty::before {
    background-color: var(--radio-control-bg);
  }

  /* Hover indicator color (unselected) */
  .radio:has([data-slot="radio-content"][data-hovered="true"]):not([data-selected]):not(
      :has(input:checked)
    )
    & {
    .radio__indicator:empty::before {
      background-color: var(--radio-control-bg-hover);
    }
  }
}

/* ==========================================================================
   Base radio styles

   Structure (explicit composition):
     .radio                      → RadioField wrapper (column)
       .radio__content            → RadioButton: the clickable row (control + label)
         .radio__control
         [data-slot="label"]
       [data-slot="description"] → field-level sibling, below the row
       [data-slot="field-error"]
   ========================================================================== */

.radio {
  @apply flex flex-col items-start gap-1 outline-none no-highlight;

  cursor: var(--cursor-interactive);

  [data-slot="label"] {
    @apply select-none;
  }

  .radio__content [data-slot="label"] {
    cursor: var(--cursor-interactive);
  }

  /* Field-level help text (siblings of the button), indented to align under the label */
  & > [data-slot="description"],
  & > [data-slot="field-error"] {
    @apply w-full min-w-0 cursor-default ps-7 text-xs text-wrap wrap-break-word text-muted select-none;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;

    [data-slot="description"],
    [data-slot="field-error"] {
      @apply status-disabled;
    }
  }
}

/* Radio content — the clickable label (control + label text) */
.radio__content {
  @apply relative inline-flex cursor-[inherit] items-center gap-3 text-sm font-medium text-foreground outline-none select-none no-highlight;
}

/* ==========================================================================
   Radio control (the circular button)
   ========================================================================== */

.radio__control {
  @apply relative inline-flex size-4 shrink-0 items-center justify-center rounded-lg border [border-width:var(--border-width-field)] border-field-border bg-field shadow-field outline-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    transform 100ms var(--ease-out);
  @apply motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Interactive states */
  /* Focus */
  .radio:has([data-slot="radio-content"]:focus-visible) &,
  .radio [data-slot="radio-content"]:focus-visible &,
  .radio:has([data-slot="radio-content"][data-focus-visible="true"]) &,
  .radio [data-slot="radio-content"][data-focus-visible="true"] & {
    @apply status-focused;
  }

  /* Hover */
  @media (hover: hover) {
    .radio:has([data-slot="radio-content"]:hover) &,
    .radio [data-slot="radio-content"]:hover &,
    .radio:has([data-slot="radio-content"][data-hovered="true"]) &,
    .radio [data-slot="radio-content"][data-hovered="true"] & {
      @apply border-field-border-hover;
    }

    /* Hover - only when not selected */
    .radio:has([data-slot="radio-content"]:hover):not([data-selected]):not(:has(input:checked)) &,
    .radio:has([data-slot="radio-content"][data-hovered="true"]):not([data-selected]):not(
        :has(input:checked)
      )
      & {
      .radio__indicator:empty::before {
        @apply bg-field-hover;
      }
    }
  }

  /* Pressed */
  .radio:has([data-slot="radio-content"]:active) &,
  .radio [data-slot="radio-content"]:active &,
  .radio:has([data-slot="radio-content"][data-pressed="true"]) &,
  .radio [data-slot="radio-content"][data-pressed="true"] & {
    @apply scale-95;
  }

  /* Selection states */
  /* Selected */
  .radio[data-selected] &,
  .radio:has([data-slot="radio-content"][aria-checked="true"]) &,
  .radio:has(input:checked) & {
    @apply border-transparent bg-accent;
  }

  /* Selected + Pressed */
  .radio[data-selected]:has([data-slot="radio-content"]:active) &,
  .radio:has(input:checked):has([data-slot="radio-content"]:active) &,
  .radio[data-selected]:has([data-slot="radio-content"][data-pressed="true"]) &,
  .radio:has([data-slot="radio-content"][data-pressed="true"][aria-checked="true"]) &,
  .radio:has(input:checked):has([data-slot="radio-content"][data-pressed="true"]) & {
    @apply bg-accent-hover;
  }

  /* Validation states */
  /* Invalid */
  .radio[data-invalid="true"] &,
  .radio[aria-invalid="true"] & {
    @apply status-invalid-field;
  }

  /* Invalid + Selected */
  .radio[data-invalid="true"][data-selected] &,
  .radio[aria-invalid="true"][data-selected] &,
  .radio[data-invalid="true"]:has(input:checked) &,
  .radio[aria-invalid="true"]:has(input:checked) & {
    @apply status-invalid-field;
  }
}

/* ==========================================================================
   Radio indicator (the inner dot)
   ========================================================================== */

.radio__indicator {
  @apply absolute inset-0 flex items-center justify-center;

  pointer-events: none;
}

/* :empty pseudo-class ensures these styles only apply when the indicator has no custom children
   (e.g., custom icon). When custom content is present, these default dot styles are not applied. */
.radio__indicator:empty::before {
  content: "";
  @apply rounded-lg bg-field;

  width: 100%;
  height: 100%;
  scale: 1;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    scale 200ms var(--ease-out),
    background-color 200ms var(--ease-out);
  @apply motion-reduce:transition-none;
}

/* Selected state */
.radio[data-selected] .radio__indicator:empty::before,
.radio:has([data-slot="radio-content"][aria-checked="true"]) .radio__indicator:empty::before,
.radio:has(input:checked) .radio__indicator:empty::before {
  @apply bg-accent-foreground;
  scale: 0.4286; /* 6px */
}

/* Selected + Pressed state */
.radio[data-selected]:has([data-slot="radio-content"]:active) .radio__indicator:empty::before,
.radio:has(input:checked):has([data-slot="radio-content"]:active) .radio__indicator:empty::before,
.radio[data-selected]:has([data-slot="radio-content"][data-pressed="true"])
  .radio__indicator:empty::before,
.radio:has([data-slot="radio-content"][data-pressed="true"][aria-checked="true"])
  .radio__indicator:empty::before,
.radio:has(input:checked):has([data-slot="radio-content"][data-pressed="true"])
  .radio__indicator:empty::before {
  scale: 0.5714; /* 8px */
}

/* =============================================================================
 * RangeCalendar Component Styles
 *
 * A compound component for contiguous date range selection.
 * Uses BEM naming convention: range-calendar, range-calendar__element, range-calendar--modifier
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * Base RangeCalendar Styles
 * -------------------------------------------------------------------------- */
.range-calendar {
  @apply w-63 max-w-63;

  container-type: inline-size;
}

/* Week view – visibleDuration={{ weeks: n }} */
.range-calendar--week-view {
  .range-calendar__cell {
    /* Keep cells circular on the 7-column grid; only filled cells take space. */
    @apply aspect-square size-auto w-full place-self-center;
  }
}

/* Day view – visibleDuration={{ days: n }} */
.range-calendar--day-view {
  .range-calendar__cell {
    @apply aspect-square size-auto w-full place-self-center;
  }

  /*
   * Isolate header and body into separate 7-column grids. With display:contents
   * on the root grid, fewer than 7 weekday headers flow into the same row as dates.
   */
  .range-calendar__grid {
    display: flex;
    flex-direction: column;
  }

  .range-calendar__grid-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    @apply w-full;

    & > tr {
      display: contents;
    }
  }

  .range-calendar__grid-body {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    @apply mt-1 w-full;

    & > tr {
      display: contents;
    }

    & > tr:first-child > td {
      @apply mt-0;
    }
  }
}

/* -----------------------------------------------------------------------------
 * RangeCalendar Header
 * -------------------------------------------------------------------------- */
.range-calendar__header {
  @apply flex items-center justify-between px-0.5 pb-4;

  &:has(.calendar-year-picker__trigger[data-open="true"]) {
    .range-calendar__nav-button {
      @apply pointer-events-none opacity-0;
    }
  }
}

.range-calendar__heading {
  @apply flex-1 text-sm font-medium;
}

.range-calendar__nav-button {
  @apply flex size-6 items-center justify-center rounded-xl text-accent-soft-foreground;

  will-change: scale;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-out),
    background-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out),
    opacity 150ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  cursor: var(--cursor-interactive);

  /* Hover state – only on devices that support hover (avoids false triggers on touch) */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default text-accent-soft-foreground;
    }
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    transform: scale(0.95);
  }

  /* Focus state */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"] {
    @apply status-disabled;
  }
}

.range-calendar__nav-button-icon {
  @apply size-4 rtl:rotate-180;
}

/* -----------------------------------------------------------------------------
 * RangeCalendar Grid
 * -------------------------------------------------------------------------- */
.range-calendar__grid {
  /* Override table display with CSS Grid for easier customization */
  display: grid;
  /*
   * `minmax(0, 1fr)` instead of `1fr` so columns stay equal and never grow to fit
   * their content. `1fr` alone is `minmax(auto, 1fr)`, which lets long weekday labels
   * (e.g. pt-PT "domingo", "segunda") widen their column past the fixed calendar width.
   */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  @apply w-full;

  &[aria-readonly="true"] {
    .range-calendar__cell {
      @apply pointer-events-none;
    }
  }
}

.range-calendar__grid-header {
  /* Grid header (thead) styles */
  display: contents;

  & > tr {
    display: contents;
  }
}

.range-calendar__grid-body {
  /* Grid body (tbody) styles */
  display: contents;

  & > tr {
    display: contents;
  }

  /* Add top spacing between header and first body row */
  & > tr:first-child > td {
    @apply mt-1;
  }
}

.range-calendar__grid-row {
  /* Use 'contents' so cells participate directly in grid */
  /* Note: This class can be used for custom row styling if needed */
  display: contents;
}

.range-calendar__header-cell {
  /* Header cell (th - weekday names) styles */
  /*
   * Block (not flex) so `truncate` can apply an ellipsis to the label text when a
   * locale's weekday name is wider than the column, instead of letting labels overflow
   * and run into each other.
   */
  @apply block min-w-0 truncate pb-2 text-center text-xs font-medium text-muted;
}

/* -----------------------------------------------------------------------------
 * RangeCalendar Cells
 * -------------------------------------------------------------------------- */
.range-calendar__cell {
  @apply relative z-1 mx-0 my-[2px] rounded-3xl p-0 outline-none;
  cursor: var(--cursor-interactive);

  will-change: background-color, border-color;
  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    box-shadow 100ms var(--ease-out),
    border-color 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Inner interactive circle/capsule (equivalent to React Aria "button-base") */
  .range-calendar__cell-button {
    @apply flex aspect-square w-full items-center justify-center rounded-3xl text-sm font-medium text-foreground no-highlight;

    will-change: scale;
    transition: scale 200ms var(--ease-out);
    @apply transform-gpu motion-reduce:transition-none;
  }

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply z-2;

    .range-calendar__cell-button {
      @apply status-focused;
    }
  }

  /* Today indicator */
  &[data-today="true"] {
    .range-calendar__cell-button {
      @apply bg-accent-soft text-accent-soft-foreground;
    }

    @media (hover: hover) {
      &:hover:not([data-selected="true"]),
      &[data-hovered="true"]:not([data-selected="true"]) {
        .range-calendar__cell-button {
          @apply bg-accent-soft-hover;
        }
      }
    }
  }

  /* Range selected track (middle segment) */
  &[data-selected="true"]:not([data-outside-month="true"]) {
    @apply rounded-none bg-accent-soft;
  }

  /* Round row boundaries so the range track looks continuous across weeks */
  &[data-selected="true"]:is(td:first-child > *, [aria-disabled] + td > *) {
    @apply rounded-ss-lg rounded-es-lg;
    &[data-selection-start="true"] {
      @apply rounded-ss-3xl rounded-es-3xl;
    }
  }

  &[data-selected="true"]:is(td:last-child > *, td:has(+ [aria-disabled]) > *) {
    @apply rounded-se-lg rounded-ee-lg;
    &[data-selection-end="true"] {
      @apply rounded-se-3xl rounded-ee-3xl;
    }
  }

  /* Range caps (start/end) */
  &[data-selection-start="true"]:not([data-outside-month="true"]),
  &[data-selection-end="true"]:not([data-outside-month="true"]) {
    @apply z-2;

    .range-calendar__cell-button {
      @apply bg-accent text-accent-foreground;
    }
  }

  /* &[data-selection-start="true"]:has(+ [data-selection-end="true"]) {
    @apply rounded-full;
  } */

  &[data-selection-start="true"]:not([data-outside-month="true"]) {
    @apply rounded-ss-3xl rounded-es-3xl;
  }

  &[data-selection-end="true"]:not([data-outside-month="true"]) {
    @apply rounded-se-3xl rounded-ee-3xl;
  }

  /* Pressed state */
  &:active,
  &[data-pressed="true"] {
    .range-calendar__cell-button {
      scale: 0.9;
    }

    &[data-selection-start="true"],
    &[data-selection-end="true"] {
      .range-calendar__cell-button {
        @apply bg-accent-hover;
      }
    }
  }

  /* Hover state for non-selected days */
  @media (hover: hover) {
    &:hover:not([data-selected="true"]),
    &[data-hovered="true"]:not([data-selected="true"]) {
      .range-calendar__cell-button {
        @apply bg-default;
      }
    }
  }

  /* Outside month (previous/next month days) */
  &[data-outside-month="true"] {
    @apply text-muted opacity-50;
  }

  &[data-selected="true"][data-outside-month="true"]:not(
      [data-selection-start="true"],
      [data-selection-end="true"]
    ) {
    @apply bg-default/20;
  }

  /* Unavailable dates */
  &[data-unavailable="true"] {
    @apply status-disabled;
  }

  /* Disabled state */
  &:disabled:not([data-outside-month="true"]),
  &[data-disabled="true"]:not([data-outside-month="true"]) {
    @apply status-disabled;

    text-decoration: line-through;
  }
}

/* Outside-month cell followed by selected cell across adjacent table cells */
.range-calendar__grid-body
  td:has(> .range-calendar__cell[data-outside-month="true"])
  + td
  > .range-calendar__cell[data-selected="true"] {
  @apply rounded-ss-lg rounded-es-lg;

  &[data-outside-month="true"],
  &[data-selection-start="true"] {
    @apply rounded-ss-3xl rounded-es-3xl;
  }
}

/* Selected cell followed by outside-month cell across adjacent table cells */
.range-calendar__grid-body
  td:has(> .range-calendar__cell[data-selected="true"]):has(
    + td > .range-calendar__cell[data-outside-month="true"]
  )
  > .range-calendar__cell[data-selected="true"] {
  @apply rounded-se-lg rounded-ee-lg;

  &[data-outside-month="true"],
  &[data-selection-end="true"] {
    @apply rounded-se-3xl rounded-ee-3xl;
  }
}

/* Cell indicator - small dot at bottom center of cell */
.range-calendar__cell-indicator {
  @apply absolute bottom-1 left-1/2 size-[3px] -translate-x-1/2 rounded-xs bg-muted;

  /* Indicator color changes when cell is selected */
  [data-selected="true"] > & {
    @apply bg-accent-foreground;
  }
}

/* Base scroll-shadow component */
.scroll-shadow {
  @apply relative;
  --scroll-shadow-size: 40px;
  --scroll-shadow-scrollbar-size: 10px;
  --scroll-shadow-offset: 0px;
}

/* Fade sizes for the scroll-driven variant below. They stay at 0px whenever the scroll
   timeline is inactive, which is exactly the state of a container without overflow. */
@property --scroll-shadow-start-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --scroll-shadow-end-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes scroll-shadow-start-fade {
  from {
    --scroll-shadow-start-fade: 0px;
  }
  to {
    --scroll-shadow-start-fade: var(--scroll-shadow-size);
  }
}

@keyframes scroll-shadow-end-fade {
  from {
    --scroll-shadow-end-fade: var(--scroll-shadow-size);
  }
  to {
    --scroll-shadow-end-fade: 0px;
  }
}

/* Orientation: Vertical */
.scroll-shadow--vertical {
  @apply scrollbar overflow-y-auto;
}

/* Orientation: Horizontal */
.scroll-shadow--horizontal {
  @apply scrollbar overflow-x-auto;
}

/* Variant: Fade - Vertical */
.scroll-shadow--fade.scroll-shadow--vertical {
  /* `[data-scroll-shadow-mode="auto"]` lets the scroll-driven variant below reuse this
     plumbing. It only paints once `--scroll-linear-gradient` is set, since an undefined
     variable makes `mask-image` invalid at computed-value time, which resolves to `none`.

     The gradient layer covers the whole box and the opaque scrollbar-lane layer sits on top
     of it. Splitting the box between the two layers instead leaves the device pixel on the
     boundary partly covered by each at fractional pixel ratios, which paints a faint line. */
  &:where(
    [data-top-scroll="true"],
    [data-bottom-scroll="true"],
    [data-top-bottom-scroll="true"],
    [data-scroll-shadow-mode="auto"]
  ) {
    mask-image: linear-gradient(var(--scroll-linear-gradient)), linear-gradient(#000, #000);
    mask-position:
      left top,
      right top;
    mask-repeat: no-repeat;
    mask-size:
      100% 100%,
      var(--scroll-shadow-scrollbar-size) 100%;
    -webkit-mask-image: linear-gradient(var(--scroll-linear-gradient)), linear-gradient(#000, #000);
    -webkit-mask-position:
      left top,
      right top;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size:
      100% 100%,
      var(--scroll-shadow-scrollbar-size) 100%;
  }

  &[data-top-scroll="true"] {
    --scroll-linear-gradient: 0deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;
  }

  &[data-bottom-scroll="true"] {
    --scroll-linear-gradient: 180deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;
  }

  &[data-top-bottom-scroll="true"] {
    --scroll-linear-gradient:
      #000, #000, transparent 0, #000 var(--scroll-shadow-size),
      #000 calc(100% - var(--scroll-shadow-size)), transparent;
  }
}

/* Variant: Fade - Horizontal */
.scroll-shadow--fade.scroll-shadow--horizontal {
  &:where(
    [data-left-scroll="true"],
    [data-right-scroll="true"],
    [data-left-right-scroll="true"],
    [data-scroll-shadow-mode="auto"]
  ) {
    mask-image: linear-gradient(var(--scroll-linear-gradient)), linear-gradient(#000, #000);
    mask-position:
      left top,
      left bottom;
    mask-repeat: no-repeat;
    mask-size:
      100% 100%,
      100% var(--scroll-shadow-scrollbar-size);
    -webkit-mask-image: linear-gradient(var(--scroll-linear-gradient)), linear-gradient(#000, #000);
    -webkit-mask-position:
      left top,
      left bottom;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size:
      100% 100%,
      100% var(--scroll-shadow-scrollbar-size);
  }

  /* `left`/`right` data attributes are logical (before/end of scroll). In RTL the
     start edge is on the right, so the physical fade direction must be swapped. */
  &[data-left-scroll="true"] {
    --scroll-linear-gradient: 270deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;

    &:dir(rtl) {
      --scroll-linear-gradient: 90deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;
    }
  }

  &[data-right-scroll="true"] {
    --scroll-linear-gradient: 90deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;

    &:dir(rtl) {
      --scroll-linear-gradient: 270deg, #000 calc(100% - var(--scroll-shadow-size)), transparent;
    }
  }

  &[data-left-right-scroll="true"] {
    --scroll-linear-gradient:
      to right, #000, #000, transparent 0, #000 var(--scroll-shadow-size),
      #000 calc(100% - var(--scroll-shadow-size)), transparent;
  }
}

.scroll-shadow--hide-scrollbar {
  @apply scrollbar-none;
  --scroll-shadow-scrollbar-size: 0px;
}

/* Variant: Fade - scroll-driven
   Where scroll timelines are available the fade is derived from the real scroll state,
   so it is already correct on the first paint and needs no measurement or hydration.
   A container without overflow has an inactive timeline, which leaves both fades at 0px
   and collapses the mask to a no-op (see the no-overflow rule at the end of this block for
   timelines that become inactive later). The attribute-driven rules above remain the
   fallback for engines without scroll timelines, and keep serving controlled mode.

   Two consequences of deriving the mask from CSS alone:
   - Auto mode always resolves a `mask-image`, even with nothing to scroll, so the root is
     always a stacking context and a containing block for fixed descendants. Gating that on
     overflow would need a measurement, which is the flicker this variant exists to avoid.
   - The `animation` shorthand here lives in the components layer, so an `animate-*` utility
     on the root replaces it and pins both fades at 0px, leaving no fade at all. */
@supports (animation-timeline: scroll(self)) {
  /* `.scroll-shadow` is repeated so these rules outrank the attribute-driven gradients
     above on specificity rather than on source order, which a re-ordering could break. */
  .scroll-shadow.scroll-shadow--fade[data-scroll-shadow-mode="auto"] {
    animation:
      scroll-shadow-start-fade linear both,
      scroll-shadow-end-fade linear both;
    animation-range:
      var(--scroll-shadow-offset) calc(var(--scroll-shadow-offset) + var(--scroll-shadow-size)),
      calc(100% - var(--scroll-shadow-size) - var(--scroll-shadow-offset))
        calc(100% - var(--scroll-shadow-offset));
  }

  /* The orientation rules also outrank the `animation` shorthand above, which resets
     `animation-timeline` to `auto`, so the timeline survives regardless of order. */
  .scroll-shadow.scroll-shadow--fade.scroll-shadow--vertical[data-scroll-shadow-mode="auto"] {
    animation-timeline: scroll(self block), scroll(self block);
    --scroll-linear-gradient:
      180deg, transparent 0, #000 var(--scroll-shadow-start-fade),
      #000 calc(100% - var(--scroll-shadow-end-fade)), transparent 100%;
  }

  .scroll-shadow.scroll-shadow--fade.scroll-shadow--horizontal[data-scroll-shadow-mode="auto"] {
    animation-timeline: scroll(self inline), scroll(self inline);
    --scroll-linear-gradient:
      90deg, transparent 0, #000 var(--scroll-shadow-start-fade),
      #000 calc(100% - var(--scroll-shadow-end-fade)), transparent 100%;

    /* Inline-axis progress starts at the right edge in RTL, so flip the physical direction */
    &:dir(rtl) {
      --scroll-linear-gradient:
        270deg, transparent 0, #000 var(--scroll-shadow-start-fade),
        #000 calc(100% - var(--scroll-shadow-end-fade)), transparent 100%;
    }
  }

  /* A timeline that goes inactive after it was active (content that overflowed, was
     scrolled, then shrank to fit) keeps its last fade values in Chromium and WebKit instead
     of falling back to 0px. Once the hook has measured no overflow, drop the animation so
     both fades return to their 0px initial value. First paint carries no state attributes,
     so it stays measurement-free. */
  .scroll-shadow.scroll-shadow--fade.scroll-shadow--vertical[data-scroll-shadow-mode="auto"][data-top-scroll="false"][data-bottom-scroll="false"],
  .scroll-shadow.scroll-shadow--fade.scroll-shadow--horizontal[data-scroll-shadow-mode="auto"][data-left-scroll="false"][data-right-scroll="false"] {
    animation: none;
  }
}

/* Search field styles */
.search-field {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }

  &[data-empty="true"] {
    [data-slot="search-field-clear-button"] {
      @apply pointer-events-none opacity-0;
    }
  }
}

.search-field__group {
  @apply relative inline-flex h-9 items-center overflow-hidden rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--search-field-group-bg`; variants override the three tokens. */
  --search-field-group-bg: var(--color-field);
  --search-field-group-bg-hover: var(--color-field-hover);
  --search-field-group-bg-focus: var(--field-focus);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Hover state */
  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      @apply bg-field-hover;
      --search-field-group-bg: var(--search-field-group-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus within state */
  &[data-focus-within="true"],
  &:focus-within {
    @apply status-focused-field;
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --search-field-group-bg: var(--search-field-group-bg-focus);
    background-color: var(--search-field-group-bg);
    border-color: var(--color-field-border-invalid);
  }

  /* Disabled state */
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

.search-field__input {
  @apply flex-1 rounded-none border-0 bg-transparent px-3 py-2 text-base shadow-none outline-none sm:text-sm;

  /* Hide browser default search clear button */
  &::-webkit-search-cancel-button,
  &::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
  }

  /* Remove border radius on left side when search icon is present */
  .search-field__group:has([data-slot="search-field-search-icon"]) & {
    @apply rounded-s-none ps-2;
  }

  /* Remove border radius on right side when clear button is present */
  .search-field__group:has([slot="clear"]) & {
    @apply rounded-e-none pe-2;
  }

  /* Focus state - handled by group */
  &:focus,
  &:focus-visible {
    @apply outline-none;
  }

  /**
   * Cover the UA autofill paint with the group's own fill so the icon, input,
   * and clear button stay one color. `--search-field-group-bg` is inherited
   * from `.search-field__group` and already tracks the variant.
   * box-shadow is not transitioned: the 1000px inset must appear at once.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--search-field-group-bg) inset;
    box-shadow: 0 0 0 1000px var(--search-field-group-bg) inset;
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition: background-color 9999s ease-in-out 0s;

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

.search-field__search-icon {
  @apply pointer-events-none shrink-0 text-field-placeholder;
  @apply ms-3 me-0 size-4;
}

.search-field__clear-button {
  @apply me-2 size-5 shrink-0;

  /* Overrides close button default icon size from 16px to 12px */
  [data-slot="close-button-icon"] {
    @apply size-3;
  }
}

/* Variant property definitions */
.search-field--primary {
  /* Default styles */
}

.search-field--secondary .search-field__group {
  @apply shadow-none;
  background-color: var(--search-field-group-bg);

  --search-field-group-bg: var(--default);
  --search-field-group-bg-hover: var(--default-hover);
  --search-field-group-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus-within),
    &[data-hovered="true"]:not([data-focus-within="true"]) {
      --search-field-group-bg: var(--search-field-group-bg-hover);
      background-color: var(--search-field-group-bg);
    }
  }

  &:focus-within,
  &[data-focus-within="true"] {
    --search-field-group-bg: var(--search-field-group-bg-focus);
    background-color: var(--search-field-group-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    border-color: var(--color-field-border-invalid);
    --search-field-group-bg: var(--search-field-group-bg-focus);
    background-color: var(--search-field-group-bg);
  }

  [data-slot="search-field-input"] {
    @apply bg-transparent;
  }
}

/* Full width modifier */
.search-field--full-width {
  @apply w-full;
}

.search-field__group--full-width {
  @apply w-full;
}

/* Select styles */
.select {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }
}

.select__trigger {
  @apply relative isolate inline-flex min-h-9 rounded-field border bg-field px-3 py-2 text-sm text-field-foreground shadow-field outline-none select-none no-highlight;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Add inline-end padding when indicator is present */
  &:has(.select__indicator) {
    @apply pe-7;
  }

  /* Hover state - exclude when clear button is hovered to prevent double hover effect */
  @media (hover: hover) {
    &:hover:not(:has(.select__clear-button:hover)),
    &[data-hovered="true"]:not(:has(.select__clear-button:hover)) {
      @apply bg-field-hover;
      border-color: var(--field-border-hover);
    }
  }

  /* Focus visible state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
    border-color: var(--field-border-focus);
    background-color: var(--field-focus);
  }

  /* Focus state */
  &:focus,
  &[data-focus="true"] {
  }

  /* Invalid state */
  .select[data-invalid="true"] &,
  .select[aria-invalid="true"] & {
    @apply status-invalid-field;
    background-color: var(--field-focus);
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }
}

/* Variant property definitions */
.select--primary {
  /* Default styles */
}

.select--secondary .select__trigger {
  @apply shadow-none;
  background-color: var(--select-trigger-bg);

  --select-trigger-bg: var(--default);
  --select-trigger-bg-hover: var(--default-hover);
  --select-trigger-bg-focus: var(--default);

  /* Exclude when clear button is hovered to prevent double hover effect */
  @media (hover: hover) {
    &:hover:not(:has(.select__clear-button:hover)),
    &[data-hovered="true"]:not(:has(.select__clear-button:hover)) {
      background-color: var(--select-trigger-bg-hover);
    }
  }

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    background-color: var(--select-trigger-bg-focus);
  }

  &:focus,
  &[data-focus="true"] {
  }

  .select[data-invalid="true"] &,
  .select[aria-invalid="true"] & {
    background-color: var(--select-trigger-bg-focus);
  }
}

.select__value {
  @apply flex-1 text-start text-base wrap-break-word text-current sm:text-sm;

  &[data-placeholder="true"] {
    @apply text-field-placeholder;
  }

  /* Removes the list-box-item indicator element from the select value*/
  [data-slot="list-box-item-indicator"] {
    @apply hidden;
  }
}

/* Clear Button styles */
.select__clear-button {
  @apply relative isolate inline-flex size-5 shrink-0 origin-center transform-gpu items-center justify-center self-center rounded-xl bg-transparent p-1 text-muted select-none no-highlight;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /**
   * The visible box stays at 20px so it fits inside the trigger's 36px min-height
   * without growing it. Expand the pointer target to the 24px floor in WCAG 2.5.8.
   */
  &::after {
    @apply absolute -inset-0.5;
    content: "";
  }

  /* Transition only when visible - disappears immediately when cleared */
  &:not([data-empty="true"]) {
    transition: opacity 150ms var(--ease-smooth);
    @apply motion-reduce:transition-none;
  }

  &[data-empty="true"] {
    @apply pointer-events-none opacity-0;
  }

  [data-slot="select-clear-button-icon"] {
    @apply size-3.5;
  }

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default-hover;
    }
  }

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.93);
  }
}

.select__indicator {
  @apply absolute inset-y-0 end-2 my-auto flex shrink-0 items-center justify-center text-field-placeholder transition duration-150;

  &[data-open="true"] {
    @apply rotate-180;
  }

  &[data-slot="select-default-indicator"] {
    @apply size-4;
  }
}

/* Similar to popover content styles */
.select__popover {
  @apply min-w-(--trigger-width) origin-(--trigger-anchor-point) scroll-py-1 scrollbar overflow-y-auto overscroll-contain bg-overlay p-0 text-sm;
  border-radius: min(32px, calc(var(--radius-2xl) + var(--spacing) * 1.5));
  box-shadow: var(--overlay-shadow);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-95 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-95-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-95-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-95-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-95-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /* Arrow styling */
  & [data-slot="popover-overlay-arrow"] {
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="popover-overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="popover-overlay-arrow"] {
    rotate: 90deg;
  }

  /* Listbox styles */
  [data-slot="list-box"] {
    @apply p-1.5 outline-none;
  }

  [data-slot="list-box-item"] {
    @apply px-2.5;

    /* list-box-item.css is imported earlier and at equal specificity, so the shorthand above
       would otherwise reset the room it reserves for the absolutely positioned indicator */
    &:has(.list-box-item__indicator) {
      @apply pe-7;
    }
  }

  /* As the popover closes fast in single-select mode, the default item indicator transition is not even visible - so we disable it only for single-select */
  [data-slot="list-box"]:not([aria-multiselectable="true"]) [data-slot="list-box-item-indicator"],
  [data-slot="list-box"]:not([aria-multiselectable="true"])
    [data-slot="list-box-item-indicator"]
    [data-slot="list-box-item-indicator--checkmark"] {
    @apply transition-none;
  }
}

/* Full width modifier */
.select--full-width {
  @apply w-full;
}

.select__trigger--full-width {
  @apply w-full;
}

/* Separator Component Styles */

/* Base separator with default horizontal orientation */
.separator {
  @apply shrink-0 rounded-sm border-t-0 border-b-0 bg-separator;

  /* Default size - horizontal orientation */
  @apply h-px w-full;
}

/* Orientation variants */
.separator--horizontal {
  @apply h-px w-full;
}

.separator--vertical {
  @apply h-auto min-h-2 w-px self-stretch;
}

/* Color variants */
.separator--default {
  @apply bg-separator;
}

.separator--secondary {
  @apply bg-separator-secondary;
}

.separator--tertiary {
  @apply bg-separator-tertiary;
}

/* Sheet — visual layer on React Aria's scroll-snap Sheet.
 * Gesture, snap, and exit are owned by the primitive. Do not set transform
 * or position on the panel; that fights the scrollport. */

@keyframes heroui-sheet-backdrop {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes heroui-sheet-scale-back {
  to {
    transform: translateZ(-120px);
  }
}

.sheet__overlay {
  @apply z-(--z-index-overlay);

  &[data-closed] {
    @apply pointer-events-none;
  }
}

/* Only the bottom-most sheet in a stack dims the page. */
.sheet__backdrop {
  @apply bg-transparent;
}

.sheet__backdrop[data-stack-index="0"].sheet__backdrop--opaque {
  @apply bg-backdrop;
}

.sheet__backdrop[data-stack-index="0"].sheet__backdrop--blur {
  @apply bg-background/[0.01] backdrop-blur-sm;
}

.sheet__backdrop--transparent {
  @apply bg-transparent;
}

.sheet__content {
  /* Padding from overscroll sits outside the height, so a 100% dialog fills the sheet. */
  @apply z-1 box-content overflow-clip outline-none;
}

/* Promote only stacked sheets. Chrome rounds fractional bounds on promoted
   layers, which can prevent React Aria from detecting full expansion. */
.sheet__content[data-has-descendants] {
  @apply [transform:perspective(1000px)] will-change-transform;
}

.sheet__content--bottom,
.sheet__content--top {
  @apply max-h-[calc(100%-2rem)] w-full;
}

.sheet__content--bottom {
  @apply rounded-t-2xl;
}

.sheet__content--top {
  @apply rounded-b-2xl;
}

.sheet__content--left,
.sheet__content--right {
  @apply h-full max-h-none w-[min(24rem,96vw)];
}

.sheet__content--left {
  @apply rounded-r-2xl;
}

.sheet__content--right {
  @apply rounded-l-2xl;
}

.sheet__content[data-detached] {
  @apply m-2 max-h-[calc(100%-1rem)] rounded-2xl;
}

.sheet__content--bottom[data-detached],
.sheet__content--top[data-detached] {
  @apply w-[calc(100%-1rem)];
}

.sheet__content--left[data-detached],
.sheet__content--right[data-detached] {
  @apply h-[calc(100%-1rem)];
}

/* A snap sheet needs a definite size so flex children, such as a virtualized
   picker, can fill it. The first snap point reveals only the top of that size. */
.sheet__content--bottom[data-snap-points],
.sheet__content--top[data-snap-points] {
  @apply h-full max-h-none;
}

.sheet__content--left[data-snap-points],
.sheet__content--right[data-snap-points] {
  @apply w-full max-w-none;
}

/* The full detent must include the detached margins inside the viewport. */
.sheet__content--bottom[data-detached][data-snap-points],
.sheet__content--top[data-detached][data-snap-points] {
  @apply h-[calc(100%-1rem)];
}

.sheet__content--left[data-detached][data-snap-points],
.sheet__content--right[data-detached][data-snap-points] {
  @apply w-[calc(100%-1rem)];
}

.sheet__dialog {
  @apply relative flex min-h-0 flex-col overflow-hidden bg-overlay text-overlay-foreground shadow-overlay outline-none;
}

.sheet__content[data-detached] .sheet__dialog {
  @apply rounded-2xl;
}

.sheet__dialog--bottom {
  @apply rounded-t-2xl;
}

.sheet__dialog--top {
  @apply rounded-b-2xl;
}

.sheet__dialog--left {
  @apply rounded-r-2xl;
}

.sheet__dialog--right {
  @apply rounded-l-2xl;
}

.sheet__header {
  @apply flex shrink-0 flex-col gap-1 px-5 pt-4 pb-2;
}

.sheet__heading {
  @apply text-lg font-semibold;
}

/* Scroll the body only once the sheet is fully expanded, so a swipe at a
   partial detent expands the sheet instead of scrolling its content. */
.sheet__body {
  @apply min-h-0 flex-auto scrollbar overflow-hidden px-5 py-2;
}

.sheet__content[data-expanded] .sheet__body {
  @apply overflow-y-auto [-webkit-overflow-scrolling:touch];
}

.sheet__footer {
  @apply flex shrink-0 flex-wrap items-center justify-end gap-2 px-5 pt-2 pb-4;
}

.sheet__handle {
  @apply relative flex shrink-0 cursor-grab touch-none items-center justify-center py-3 select-none;
}

.sheet__handle[data-dragging] {
  @apply cursor-grabbing;
}

/* Let a mouse drag follow the pointer instead of snapping on every move. */
[data-sheet-scroll][data-handle-dragging] {
  @apply snap-none!;
}

.sheet__handle-bar {
  @apply block h-[0.3rem] w-8 rounded-full bg-default;
}

.sheet__close-trigger {
  @apply absolute top-3 right-3 z-10 cursor-(--cursor-interactive) text-muted outline-none no-highlight;

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply text-foreground;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet__backdrop,
  .sheet__content {
    @apply [animation-duration:1ms];
  }
}

.skeleton {
  @apply pointer-events-none relative overflow-hidden rounded-sm bg-surface-tertiary/70;
}

/* TODO: Skeleton with parent are not visible */

/* Animation types */
.skeleton--shimmer {
  /* The shimmer travels from inline-start to inline-end. The shared `skeleton` keyframes and the
     start offset below scale their physical offsets by this sign. `:dir(rtl)` resolves the
     element's own direction, so a nested `dir="ltr"` subtree keeps the LTR sign (Tailwind's `rtl`
     variant would still match it through `[dir="rtl"] *`). */
  --skeleton-shimmer-direction: 1;

  &:dir(rtl) {
    --skeleton-shimmer-direction: -1;
  }

  &::after {
    @apply absolute inset-0 animate-skeleton bg-linear-to-r from-transparent via-surface-tertiary to-transparent content-[''];

    translate: calc(var(--skeleton-shimmer-direction) * -100%) 0;
  }

  /* When applied to a parent container with multiple skeletons */
  &:has(.skeleton) {
    &::after {
      content: none;
    }

    /* Single synchronized shimmer that passes over all children */
    &::before {
      @apply absolute inset-0 animate-skeleton content-[''];

      translate: calc(var(--skeleton-shimmer-direction) * -100%) 0;
      background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
      );
      z-index: 10;
      pointer-events: none;
      /* Use mix-blend-mode to only show over skeleton elements */
      mix-blend-mode: overlay;
    }

    /* Ensure children don't have their own shimmer */
    & .skeleton {
      &::after {
        content: none;
      }
    }
  }
}

.skeleton--pulse {
  @apply animate-pulse;
}

.skeleton--none {
}

/* Slider styles */

.slider {
  @apply grid w-full gap-1;

  grid-template-areas:
    "label output"
    "track track";
  grid-template-columns: 1fr auto;

  [data-slot="label"] {
    @apply w-fit text-sm font-medium;

    grid-area: label;
  }

  .slider__output {
    @apply text-sm font-medium tabular-nums;

    grid-area: output;
  }

  .slider__track {
    @apply relative rounded-xl bg-default;

    grid-area: track;
  }

  .slider__fill {
    @apply pointer-events-none absolute bg-accent;
  }

  .slider__steps {
    @apply pointer-events-none absolute inset-0 z-1;
  }

  .slider__step {
    @apply absolute size-[3px] rounded-full bg-muted/25;

    &[data-filled="true"] {
      @apply bg-accent-foreground/25;
    }
  }

  .slider__marks {
    @apply grid;

    grid-area: marks;
    grid-template-columns: minmax(0, 1fr);
  }

  .slider__mark {
    @apply relative w-max text-xs text-muted tabular-nums;

    grid-area: 1 / 1;
    justify-self: start;

    /* Fade between muted and foreground as the mark enters or leaves the range */
    transition: color 200ms var(--ease-smooth);
    @apply motion-reduce:transition-none;

    &[data-filled="true"] {
      @apply text-foreground;
    }
  }

  .slider__thumb {
    /* Flex container for centering pseudo-elements */
    @apply absolute z-2 flex cursor-grab items-center justify-center rounded-xl bg-accent no-highlight;

    /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
    transition:
      background-color 250ms var(--ease-smooth),
      transform 250ms var(--ease-out),
      box-shadow 150ms var(--ease-out);
    @apply motion-reduce:transition-none;

    /* after: Visible thumb element */
    &::after {
      @apply relative z-10 rounded-lg bg-accent-foreground text-black shadow-field;
      content: "";

      /**
       * Transitions
       */
      @apply origin-center transition-all motion-reduce:transition-none;
    }

    /* Dragging state - cursor changes and thumb scales down */
    &[data-dragging="true"] {
      @apply cursor-grabbing;

      &::after {
        @apply scale-[0.9] motion-reduce:scale-100;
      }
    }

    /* Focus state - increase z-index */
    &[data-focus-visible="true"] {
      @apply z-10 status-focused;
    }

    /* Disabled state */
    &[data-disabled="true"] {
      @apply cursor-default;
    }
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;

    [data-slot="label"] {
      @apply opacity-100;
    }
  }

  /* Horizontal orientation */
  &[data-orientation="horizontal"] {
    flex-direction: column;

    &:has(> .slider__marks) {
      grid-template-areas:
        "label output"
        "track track"
        "marks marks";
    }

    .slider__steps .slider__step {
      @apply top-1/2 -translate-x-1/2 -translate-y-1/2;
    }

    .slider__marks {
      /* Match the usable track length inside the transparent thumb borders. */
      @apply mx-3;
    }

    .slider__mark {
      @apply -translate-x-1/2;
    }

    .slider__steps[data-direction="rtl"] .slider__step,
    .slider__marks[data-direction="rtl"] .slider__mark {
      @apply translate-x-1/2;
    }

    .slider__track {
      @apply h-5 w-full;
      /* Add transparent borders to provide space for thumb at edges */
      /* Thumb width is 1.5rem (24px), so half is 0.75rem (12px) */
      @apply border-x-[0.75rem] border-x-transparent;

      &[data-fill-start="true"] {
        @apply border-s-accent;
      }

      &[data-fill-end="true"] {
        @apply border-e-accent;
      }
    }

    .slider__fill,
    .slider__thumb {
      @apply h-full;
    }

    .slider__thumb {
      @apply top-1/2;

      /* Thumb width + border width */
      width: calc(1.5rem + 0.25rem);

      &::after {
        width: 1.5rem;
        height: 1rem;
      }
    }
  }

  /* Vertical orientation */
  &[data-orientation="vertical"] {
    @apply h-full gap-2;

    flex-direction: row;
    grid-template-areas:
      "output"
      "track"
      "label";
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;

    &:has(> .slider__marks) {
      grid-template-areas:
        "output output"
        "track marks"
        "label label";
      grid-template-columns: auto auto;
      justify-content: center;
    }

    .slider__steps .slider__step {
      @apply left-1/2 -translate-x-1/2 translate-y-1/2;
    }

    .slider__marks {
      @apply my-3;

      grid-template-rows: minmax(0, 1fr);
      grid-template-columns: max-content;
    }

    .slider__mark {
      @apply translate-y-1/2;

      align-self: end;
    }

    .slider__output {
      text-align: center;
    }

    [data-slot="label"] {
      text-align: center;
    }

    .slider__track {
      @apply h-full w-5;
      /* Add transparent borders to provide space for thumb at edges */
      /* Thumb height is 1.5rem (24px), so half is 0.75rem (12px) */
      @apply border-y-[0.75rem] border-y-transparent;
      justify-self: center;

      &[data-fill-start="true"] {
        @apply border-b-accent;
      }

      &[data-fill-end="true"] {
        @apply border-t-accent;
      }
    }

    .slider__fill,
    .slider__thumb {
      @apply w-full;
    }

    .slider__thumb {
      /* Cross-axis centering; React Aria applies a physical translateX(-50%), so keep left-1/2 for RTL correctness */
      @apply left-1/2;

      /* Thumb height + border height */
      height: calc(1.5rem + 0.25rem);

      &::after {
        width: 1rem;
        height: 1.5rem;
      }
    }
  }
}

/* Base spinner styles */
.spinner {
  @apply pointer-events-none inline-flex size-6 shrink-0 animate-spin-fast motion-reduce:animate-none;
}

/* Size variants */
.spinner--sm {
  @apply size-4;
}

.spinner--md {
  /* No styles as this is the default size */
}

.spinner--lg {
  @apply size-8;
}

.spinner--xl {
  @apply size-10;
}

/* Color variants */
.spinner--current {
  color: inherit;
}

.spinner--accent {
  color: var(--accent);
}

.spinner--danger {
  color: var(--danger);
}

.spinner--success {
  color: var(--success);
}

.spinner--warning {
  color: var(--warning);
}

/* Surface component styles */

/* Block */
.surface {
  @apply relative text-foreground;
}

/* Modifier - variant */
.surface--transparent {
  @apply bg-transparent;
}

.surface--default {
  @apply bg-surface text-surface-foreground;
}

.surface--secondary {
  @apply bg-surface-secondary text-surface-secondary-foreground;
}

.surface--tertiary {
  @apply bg-surface-tertiary text-surface-tertiary-foreground;
}

/* Switch Group styles */
.switch-group {
  @apply flex flex-col gap-6;
}

.switch-group__items {
  @apply flex gap-4;
}

/* Orientation modifiers */
.switch-group--horizontal .switch-group__items {
  @apply flex-row;
}

.switch-group--vertical .switch-group__items {
  @apply flex-col;
}

/* Switch base styles */
.switch {
  @apply flex flex-col items-start gap-1 no-highlight;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Default tokens for switch control states */
  --switch-control-bg: var(--default);
  --switch-control-bg-hover: color-mix(in oklab, var(--switch-control-bg), transparent 20%);
  --switch-control-bg-pressed: var(--switch-control-bg-hover);
  --switch-control-bg-checked: var(--accent);
  --switch-control-bg-checked-hover: var(--accent-hover);

  /* Disabled state */
  &[data-disabled="true"] {
    @apply status-disabled;

    [data-slot="description"],
    [data-slot="field-error"] {
      @apply status-disabled;
    }

    .switch__thumb {
      @apply bg-default-foreground/20;
    }
  }

  /* Field-level help text below the control + label row */
  & > [data-slot="description"] {
    @apply w-full min-w-0 ps-[calc(2.5rem+0.75rem)];
  }

  & > [data-slot="field-error"] {
    @apply w-full min-w-0 ps-[calc(2.5rem+0.75rem)] text-xs text-muted;
  }

  &.switch--sm > [data-slot="description"] {
    @apply ps-[calc(2rem+0.75rem)];
  }

  &.switch--sm > [data-slot="field-error"] {
    @apply ps-[calc(2rem+0.75rem)];
  }

  &.switch--lg > [data-slot="description"] {
    @apply ps-[calc(3rem+0.75rem)];
  }

  &.switch--lg > [data-slot="field-error"] {
    @apply ps-[calc(3rem+0.75rem)];
  }

  /* Disabled + Selected state */
  &:disabled[aria-checked="true"],
  &:disabled[data-selected="true"],
  &[data-disabled="true"][aria-checked="true"],
  &[data-disabled="true"][data-selected="true"],
  &[aria-disabled="true"][aria-checked="true"],
  &[aria-disabled="true"][data-selected="true"] {
    .switch__thumb {
      opacity: 0.4;
    }
  }
}

/* Size variants - default is medium */
.switch--sm {
  /* Small size modifier */
}

.switch--md {
  /* Medium size - no styles as this is the default */
}

.switch--lg {
  /* Large size modifier */
}

/* Switch control (track) */
.switch__control {
  /* Default size (medium) */
  @apply relative flex shrink-0 items-center overflow-hidden rounded-xl;
  height: 1.25rem; /* 20px on desktop (14px base), 20px on mobile (16px base) - scales with font-size */
  width: 2.5rem; /* 35px on desktop, 40px on mobile - scales with font-size */

  background-color: var(--switch-control-bg);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 250ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Focus states */
  .switch:focus-visible &,
  .switch:has([data-slot="switch-content"][data-focus-visible="true"]) &,
  .switch [data-slot="switch-content"][data-focus-visible="true"] & {
    @apply status-focused;
  }

  /* Hover states */
  .switch:hover &,
  .switch:has([data-slot="switch-content"][data-hovered="true"]) &,
  .switch [data-slot="switch-content"][data-hovered="true"] & {
    background-color: var(--switch-control-bg-hover);
  }

  /* Pressed states */
  .switch:active &,
  .switch:has([data-slot="switch-content"][data-pressed="true"]) &,
  .switch [data-slot="switch-content"][data-pressed="true"] & {
    background-color: var(--switch-control-bg-pressed);
    @apply motion-reduce:transform-none;
  }

  /* Checked states */
  .switch[aria-checked="true"] &,
  .switch[data-selected="true"] & {
    background-color: var(--switch-control-bg-checked);
  }

  /* Checked + Hover states */
  .switch[aria-checked="true"]:hover &,
  .switch[data-selected="true"]:hover &,
  .switch[aria-checked="true"][data-hovered="true"] &,
  .switch[data-selected="true"][data-hovered="true"] &,
  .switch:has([data-slot="switch-content"][data-hovered="true"])[data-selected="true"] & {
    background-color: var(--switch-control-bg-checked-hover);
  }

  /* Checked + Pressed states */
  .switch[aria-checked="true"]:active &,
  .switch[data-selected="true"]:active &,
  .switch[aria-checked="true"][data-pressed="true"] &,
  .switch[data-selected="true"][data-pressed="true"] &,
  .switch:has([data-slot="switch-content"][data-pressed="true"])[data-selected="true"] & {
    background-color: var(--switch-control-bg-checked-hover);
  }
}

/* Switch content — the clickable label (control + label text) */
.switch__content {
  @apply relative inline-flex cursor-[inherit] items-center gap-3 text-sm font-medium text-foreground outline-none select-none no-highlight;
}

/* Size-specific control dimensions */
.switch--sm .switch__control {
  @apply rounded-lg;
  height: 1rem; /* ~14px on desktop, ~16px on mobile */
  width: 2rem; /* ~32px on desktop, ~36px on mobile */
}

.switch--md .switch__control {
  /* No styles as this is the default size */
}

.switch--lg .switch__control {
  height: 1.5rem; /* ~21px on desktop, ~24px on mobile */
  width: 3rem; /* ~48px on desktop, ~56px on mobile */
}

/* Switch thumb */
.switch__thumb {
  /**
   * Default size (medium). Relative positioning moves the thumb without changing
   * its flex layout. A separate compositing layer keeps the thumb's paint stable.
   * Logical offsets follow CSS direction and percentages use the actual track width.
   */
  @apply relative ms-0.5 flex origin-center transform-gpu rounded-lg bg-white text-black shadow-field;
  --switch-thumb-offset: calc(100% - 1.375rem - var(--spacing));
  inset-inline-start: 0;
  height: 1rem; /* ~14px on desktop, ~16px on mobile */
  width: 1.375rem; /* ~19px on desktop, ~22px on mobile */

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    inset-inline-start 300ms var(--ease-out-fluid),
    background-color 200ms var(--ease-out);
  @apply motion-reduce:transition-none;

  /* Selected/checked state - slide to the end of the track */
  .switch[aria-checked="true"] &,
  .switch[data-selected="true"] & {
    @apply bg-accent-foreground text-accent;
    inset-inline-start: var(--switch-thumb-offset);
    box-shadow:
      0px 0px 5px 0px rgb(0 0 0 / 0.02),
      0px 2px 10px 0px rgb(0 0 0 / 0.06),
      0px 0px 1px 0px rgb(0 0 0 / 0.3);
  }

  .switch:active &,
  .switch[data-pressed="true"] & {
  }
}

/* Size-specific thumb dimensions */
.switch--sm .switch__thumb {
  @apply rounded-md;
  height: 0.75rem; /* ~10.5px on desktop, ~12px on mobile */
  width: 1.03125rem; /* ~14.4px on desktop, ~16.5px on mobile - maintains 1.375:1 ratio */
  --switch-thumb-offset: calc(100% - 1.03125rem - var(--spacing));
}

.switch--lg .switch__thumb {
  @apply rounded-xl;
  height: 1.25rem; /* ~17.5px on desktop, ~20px on mobile */
  width: 1.71875rem; /* ~24px on desktop, ~27.5px on mobile - maintains 1.375:1 ratio */
  --switch-thumb-offset: calc(100% - 1.71875rem - var(--spacing));
}

/* Switch thumb content container */
.switch__thumb > * {
  @apply flex size-full items-center justify-center;
}

.switch [data-slot="label"] {
  @apply select-none;
}

.switch__content [data-slot="label"] {
  cursor: var(--cursor-interactive);
}

.switch [data-slot="description"] {
  @apply cursor-default select-none;
}

/* ==========================================================================
   Table — Data display component for structured tabular data.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Table Root — Outer container for table + optional footer.
   Primary variant: gray background with the table body as a white card inside.
   -------------------------------------------------------------------------- */
.table-root {
  @apply relative grid w-full overflow-clip;
  grid-template-columns: minmax(0, 1fr);
}

/* --------------------------------------------------------------------------
   Scroll Container — Allows the table to scroll horizontally while the
   wrapper and footer remain at full width. The parent grid with
   minmax(0, 1fr) creates a hard width boundary that table layout
   cannot push beyond.
   -------------------------------------------------------------------------- */
.table__scroll-container {
  @apply scrollbar overflow-x-auto;
  scrollbar-gutter: auto;
}

.table-root--primary {
  @apply bg-surface-secondary px-1 pb-1;
  border-radius: min(32px, calc(var(--radius) * 2.5));
}

.table-root--secondary {
  /* No background, padding, or rounding on the root */
}

/* Secondary: header is a standalone rounded card.
   Background is on cells (not <thead>) because Firefox does not support */
.table-root--secondary .table__header {
  @apply border-b-0 bg-transparent;
}

.table-root--secondary .table__column {
  @apply bg-surface-secondary;
}

/* Round only the truly first/last column header.
   Non-virtualized: column is a <th> child of <tr>.
   Virtualized: column is wrapped in a `VirtualizerItem` (role="presentation") so
   `:first-child` / `:last-child` on `.table__column` would match every column
   (each is the only child of its wrapper). Walk up to the row instead. */
.table-root--secondary
  :is(
    th.table__column:first-child,
    [role="row"] > [role="presentation"]:first-of-type > .table__column
  ) {
  border-start-start-radius: min(32px, var(--radius-2xl));
  border-end-start-radius: min(32px, var(--radius-2xl));
}

.table-root--secondary
  :is(
    th.table__column:last-child,
    [role="row"] > [role="presentation"]:last-of-type > .table__column
  ) {
  border-start-end-radius: min(32px, var(--radius-2xl));
  border-end-end-radius: min(32px, var(--radius-2xl));
}

/* Secondary: body has no shadow or rounded corners */
.table-root--secondary .table__body {
  @apply shadow-none;

  /* Non-virtualized */
  & tr:first-child td:first-child,
  & tr:first-child td:last-child,
  & tr:last-child td:first-child,
  & tr:last-child td:last-child {
    @apply rounded-none;
  }

  /* Virtualized: undo the rounding applied by .table__body:not(tbody) */
  &:not(tbody) {
    @apply overflow-visible rounded-none;
  }
}

/* Secondary: rows are transparent and keep bottom border on every row */
.table-root--secondary .table__row {
  .table__cell {
    @apply border-b border-separator-tertiary/50 bg-transparent;
  }

  @media (hover: hover) {
    &:hover .table__cell,
    &[data-hovered="true"] .table__cell {
      @apply bg-default/50;
    }
  }
}

/* --------------------------------------------------------------------------
   Table Content (<table> element) — the white card inside the root
   -------------------------------------------------------------------------- */
.table__content {
  @apply w-full border-separate border-spacing-0 text-sm;
}

/* Primary variant: table gets the white surface card look */
.table-root--primary .table__content {
  @apply overflow-clip;
}

/* --------------------------------------------------------------------------
   Table Header (<thead>)
   -------------------------------------------------------------------------- */
.table__header {
  @apply border-b border-separator/50 bg-surface-secondary;
}

/* --------------------------------------------------------------------------
   Table Column (<th>)
   -------------------------------------------------------------------------- */
.table__column {
  @apply relative px-4 py-2.5 text-start text-xs font-medium text-muted;

  /* Separator between columns — a short vertical line on the right edge */
  &::after {
    content: "";
    @apply pointer-events-none absolute end-0 top-1/2 h-4 w-px -translate-y-1/2 rounded-sm bg-separator;
  }

  &:last-child:not(:only-child)::after {
    content: none;
  }

  /* Sortable columns */
  &[data-allows-sorting="true"] {
    cursor: var(--cursor-interactive);
  }

  @media (hover: hover) {
    &[data-allows-sorting="true"]:hover,
    &[data-allows-sorting="true"][data-hovered="true"] {
      @apply text-foreground;
    }
  }

  /* Focus visible — inset shadow for consistent table focus styling */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply rounded-lg outline-none;
    box-shadow: inset 0 0 0 2px var(--focus);
  }
}

/* Virtualized: each column is wrapped in a `VirtualizerItem` (role="presentation"),
   so `.table__column:last-child:not(:only-child)::after` above never matches.
   Hide the trailing separator on the rightmost wrapper instead. */
[role="row"] > [role="presentation"]:last-of-type:not(:only-of-type) > .table__column::after {
  content: none;
}

/* --------------------------------------------------------------------------
   Sortable Column Header — wraps the column label and an optional indicator
   icon. Rendered inside a sortable `Table.Column`'s render prop callback.
   -------------------------------------------------------------------------- */
.table__sortable-column-header {
  @apply flex items-center justify-between;
}

/* --------------------------------------------------------------------------
   Sortable Column Indicator — chevron that flips based on `data-direction`.
   Defaults to pointing up (ascending) and rotates 180° for descending.
   -------------------------------------------------------------------------- */
.table__sortable-column-indicator {
  @apply inline-grid size-3 transform place-content-center transition-transform duration-100 ease-out;

  &[data-direction="descending"] {
    @apply rotate-180;
  }
}

/* --------------------------------------------------------------------------
   Table Body (<tbody>)
   -------------------------------------------------------------------------- */
.table__body {
  /* Non-virtualized: round corners via first/last cells
     (border-radius on <tbody> itself has no effect).
     Logical properties so corners follow `dir` in RTL. */
  & tr:first-child td:first-child {
    border-start-start-radius: min(32px, var(--radius-2xl));
  }
  & tr:first-child td:last-child {
    border-start-end-radius: min(32px, var(--radius-2xl));
  }
  & tr:last-child td:first-child {
    border-end-start-radius: min(32px, var(--radius-2xl));
  }
  & tr:last-child td:last-child {
    border-end-end-radius: min(32px, var(--radius-2xl));
  }

  /* Virtualized: elements are divs, not tr/td. VirtualizerItem wrappers
     break :first-child/:last-child on rows and cells, so round the body
     itself and clip overflow instead. */
  &:not(tbody) {
    @apply relative h-full overflow-clip;
    border-radius: min(32px, var(--radius-2xl));
  }
}

/* --------------------------------------------------------------------------
   Table Row (<tr>)
   -------------------------------------------------------------------------- */
.table__row {
  @apply relative h-full;

  /* Bottom separator */
  @apply border-b border-separator/50;

  /* Last row in body has no bottom border */
  &:last-child {
    @apply border-b-0;
  }

  /* Hover state — applied to cells so Firefox clips bg to border-radius */
  @media (hover: hover) {
    &:hover .table__cell,
    &[data-hovered="true"] .table__cell {
      @apply bg-surface/40;
    }
  }

  /* Selected state */
  &[data-selected="true"] .table__cell {
    @apply bg-surface/10;
  }

  /* Disabled state */
  &[aria-disabled="true"],
  &[data-disabled="true"] {
    @apply status-disabled;
  }

  /* Row focus ring: see “Table row focus ring” block below (after `.table__cell`). */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply outline-none;
  }

  /* Dragging state */
  &[data-dragging="true"] {
    @apply opacity-50;
  }

  /* Drop target state */
  &[data-drop-target="true"] .table__cell {
    @apply bg-accent-soft;
  }
}

/* --------------------------------------------------------------------------
   Table Cell (<td>)
   -------------------------------------------------------------------------- */
.table__cell {
  @apply h-full bg-surface px-4 py-3 align-middle text-sm text-foreground;

  @apply border-b border-separator-tertiary/50;

  /* Focus visible — inset shadow so focus stays within the cell boundaries */
  &:focus-visible,
  &[data-focus-visible="true"] {
    @apply rounded-lg outline-none;
    box-shadow: inset 0 0 0 2px var(--focus);
  }
}

/* --------------------------------------------------------------------------
   Table row focus ring — must follow `.table__cell` (cascade). One continuous
   inset ring split across cells; `:is(.table__cell, .table__column)` + direct vs
   `> *:…` covers virtualized wrappers. `:is(:focus-visible, [data-focus-visible])`
   matches row keyboard focus from RAC.
   -------------------------------------------------------------------------- */
.table__row:is(:focus-visible, [data-focus-visible="true"]) :is(.table__cell, .table__column) {
  @apply shadow-none;
}

.table__row:is(:focus-visible, [data-focus-visible="true"])
  > :is(.table__cell, .table__column):only-child,
.table__row:is(:focus-visible, [data-focus-visible="true"])
  > *:only-child
  :is(.table__cell, .table__column) {
  @apply rounded-lg shadow-[inset_0_0_0_2px_var(--focus)] outline-none;
}

.table__row:is(:focus-visible, [data-focus-visible="true"])
  > :is(.table__cell, .table__column):first-child:not(:only-child),
.table__row:is(:focus-visible, [data-focus-visible="true"])
  > *:first-child:not(:only-child)
  :is(.table__cell, .table__column) {
  @apply rounded-s-lg shadow-[inset_2px_0_0_0_var(--focus),inset_0_2px_0_0_var(--focus),inset_0_-2px_0_0_var(--focus)] outline-none;
}

.table__row:is(:focus-visible, [data-focus-visible="true"])
  > :is(.table__cell, .table__column):last-child:not(:only-child),
.table__row:is(:focus-visible, [data-focus-visible="true"])
  > *:last-child:not(:only-child)
  :is(.table__cell, .table__column) {
  @apply rounded-e-lg shadow-[inset_-2px_0_0_0_var(--focus),inset_0_2px_0_0_var(--focus),inset_0_-2px_0_0_var(--focus)] outline-none;
}

.table__row:is(:focus-visible, [data-focus-visible="true"])
  > :is(.table__cell, .table__column):not(:first-child):not(:last-child):not(:only-child),
.table__row:is(:focus-visible, [data-focus-visible="true"])
  > *:not(:first-child):not(:last-child):not(:only-child)
  :is(.table__cell, .table__column) {
  @apply shadow-[inset_0_2px_0_0_var(--focus),inset_0_-2px_0_0_var(--focus)] outline-none;
}

/* --------------------------------------------------------------------------
   Tree / expandable rows — indent the tree column by depth (any level).
   React Aria sets `--table-row-level` (1-based) on each body row and
   `data-level` on cells; tree column cells expose `[data-tree-column]`.
   The row custom property inherits onto cells (1rem per level).
   -------------------------------------------------------------------------- */
.table__cell[data-tree-column] {
  padding-inline-start: calc(1rem * var(--table-row-level, 1));
}

/* --------------------------------------------------------------------------
   Table Footer (div outside <table>, sits on gray bg)
   -------------------------------------------------------------------------- */
.table__footer {
  @apply flex items-center px-4 py-2.5;
}

/* --------------------------------------------------------------------------
   Resizable Container — wraps table to enable column resizing via React Aria.
   -------------------------------------------------------------------------- */
.table__resizable-container {
  @apply relative scrollbar overflow-auto;
  scrollbar-gutter: auto;
}

/* --------------------------------------------------------------------------
   Column Resizer — drag handle between resizable columns.
   Replaces the ::after separator when present.
   -------------------------------------------------------------------------- */
.table__column-resizer {
  /* Hit area: the header's full height and 24px (WCAG 2.2 target size) centred
     on the column's end edge. It straddles the next header, so it is lifted
     above it — otherwise that header paints over (and steals) its far half. */
  @apply absolute inset-y-0 end-0 z-10 w-6 translate-x-1/2 cursor-col-resize touch-none rtl:-translate-x-1/2;
  /* Reset appearance */
  @apply border-none bg-transparent outline-none;

  /* Visible line — matches the ::after separator it replaces */
  &::before {
    content: "";
    @apply pointer-events-none absolute top-1/2 left-1/2 h-4 w-px -translate-1/2 rounded-sm bg-separator;
  }

  &[data-hovered="true"]::before,
  &:hover::before,
  &[data-resizing="true"]::before {
    @apply h-full w-0.5 bg-accent;
  }

  &[data-focus-visible="true"]::before,
  &:focus-visible::before {
    @apply h-full w-0.5 bg-focus;
  }
}

/* Hide the ::after separator when a resizer is present in the column */
.table__column:has(.table__column-resizer)::after {
  content: none;
}

/* --------------------------------------------------------------------------
   Load More Item — sentinel row for infinite scrolling.
   Non-virtualized: <tr> with <td colSpan=N> inside.
   Virtualized: <div> with <div role="rowheader"> inside.
   -------------------------------------------------------------------------- */
.table__load-more {
  & td,
  & [role="rowheader"] {
    @apply py-3 text-center;
    & > * {
      @apply mx-auto;
    }
  }
}

/* --------------------------------------------------------------------------
   Load More Content — styled container for the loading indicator inside
   the load-more sentinel row.
   -------------------------------------------------------------------------- */
.table__load-more-content {
  @apply flex items-center justify-center gap-2 py-2;
}

/* Base tabs component */
.tabs {
  @apply flex gap-2;

  /* Orientation styles */
  &[data-orientation="horizontal"] {
    @apply flex-col;
  }

  &[data-orientation="vertical"] {
    @apply flex-row;
  }
}

/* Tab list container */
.tabs__list-container {
  @apply relative bg-default;

  border-radius: calc(var(--radius) * 2.5);

  /* Vertical scroller fills the container height so overflow detection
     engages when the wrapper height is constrained (e.g. h-[240px]) */
  > .tabs__list-container__scroller[data-orientation="vertical"] {
    @apply h-full;
  }

  /* Overflow chevron buttons */
  > .tabs__list-container__scroll-prev,
  > .tabs__list-container__scroll-next {
    @apply absolute z-2 hidden size-4 cursor-(--cursor-interactive) items-center justify-center rounded-full border-0 bg-transparent p-0 text-foreground outline-none;

    /**
    * Transitions
    * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
    */
    transition: opacity 150ms var(--ease-smooth);
    @apply motion-reduce:transition-none;

    @media (hover: hover) {
      &:hover {
        @apply opacity-70;
      }
    }

    &:focus-visible {
      @apply status-focused;
    }
  }

  /* Chevron position - horizontal orientation */
  &:has([data-orientation="horizontal"]) {
    > .tabs__list-container__scroll-prev {
      @apply start-1 top-1/2 -translate-y-1/2;
    }

    > .tabs__list-container__scroll-next {
      @apply end-1 top-1/2 -translate-y-1/2;
    }

    > .tabs__list-container__scroll-prev,
    > .tabs__list-container__scroll-next {
      @apply rtl:rotate-180;
    }
  }

  /* Chevron position - vertical orientation */
  &:has([data-orientation="vertical"]) {
    > .tabs__list-container__scroll-prev {
      @apply top-1 left-1/2 -translate-x-1/2;
    }

    > .tabs__list-container__scroll-next {
      @apply bottom-1 left-1/2 -translate-x-1/2;
    }
  }

  /* Show chevrons only when ScrollShadow reports scrolling is possible */
  &:has(
      > :is(
        [data-left-scroll="true"],
        [data-left-right-scroll="true"],
        [data-top-scroll="true"],
        [data-top-bottom-scroll="true"]
      )
    )
    > .tabs__list-container__scroll-prev {
    @apply inline-flex;
  }

  &:has(
      > :is(
        [data-right-scroll="true"],
        [data-left-right-scroll="true"],
        [data-bottom-scroll="true"],
        [data-top-bottom-scroll="true"]
      )
    )
    > .tabs__list-container__scroll-next {
    @apply inline-flex;
  }
}

/* Tab list */
.tabs__list {
  @apply inline-flex p-1;

  /* Horizontal orientation - grow with content so ScrollShadow can detect overflow */
  &[data-orientation="horizontal"] {
    @apply w-max min-w-full flex-row;
  }

  /* Vertical orientation */
  &[data-orientation="vertical"] {
    @apply flex-col gap-1;

    .tabs__tab {
      @apply min-w-20;
    }
  }
}

/* Individual tab */
.tabs__tab {
  @apply relative flex h-8 w-full items-center justify-center rounded-3xl px-4 text-center text-sm font-medium text-muted outline-none no-highlight;

  z-index: 1;
  cursor: var(--cursor-interactive);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 150ms var(--ease-smooth),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out),
    opacity 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  /* Selected state */
  &[data-selected="true"] {
    @apply text-segment-foreground;

    /* Hide separator on the selected tab and the one following it */
    .tabs__separator,
    & + .tabs__tab .tabs__separator {
      @apply opacity-0;
    }
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Hover states - both approaches for compatibility */
  @media (hover: hover) {
    &:not([data-selected="true"]):not([data-disabled="true"]):hover,
    &[data-hovered="true"]:not([data-selected="true"]):not([data-disabled="true"]) {
      @apply opacity-70;
    }
  }

  /* Focus states - comprehensive fallback */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }
}

/* Tab content alignment - center is the default, handled by .tabs__tab.
   Scoped to the direct child holding the tab list (the list container, or the
   list itself when Tabs.ListContainer is omitted) so a nested Tabs inside a
   panel keeps its own alignment. */
.tabs--align-start > :is(.tabs__list-container, .tabs__list) .tabs__tab {
  @apply justify-start text-start;
}

.tabs--align-end > :is(.tabs__list-container, .tabs__list) .tabs__tab {
  @apply justify-end text-end;
}

/* Tab separator */
.tabs__separator {
  @apply pointer-events-none absolute rounded-sm bg-muted/25;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: opacity 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  /* Horizontal tabs - vertical separator */
  .tabs__list[data-orientation="horizontal"] & {
    @apply start-0 top-1/4 h-1/2 w-px;
  }

  /* Vertical tabs - horizontal separator */
  .tabs__list[data-orientation="vertical"] & {
    @apply start-[5%] top-0 h-px w-[90%];
  }
}

/* Tab panel */
.tabs__panel {
  @apply w-full p-2 outline-none;

  /* Exiting animations */
  &[data-exiting="true"] {
    @apply absolute start-0 top-0 w-full;
  }

  /* Orientation spacing */
  &[data-orientation="horizontal"] {
    @apply mt-4;
  }

  &[data-orientation="vertical"] {
    @apply ms-4;
  }
}

/* Tab indicator - React Aria's SelectionIndicator */
.tabs__indicator {
  @apply absolute start-0 top-0 size-full rounded-3xl bg-segment shadow-surface;

  z-index: -1;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition-duration: 250ms;
  transition-property: translate, width, height;
  transition-timing-function: var(--ease-out-fluid);
  @apply motion-reduce:transition-none;

  /* Avoid capturing transient collection positions during initial hydration. */
  &[data-animation-ready="false"] {
    @apply transition-none;
  }
}

/* ==========================================================================
   Secondary Variant
   ========================================================================== */

.tabs--secondary {
  /* Container - flat, no pill. Underline on container (not list) so it stays
     stable when the inner list scrolls horizontally inside the ScrollShadow. */
  > .tabs__list-container {
    @apply rounded-none bg-transparent;

    /* Tab list - remove padding */
    .tabs__list {
      @apply p-0;
    }

    /* Hide separators in secondary variant */
    .tabs__separator {
      @apply hidden;
    }

    /* Tab - adjust for secondary variant */
    .tabs__tab {
      @apply rounded-none;

      /* Selected state - use text-foreground */
      &[data-selected="true"] {
        @apply text-foreground;
      }
    }

    /* Tab indicator - line style */
    .tabs__indicator {
      @apply rounded-none bg-accent shadow-none;
    }
  }

  /* Horizontal orientation - bottom border + bottom line indicator */
  &[data-orientation="horizontal"] > .tabs__list-container {
    @apply border-b border-border;

    .tabs__indicator {
      @apply top-auto bottom-0 h-0.5;
    }
  }

  /* Vertical orientation - left border + left line indicator */
  &[data-orientation="vertical"] > .tabs__list-container {
    @apply border-s border-border;

    .tabs__indicator {
      @apply start-0 top-0 h-full w-0.5;
    }
  }
}

/* Base styles */
.tag-group {
  @apply relative flex flex-col gap-1;
}

.tag-group__list {
  @apply relative flex flex-wrap gap-1.5;
}

.tag-group [slot="description"],
.tag-group [data-slot="description"],
.tag-group [slot="errorMessage"],
.tag-group [data-slot="error-message"] {
  @apply p-1;
}

/* Tag component styles */
.tag {
  --optical-offset: 0.031em;

  @apply relative inline-flex items-center gap-1 rounded-xl font-medium select-none no-highlight;

  /* Default size - matches .tag--md */
  @apply px-2 py-1 text-xs;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 100ms var(--ease-smooth),
    scale 100ms var(--ease-smooth),
    opacity 100ms var(--ease-smooth),
    background-color 100ms var(--ease-smooth),
    box-shadow 100ms var(--ease-out);
  @apply origin-center transform-gpu motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* SVG icon styling */
  & svg {
    @apply pointer-events-none size-3 shrink-0 self-center text-current;
  }
}

/* Disabled state */
.tag:is([data-disabled="true"], [aria-disabled="true"]) {
  @apply status-disabled;
}

/* Focus visible state (keyboard focus only) */
.tag:is(:focus-visible, [data-focus-visible]) {
  @apply status-focused;
}

/* Pressed/Active state */
.tag:is(:active, [data-pressed="true"]) {
}

/* Selected state */
.tag:is([data-selected="true"], [aria-selected="true"]) {
  @apply bg-accent-soft text-accent-soft-foreground;

  /* Selected + Hover state */
  @media (hover: hover) {
    &:is(:hover, [data-hovered="true"]) {
      @apply bg-accent-soft-hover;
    }
  }
}

/* Size */
.tag--sm {
  @apply px-2 py-0.5 text-xs;
}

.tag--md {
  /* No styles as this is the default size */
}

.tag--lg {
  @apply rounded-2xl px-2.5 py-1.5 text-sm;
}

/* Variant */
.tag--default {
  @apply bg-default text-default-foreground;

  /* Hover state (when not selected or disabled) */
  @media (hover: hover) {
    &:is(:hover, [data-hovered="true"]):not([data-selected="true"]):not([data-disabled="true"]) {
      @apply bg-default-hover;
    }
  }
}

.tag--surface {
  @apply bg-surface text-surface-foreground;

  /* Hover state (when not selected or disabled) */
  @media (hover: hover) {
    &:is(:hover, [data-hovered="true"]):not([data-selected="true"]):not([data-disabled="true"]) {
      @apply bg-surface-hover;
    }
  }
}

/* Remove Button  */
.tag__remove-button {
  /**
   * The glyph is 12px, half the minimum target size. A finger tap that misses it lands on the
   * tag body, which consumes the press without removing anything, so removing a tag by touch
   * takes several attempts. `touch-target` widens the pressable area to 24px. On `--sm` the
   * overlay reaches ~2px past the tag box, which the 6px list gap absorbs, so it never
   * overlaps a neighbouring tag.
   */
  @apply touch-target size-3 text-inherit;

  /* SVG icon styling */
  & svg {
    @apply size-[inherit] shrink-0 self-center text-current;
  }
}

/* use textarea instead of text-area to avoid conflict with Tailwind `text-` prefix */
.textarea {
  @apply rounded-field border bg-field px-3 py-2 text-base text-field-foreground shadow-field outline-none placeholder:text-field-placeholder sm:text-sm;

  min-height: 38px;

  border-width: var(--border-width-field);
  border-color: var(--field-border);

  /* Current fill. States reassign `--textarea-bg`; variants override the three tokens. */
  --textarea-bg: var(--color-field);
  --textarea-bg-hover: var(--color-field-hover);
  --textarea-bg-focus: var(--field-focus);
  /* Inset layer covers the UA autofill paint. The rest keeps shadow-field and the focus ring. */
  --textarea-autofill-shadow:
    0 0 0 1000px var(--textarea-bg) inset, var(--tw-inset-shadow, 0 0 #0000),
    var(--tw-inset-ring-shadow, 0 0 #0000), var(--tw-ring-offset-shadow, 0 0 #0000),
    var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow, 0 0 #0000);

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    background-color 150ms var(--ease-smooth),
    border-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  @media (hover: hover) {
    &:hover:not(:focus):not(:focus-visible),
    &[data-hovered="true"]:not([data-focused="true"]):not([data-focus-visible="true"]) {
      @apply bg-field-hover;
      --textarea-bg: var(--textarea-bg-hover);
      border-color: var(--field-border-hover);
    }
  }

  /* Focus state */
  &:focus,
  &[data-focused="true"] {
    @apply status-focused-field;
    border-color: var(--field-border-focus);
    --textarea-bg: var(--textarea-bg-focus);
    background-color: var(--textarea-bg);
  }

  &[data-invalid="true"] {
    @apply status-invalid-field;
    --textarea-bg: var(--textarea-bg-focus);
    background-color: var(--textarea-bg);
  }

  /* Disabled state */
  &:disabled,
  &[data-disabled="true"],
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /**
   * Browser autofill (`:-webkit-autofill` in Chromium, `:autofill` in Firefox).
   * The user agent paints its own background over the author background, which
   * drops `.textarea--secondary`'s fill. Cover that paint with `--textarea-bg`
   * (the variant's current fill) and keep the field foreground. Border stays on
   * the rules above. The long background-color transition stops Chromium's
   * highlight from fading in. box-shadow is not transitioned: the 1000px inset
   * must appear at once, or the highlight shows while that cover grows in from 0.
   */
  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus,
  &:-webkit-autofill:active,
  &:autofill,
  &:autofill:hover,
  &:autofill:focus,
  &:autofill:active {
    background-color: var(--textarea-bg);
    box-shadow: var(--textarea-autofill-shadow);
    -webkit-box-shadow: var(--textarea-autofill-shadow);
    -webkit-text-fill-color: var(--field-foreground);
    caret-color: var(--field-foreground);
    transition:
      background-color 9999s ease-in-out 0s,
      border-color 150ms var(--ease-smooth);

    @media (prefers-reduced-motion: reduce) {
      transition: background-color 9999s ease-in-out 0s;
    }
  }
}

/* Variant property definitions */
.textarea--primary {
  /* Default styles */
}

.textarea--secondary {
  @apply shadow-none;
  background-color: var(--textarea-bg);

  --textarea-bg: var(--default);
  --textarea-bg-hover: var(--default-hover);
  --textarea-bg-focus: var(--default);

  @media (hover: hover) {
    &:hover:not(:focus):not(:focus-visible),
    &[data-hovered="true"]:not([data-focused="true"]):not([data-focus-visible="true"]) {
      --textarea-bg: var(--textarea-bg-hover);
      background-color: var(--textarea-bg);
    }
  }

  &:focus,
  &[data-focused="true"] {
    --textarea-bg: var(--textarea-bg-focus);
    background-color: var(--textarea-bg);
  }

  /* Invalid state */
  &[data-invalid="true"] {
    @apply status-invalid-field;
    --textarea-bg: var(--textarea-bg-focus);
    background-color: var(--textarea-bg);
  }
}

/* Full width modifier */
.textarea--full-width {
  @apply w-full;
}

/* Text field styles */
/* use textfield instead of text-field to avoid conflict with Tailwind `text-` prefix */
.textfield {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }
}

/* Full width modifier */
.textfield--full-width {
  @apply w-full;

  /* Automatically make Input full width when TextField is full width */
  [data-slot="input"],
  [data-slot="textarea"] {
    @apply w-full;
  }
}

/* Time field styles */
.time-field {
  @apply flex flex-col gap-1;

  &[data-invalid="true"],
  &[aria-invalid="true"] {
    [data-slot="description"] {
      @apply hidden;
    }
  }

  [data-slot="label"] {
    @apply w-fit;
  }
}

/* Full width modifier */
.time-field--full-width {
  @apply w-full;
}

/* Toast component styles */

/* Toast Region */
.toast-region {
  @apply pointer-events-none fixed z-(--z-index-toast) outline-none;
  @apply w-[calc(100vw-2rem)] sm:w-auto sm:min-w-(--toast-width);

  display: block;
}

/* Placement - Bottom */
.toast-region--bottom {
  /* left-1/2 + -translate-x-1/2 centers in both LTR and RTL */
  @apply bottom-4 left-1/2 -translate-x-1/2;
}

.toast-region--bottom-start {
  @apply start-4 bottom-4;
}

.toast-region--bottom-end {
  @apply end-4 bottom-4;
}

/* Placement - Top */
.toast-region--top {
  @apply top-4 left-1/2 -translate-x-1/2;
}

.toast-region--top-start {
  @apply start-4 top-4;
}

.toast-region--top-end {
  @apply end-4 top-4;
}

.toast-region:focus-visible,
.toast-region[data-focus-visible="true"] {
  @apply outline-2 outline-offset-2 outline-focus;
}

/* Base */
.toast {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  border-radius: min(32px, var(--radius-3xl));

  /* Motion state */
  --toast-y: var(--offset-collapsed, 0px);
  --toast-enter: 0%;
  --toast-scale: var(--scale-collapsed, 1);
  transform: translateY(calc(var(--dir, 1) * (var(--toast-y) + var(--toast-enter))))
    scale(var(--toast-scale));
  height: var(--toast-height, auto);

  /* Grid, not flex-wrap: below sm the action sits in the content column, content-sized. A flex basis wide enough to wrap the button also stretched it to the row. */
  @apply pointer-events-auto grid grid-cols-[auto_minmax(0,1fr)] items-start justify-start gap-x-1.5 gap-y-2 bg-surface px-4 py-3 shadow-overlay;
  @apply sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:gap-y-0;

  /* Timing tokens */
  --toast-ease: var(--ease-out-fluid);
  --toast-enter-duration: 350ms;
  --toast-exit-duration: 250ms;
  --toast-translate-duration: var(--toast-enter-duration);
  --toast-height-duration: var(--toast-enter-duration);
  --toast-opacity-duration: 150ms;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER animation/transition for correct override specificity
   */
  transition:
    transform var(--toast-translate-duration) var(--toast-ease),
    height var(--toast-height-duration) var(--toast-ease),
    opacity var(--toast-opacity-duration) var(--toast-ease);

  @apply motion-reduce:animate-none motion-reduce:transition-none;
}

/* Enter */
.toast[data-entering="true"] {
  --toast-enter: -100%;
}

/* Stacking direction */
.toast--bottom,
.toast--bottom-start,
.toast--bottom-end {
  --dir: -1;
  bottom: 0;
  transform-origin: bottom center;

  &[data-expanded="true"]::after {
    top: calc(-1 * var(--gap, 12px) - 1px);
    bottom: 0;
  }
}

.toast--top,
.toast--top-start,
.toast--top-end {
  --dir: 1;
  top: 0;
  transform-origin: top center;

  &[data-expanded="true"]::after {
    top: 0;
    bottom: calc(-1 * var(--gap, 12px) - 1px);
  }
}

/* Content fade between collapsed / expanded */
.toast > :not([data-slot="toast-close"]) {
  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: opacity 200ms var(--toast-ease);
  @apply motion-reduce:transition-none;
}

/* Collapsed non-front: force height to front toast (Sonner-style unified stack height) */
.toast:not([data-frontmost="true"]):not([data-expanded="true"]) {
  --toast-y: var(--offset-collapsed, 0px);
  height: var(--front-height, 0px);
  overflow: hidden;

  > :not([data-slot="toast-close"]) {
    opacity: 0;
  }

  .toast__close-button {
    @apply pointer-events-none opacity-0;
    outline: none;
  }
}

/* Expanded */
.toast[data-expanded="true"] {
  --toast-y: var(--offset-expanded, 0px);
  --toast-scale: 1;
  height: var(--toast-height, auto);
}

/* Expanded hit area that covers the gap between toasts */
.toast[data-expanded="true"]::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset-inline: 0;
}

/* Exit */
.toast[data-exiting="true"] {
  @apply opacity-0;
}

.toast[data-exiting="true"][data-frontmost="true"] {
  --toast-translate-duration: var(--toast-exit-duration);
  --toast-opacity-duration: 150ms;
  --toast-enter: -100%;
  --toast-scale: 1;
}

.toast[data-exiting="true"][data-expanded="true"]:not([data-frontmost="true"]) {
  --toast-translate-duration: 200ms;
  --toast-opacity-duration: 150ms;
  --toast-scale: 0.96;
}

.toast[data-exiting="true"]:not([data-expanded="true"]):not([data-frontmost="true"]) {
  --toast-translate-duration: 200ms;
  --toast-opacity-duration: 150ms;
  --toast-scale: calc(var(--scale-collapsed, 1) * 0.96);
}

/* Hidden (beyond maxVisibleToasts) */
.toast[data-hidden="true"] {
  @apply pointer-events-none grid opacity-0;
}

.toast:focus-visible,
.toast[data-focus-visible="true"] {
  @apply outline-2 outline-offset-2 outline-focus;
}

/* Content */
.toast__content {
  /* min-w-0 lets the text wrap inside the track instead of widening it. */
  @apply col-start-2 row-start-1 flex min-w-0 flex-col items-start self-center;
}

/* Indicator */
.toast__indicator {
  @apply col-start-1 row-start-1 flex shrink-0 items-center justify-center p-1 text-overlay-foreground select-none;

  [data-slot="toast-default-icon"] {
    @apply box-content size-4;
  }

  [data-slot="spinner"] {
    @apply size-4;
  }

  [data-slot="spinner-icon"] {
    @apply size-4;
  }
}

/* Settled promise icon (data-swapped skips first paint) */
.toast__indicator[data-swapped="true"] > :not([data-slot="spinner"]) {
  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER animation/transition for correct override specificity
   */
  animation:
    toast-indicator-fade 150ms var(--toast-ease),
    toast-indicator-scale 200ms var(--toast-ease);
  @apply motion-reduce:animate-none;
}

/* Title */
.toast__title {
  @apply text-sm leading-5 font-medium text-overlay-foreground;
}

/* Description */
.toast__description {
  @apply text-sm text-muted;
}

/* Close button */
.toast__close-button {
  @apply pointer-events-none absolute -end-1 -top-1 size-5 border-border bg-default opacity-0 sm:border sm:bg-overlay;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: opacity 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  [data-slot="close-button-icon"] {
    @apply size-3.5 sm:size-3;
  }

  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      @apply bg-default;
    }
  }
}

/* Reveal close button on hover */
.toast[data-frontmost="true"]:hover .toast__close-button,
.toast[data-expanded="true"]:hover .toast__close-button,
.toast[data-frontmost="true"][data-hovered="true"] .toast__close-button,
.toast[data-expanded="true"][data-hovered="true"] .toast__close-button {
  @apply pointer-events-auto opacity-100;
}

/* Exiting toasts never show the close button */
.toast[data-exiting="true"] .toast__close-button {
  @apply pointer-events-none opacity-0;
}

/* Action */
.toast__action {
  /* Same column as the content, so it lines up with the title and stays as wide as its label. */
  @apply col-start-2 row-start-2 justify-self-start;
  @apply sm:col-start-3 sm:row-start-1;
}

/* No indicator: the first track would stay, and so would the column gap. */
.toast:not(:has(.toast__indicator)) {
  @apply grid-cols-1 sm:grid-cols-[minmax(0,1fr)_auto];
}

.toast:not(:has(.toast__indicator)) .toast__content {
  @apply col-start-1;
}

.toast:not(:has(.toast__indicator)) .toast__action {
  @apply col-start-1 sm:col-start-2;
}

/* Variants */
.toast--accent .toast__title {
  @apply text-accent-soft-foreground;
}

.toast--success .toast__title {
  @apply text-success-soft-foreground;
}

.toast--success .toast__indicator {
  @apply text-success-soft-foreground;
}

.toast--warning .toast__title {
  @apply text-warning-soft-foreground;
}

.toast--warning .toast__indicator {
  @apply text-warning-soft-foreground;
}

.toast--danger .toast__title {
  @apply text-danger-soft-foreground;
}

.toast--danger .toast__indicator {
  @apply text-danger-soft-foreground;
}

@keyframes toast-indicator-fade {
  from {
    opacity: 0;
  }
}

@keyframes toast-indicator-scale {
  from {
    scale: 0.92;
  }
}

/*
 * iOS Safari paints a plate behind the floating toolbar when a wide fixed box
 * sits on that edge. The centered rule is the verified workaround. Start and end
 * need the same narrow anchor or they keep `calc(100vw - 2rem)`. The repeated
 * `.toast-region` beats the `sm:` min-width above. `translate` stays off the
 * stacking `transform`, and flips in RTL so the centered toast stays centered.
 * Region offsets are untouched, so a safe-area override still moves the stack.
 * The anchor has no box, so the focus ring moves to the frontmost toast.
 */
@supports (-webkit-touch-callout: none) {
  .toast-region.toast-region--bottom,
  .toast-region.toast-region--bottom-start,
  .toast-region.toast-region--bottom-end {
    @apply w-0 min-w-0;
  }

  .toast-region--bottom .toast {
    @apply end-auto w-[min(var(--toast-width),calc(100vw-2rem))] -translate-x-1/2 rtl:translate-x-1/2;
  }

  .toast-region--bottom-start .toast,
  .toast-region--bottom-end .toast {
    @apply w-[min(var(--toast-width),calc(100vw-2rem))];
  }

  .toast-region--bottom-start .toast {
    @apply end-auto;
  }

  .toast-region--bottom-end .toast {
    @apply start-auto;
  }

  .toast-region--bottom:focus-visible,
  .toast-region--bottom[data-focus-visible="true"],
  .toast-region--bottom-start:focus-visible,
  .toast-region--bottom-start[data-focus-visible="true"],
  .toast-region--bottom-end:focus-visible,
  .toast-region--bottom-end[data-focus-visible="true"] {
    @apply outline-none;
  }

  .toast-region--bottom:focus-visible .toast[data-frontmost="true"],
  .toast-region--bottom[data-focus-visible="true"] .toast[data-frontmost="true"],
  .toast-region--bottom-start:focus-visible .toast[data-frontmost="true"],
  .toast-region--bottom-start[data-focus-visible="true"] .toast[data-frontmost="true"],
  .toast-region--bottom-end:focus-visible .toast[data-frontmost="true"],
  .toast-region--bottom-end[data-focus-visible="true"] .toast[data-frontmost="true"] {
    @apply outline-2 outline-offset-2 outline-focus;
  }
}

/* ==========================================================================
   ToggleButtonGroup - Groups multiple ToggleButtons into a unified control
   ========================================================================== */

/* Base styles */
.toggle-button-group {
  @apply inline-flex h-auto w-fit items-center justify-center gap-0;
}

/* ==========================================================================
   Orientation variants
   ========================================================================== */

.toggle-button-group--horizontal {
  @apply flex-row;
}

.toggle-button-group--vertical {
  @apply flex-col;
}

/* ==========================================================================
   Full width modifier
   ========================================================================== */

.toggle-button-group--full-width {
  @apply w-full;
}

/* ==========================================================================
   Attached mode (default) - buttons connected with dividers
   ========================================================================== */

/* Remove border radius from all toggle buttons in attached group */
.toggle-button-group .toggle-button {
  @apply rounded-none;
}

/* Apply border radius to first button (start edge) */
.toggle-button-group--horizontal .toggle-button:first-child {
  @apply rounded-s-3xl;
}

/* Apply border radius to last button (end edge) */
.toggle-button-group--horizontal .toggle-button:last-child {
  @apply rounded-e-3xl;
}

/* If only one button, apply both rounded edges */
.toggle-button-group--horizontal .toggle-button:first-child:last-child {
  @apply rounded-3xl;
}

/* Apply border radius to first button (top edge) in vertical */
.toggle-button-group--vertical .toggle-button:first-child {
  @apply rounded-t-3xl;
}

/* Apply border radius to last button (bottom edge) in vertical */
.toggle-button-group--vertical .toggle-button:last-child {
  @apply rounded-b-3xl;
}

/* If only one button in vertical, apply all rounded edges */
.toggle-button-group--vertical .toggle-button:first-child:last-child {
  @apply rounded-3xl;
}

/* Remove scale transform on active/pressed state for buttons in group */
.toggle-button-group .toggle-button:active,
.toggle-button-group .toggle-button[data-pressed="true"] {
  transform: none;
}

/* Override focus ring to use inset style so it stays within button bounds */
.toggle-button-group .toggle-button:focus-visible:not([data-focused]),
.toggle-button-group .toggle-button[data-focus-visible="true"] {
  --tw-ring-offset-width: 0px;
  @apply ring-inset;
}

/* Full width: stretch each toggle button */
.toggle-button-group--full-width .toggle-button {
  @apply flex-1;
}

/* ==========================================================================
   Separator (compound component)
   ========================================================================== */

.toggle-button-group__separator {
  @apply rounded-sm bg-current opacity-15;
  position: absolute;
  pointer-events: none;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition: opacity 150ms var(--ease-smooth);
  @apply motion-reduce:transition-none;

  /* Horizontal orientation - vertical divider */
  .toggle-button-group--horizontal & {
    inset-inline-start: -1px;
    top: 25%;
    width: 1px;
    height: 50%;
  }

  /* Vertical orientation - horizontal divider */
  .toggle-button-group--vertical & {
    inset-inline-start: 25%;
    top: -1px;
    width: 50%;
    height: 1px;
  }
}

/* ==========================================================================
   Detached mode - buttons separated with gaps
   ========================================================================== */

.toggle-button-group--detached {
  @apply gap-1;
}

/* Restore border radius in detached mode */
.toggle-button-group--detached .toggle-button {
  @apply rounded-3xl;
}

/* Hide separators in detached mode */
.toggle-button-group--detached .toggle-button-group__separator {
  display: none;
}

/* ==========================================================================
   ToggleButton - Interactive toggle control for on/off states
   ========================================================================== */

/* Base styles */
.toggle-button {
  @apply relative isolate inline-flex h-10 w-fit origin-center items-center justify-center gap-2 rounded-3xl px-4 text-sm font-medium whitespace-nowrap outline-none select-none no-highlight md:h-9;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    transform 250ms var(--ease-smooth),
    background-color 100ms var(--ease-out),
    box-shadow 100ms var(--ease-out);
  @apply transform-gpu motion-reduce:transition-none;

  /* Cursor */
  cursor: var(--cursor-interactive);

  /* Default tokens (unselected state) */
  --toggle-button-bg: var(--default);
  --toggle-button-bg-hover: var(--default-hover);
  --toggle-button-bg-pressed: var(--default-hover);
  --toggle-button-fg: currentColor;

  /* Selected state tokens */
  --toggle-button-bg-selected: var(--accent-soft);
  --toggle-button-bg-selected-hover: var(--accent-soft-hover);
  --toggle-button-bg-selected-pressed: var(--accent-soft-hover);
  --toggle-button-fg-selected: var(--accent-soft-foreground);

  background-color: var(--toggle-button-bg);
  color: var(--toggle-button-fg);

  /* Focus state */
  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }

  /* Disabled state */
  &:disabled,
  &[aria-disabled="true"] {
    @apply status-disabled;
  }

  /* Hover */
  @media (hover: hover) {
    &:hover,
    &[data-hovered="true"] {
      background-color: var(--toggle-button-bg-hover);
    }
  }

  /* Active / pressed */
  &:active,
  &[data-pressed="true"] {
    background-color: var(--toggle-button-bg-pressed);
    transform: scale(0.97);
  }

  /* Selected state */
  &[data-selected="true"] {
    background-color: var(--toggle-button-bg-selected);
    color: var(--toggle-button-fg-selected);

    @media (hover: hover) {
      &:hover,
      &[data-hovered="true"] {
        background-color: var(--toggle-button-bg-selected-hover);
      }
    }

    &:active,
    &[data-pressed="true"] {
      background-color: var(--toggle-button-bg-selected-pressed);
    }
  }

  /* SVG icon styling */
  & svg {
    @apply pointer-events-none -mx-0.5 my-0.5 size-5 shrink-0 self-center sm:my-1 sm:size-4;
  }
}

/* ==========================================================================
   Size variants
   ========================================================================== */

.toggle-button--sm {
  @apply h-9 px-3 md:h-8;

  & svg {
    @apply size-4;
  }

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.98);
  }
}

.toggle-button--md {
  /* No styles as this is the default size */
}

.toggle-button--lg {
  @apply h-11 text-base md:h-10;

  &:active,
  &[data-pressed="true"] {
    transform: scale(0.96);
  }
}

/* ==========================================================================
   Variant styles
   ========================================================================== */

.toggle-button--default {
  --toggle-button-bg: var(--default);
  --toggle-button-bg-hover: var(--default-hover);
  --toggle-button-bg-pressed: var(--default-hover);
}

.toggle-button--ghost {
  --toggle-button-bg: transparent;
  --toggle-button-bg-hover: var(--default);
  --toggle-button-bg-pressed: var(--default);
  --toggle-button-fg: var(--default-foreground);
}

/* ==========================================================================
   Icon-only modifier
   ========================================================================== */

.toggle-button--icon-only {
  @apply w-10 p-0 md:w-9;
}

.toggle-button--icon-only.toggle-button--sm {
  @apply w-9 md:w-8;
}

.toggle-button--icon-only.toggle-button--lg {
  @apply w-11 md:w-10;
}

/* Full width modifier */
.toggle-button--full-width {
  @apply w-full;
}

/* ==========================================================================
   Toolbar - Container for interactive controls with arrow key navigation
   ========================================================================== */

/* Base styles */
.toolbar {
  @apply grid w-fit grid-flow-col items-center gap-2;

  .separator--vertical {
    @apply h-1/2 self-center;
  }

  .separator--horizontal {
    @apply w-1/2 justify-center justify-self-center;
  }
}

/* Orientation variants */
.toolbar--horizontal {
}

.toolbar--vertical {
  @apply grid-flow-row items-start justify-start;
  .button-group {
    @apply justify-start;
  }
}

/* Attached variant */
.toolbar--attached {
  @apply rounded-3xl bg-surface p-1 shadow-overlay;
}

/* Tooltip component styles */

/* Base tooltip styles */
.tooltip {
  @apply max-w-xs origin-(--trigger-anchor-point) bg-overlay p-2 text-xs break-all;
  border-radius: min(32px, var(--radius-xl));
  box-shadow: var(--overlay-shadow);

  /* Entering animations */
  &[data-entering="true"] {
    animation: heroui-overlay-enter-90 150ms var(--ease-smooth);

    /* Placement-specific translations */
    &[data-placement="top"] {
      animation-name: heroui-overlay-enter-90-y;
    }

    &[data-placement="bottom"] {
      animation-name: heroui-overlay-enter-90-ny;
    }

    &[data-placement="left"] {
      animation-name: heroui-overlay-enter-90-x;
    }

    &[data-placement="right"] {
      animation-name: heroui-overlay-enter-90-nx;
    }
  }

  /* Exit must outrank the placement `animation-name` above. Fill stays `none` so WebKit plays it. */
  &[data-exiting="true"],
  &[data-exiting="true"][data-placement] {
    animation: heroui-overlay-exit 100ms var(--ease-smooth);
    /* Stays non-interactive while closing, even if the exit animation is interrupted. */
    @apply pointer-events-none;
  }

  /* Arrow styling */
  & [data-slot="overlay-arrow"] {
    @apply stroke-border/40;
    fill: var(--overlay);
  }

  /* Arrow rotation based on placement */
  &[data-placement="bottom"] [data-slot="overlay-arrow"] {
    rotate: 180deg;
  }

  &[data-placement="left"] [data-slot="overlay-arrow"] {
    rotate: -90deg;
  }

  &[data-placement="right"] [data-slot="overlay-arrow"] {
    rotate: 90deg;
  }
}

/* Tooltip trigger */
.tooltip__trigger {
  @apply inline-block;

  /**
   * Transitions
   * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
   */
  transition:
    color 150ms var(--ease-smooth),
    background-color 150ms var(--ease-smooth),
    box-shadow 150ms var(--ease-out);
  @apply motion-reduce:transition-none;

  &:focus-visible:not([data-focused]),
  &[data-focus-visible="true"] {
    @apply status-focused;
  }
}

.typography {
  @apply text-foreground;
}

.typography-prose {
  @apply text-foreground;
}

.typography-prose h1 {
  @apply text-4xl font-semibold tracking-tight;
}

.typography-prose h2 {
  @apply text-3xl font-semibold tracking-tight;
}

.typography-prose h3 {
  @apply text-2xl font-semibold tracking-tight;
}

.typography-prose h4 {
  @apply text-xl font-semibold tracking-tight;
}

.typography-prose h5 {
  @apply text-lg font-semibold tracking-tight;
}

.typography-prose h6 {
  @apply text-base font-semibold tracking-tight;
}

.typography-prose p {
  @apply text-base leading-7;
}

.typography-prose code {
  @apply rounded-md bg-default px-1.5 py-0.5 font-mono text-sm text-foreground;
}

.typography-prose a {
  @apply font-medium text-link underline underline-offset-4;
}

.typography-prose blockquote {
  @apply mt-4 border-s-4 border-border ps-4 text-muted italic;
}

.typography-prose ul {
  @apply my-4 list-disc space-y-2 ps-6;
}

.typography-prose ol {
  @apply my-4 list-decimal space-y-2 ps-6;
}

.typography-prose li {
  @apply text-base leading-7;
}

.typography-prose hr {
  @apply my-8 border-separator;
}

.typography-prose pre {
  @apply my-4 overflow-x-auto rounded-xl bg-default p-4 font-mono text-sm leading-relaxed;
}

.typography-prose strong {
  @apply font-semibold text-foreground;
}

.typography-prose em {
  @apply italic;
}

.typography-prose img {
  @apply my-4 rounded-xl;
}

.typography--h1 {
  @apply text-4xl font-semibold tracking-tight;
}

.typography--h2 {
  @apply text-3xl font-semibold tracking-tight;
}

.typography--h3 {
  @apply text-2xl font-semibold tracking-tight;
}

.typography--h4 {
  @apply text-xl font-semibold tracking-tight;
}

.typography--h5 {
  @apply text-lg font-semibold tracking-tight;
}

.typography--h6 {
  @apply text-base font-semibold tracking-tight;
}

.typography--body {
  @apply text-base leading-7;
}

.typography--body-sm {
  @apply text-sm leading-6;
}

.typography--body-xs {
  @apply text-xs leading-5;
}

.typography--code {
  @apply rounded-md bg-default px-1.5 py-0.5 font-mono text-sm text-foreground;
}

.typography--align-start {
  @apply text-start;
}

.typography--align-center {
  @apply text-center;
}

.typography--align-end {
  @apply text-end;
}

.typography--align-justify {
  @apply text-justify;
}

.typography--color-default {
  @apply text-foreground;
}

.typography--color-muted {
  @apply text-muted;
}

.typography--truncate {
  @apply block truncate;
}

.typography--weight-normal {
  @apply font-normal;
}

.typography--weight-medium {
  @apply font-medium;
}

.typography--weight-semibold {
  @apply font-semibold;
}

.typography--weight-bold {
  @apply font-bold;
}

