/*
 * 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 detail-view loading spinner (loader.show/close in dashboard-CMSTop*Detail.js) ──
 * The loader built its CSS into a runtime <style> tag, which this app's nonce CSP blocks — and
 * the injecting innerHTML threw, aborting show() before the spinner divs were created. The JS now
 * skips that injection and relies on these rules instead. Scoped to the loader's element IDs
 * (#backgroundDiv / #loaderDiv) so the generic .loader/.textDiv class names can't collide with
 * anything else on the page. Colour/speed match the loader.show("#255AC4", 1.5, ...) call sites.
 */
#backgroundDiv {
  background-color: #414141;
  opacity: 0.5;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  position: fixed;
  z-index: 10;
}
#loaderDiv {
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -6.25em;
  margin-left: -6.25em;
  z-index: 20;
}
#loaderDiv .loader {
  border: 10px solid #f3f3f3;
  border-top: 10px solid #255AC4;
  margin: auto;
  animation: ytcms-loader-spin 1.5s linear infinite;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 1;
}
#loaderDiv .textDiv {
  text-align: center;
  margin-top: 0.5em;
  padding: 0.5em;
  border-radius: 0.25em;
  background-color: #71836b;
  color: white;
}
@keyframes ytcms-loader-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── 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; }
