/*
 * Tailwind v4 utility-order regression fix.
 *
 * v4 emits display utilities alphabetically, so the generated `.hidden`
 * (display: none) appears BEFORE `.inline-flex`, `.inline`, `.table`, etc.
 * Elements that carry both classes (very common with conditional buttons —
 * see #vutAiOptimizeErrorBtn, which is created with
 *   class="… inline-flex … hidden"
 * and toggled visible/hidden by JS) silently lose to the later rule and
 * render as empty boxes. Tailwind v3 placed `.hidden` last specifically to
 * avoid this; v4 dropped that ordering guarantee.
 *
 * This file is loaded AFTER tailwind.built.css on every page, so the
 * !important wins regardless of source order.
 */
.hidden { display: none !important; }

/* ── Responsive show-utilities must still beat the !important .hidden above ──
 * The `!important` above (needed for JS-toggled inline-flex/hidden buttons)
 * also clobbers Tailwind's responsive show pattern `hidden sm:block` — a
 * non-important media-query utility can't override !important, so elements
 * like the AuxMode header logo (class="hidden sm:block") stay hidden at every
 * width. Re-assert each responsive display utility the app actually uses, with
 * !important, scoped to its breakpoint. [class~="…"] targets the utility by
 * name (it's a whole class token) without enumerating every element, and these
 * rules sit AFTER `.hidden` so they win at and above their breakpoint while the
 * element stays hidden below it.
 */
@media (min-width: 40rem) { /* sm */
  [class~="sm:block"]        { display: block !important; }
  [class~="sm:inline"]       { display: inline !important; }
  [class~="sm:inline-block"] { display: inline-block !important; }
}
@media (min-width: 48rem) { /* md */
  [class~="md:flex"] { display: flex !important; }
  [class~="md:grid"] { display: grid !important; }
}

/* ── Required-field column headers ─────────────────────────────────────
 * Removed: previously this file marked every required-field <th> red
 * unconditionally. That visually conflicted with the dynamic logic in
 * updateVutHeaderValidation / updateAutHeaderValidation /
 * updateOutHeaderValidation, which already toggles the <th> to
 * bg-red-600 only when at least one cell in that column has an error
 * (empty required value), and back to bg-gray-50 when all cells are
 * filled. Letting the JS drive header colour gives a useful per-column
 * "you have an unfilled required cell here" signal instead of a noisy
 * always-red reminder.
 */

/* ── jQuery Sparkline tooltip (.jqstooltip) ────────────────────────────
 * jQuery Sparkline injects its tooltip CSS via a runtime <style> tag, which
 * the app's nonce-based CSP blocks → unstyled tooltip that stretched full-screen.
 * Replicate the library's intended defaults here (a loaded stylesheet) so it's a
 * small dark box like the Chart.js tooltips. CRITICAL for positioning: the library
 * calibrates by reading the EMPTY tooltip's offset right after appending it, so it
 * MUST start at left:0/top:0 — otherwise its cursor-following math is skewed and
 * the popup lands in a corner. Keep box-sizing:content-box to beat Tailwind's
 * global border-box (the library sets the measured width/height inline assuming
 * content-box). The library measures the tooltip via an off-screen sizing div whose inline style
 * attribute is ALSO CSP-blocked, so it mis-measures as full-width and writes a full-width inline
 * width onto the tooltip → force width/height:auto to shrink-wrap to content (this also fixes the
 * sizing div, which shares this class, so the library's own width/placement math comes out right).
 * Net: left/top:0 = correct cursor positioning; width/height:auto = small box.
 * POSITION must be FIXED, not absolute: the library appends the tooltip as the last child of
 * <body>, which on the CMS shell is `display:flex; flex-direction:column`. An absolutely-positioned
 * child of a flex container gets a flex-influenced static origin, so the library's one-time offset
 * calibration (tooltip.offset() on the empty element) misreads X and pins the popup to the left edge
 * (confirmed live: offsetParent=BODY@(0,0) yet computed left=11px with the cursor at ~400px). Fixed
 * positions relative to the viewport (clean 0,0 origin, no flex interference); safe because the
 * sparklines sit above the fold so the library's scroll-clamp never bites.
 */
.jqstooltip {
  position: fixed !important;
  left: 0;
  top: 0;
  visibility: hidden;
  box-sizing: content-box !important;
  width: auto !important;
  height: auto !important;
  white-space: nowrap;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font: 12px/1.45 -apple-system, "Segoe UI", Arial, sans-serif;
  text-align: left;
  z-index: 10050;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.jqsfield {
  color: #fff;
  white-space: nowrap;
  font: 12px/1.45 -apple-system, "Segoe UI", Arial, sans-serif;
  text-align: left;
}

/* ── CMS loading overlay ──────────────────────────────────────────────────────────────────────
 * 🔴 THE LEGACY RULES THAT LIVED HERE WERE REMOVED 2026-08-17, AND THEY WERE ACTIVELY BREAKING
 * THE CURRENT LOADER. Do not reinstate them; js/cms/cms-loader.js styles itself inline.
 *
 * They styled the OLD circular border-spinner (#loaderDiv .loader, a 100px ring; #loaderDiv .textDiv,
 * a green label box) which was deleted from 40 files when cms-loader.js replaced it. Nothing has
 * emitted those class names since, and the ytcms-loader-spin keyframe they drove was referenced
 * nowhere else. But two rules kept applying to the NEW overlay, because it deliberately reuses the
 * same element ids so youtube-cms-init.js's teardown nets keep working:
 *
 *   #backgroundDiv { opacity: 0.5 }   <- ELEMENT opacity, so it applied to the WHOLE SUBTREE.
 *                                        The card is a child, so no background could make it look
 *                                        solid: it rendered at 50% whatever it was set to. This is
 *                                        what "the loading is transparent" meant, across four
 *                                        rounds of adjusting a card that was provably opaque.
 *   #loaderDiv { position: fixed; top: 50%; left: 50%; margin: -6.25em }
 *                                     <- fought the overlay's own flex centring.
 *
 * The lesson worth keeping: an inline style loses to nothing here, but ELEMENT OPACITY ON AN
 * ANCESTOR cannot be overridden by a descendant at all. cms-loader.js now sets opacity:1 on the
 * backdrop explicitly as a belt-and-braces defence against exactly this.
 */
}

/* ── Monthly Totals %-change cells (Get_CMSMonthlyTotals emits <span class='cms-pct-up|down'>) ──
 * CSP-safe colouring for the Total Revenue / Total Views month-over-month change columns. */
.cms-pct-up   { color: #079f26; font-weight: 600; }
.cms-pct-down { color: #c0392b; font-weight: 600; }
