/*
 * Cascade layer order for the whole app. MUST be the first statement here.
 *
 * /srp loads Bootstrap 5 and leisure-ui's vendored stylesheets so the
 * verbatim-ported SRP markup renders. Those sheets are unlayered by nature, and
 * unlayered CSS outranks ANY layered CSS regardless of specificity — so without
 * this they beat every Tailwind utility, including the ones styling corp's
 * header and footer, which sit above that route in the root layout.
 *
 * The slot matters in both directions, and both were observed breaking:
 *
 *   - BELOW `base`: Tailwind's Preflight outranks Bootstrap's reboot, so the
 *     ported SRP markup loses its headings, buttons, lists and card borders.
 *   - UNLAYERED (the default): those sheets outrank every Tailwind utility, so
 *     corp's header and footer lose their colours, spacing and button fills.
 *
 * Sitting between `base` and `components` satisfies both: Bootstrap beats
 * Preflight so the SRP renders as it does in leisure-ui, and corp's Tailwind
 * chrome — utilities, plus `.lx-*` in `components` — beats Bootstrap.
 *
 * app/srp/layout.tsx pulls the sheets into this layer.
 *
 * `bootstrap-compat` sits ABOVE utilities and exists for the handful of class
 * names Tailwind and Bootstrap both claim with different meanings. See below.
 *
 * `vendor-important-overrides` sits BELOW `leisure-vendor`, which looks
 * backwards and is not. For `!important` declarations the cascade reverses
 * layer order — the EARLIEST layer wins, and unlayered important declarations
 * are the weakest of all. So an `!important` rule in a vendored sheet (and
 * home-v3.css has several) cannot be overridden from a component's own CSS at
 * any specificity. This layer is the one place that can beat them. Put only
 * `!important` declarations in it: a normal declaration placed here would be
 * weaker than the vendor sheet, which is the opposite of what you want.
 */
@layer theme, base, vendor-important-overrides, leisure-vendor, components, utilities, bootstrap-compat;

@import "tailwindcss";
@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));

/*
 * Design tokens. shadcn/ui components consume these via the `@theme inline`
 * block below, so a component never hardcodes a color — restyle the app by
 * editing these variables, not the components.
 */
:root {
  --radius: 0.625rem;

  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);

  /* ---------------------------------------------------------------------
   * Leisure design tokens — copied verbatim from leisure-ui.com's
   * public/assets/css/leisure-new-style.css :root block.
   *
   * leisure-ui wraps most of these in CSS light-dark(). We pin the light
   * value here because `color-scheme` below is fixed to light: the chrome
   * must match leisure-ui's light rendering exactly, and corp's shadcn dark
   * mode is a separate `.dark` class system. Revisit together, not piecemeal.
   * ------------------------------------------------------------------- */
  --color-first: #2f6271;
  --color-first-same: #2f6271;
  --color-dark-first: #1b4d61;
  --color-second: #f45d6b;
  --color-second-dark: #c33643;
  --color-second-light: #ffe3e5;
  --color-content: #474646;
  --color-leisure-dark: #333;
  --color-black-same: #000;
  --color-white-same: #fff;
  --bgColor-white: #fff;
  --bgColor-light: #f5f5f5;
  --bg-body-color: #f7f7f7;
  --color-blue-light: #e7f2ff;
  --color-gray-2: #bab6ba;
  --border-gray-dark: #605d5d;

  /* Footer photo overlay. home-v3.css:2929 sets this with !important, beating
   * custom-fixes.css's rgba(47,98,113,.95) — so this darker value is what
   * actually renders. */
  --footer-overlay: rgba(15, 39, 51, 0.97);
  --footer-top-bg: #223e57;
  --border-white-light: rgba(255, 255, 255, 0.28);

  /* Bootstrap 5's default body stack. leisure-ui never sets a body
   * font-family, so its chrome renders in this, not in Lato/Inter. */
  --font-family-system:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans",
    Arial, sans-serif;
  --font-family-heading: var(--font-gilda), "Gilda Display", serif;
  --font-family-content: var(--font-lato), "Lato", sans-serif;

  color-scheme: light;

  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);

  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);

  /* ---------------------------------------------------------------------
   * Employee-signup (Business invite acceptance) tokens — copied verbatim
   * (light-mode resolved, since color-scheme is pinned to light above)
   * from the employee-signup design prototype's assets/css/flight-approval.css
   * :root block, so this one page matches that reference exactly. Scoped
   * under --fra-* so they don't collide with the --color-lx-* chrome tokens
   * used elsewhere. --fra-coral is identical to --color-second (#f45d6b) —
   * kept as its own token anyway so this block stays a faithful, literal copy.
   * ------------------------------------------------------------------- */
  --fra-navy: #0f2733;
  --fra-navy-2: #1b4d61;
  --fra-coral: #f45d6b;
  --fra-coral-dark: #d9434f;
  --fra-bg: #f4f6f8;
  --fra-surface: #ffffff;
  --fra-surface-2: #f8fafc;
  --fra-border: #e5e9ee;
  --fra-border-strong: #cfd6de;
  --fra-text: #1f2933;
  --fra-muted: #6b7785;
  --fra-heading: #0f2733;
  --fra-hover: #f1f5f9;
  --fra-pending: #b45309;
  --fra-pending-bg: #fff4dc;
  --fra-pending-border: #f6d38b;
  --fra-approved: #15803d;
  --fra-approved-solid: #16a34a;
  --fra-approved-bg: #e3f8ea;
  --fra-rejected: #c42b2b;
  --fra-rejected-bg: #fdeaea;
  --fra-blue-bg: #e7f2ff;
  --fra-info: #4338ca;
  --fra-info-bg: #eef0ff;
  --fra-info-solid: #4f46e5;
  --fra-info-hover: #4338ca;
  /* Added for the request overlay / submitted / My-requests screens. Same
   * source and the same light-mode resolution as the block above: the design's
   * assets/css/flight-approval.css :root. --fra-info is the indigo the mockups
   * use for in-review and "more info needed" states. */
  --fra-selected: #eef5ff;
  --fra-rejected-solid: #dc2626;
  --fra-rejected-hover: #b91c1c;
  --fra-approved-hover: #12813b;
  --fra-shadow: 0 1px 2px rgba(15, 39, 51, 0.06), 0 4px 16px rgba(15, 39, 51, 0.06);
  --fra-shadow-lg: 0 16px 48px rgba(15, 39, 51, 0.2);

  --fra-radius: 14px;
  --fra-radius-sm: 10px;
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);

  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);

  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);
}

@theme {
  /* Bootstrap 5 breakpoints, so a ported `col-lg-*` maps to `lg:` and means
   * the same width it did in leisure-ui. Tailwind's defaults (640/768/1024/
   * 1280/1536) would silently reflow every ported layout. */
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-2xl: 1400px;

  /* The chrome swaps between the mobile and desktop headers at 1225px in
   * leisure-ui (`@media screen and (max-width: 1225px)`), which is not a
   * Bootstrap breakpoint. `nav:` = 1226px and up = desktop header. */
  --breakpoint-nav: 1226px;

  --color-lx-first: var(--color-first);
  --color-lx-second: var(--color-second);
  --color-lx-dark: var(--color-leisure-dark);
  --color-lx-white: var(--bgColor-white);
  --color-lx-white-same: var(--color-white-same);
  --color-lx-black-same: var(--color-black-same);
  --color-lx-blue-light: var(--color-blue-light);
  --color-lx-gray: var(--color-gray-2);
  --color-lx-gray-dark: var(--border-gray-dark);
  --color-lx-body: var(--bg-body-color);
  --color-lx-footer-top: var(--footer-top-bg);
  --color-lx-border-white: var(--border-white-light);
}

@theme inline {
  --font-sans: var(--font-inter);
  --font-mono: var(--font-geist-mono);

  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);

  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);

  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }

  body {
    @apply bg-background text-foreground;
    font-family: var(--font-family-system);
  }
}

/* ---------------------------------------------------------------------------
 * Request-approval overlay: neutralising Bootstrap's reboot.
 *
 * The overlay is portalled to document.body, and on /srp that document carries
 * leisure-ui's vendored stylesheets — so Bootstrap's element-level reboot rules
 * reach it even though the markup is corp's own Tailwind. The visible symptoms
 * were a 16px gap under the dialog subtitle (`p { margin-bottom: 1rem }`) and
 * indented lists (`ul { padding-left: 2rem }`).
 *
 * Deliberately in `components`, NOT `bootstrap-compat`:
 *
 *   @layer theme, base, leisure-vendor, components, utilities, bootstrap-compat
 *
 * `components` sits above `leisure-vendor` (so it beats the reboot) and below
 * `utilities` (so it does NOT beat the overlay's own `mb-*` / `mt-*` classes).
 * Putting a blanket `margin: 0` in `bootstrap-compat` would outrank every
 * margin utility in the dialog and flatten the whole layout.
 *
 * This cannot fix Bootstrap's *utility* collisions — `.py-5` is
 * `3rem !important` there and 20px in Tailwind, and an important declaration in
 * an earlier layer beats an important one in a later layer. Those are avoided
 * at the source instead: the overlay writes `py-[20px]` rather than `py-5`.
 * See components/employee-requests/.
 * ------------------------------------------------------------------------- */
@layer components {
  [data-corp-modal] :is(p, h1, h2, h3, h4, h5, h6, ul, ol, dl, dd, blockquote, figure) {
    margin: 0;
  }

  [data-corp-modal] :is(ul, ol) {
    padding-left: 0;
  }

  /*
   * Icons inherit their colour again.
   *
   * Every lucide icon is `stroke="currentColor"`, so it renders in whatever
   * `color` resolves to. Inside /srp something in the vendored cascade gives a
   * bare <svg> `--color-content` (#474646) instead of letting it inherit — the
   * send icon on the navy header tile and the one on the coral submit button
   * both came out dark grey on a dark ground. Restoring inheritance fixes every
   * icon in the dialog at once rather than one `text-white` at a time.
   *
   * The descendant half matters: lucide strokes on the <svg> itself and its
   * paths inherit, so rescuing the svg alone appeared to fix everything — but
   * a Bootstrap icon fills per <path>, and those stayed #474646. Whatever sets
   * this reaches the children too.
   *
   * In `components`, so an explicit `text-*` utility on an icon still wins.
   */
  [data-corp-modal] svg,
  [data-corp-modal] svg * {
    color: inherit;
  }

  /*
   * The same rescue for the home pages' panels (LEIS-1013).
   *
   * `/` and `/admin` load the vendored sheets too, because both search forms
   * are ported Bootstrap markup — so every lucide icon in the corp-authored
   * sections below the search came out #474646. Measured: 38 of them,
   * including the plane on the navy "Trip details" tile of a request card,
   * which is dark grey on a dark ground and effectively invisible.
   *
   * Scoped to `[data-corp-home]` rather than the whole route on purpose. The
   * search form's own icons are vendor-styled and several are deliberately
   * `#474646`; blanketing the page would restyle ported markup this change has
   * no business touching. The attribute sits on the panels wrapper, so the
   * form is outside it.
   */
  [data-corp-home] svg,
  [data-corp-home] svg * {
    color: inherit;
  }
}

/* ---------------------------------------------------------------------------
 * Site chrome primitives, ported from leisure-ui.com.
 *
 * Everything else in the header and footer is Tailwind utilities. These three
 * earn a rule because they are structural rather than presentational.
 * ------------------------------------------------------------------------- */
@layer components {
  /*
   * leisure-ui's `.container`. Bootstrap's stepped max-widths (540/720/960/
   * 1140/1320) are all overridden there by an unconditional
   * `.container { max-width: 1320px !important }` in leisure-new-style.css,
   * which outranks the media-query steps below it. The real container is
   * therefore fluid to a single 1320px cap.
   */
  /*
   * The chrome renders in Bootstrap's system stack, not Inter. leisure-ui
   * never sets a body font-family, so its header and footer inherit
   * --bs-body-font-family; matching that is what keeps the type metrics —
   * and therefore the line wrapping — identical. Set explicitly here rather
   * than relying on `body` winning over Tailwind's preflight `html` rule.
   */
  .lx-chrome {
    font-family: var(--font-family-system);
  }

  .lx-container {
    width: 100%;
    max-width: 1320px;
    margin-inline: auto;
    padding-inline: 0.75rem;
  }

  /*
   * The fixed header's content offset. leisure-ui puts this on `.wrapper`:
   * 62px by default, 50px at <=1225px, 47px at <=767px (home-v3.css, all
   * !important).
   */
  .lx-chrome-offset {
    padding-top: 47px;
  }

  @media (min-width: 768px) {
    .lx-chrome-offset {
      padding-top: 50px;
    }
  }

  @media (min-width: 1226px) {
    .lx-chrome-offset {
      padding-top: 62px;
    }
  }

  /* Footer photo + overlay. The ::before carries the overlay so the content
   * layers above it at z-index 2, exactly as leisure-ui does. */
  .lx-footer {
    position: relative;
    background-image: url("/images/v3/footer-bg.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
  }

  .lx-footer::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--footer-overlay);
    border-radius: inherit;
    z-index: 1;
  }
}

/*
 * Bootstrap compatibility.
 *
 * A few bare class names are utilities in Tailwind AND components in Bootstrap.
 * Because `utilities` outranks `leisure-vendor`, Tailwind wins — which silently
 * breaks ported markup that meant the Bootstrap one.
 *
 * `collapse` is the one that actually bit: Tailwind's `.collapse` is
 * `visibility: collapse`, which on a non-table element renders like
 * `visibility: hidden` — content invisible but still taking up space. Every
 * flight-filter accordion body (Stops, Airlines, Max Price, Journey/Layover
 * Duration, Departure/Arrival Time) went blank while still reserving its
 * height. Restoring visibility is enough; Bootstrap's own
 * `.collapse:not(.show) { display: none }` still drives open/closed, and
 * display and visibility are independent properties.
 *
 * NOT fixed here, deliberately: `border`, `shadow` and `table` also collide,
 * but they are cosmetic (border colour/width, shadow size) rather than
 * breaking, and corp's own footer genuinely uses Tailwind's bare `border` on
 * the app-store badges — a global restore would break the chrome to fix
 * nothing visible. Revisit per-case if an SRP screen looks wrong.
 */
@layer bootstrap-compat {
  .collapse {
    visibility: visible;
  }
}

/*
 * ApprovalQueue.tsx's wrapped status badge (LEIS-1034).
 *
 * `.fra-badge` is `display: inline-flex` with its bullet dot as a `::before`
 * flex item — fine when the label is short and `nowrap`, but "Cancellation
 * requested" / "Change requested" wrap onto two lines to avoid forcing the
 * Status column (and the whole table) wider. A wrapped flex item still has
 * the default `flex-shrink: 1`, so the 6px dot was being compressed to fit
 * the line box and rendered as an oval instead of a circle. `::before` has
 * no element to attach an inline style to from React, so this is a CSS rule
 * rather than a prop.
 */
.fra-badge-wrap::before {
  flex-shrink: 0;
}
