/* ----------------------------------------------------------------------
 * layout-fix.css
 * ----------------------------------------------------------------------
 *
 * Cross-page layout polish that complements the Velzon SCSS without
 * touching its source files (the source SCSS is compiled outside of the
 * Symfony pipeline and rebuilding it is out of scope for this PR).
 *
 * Two concerns are addressed here:
 *
 *  1. Footer reliability
 *     -------------------
 *     The Velzon footer relies on `position: absolute; bottom: 0` anchored
 *     to a `.main-content` ancestor. That layout is correct in steady
 *     state but two failure modes show up in production:
 *       - Tall content that grows after a Turbo Frame load can briefly
 *         leave the footer overlapping the bottom rows of the new payload
 *         until the next style recalculation.
 *       - Short pages occasionally render with a mid-page footer when the
 *         theme initialisation script swaps the sidebar size and forces a
 *         layout reflow before `.main-content` reaches `min-height: 100vh`.
 *
 *     We harden both cases here:
 *       - explicit `width: 100%` so Bootstrap's container padding does
 *         not visually narrow the footer on intermediate breakpoints,
 *       - a subtle border-top + background so the footer is always
 *         visually anchored even on very short pages,
 *       - safety `min-height` on `.main-content` raised slightly so the
 *         footer sits at the viewport bottom on empty states.
 *
 *  2. Page-content bottom padding
 *     ----------------------------
 *     The Velzon footer height variable is `var(--vz-footer-height)` and
 *     defaults to 60px; some pages (notably the customer index after a
 *     Bootstrap collapse expands inline) clip their last row under the
 *     footer. We add a defensive bottom padding to `.page-content` so the
 *     final content row always remains visible.
 *
 * ---------------------------------------------------------------------- */

.main-content {
    /* Slight bump from the SCSS default to keep the footer attached to
       the viewport bottom on very short pages (empty states, error
       pages, login redirect intermediate states). */
    min-height: 100vh;
}

.page-content {
    /* Defensive — the footer is `position: absolute; height: 60px`, so
       we keep at least that much breathing room below the last row. */
    padding-bottom: calc(var(--vz-footer-height, 60px) + 1rem);
}

.footer {
    /* Velzon-style footer: full width of `.main-content` (i.e. from the
       end of the sidebar to the right edge), pure white surface in
       light mode (matches https://themesbrand.com/velzon/html/master),
       faint top border. The corporate theme overrides `--bs-card-bg`
       and `--vz-footer-bg` with a peach/cream tint that bleeds into
       the body background — we therefore pin the footer to `#fff`
       explicitly in light mode and switch back to the theme surface
       only in dark mode (where pure white would be unreadable).

       The `right: 0` re-assert is defensive — a handful of Velzon layout
       variants (boxed, detached) override `left` and forget the
       symmetric `right`, leaving the footer truncated on the right
       side. Forcing it here keeps the footer width correct everywhere. */
    right: 0;
    width: auto;
    /* `!important` is required to win against
       `app.min.css { .footer { background-color: var(--vz-footer-bg) } }`
       — the Velzon compiled bundle declares the footer surface with a
       higher cascade weight (it ships after our override in some
       layout variants where head-css.html.twig is partially recreated
       by a controller). Without `!important` the corporate theme's
       peach `--vz-footer-bg` bleeds through and the footer reads
       "broken" against the cream body. */
    background-color: #ffffff !important;
    border-top: 1px solid rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.08) !important;
    box-shadow: none;
    /* Ensure the footer always sits above any decorative element that
       might bleed into the bottom of `.main-content` (e.g. a faint
       gradient on the dashboard). */
    z-index: 1;
}

/* Dark theme: a pure-white footer would clash hard with the dark UI.
   Fall back to the theme's footer surface so the chrome stays
   coherent across themes. */
[data-bs-theme="dark"] .footer {
    background-color: var(--vz-footer-bg, var(--bs-card-bg, #1a1d21)) !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

/* ── Generic spinner utility — used by the balance-refresh Stimulus
      controller (and any future "refresh KPI" button). Kept here in the
      cross-page polish file so any consumer adding `animate-spin` to an
      icon gets the rotation for free without bespoke CSS. */
@keyframes pcs-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.animate-spin {
    animation: pcs-spin 0.85s linear infinite;
    transform-origin: center;
    display: inline-block;
}

.footer .container-fluid {
    /* Keep the centred copyright line spanning the full footer width. */
    max-width: 100%;
}

.footer p {
    /* Soften the copyright line so it reads as a chrome element rather
       than competing with the page content above. */
    color: var(--bs-secondary-color, rgba(33, 37, 41, 0.65));
}
