/* ===== Eficium Theme Engine (Turnos) =====
   Canonical skins: dark / light / neon
   Legacy aliases are still supported via data-tpl selectors.
*/

body[data-tpl]{
  background: var(--bg, #0b1220);
  color: var(--text, #e5e7eb);
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
  font-family: var(--font-body, "Sora", system-ui, -apple-system, Segoe UI, Roboto, Arial);
}

/* Wallpaper layer */
body[data-tpl]::before{
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--wallpaper-image, none);
  background-size: var(--wallpaper-size, cover);
  background-repeat: var(--wallpaper-repeat, no-repeat);
  background-position: center;
  opacity: 0;
  filter: blur(var(--wallpaper-blur, 0px));
  pointer-events: none;
  z-index: -1;
}
body.has-wallpaper::before{
  opacity: var(--wallpaper-opacity, 0);
}
body.wallpaper-only-pos:not(.admin-page)::before{
  opacity: 0 !important;
}
body.admin-page.wallpaper-only-pos::before{
  opacity: var(--wallpaper-opacity, 0) !important;
}

/* Per-tenant FX toggles */
body.fx-bg-off{ background: var(--bg, #0b1220) !important; }
body.fx-grid-off .fx-grid{ display: none !important; }
body.fx-aura-off .fx-aura{ display: none !important; }
body.fx-beams-off .fx-beams{ display: none !important; }
body.fx-rings-off .fx-rings{ display: none !important; }
body.fx-noise-off .fx-noise{ display: none !important; }
body.fx-scan-off .fx-scan{ display: none !important; }
body.fx-hex-off .fx-hex{ display: none !important; }

/* Typography packs */
body[data-tpl]{ --font-body: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body[data-tpl].font-pro{ --font-body: "Sora", system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body[data-tpl].font-tech{ --font-body: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body[data-tpl].font-scifi{ --font-body: "Rajdhani", system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body[data-tpl].font-scifi h1,
body[data-tpl].font-scifi .panel-title,
body[data-tpl].font-scifi .brand-title{
  font-family: "Orbitron", "Rajdhani", system-ui, -apple-system, Segoe UI, Roboto, Arial;
  letter-spacing: 1px;
}

/* Shape pack */
body[data-tpl].shape-angular .glass-card,
body[data-tpl].shape-angular .section-card,
body[data-tpl].shape-angular .app-card,
body[data-tpl].shape-angular .card,
body[data-tpl].shape-angular .wrap,
body[data-tpl].shape-angular .btn,
body[data-tpl].shape-angular .input-dark,
body[data-tpl].shape-angular .form-control,
body[data-tpl].shape-angular .form-select{
  border-radius: 14px !important;
}

/* FX layers */
.fx{
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

.fx-aura{
  opacity: calc(var(--aura, .55) * 0.58);
  filter: blur(96px) saturate(1.12);
  background:
    radial-gradient(1200px 760px at 18% 8%, var(--p) 0%, transparent 62%),
    radial-gradient(1050px 720px at 88% 18%, var(--s) 0%, transparent 60%),
    radial-gradient(900px 720px at 50% 90%, var(--a) 0%, transparent 62%);
  animation: fx-aura-float 14s ease-in-out infinite alternate;
  transform: translateZ(0);
}

.fx-grid{
  background-image:
    linear-gradient(to right, rgba(255,255,255,.085) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.085) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: calc(var(--pattern, .35) * 0.2);
  mask-image: radial-gradient(circle at 50% 18%, rgba(0,0,0,1), rgba(0,0,0,.25) 55%, transparent 75%);
  animation: fx-grid-drift 64s linear infinite;
  transform: translateZ(0);
}

.fx-hex{
  background-image:
    radial-gradient(circle at 12px 10px, var(--s) 0 2px, transparent 2px),
    radial-gradient(circle at 32px 26px, var(--p) 0 2px, transparent 2px),
    radial-gradient(circle at 52px 10px, var(--a) 0 2px, transparent 2px);
  background-size: 64px 42px;
  opacity: calc(var(--pattern, .35) * 0.18);
  transform: skewY(-7deg);
  transform-origin: 50% 50%;
  animation: fx-hex-drift 56s linear infinite;
}

.fx-noise{
  opacity: 0.06;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120\" height=\"120\"><filter id=\"n\"><feTurbulence type=\"fractalNoise\" baseFrequency=\"0.9\" numOctaves=\"3\" stitchTiles=\"stitch\"/></filter><rect width=\"120\" height=\"120\" filter=\"url(%23n)\" opacity=\"0.55\"/></svg>');
  background-size: 200px 200px;
  mix-blend-mode: overlay;
}

.fx-scan{
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.1) 0px,
    rgba(255,255,255,.1) 1px,
    transparent 3px,
    transparent 7px
  );
  opacity: calc(var(--scan, 1) * var(--pattern, .35) * 0.14);
  mix-blend-mode: overlay;
  animation: fx-scan-drift 12s linear infinite;
}

.fx-beams{
  opacity: 0;
  filter: blur(80px) saturate(1.24);
  background:
    linear-gradient(115deg, transparent 0%, var(--p) 46%, transparent 72%),
    linear-gradient(65deg, transparent 0%, var(--s) 42%, transparent 70%),
    linear-gradient(140deg, transparent 10%, var(--a) 52%, transparent 78%);
  mix-blend-mode: screen;
  animation: fx-beams-move 22s ease-in-out infinite alternate;
  transform: translateZ(0);
}

.fx-rings{
  opacity: 0;
  background:
    repeating-radial-gradient(circle at 50% 55%,
      rgba(255,255,255,.12) 0 1px,
      transparent 1px 22px
    );
  mix-blend-mode: overlay;
  animation: fx-rings-pulse 14s ease-in-out infinite alternate;
}

.fx-vignette{
  background: radial-gradient(circle at 50% 40%,
    transparent 0%,
    rgba(0,0,0,.35) 55%,
    rgba(0,0,0,.72) 100%
  );
  opacity: 0.95;
}

@keyframes fx-grid-drift{
  from{ background-position: 0 0, 0 0; }
  to{ background-position: 640px 220px, 220px 640px; }
}
@keyframes fx-hex-drift{
  from{ transform: skewY(-7deg) translate3d(0,0,0); }
  to{ transform: skewY(-7deg) translate3d(-120px, 60px, 0); }
}
@keyframes fx-scan-drift{
  from{ background-position: 0 0; }
  to{ background-position: 0 80px; }
}
@keyframes fx-beams-move{
  from{ transform: translate3d(-6%, -4%, 0) rotate(-2deg); }
  to{ transform: translate3d(6%, 4%, 0) rotate(2deg); }
}
@keyframes fx-rings-pulse{
  from{ transform: scale(0.98); opacity: 0.55; }
  to{ transform: scale(1.03); opacity: 0.85; }
}
@keyframes fx-aura-float{
  from{ transform: translate3d(0,0,0) scale(1); }
  to{ transform: translate3d(0,-14px,0) scale(1.03); }
}

/* Animation intensity */
body.anim-off .fx-aura,
body.anim-off .fx-grid,
body.anim-off .fx-hex,
body.anim-off .fx-beams,
body.anim-off .fx-rings,
body.anim-off .fx-scan{ animation: none !important; }
body.anim-subtle .fx-aura{ animation-duration: 18s; }
body.anim-active .fx-aura{ animation-duration: 10s; }
body.anim-subtle .fx-grid{ animation-duration: 80s; }
body.anim-active .fx-grid{ animation-duration: 42s; }
body.anim-subtle .fx-hex{ animation-duration: 70s; }
body.anim-active .fx-hex{ animation-duration: 38s; }
body.anim-subtle .fx-scan{ animation-duration: 18s; }
body.anim-active .fx-scan{ animation-duration: 8s; }
body.anim-subtle .fx-beams{ animation-duration: 26s; }
body.anim-active .fx-beams{ animation-duration: 14s; }
body.anim-subtle .fx-rings{ animation-duration: 18s; }
body.anim-active .fx-rings{ animation-duration: 10s; }

/* ===== Canonical dark (with legacy aliases) ===== */
body[data-tpl="dark"],
body[data-tpl="elite_dark"],
body[data-tpl="titanium_glass"],
body[data-tpl="hud_matrix"],
body[data-tpl="titanium"],
body[data-tpl="matrix"],
body[data-tpl="robot"],
body[data-tpl="aurora"],
body[data-tpl="noir"],
body[data-tpl="solar_hud"],
body[data-tpl="hexa_blueprint"],
body[data-tpl="noir_minimal"]{
  color-scheme: dark;
  background:
    radial-gradient(1100px 760px at 14% 10%, color-mix(in srgb, var(--p) 18%, transparent) 0%, transparent 65%),
    radial-gradient(980px 720px at 86% 14%, color-mix(in srgb, var(--s) 16%, transparent) 0%, transparent 66%),
    radial-gradient(980px 820px at 55% 92%, color-mix(in srgb, var(--a) 12%, transparent) 0%, transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,.05) 0%, transparent 38%),
    var(--bg);
}
body[data-tpl="dark"] .fx-grid,
body[data-tpl="titanium_glass"] .fx-grid,
body[data-tpl="hud_matrix"] .fx-grid{
  opacity: calc(var(--pattern, .35) * 0.18);
}
body[data-tpl="dark"] .fx-beams,
body[data-tpl="titanium_glass"] .fx-beams,
body[data-tpl="hud_matrix"] .fx-beams{
  opacity: calc(var(--aura, .55) * 0.12);
}
body[data-tpl="dark"] .fx-rings,
body[data-tpl="titanium_glass"] .fx-rings,
body[data-tpl="hud_matrix"] .fx-rings{
  opacity: calc(var(--pattern, .35) * 0.06);
}

/* ===== Canonical light (with legacy aliases) ===== */
body[data-tpl="light"],
body[data-tpl="elite_light"],
body[data-tpl="quartz_light"],
body[data-tpl="tech_clean"],
body[data-tpl="clean"],
body[data-tpl="clean_ops"],
body[data-tpl="techclean"],
body[data-tpl="mlts"]{
  color-scheme: light;
  background:
    radial-gradient(900px 680px at 12% 8%, color-mix(in srgb, var(--p) 16%, white) 0%, transparent 64%),
    radial-gradient(880px 680px at 86% 18%, color-mix(in srgb, var(--s) 12%, white) 0%, transparent 66%),
    linear-gradient(180deg, rgba(255,255,255,.92) 0%, rgba(245,247,255,.98) 55%, rgba(245,247,255,1) 100%),
    var(--bg);
}
body[data-tpl="light"] .fx-noise,
body[data-tpl="quartz_light"] .fx-noise,
body[data-tpl="tech_clean"] .fx-noise{
  opacity: 0.04;
  mix-blend-mode: multiply;
}
body[data-tpl="light"] .fx-scan,
body[data-tpl="quartz_light"] .fx-scan,
body[data-tpl="tech_clean"] .fx-scan{ opacity: 0; }
body[data-tpl="light"] .fx-grid,
body[data-tpl="quartz_light"] .fx-grid,
body[data-tpl="tech_clean"] .fx-grid{
  opacity: calc(var(--pattern, .35) * 0.18);
  background-size: 30px 30px;
  background-image:
    linear-gradient(to right, rgba(11,18,32,.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(11,18,32,.1) 1px, transparent 1px);
}
body[data-tpl="light"] .fx-beams,
body[data-tpl="light"] .fx-rings,
body[data-tpl="quartz_light"] .fx-beams,
body[data-tpl="quartz_light"] .fx-rings,
body[data-tpl="tech_clean"] .fx-beams,
body[data-tpl="tech_clean"] .fx-rings{
  mix-blend-mode: multiply;
}
body[data-tpl="light"] .fx-vignette,
body[data-tpl="quartz_light"] .fx-vignette,
body[data-tpl="tech_clean"] .fx-vignette{
  opacity: 0.16;
  background: radial-gradient(circle at 50% 40%, transparent 0%, rgba(11,18,32,.1) 58%, rgba(11,18,32,.18) 100%);
}

/* ===== Canonical neon (with legacy aliases) ===== */
body[data-tpl="neon"],
body[data-tpl="neon_overdrive"],
body[data-tpl="cyber"],
body[data-tpl="tron"],
body[data-tpl="cyberpunk_pulse"]{
  color-scheme: dark;
  background:
    radial-gradient(1200px 900px at 18% 12%, color-mix(in srgb, var(--p) 32%, transparent) 0%, transparent 62%),
    radial-gradient(1100px 860px at 86% 18%, color-mix(in srgb, var(--s) 28%, transparent) 0%, transparent 64%),
    radial-gradient(980px 820px at 55% 92%, color-mix(in srgb, var(--a) 26%, transparent) 0%, transparent 66%),
    var(--bg);
}
body[data-tpl="neon"] .fx-noise,
body[data-tpl="neon_overdrive"] .fx-noise{
  opacity: 0.1;
  mix-blend-mode: screen;
}
body[data-tpl="neon"] .fx-grid,
body[data-tpl="neon_overdrive"] .fx-grid{
  opacity: calc(var(--pattern, .35) * 0.22);
  background-size: 44px 44px;
}
body[data-tpl="neon"] .fx-hex,
body[data-tpl="neon_overdrive"] .fx-hex{
  opacity: calc(var(--pattern, .35) * 0.24);
}
body[data-tpl="neon"] .fx-beams,
body[data-tpl="neon_overdrive"] .fx-beams{
  opacity: calc(var(--aura, .55) * 0.3);
}
body[data-tpl="neon"] .fx-rings,
body[data-tpl="neon_overdrive"] .fx-rings{
  opacity: calc(var(--pattern, .35) * 0.14);
  mix-blend-mode: screen;
}
body[data-tpl="neon"] .fx-scan,
body[data-tpl="neon_overdrive"] .fx-scan{
  opacity: calc(var(--scan, 1) * (0.22 + var(--pattern, .35) * 0.24));
}
body[data-tpl="neon"] .fx-aura,
body[data-tpl="neon_overdrive"] .fx-aura{
  opacity: calc(var(--aura, .55) * 0.9);
  filter: blur(130px) saturate(1.22);
  animation-duration: 7s;
}
