/* ==========================================================================
   u4-dash.css — Up-4ever dashboard LAYOUT shell
   Skeleton + responsive + scrollbar + shared helpers ONLY.
   Per-component visuals live inline. Fonts are self-hosted globally
   (Changa display 700-800 / Poppins body) — do NOT add Google Fonts here.

   Brand tokens (reference):
     ink      #1A1330 / #271646      muted #8B82A3 #9C93B2 #A49CBC #544B6B
     line     #ECE9F2               purple #7A3FE0  magenta #C257E5  deep #6139B7
     gradient linear-gradient(135deg,#7A3FE0,#C257E5)
     gold #FFCB3E  success #2E9E59  danger #E0556B  amber #E08A2E
     bg #FBFAFC    soft #FAF8FE / #F4EEFD
   ========================================================================== */

body {
  background: #FBFAFC;
  margin: 0;
  /* The dashboard body is NOT .u4site, so u4-site.css's `body.u4site` font rule
     never reaches it — without this, migrated page content falls back to the
     browser serif default. Set the brand body font here so EVERY dashboard page
     (and any future migrated page) inherits Poppins; headings/amounts override
     with inline Changa. */
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  color: #1A1330;
  -webkit-font-smoothing: antialiased;
}

/* The dashboard body is NOT .u4site, so u4-site.css's box-sizing reset doesn't
   reach it. The shell + its inline-styled cards (Claude Design uses
   *{box-sizing:border-box}) assume border-box — without this, width:100% + padding
   overflows and produces a horizontal scrollbar. */
.u4d-shell,
.u4d-shell * {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Shell skeleton
   main.html: <div class="u4d-shell"><aside class="u4d-sidebar">…</aside>
                <div class="u4d-body"><header class="u4d-topbar">…</header>
                  <main class="u4d-content">{page}</main></div></div>
   -------------------------------------------------------------------------- */

.u4d-shell {
  display: flex;
  min-height: 100vh;
}

.u4d-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.u4d-content {
  flex: 1;
  padding: 30px 34px 48px;
  width: 100%;
  /* fluid: fill the area beside the sidebar on any width (no narrow cap) */
  max-width: none;
  font-family: 'Poppins', system-ui, sans-serif;
}

/* --------------------------------------------------------------------------
   Sidebar — sticky full-height column with its own thin purple scrollbar
   -------------------------------------------------------------------------- */

.u4d-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 50;
}

.u4d-sidebar::-webkit-scrollbar {
  width: 8px;
}

.u4d-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.u4d-sidebar::-webkit-scrollbar-thumb {
  background: rgba(122, 63, 224, .2);
  border-radius: 8px;
}

.u4d-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 63, 224, .35);
}

/* Firefox thin scrollbar */
.u4d-sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 63, 224, .2) transparent;
}

/* --------------------------------------------------------------------------
   Topbar — sticky header above the content
   -------------------------------------------------------------------------- */

.u4d-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
}

/* --------------------------------------------------------------------------
   Off-canvas backdrop (shown when sidebar is open on small screens)
   -------------------------------------------------------------------------- */

.u4d-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 19, 48, .45);
  z-index: 45;
  opacity: 0;
  transition: opacity .25s ease;
}

.u4d-backdrop.is-open {
  display: block;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Shared dashboard helpers (reusable across dashboard pages)
   -------------------------------------------------------------------------- */

.u4d-card {
  background: #fff;
  border: 1px solid #ECE9F2;
  border-radius: 16px;
}

.u4d-h {
  font-family: 'Changa', sans-serif;
  font-weight: 700;
  color: #1A1330;
}

/* --------------------------------------------------------------------------
   Responsive — below 1024px the sidebar goes off-canvas
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .u4d-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 50;
  }

  .u4d-sidebar.is-open {
    transform: translateX(0);
  }

  .u4d-content {
    padding: 20px 16px;
  }

  /* Topbar stat chips wrap on small screens */
  .u4d-topbar {
    flex-wrap: wrap;
  }
}

/* --------------------------------------------------------------------------
   Reduced-motion guard
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .u4d-sidebar,
  .u4d-backdrop {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Legacy-CSS bleed guard
   Dashboard pages not yet migrated off the mega4up "v2" CSS still load that
   stylesheet, whose generic `body.v2 a:hover { color: hsl(var(--primary)) }`
   (the OLD mega4up brand color) out-specifies the shell's own link :hover rules
   and bleeds the wrong color onto the sidebar/topbar links on hover. Re-assert
   the Up-4ever brand colors with higher specificity so the new shell always
   looks right regardless of v2. (Drops out naturally once every page is migrated
   and v2 is no longer loaded.)
   -------------------------------------------------------------------------- */
.u4d-sidebar a.u4d-sb-link:hover { color: #6139B7; }
.u4d-sidebar a.u4d-sb-link:hover svg { color: #7A3FE0; }
.u4d-sidebar a.u4d-sb-link.is-active:hover { color: #6D28C9; }
.u4d-sidebar a.u4d-sb-out:hover { color: #E0556B; }
.u4d-sidebar a.u4d-sb-admin:hover { color: #7A3FE0; }
.u4dt a.u4dt-upload:hover { color: #fff; }
.u4dt .u4dt-menu a:hover { color: #6139B7; }

/* ==========================================================================
   FM overlays on migrated (dash_migrated) pages
   js/fm-app.js appends toasts (#fm-toast-stack/.fm-toast) and dialogs
   (.modal.fm-confirm / .modal.fm-modal, shown via bootstrap.Modal) directly to
   <body>. Their styling used to come from bootstrap.css (.modal* chrome) +
   v2-dashboard-pro.css (.fm-toast* and .fm-confirm* rules) — BOTH dropped on migrated
   pages, leaving them unstyled (bare dialog at top-of-document, bare toast at
   bottom). Re-provide that styling here: u4-dash.css loads on EVERY dashboard
   page, and BEFORE the v2/bootstrap sheets on non-migrated pages (so those still
   override this — no change there); on migrated pages this is the only source.
   Modal chrome is scoped to .fm-confirm/.fm-modal so it can't affect any other
   element; brand colours replace the dropped v2 hsl(var(--*)) tokens.
   ========================================================================== */

/* ---- Bootstrap modal chrome (subset FM.confirmModal / openModalFromUrl use) ---- */
.fm-confirm, .fm-modal {
  position: fixed; inset: 0; z-index: 10600; display: none;
  width: 100%; height: 100%; overflow-x: hidden; overflow-y: auto; outline: 0;
}
.fm-confirm.show, .fm-modal.show { display: block; }
.fm-confirm .modal-dialog, .fm-modal .modal-dialog {
  position: relative; width: auto; margin: 1.75rem auto; max-width: 500px; pointer-events: none;
}
.fm-confirm .modal-dialog-centered, .fm-modal .modal-dialog-centered {
  display: flex; align-items: center; min-height: calc(100% - 3.5rem);
}
.fm-confirm .modal-sm { max-width: 340px; }
.fm-modal .modal-lg { max-width: 800px; }
.fm-confirm .modal-content, .fm-modal .modal-content {
  position: relative; display: flex; flex-direction: column; width: 100%; pointer-events: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 30px 60px -15px rgba(26,19,48,.4);
  overflow: hidden; font-family: 'Poppins', system-ui, sans-serif;
}
.fm-confirm .modal-header, .fm-modal .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #F0EDF6;
}
.fm-confirm .modal-title, .fm-modal .modal-title {
  font-family: 'Changa', sans-serif; font-weight: 700; font-size: 16px; color: #1A1330; margin: 0;
}
.fm-confirm .modal-body, .fm-modal .modal-body { padding: 20px; }
.fm-confirm .modal-footer, .fm-modal .modal-footer {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
}
.fm-confirm .btn-close, .fm-modal .btn-close {
  width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent;
  color: #9C93B2; cursor: pointer; font-size: 0; line-height: 0;
}
.fm-confirm .btn-close::before, .fm-modal .btn-close::before {
  content: "\00d7"; font-size: 22px; line-height: 1; color: #9C93B2;
}
.fm-confirm .btn-close:hover, .fm-modal .btn-close:hover { background: #F4F2F8; }
/* backdrop is injected by bootstrap.Modal as a body-level sibling */
.modal-backdrop { position: fixed; inset: 0; z-index: 10550; width: 100vw; height: 100vh; background: #1A1330; }
.modal-backdrop.fade { opacity: 0; transition: opacity .15s linear; }
.modal-backdrop.show { opacity: .45; }
body.modal-open { overflow: hidden; }

/* utilities FM puts on body-level dialog nodes (scoped to the dialog) */
.fm-confirm .border-0, .fm-modal .border-0 { border: 0 !important; }
.fm-confirm .p-0, .fm-modal .p-0 { padding: 0 !important; }
.fm-confirm .p-4, .fm-modal .p-4 { padding: 24px !important; }
.fm-confirm .pt-0, .fm-modal .pt-0 { padding-top: 0 !important; }
.fm-confirm .mt-3, .fm-modal .mt-3 { margin-top: 16px; }
.fm-confirm .text-center, .fm-modal .text-center { text-align: center; }
.fm-confirm .justify-content-center, .fm-modal .justify-content-center { justify-content: center; }
.fm-confirm .small, .fm-modal .small { font-size: 12.5px; }
.fm-confirm .btn, .fm-modal .btn {
  display: inline-flex; align-items: center; justify-content: center; font-family: 'Poppins', sans-serif;
  font-size: 13.5px; font-weight: 700; padding: 11px 20px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer; line-height: 1; text-decoration: none;
}
.fm-confirm .btn-primary, .fm-modal .btn-primary { color: #fff; background: linear-gradient(135deg,#7A3FE0,#C257E5); }
.fm-confirm .btn-danger, .fm-modal .btn-danger { color: #fff; background: #E0556B; }
.fm-confirm .btn-outline-light, .fm-modal .btn-outline-light { color: #544B6B; background: #fff; border-color: #ECE9F2; }
.fm-confirm .btn-outline-light:hover, .fm-modal .btn-outline-light:hover { background: #FBFAFC; color: #1A1330; }

/* ---- FM toasts ---- */
.fm-toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 10800; display: flex; flex-direction: column;
  gap: .5rem; max-width: min(22rem, calc(100vw - 2rem)); pointer-events: none;
}
.fm-toast {
  display: flex; align-items: flex-start; gap: .625rem; padding: .6875rem .875rem; background: #fff;
  color: #1A1330; border: 1px solid #ECE9F2; border-left: 3px solid #9C93B2; border-radius: 11px;
  box-shadow: 0 12px 28px -10px rgba(26,19,48,.28), 0 4px 8px rgba(26,19,48,.06);
  font-size: 13.5px; font-family: 'Poppins', sans-serif; pointer-events: auto;
  transform: translateY(-6px); opacity: 0; transition: transform .18s ease, opacity .18s ease;
}
.fm-toast.is-visible { transform: translateY(0); opacity: 1; }
.fm-toast__icon {
  flex-shrink: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; color: #fff; background: #9C93B2;
}
.fm-toast__msg { flex: 1; min-width: 0; line-height: 1.35; word-break: break-word; }
.fm-toast__close {
  background: none; border: 0; padding: 0 .25rem; font-size: 1.25rem; line-height: 1;
  color: #9C93B2; cursor: pointer; align-self: flex-start;
}
.fm-toast__close:hover { color: #1A1330; }
.fm-toast--success { border-left-color: #2E9E59; } .fm-toast--success .fm-toast__icon { background: #2E9E59; }
.fm-toast--error   { border-left-color: #E0556B; } .fm-toast--error   .fm-toast__icon { background: #E0556B; }
.fm-toast--warn    { border-left-color: #E0A52E; } .fm-toast--warn    .fm-toast__icon { background: #E0A52E; }
.fm-toast--info    { border-left-color: #7A3FE0; } .fm-toast--info    .fm-toast__icon { background: #7A3FE0; }

/* ---- FM confirm-dialog interior + list overlay/spinner ---- */
.fm-confirm__icon {
  width: 3.25rem; height: 3.25rem; margin: 0 auto; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 50%; background: rgba(122,63,224,.12); color: #7A3FE0;
}
.fm-confirm__icon--danger { background: rgba(224,85,107,.14); color: #E0556B; }
.fm-confirm__title { font-family: 'Changa', sans-serif; font-weight: 700; font-size: 17px; color: #1A1330; margin: 0; }
.fm-confirm__body { margin-top: .5rem; color: #9C93B2; }
@keyframes fm-spin { to { transform: rotate(360deg); } }
.fm-btn-spinner, .fm-overlay__spinner {
  display: inline-block; width: 1rem; height: 1rem; border: 2px solid rgba(122,63,224,.25);
  border-top-color: #7A3FE0; border-radius: 50%; animation: fm-spin .7s linear infinite;
  margin-left: .5rem; vertical-align: -.15em;
}
.fm-overlay__spinner { width: 2rem; height: 2rem; border-width: 3px; margin: 0; }
.btn.is-loading, button.is-loading { position: relative; pointer-events: none; opacity: .85; }
.fm-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.65); -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px);
  border-radius: inherit; z-index: 5; opacity: 0; transition: opacity .16s ease;
}
.fm-overlay.is-visible { opacity: 1; }

/* ==========================================================================
   Non-migrated dashboard pages (upload, mass_dmca, etc.) still load the legacy
   v2-dashboard*.css, whose `body.v2 main { padding-left: var(--sidebar-w) }`
   (~16rem) was written for the OLD fixed navpanel. The NEW u4 sidebar is an
   in-flow flex column, so that rule wrongly shoves <main class="u4d-content">
   ~264px to the right on desktop (and the body looks cramped/centered). Re-assert
   the correct content padding for the u4 shell content only — higher specificity
   than `body.v2 main`, so it wins without touching the admin layout that still
   relies on the legacy rule.
   ========================================================================== */
body.v2 main.u4d-content { padding-left: 34px; }
@media (max-width: 1024px){ body.v2 main.u4d-content { padding-left: 16px; } }

/* Pages whose BODY is the public full-page wrapper (.u4up on the uploader)
   bring their own page chrome — max-width, auto-centering, 48/40/80 padding —
   meant for the PUBLIC shell. Inside the dashboard, .u4d-content already owns the
   page padding/width, so neutralize the inner wrapper to kill the double padding
   (which read as "too tall") and the cramped centered column. Scoped to the
   dashboard, so the public page is unaffected. */
.u4d-content .u4up { max-width: none; margin: 0; padding: 0; }
