/* ============================================================
   FlashyCSS — Authelia Custom Theme ("Cipher Grid")
   Falling hex/binary rain behind a glassmorphism login card
   Deep Rose + Dark Rose palette on void background
   CSS-only, injected via nginx sub_filter sidecar
   Target: Authelia v4.39.15 — React + MUI 7 + Emotion CSS-in-JS
   ============================================================ */

/* ----------------------------------------------------------
   1. Google Fonts + CSS Variables
   ---------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --fc-primary: #be185d;
    --fc-secondary: #9d174d;
    --fc-bg: #0a0a0f;
    --fc-panel-bg: rgba(10, 12, 20, 0.78);
    --fc-panel-border: rgba(190, 24, 93, 0.2);
    --fc-panel-border-hover: rgba(190, 24, 93, 0.35);
    --fc-text: #e0e0e0;
    --fc-text-dim: #a0a0a0;

    /* RGB triplets for rgba() usage */
    --fc-primary-rgb: 190, 24, 93;
    --fc-secondary-rgb: 157, 23, 77;

    /* Font stacks */
    --fc-font-display: 'Orbitron', monospace, sans-serif;
    --fc-font-body: 'Rajdhani', 'Segoe UI', sans-serif;
}

/* ----------------------------------------------------------
   2. Background & Body
   ---------------------------------------------------------- */
body[data-theme="dark"],
body[data-theme="light"] {
    background: var(--fc-bg) !important;
    color: var(--fc-text) !important;
    font-family: var(--fc-font-body) !important;
    margin: 0 !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
}

/* ----------------------------------------------------------
   3. Aurora Glow
   ---------------------------------------------------------- */
body::before {
    content: '' !important;
    position: fixed !important;
    inset: -25% !important;
    z-index: 0 !important;
    pointer-events: none !important;
    opacity: 0.75 !important;
    background:
        radial-gradient(ellipse at 18% 22%, rgba(var(--fc-primary-rgb), 0.28), transparent 55%),
        radial-gradient(ellipse at 82% 28%, rgba(var(--fc-secondary-rgb), 0.22), transparent 55%) !important;
    filter: blur(60px) saturate(165%) !important;
    mix-blend-mode: screen !important;
    animation: auroraDrift 14s ease-in-out infinite alternate !important;
}

/* ----------------------------------------------------------
   4. Cipher Rain
   Container #fc-cipher-bg + .cipher-col columns injected via
   nginx sub_filter sidecar into the page markup.
   ---------------------------------------------------------- */
#fc-cipher-bg {
    position: fixed !important;
    inset: 0 !important;
    z-index: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    opacity: 0.38 !important;
}

.cipher-col {
    position: absolute !important;
    top: -100% !important;
    width: 1ch !important;
    font-family: 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: rgba(var(--fc-primary-rgb), 0.65) !important;
    text-shadow: 0 0 4px rgba(var(--fc-primary-rgb), 0.5) !important;
    white-space: nowrap !important;
    writing-mode: vertical-rl !important;
    text-orientation: upright !important;
    animation: cipherFall linear infinite !important;
    user-select: none !important;
}

/* 13 columns — staggered durations (8s-20s), delays, and opacities */
.cipher-col:nth-child(1)  { left: 3%;  animation-duration: 10s !important; animation-delay: 0s !important;     opacity: 0.6 !important; }
.cipher-col:nth-child(2)  { left: 11%; animation-duration: 14s !important; animation-delay: -2s !important;    opacity: 0.45 !important; }
.cipher-col:nth-child(3)  { left: 18%; animation-duration: 8s !important;  animation-delay: -5s !important;    opacity: 0.8 !important; }
.cipher-col:nth-child(4)  { left: 25%; animation-duration: 16s !important; animation-delay: -1s !important;    opacity: 0.35 !important; }
.cipher-col:nth-child(5)  { left: 33%; animation-duration: 11s !important; animation-delay: -7s !important;    opacity: 0.65 !important; }
.cipher-col:nth-child(6)  { left: 41%; animation-duration: 18s !important; animation-delay: -3s !important;    opacity: 0.4 !important; }
.cipher-col:nth-child(7)  { left: 50%; animation-duration: 9s !important;  animation-delay: -6s !important;    opacity: 0.75 !important; }
.cipher-col:nth-child(8)  { left: 58%; animation-duration: 20s !important; animation-delay: -4s !important;    opacity: 0.3 !important; }
.cipher-col:nth-child(9)  { left: 65%; animation-duration: 12s !important; animation-delay: -8s !important;    opacity: 0.55 !important; }
.cipher-col:nth-child(10) { left: 73%; animation-duration: 15s !important; animation-delay: -2.5s !important;  opacity: 0.5 !important; }
.cipher-col:nth-child(11) { left: 80%; animation-duration: 10s !important; animation-delay: -9s !important;    opacity: 0.7 !important; }
.cipher-col:nth-child(12) { left: 88%; animation-duration: 17s !important; animation-delay: -1.5s !important;  opacity: 0.38 !important; }
.cipher-col:nth-child(13) { left: 95%; animation-duration: 13s !important; animation-delay: -5.5s !important;  opacity: 0.52 !important; }

/* ----------------------------------------------------------
   5. Scanline Sweep
   ---------------------------------------------------------- */
#root::before {
    content: '' !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 0 !important;
    pointer-events: none !important;
    opacity: 0.25 !important;
    background: linear-gradient(
        180deg,
        transparent 0%,
        transparent 45%,
        rgba(var(--fc-primary-rgb), 0.06) 48%,
        rgba(var(--fc-secondary-rgb), 0.04) 52%,
        transparent 55%,
        transparent 100%
    ) !important;
    background-size: 100% 200% !important;
    animation: scanSweep 6.5s linear infinite !important;
}

/* ----------------------------------------------------------
   6. Z-index Stacking
   ---------------------------------------------------------- */
#root {
    position: relative !important;
    z-index: 1 !important;
}

/* ----------------------------------------------------------
   7. App Bar / Header
   ---------------------------------------------------------- */
[class*="MuiAppBar-root"],
[class*="MuiPaper-root"][class*="MuiAppBar"] {
    background: rgba(10, 12, 20, 0.80) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border-bottom: 1px solid rgba(var(--fc-primary-rgb), 0.25) !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4) !important;
}

[class*="MuiToolbar-root"] {
    background: transparent !important;
    position: relative !important;
    z-index: 2 !important;
}

/* Logo / brand icon glow */
[class*="MuiAppBar"] img,
[class*="MuiAppBar"] svg {
    filter: drop-shadow(0 0 6px rgba(var(--fc-primary-rgb), 0.4)) !important;
}

/* ----------------------------------------------------------
   8. Login Card Glassmorphism
   ---------------------------------------------------------- */
[class*="MuiContainer"][class*="maxWidthXs"],
[class*="rootContainer"] {
    background: var(--fc-panel-bg) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid var(--fc-panel-border) !important;
    border-radius: 16px !important;
    box-shadow:
        0 0 30px rgba(var(--fc-primary-rgb), 0.08),
        0 0 60px rgba(var(--fc-secondary-rgb), 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
    padding: 32px !important;
    animation: cardPulse 6s ease-in-out infinite !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Hover increases border glow */
[class*="MuiContainer"][class*="maxWidthXs"]:hover,
[class*="rootContainer"]:hover {
    border-color: var(--fc-panel-border-hover) !important;
    box-shadow:
        0 0 40px rgba(var(--fc-primary-rgb), 0.14),
        0 0 80px rgba(var(--fc-secondary-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

/* Outer / inner grids — ensure transparency so background shows */
[class*="MuiGrid"][class*="gridOuter"],
[class*="MuiGrid-container"] {
    background: transparent !important;
}

[class*="MuiGrid"][class*="gridInner"] {
    background: transparent !important;
}

/* ----------------------------------------------------------
   9. Typography
   ---------------------------------------------------------- */

/* Sign-in heading — Orbitron display */
[class*="MuiTypography-h5"] {
    font-family: var(--fc-font-display) !important;
    font-weight: 900 !important;
    color: #ffffff !important;
    text-shadow:
        0 0 12px rgba(var(--fc-primary-rgb), 0.5),
        0 0 30px rgba(var(--fc-primary-rgb), 0.2) !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
}

/* Body text — Rajdhani */
[class*="MuiTypography-body1"],
[class*="MuiTypography-body2"],
[class*="MuiTypography-root"] {
    font-family: var(--fc-font-body) !important;
    color: var(--fc-text) !important;
}

/* Labels get rose-tinted color */
[class*="MuiFormLabel-root"],
[class*="MuiInputLabel-root"] {
    font-family: var(--fc-font-body) !important;
    font-weight: 600 !important;
    color: rgba(var(--fc-primary-rgb), 0.7) !important;
    transition: color 0.2s ease !important;
}

/* Focused label brightens to full rose */
[class*="MuiInputLabel-root"].Mui-focused,
[class*="MuiFormLabel-root"].Mui-focused {
    color: var(--fc-primary) !important;
}

/* ----------------------------------------------------------
   10. Form Inputs
   ---------------------------------------------------------- */

/* Input wrapper */
[class*="MuiOutlinedInput-root"] {
    background: rgba(10, 12, 20, 0.6) !important;
    border-radius: 10px !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
}

/* Input border — subtle at rest */
[class*="MuiOutlinedInput-root"] [class*="MuiOutlinedInput-notchedOutline"] {
    border-color: rgba(255, 255, 255, 0.1) !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* Hover state */
[class*="MuiOutlinedInput-root"]:hover [class*="MuiOutlinedInput-notchedOutline"] {
    border-color: rgba(var(--fc-primary-rgb), 0.4) !important;
}

/* Focused state — rose border, 2px ring + 12px glow */
[class*="MuiOutlinedInput-root"].Mui-focused [class*="MuiOutlinedInput-notchedOutline"],
[class*="MuiOutlinedInput-root"]:focus-within [class*="MuiOutlinedInput-notchedOutline"] {
    border-color: var(--fc-primary) !important;
    border-width: 2px !important;
    box-shadow:
        0 0 0 2px rgba(var(--fc-primary-rgb), 0.2),
        0 0 12px rgba(var(--fc-primary-rgb), 0.15) !important;
}

/* Input text */
[class*="MuiOutlinedInput-input"],
[class*="MuiInputBase-input"] {
    color: var(--fc-text) !important;
    font-family: var(--fc-font-body) !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
}

/* Chrome autofill override */
[class*="MuiOutlinedInput-input"]:-webkit-autofill,
[class*="MuiInputBase-input"]:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px rgba(10, 12, 20, 0.95) inset !important;
    -webkit-text-fill-color: var(--fc-text) !important;
    caret-color: var(--fc-text) !important;
}

/* ----------------------------------------------------------
   11. Sign In Button
   ---------------------------------------------------------- */
[class*="MuiButton-contained"] {
    background: linear-gradient(135deg, var(--fc-primary), var(--fc-secondary)) !important;
    border: none !important;
    color: #ffffff !important;
    font-family: var(--fc-font-body) !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    border-radius: 10px !important;
    box-shadow:
        0 0 20px rgba(var(--fc-primary-rgb), 0.35),
        0 0 40px rgba(var(--fc-secondary-rgb), 0.15) !important;
    position: relative !important;
    overflow: hidden !important;
    transition: filter 0.2s ease, box-shadow 0.2s ease !important;
}

/* Hover: brightness + intensified glow */
[class*="MuiButton-contained"]:hover {
    filter: brightness(1.1) !important;
    box-shadow:
        0 0 28px rgba(var(--fc-primary-rgb), 0.5),
        0 0 56px rgba(var(--fc-secondary-rgb), 0.25) !important;
}

/* Shimmer sweep pseudo-element */
[class*="MuiButton-contained"]::after {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.25),
        transparent
    ) !important;
    pointer-events: none !important;
}

/* Shimmer activates on hover */
[class*="MuiButton-contained"]:hover::after {
    animation: btnShine 1.2s ease forwards !important;
}

/* ----------------------------------------------------------
   12. Links
   ---------------------------------------------------------- */
a,
[class*="MuiLink-root"] {
    color: var(--fc-primary) !important;
    text-decoration: none !important;
    transition: color 0.2s ease, text-shadow 0.2s ease !important;
}

a:hover,
[class*="MuiLink-root"]:hover {
    color: #e8357a !important;
    text-shadow: 0 0 8px rgba(var(--fc-primary-rgb), 0.4) !important;
}

/* Reset password link */
[class*="resetLink"] {
    font-family: var(--fc-font-body) !important;
    font-weight: 600 !important;
}

/* Powered-by / footer links — dimmed */
[class*="links"] {
    opacity: 0.5 !important;
    transition: opacity 0.2s ease !important;
}

[class*="links"]:hover {
    opacity: 0.8 !important;
}

/* ----------------------------------------------------------
   13. Checkbox
   ---------------------------------------------------------- */
[class*="MuiCheckbox-root"] {
    color: var(--fc-text-dim) !important;
    transition: color 0.2s ease !important;
}

[class*="MuiCheckbox-root"].Mui-checked,
[class*="MuiCheckbox-colorPrimary"].Mui-checked {
    color: var(--fc-primary) !important;
}

[class*="MuiCheckbox-root"]:hover {
    background-color: rgba(var(--fc-primary-rgb), 0.08) !important;
}

/* Remember-me label text */
[class*="rememberMe"],
[class*="MuiFormControlLabel-root"] [class*="MuiTypography"] {
    font-family: var(--fc-font-body) !important;
    color: var(--fc-text-dim) !important;
}

/* ----------------------------------------------------------
   14. Icon Buttons
   ---------------------------------------------------------- */
[class*="MuiIconButton-root"] {
    color: var(--fc-text-dim) !important;
    transition: color 0.2s ease, filter 0.2s ease !important;
}

[class*="MuiIconButton-root"]:hover {
    color: var(--fc-primary) !important;
    filter: drop-shadow(0 0 6px rgba(var(--fc-primary-rgb), 0.5)) !important;
    background-color: rgba(var(--fc-primary-rgb), 0.08) !important;
}

/* Password visibility toggle */
[class*="MuiIconButton-edgeEnd"] {
    color: var(--fc-text-dim) !important;
}

[class*="MuiIconButton-edgeEnd"]:hover {
    color: var(--fc-primary) !important;
}

/* ----------------------------------------------------------
   15. Custom Scrollbar
   ---------------------------------------------------------- */

/* Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 8px !important;
}

::-webkit-scrollbar-track {
    background: var(--fc-bg) !important;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--fc-primary), var(--fc-secondary)) !important;
    border-radius: 4px !important;
}

::-webkit-scrollbar-thumb:hover {
    box-shadow: 0 0 6px rgba(var(--fc-primary-rgb), 0.5) !important;
}

/* Firefox */
* {
    scrollbar-width: thin !important;
    scrollbar-color: var(--fc-primary) var(--fc-bg) !important;
}

/* ----------------------------------------------------------
   16. Keyframes
   ---------------------------------------------------------- */

/* Aurora drift — slow translation of the glow blobs */
@keyframes auroraDrift {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(3%, -2%, 0) scale(1.02);
    }
    100% {
        transform: translate3d(-2%, 3%, 0) scale(0.98);
    }
}

/* Cipher rain — columns fall from above to below viewport */
@keyframes cipherFall {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(calc(100vh + 100%));
    }
}

/* Scanline sweep — horizontal band moving top to bottom */
@keyframes scanSweep {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 0% 100%;
    }
}

/* Login card border/shadow breathing */
@keyframes cardPulse {
    0%, 100% {
        box-shadow:
            0 0 30px rgba(var(--fc-primary-rgb), 0.08),
            0 0 60px rgba(var(--fc-secondary-rgb), 0.05),
            inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }
    50% {
        box-shadow:
            0 0 38px rgba(var(--fc-primary-rgb), 0.13),
            0 0 75px rgba(var(--fc-secondary-rgb), 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

/* Button shimmer sweep */
@keyframes btnShine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ----------------------------------------------------------
   17. prefers-reduced-motion
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    body::before,
    #root::before,
    .cipher-col,
    [class*="MuiContainer"][class*="maxWidthXs"],
    [class*="rootContainer"],
    [class*="MuiButton-contained"]::after {
        animation: none !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #fc-cipher-bg {
        display: none !important;
    }
}
