/*
  BlazorBlueprint overlay positioning fix.

  Blueprint's shipped stylesheet (blazorblueprint.css) is built with a Tailwind
  that scopes its utilities inside native CSS `@layer` rules. This app's own
  Tailwind output (css/app.css) is UNLAYERED. Per the cascade, unlayered rules
  beat layered ones regardless of selector specificity — so the app's base reset
  `*, ::before, ::after { --tw-translate-x: 0; --tw-translate-y: 0 }` outranks
  Blueprint's `.translate-x-[-50%]` / `.translate-y-[-50%]` utilities.

  The visible symptom: centered overlays (BbDialog, BbSheet) keep their
  `position:fixed; left:50%; top:50%` but lose the `translate(-50%,-50%)` pull-back,
  so they render with their top-left corner at screen center (down-and-right of
  center) instead of truly centered.

  This unlayered, !important rule restores the centering transform for any element
  that opts into both-axis centering. Floating-ui-positioned overlays (dropdowns,
  popovers, comboboxes) position via inline styles and don't carry these classes,
  so they're unaffected.

  This file is loaded AFTER blazorblueprint.css in _Layout.cshtml and is NOT
  generated by Tailwind (so it won't be overwritten by the RunTailwind step).
*/
[class*="translate-x-[-50%]"][class*="translate-y-[-50%]"] {
    transform: translate(-50%, -50%) !important;
}

/*
  Brand the create/edit form's Blueprint dropdown triggers (Brand, Company,
  Category, Tastes) to match the cream textbox inputs. Each component exposes its
  `Class` parameter differently (BbCombobox → container, not the trigger button),
  and Blueprint's layered utilities make per-element `!` Tailwind classes
  unreliable here — so we style the trigger buttons directly. All three render a
  `<button role="combobox">`. Scoped to `.sd-form` so only this form is affected.
  Colours mirror the Tailwind theme: cream #F5EBDB, ink #2A2520, peach #F0A671.
*/
.sd-form button[role="combobox"] {
    display: flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 0;
    border-radius: 1rem;
    background-color: rgb(245 235 219 / 0.4);
    color: #2A2520;
    box-shadow: none;
    font-size: 1rem;
    line-height: 1.5;
}
.sd-form button[role="combobox"]:hover {
    background-color: rgb(245 235 219 / 0.7);
}
.sd-form button[role="combobox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #F0A671;
}

/*
  Brand the dropdown PANELS to match the app's paper cards. These portal out to
  the page root (BbPortalHost), so the `.sd-form` scope can't reach them — we
  target by Blueprint's stable id pattern instead: selects render
  `select-N-content`, combobox/multiselect popovers render `popover-N-content`.
  Neither matches BbDialog, so the check-in modal is untouched. Softer radius and
  the card-lg shadow to match Components/SdCard. (paper #FFF, ink/10 border)
*/
[id^="select-"][id$="-content"],
[id^="popover-"][id$="-content"] {
    background-color: #FFFFFF !important;
    border-radius: 1rem !important;
    border-color: rgba(42, 37, 32, 0.10) !important;
    box-shadow: 0 12px 40px -12px rgba(42, 37, 32, 0.18), 0 4px 8px -4px rgba(42, 37, 32, 0.08) !important;
}

/*
  Admin button hierarchy. BbButton emits shadcn-style utilities (bg-primary,
  border-input, bg-destructive) whose theme variables this app never sets, so
  "primary" rendered as a washed-out near-gray — Save/Merge/Use were genuinely
  hard to spot among the outlines. Same unlayered-overrides-win mechanism as the
  translate fix above, scoped to .admin-shell so the consumer app is untouched.

  Tiers: primary = solid ink (slate-900) · outline = white w/ visible slate
  border · destructive = solid red · ghost stays quiet on purpose (Close only).
*/
.admin-shell button[class*="text-primary-foreground"] {
    background-color: #0f172a !important;   /* slate-900 */
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}
.admin-shell button[class*="text-primary-foreground"]:hover:not(:disabled) {
    background-color: #334155 !important;   /* slate-700 */
}
.admin-shell button[class*="border-input"] {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;       /* slate-300 */
    color: #334155 !important;              /* slate-700 */
}
.admin-shell button[class*="border-input"]:hover:not(:disabled) {
    background-color: #f8fafc !important;   /* slate-50 */
    border-color: #94a3b8 !important;       /* slate-400 */
}
.admin-shell button[class*="text-destructive-foreground"] {
    background-color: #dc2626 !important;   /* red-600 */
    color: #ffffff !important;
}
.admin-shell button[class*="text-destructive-foreground"]:hover:not(:disabled) {
    background-color: #b91c1c !important;   /* red-700 */
}

/* ── Toasts: a phone's bottom edge belongs to the thumb ─────────────────────
   Blueprint docks its toast container bottom-right at `w-full` until `md`, so on a
   phone every toast is a full-width slab across the bottom of the screen. That is
   exactly where the Queue keeps "Not now / Won't fix / Skip" — so setting one card
   aside covered the button you were about to press again, and the toast text
   ("Snoozed — <long product name> (back in ~2 weeks)") wraps to three lines while
   it sits there.

   Below md the container moves to the TOP instead, where phone notifications
   belong and nothing is tappable, and the toasts shrink: tighter padding, one
   notch smaller text, and a height cap so a burst can never wall off the screen.
   Desktop keeps bottom-right — there is room down there on a wide viewport.

   `!important` on the container geometry because those are Blueprint's own
   `bottom-0 right-0 w-full` utilities at equal specificity; the type scale inside
   needs no `!important` (see the layering note at the top of this file), only
   enough specificity to beat a bare `.text-sm`. */
@media (max-width: 767px) {
    .sd-toasts {
        top: calc(env(safe-area-inset-top, 0px) + 0.75rem) !important;
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        padding: 0 0.75rem !important;
        gap: 0.375rem !important;
        /* Docked at the top, newest-first reads downward — the reverse stacking is
           only right when the pile grows up from the bottom edge. */
        flex-direction: column !important;
        max-height: 40vh !important;
        overflow: hidden !important;
    }

    /* Admin's mobile top bar is sticky (~53px) and stays useful — clear it. */
    .sd-toasts-admin {
        top: calc(env(safe-area-inset-top, 0px) + 3.5rem) !important;
    }

    .sd-toasts > * {
        padding: 0.5rem 0.625rem !important;
        border-radius: 0.5rem !important;
    }
    .sd-toasts .text-sm {
        font-size: 0.8125rem;
        line-height: 1.15rem;
    }
    .sd-toasts .text-xs {
        font-size: 0.6875rem;
        line-height: 1rem;
    }
}

/* ── Review queue: swipe affordance ─────────────────────────────────────────
   The card follows the finger and a label says what letting go will do. Hand
   written rather than Tailwind because review-swipe.js sets these class names
   from JS, where the content scanner cannot see them.
   Fixed and parented to <body>, not the card stage: that subtree is Blazor's and is
   re-rendered per card, so review-swipe.js positions this from the card's rect
   rather than nesting a node inside something the renderer's diff owns. */
.review-swipe-cue {
    position: fixed;
    transform: translateY(-50%);
    z-index: 60;
    pointer-events: none;   /* the finger is busy dragging the card underneath */
    opacity: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background-color: #e2e8f0;  /* slate-200 */
    color: #475569;             /* slate-600 */
    transition: background-color .12s ease, color .12s ease;
}
/* Past the distance threshold — releasing now commits. */
.review-swipe-cue.is-armed {
    background-color: #0f172a;  /* slate-900 */
    color: #ffffff;
}
@media (prefers-reduced-motion: reduce) {
    .review-swipe-cue { transition: none; }
}
