/* The MaintenancePal look for the Authelia portal: the portal's own login page (portal/src/pages/Login.tsx),
   a blue page with a white card, and from 1280px the split screen with the brand panel on the left.
   Caddy serves this folder at /custom/ and links this file into every portal page (sites/auth.caddy).
   Authelia's markup is not ours: after an Authelia upgrade, open the login, second-factor and
   reset-password pages and fix the selectors here if needed. */

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/custom/fonts/roboto-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/custom/fonts/roboto-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/custom/fonts/roboto-latin-600-normal.woff2') format('woff2');
}

/* Authelia's theme variables: the portal's Blues palette, whatever theme the browser asks for. */
:root,
html[data-theme] {
    --background: #ffffff;
    --foreground: #475569;
    --card: #ffffff;
    --card-foreground: #475569;
    --popover: #ffffff;
    --popover-foreground: #475569;
    --primary: #2171b5;
    --primary-foreground: #ffffff;
    --secondary: #2171b5;
    --secondary-foreground: #ffffff;
    --info: #4292c6;
    --custom-loading-bar: #2171b5;
    --muted: #f7fbff;
    --muted-foreground: #64748b;
    --accent: #deebf7;
    --accent-foreground: #475569;
    --border: #c6dbef;
    --input: #c6dbef;
    --ring: #2171b5;
    --radius: 0.375rem;
    color-scheme: light;
}

html body {
    margin: 0;
    font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.25rem;
    letter-spacing: 0.025em;
    color: #475569;
    background: #f7fbff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── The login pages (sign in, second factor, reset password, sign out): those with Authelia's
   login shell. The settings pages keep Authelia's own layout, in the colours above. ──
   The page: blue, the card in the middle. */
body:has(.min-h-\[90vh\]) {
    background: #2171b5;
}
body:has(.min-h-\[90vh\]) #root,
body:has(.min-h-\[90vh\]) #root > div {
    background: transparent !important;
}

#root > div:has(> .min-h-\[90vh\]) {
    position: relative;
    box-sizing: border-box;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.75rem;
}

/* The portal is English only, and so is this page (sites/auth.caddy): no language button. */
#root header {
    display: none;
}

#root .min-h-\[90vh\] {
    min-height: 0 !important;
    width: 100%;
}

/* The card. */
#root .min-h-\[90vh\] > div {
    box-sizing: border-box;
    width: 100%;
    max-width: none !important;
    margin: 1.5rem auto;
    padding: 2rem 1.25rem !important;
    background: #ffffff;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* The brand where Authelia shows its logo. */
#root .min-h-\[90vh\] img.w-16 {
    display: none;
}
#root .min-h-\[90vh\] > div > div > div:first-child:has(> img.w-16) {
    height: 28px;
    margin-bottom: 1.5rem;
    padding: 0;
    background: url('/custom/brand-blue.svg') center / contain no-repeat;
}

/* Title, and on the login page the portal's own line under it. */
#root .min-h-\[90vh\] h5 {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    color: #475569;
}
#first-factor-stage h5::after {
    content: 'Enter your email address and password to open the portal.';
    display: block;
    margin-top: 0.5rem;
    font-size: 14px;
    line-height: 1.25rem;
    font-weight: 400;
    letter-spacing: 0.025em;
    color: #64748b;
}
#first-factor-stage form {
    margin-top: 1rem;
}
/* The passkey button right under Sign in, as the portal's second button: no "or" line between them. */
#first-factor-stage form > div.grid > div:has(> div > span.uppercase) {
    display: none;
}
#first-factor-stage form > div.grid > div:has(> #passkey-sign-in-button) {
    margin-top: -0.5rem;
}

/* Fields: the label above its field, as on the portal (Authelia floats it inside). */
#root .min-h-\[90vh\] div.relative:has(> input.peer) {
    display: flex;
    flex-direction: column-reverse;
    text-align: left;
}
#root .min-h-\[90vh\] input.peer + label,
#root .min-h-\[90vh\] label:has(+ input) {
    position: static;
    translate: none;
    margin-bottom: 0.25rem;
    font-size: 12px;
    line-height: 1rem;
    font-weight: 500;
    color: #475569;
}
#root .min-h-\[90vh\] input.peer,
#root .min-h-\[90vh\] label + input {
    box-sizing: border-box;
    height: auto;
    padding: 0.75rem 1rem;
    font-size: 14px;
    line-height: 1.25rem;
    color: #475569;
    background: #ffffff;
    border: 1px solid #c6dbef;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
#root .min-h-\[90vh\] input.peer::placeholder {
    color: #64748b;
    opacity: 1;
}
#root .min-h-\[90vh\] input.peer:focus,
#root .min-h-\[90vh\] label + input:focus {
    border-color: rgba(33, 113, 181, 0.4);
    box-shadow: 0 0 0 4px rgba(33, 113, 181, 0.2);
}
/* The show-password eye: on the field, which now sits under its label. */
#root .min-h-\[90vh\] div.relative:has(> div.relative > input.peer) > button {
    top: auto;
    bottom: 9px;
    translate: none;
}

#root .min-h-\[90vh\] label,
#root .min-h-\[90vh\] p,
#root .min-h-\[90vh\] span {
    letter-spacing: 0.025em;
}
#root .min-h-\[90vh\] label[for],
#root .min-h-\[90vh\] #remember-checkbox ~ label {
    font-size: 14px;
    font-weight: 400;
    color: #475569;
}

/* Buttons: the main action in the portal's blue, a second one outlined. */
#root .min-h-\[90vh\] button.bg-primary,
#sign-in-button {
    height: auto;
    padding: 0.75rem 1rem;
    font-size: 14px;
    line-height: 1.25rem;
    font-weight: 500;
    letter-spacing: 0.025em;
    text-transform: none;
    color: #ffffff;
    background: #2171b5;
    border: 1px solid #2171b5;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: all 0.2s;
}
#root .min-h-\[90vh\] button.bg-primary:hover:not(:disabled),
#sign-in-button:hover:not(:disabled) {
    background: rgba(33, 113, 181, 0.9);
    border-color: rgba(33, 113, 181, 0.9);
}
#root .min-h-\[90vh\] button.bg-primary:focus-visible,
#sign-in-button:focus-visible,
#passkey-sign-in-button:focus-visible {
    box-shadow: 0 0 0 4px rgba(33, 113, 181, 0.2);
}
#root .min-h-\[90vh\] #passkey-sign-in-button,
#root .min-h-\[90vh\] #cancel-button {
    height: auto;
    padding: 0.75rem 1rem;
    line-height: 1.25rem;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.025em;
    text-transform: none;
    color: #475569;
    background: transparent;
    border: 1px solid #c6dbef;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
#root .min-h-\[90vh\] #passkey-sign-in-button:hover:not(:disabled),
#root .min-h-\[90vh\] #cancel-button:hover:not(:disabled) {
    background: rgba(222, 235, 247, 0.4);
}

#root .min-h-\[90vh\] a,
#reset-password-button {
    font-size: 14px;
    color: #2171b5;
}
/* Authelia's own accents on the second-factor page, in the portal's colours: the explanations (violet),
   the Logout / Switch user / Methods row (pink, compiled into its stylesheet) and the code's timer (black). */
#root .min-h-\[90vh\] p[class*='5858ff'] {
    color: #64748b;
}
#root .min-h-\[90vh\] .text-secondary {
    color: #2171b5;
    text-transform: none;
    letter-spacing: 0.025em;
}
#root .min-h-\[90vh\] .text-secondary:hover {
    background: rgba(222, 235, 247, 0.4);
}
#second-factor-stage svg circle[stroke='#000'] {
    stroke: #2171b5;
}
#second-factor-stage svg circle[fill='#000'] {
    fill: #2171b5;
}

/* Footer: the portal's own line above Authelia's. */
#root .min-h-\[90vh\] > div > div > div:last-child:has(> a) {
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 2rem;
}
#root .min-h-\[90vh\] > div > div > div:last-child:has(> a)::before {
    content: '\00a9  MaintenancePal';
    color: #64748b;
}
#root .min-h-\[90vh\] > div > div > div:last-child:has(> a) > a {
    font-size: 12px;
    color: #64748b;
}

@media (min-width: 640px) {
    #root > div:has(> .min-h-\[90vh\]) {
        padding: 0 4.5rem;
    }
    #root .min-h-\[90vh\] > div {
        width: 75%;
        padding: 2rem !important;
    }
}

@media (min-width: 1024px) {
    #root .min-h-\[90vh\] > div {
        width: 50%;
    }
}

/* ── From 1280px: white page, the brand panel on the left, the form on the right ── */
@media (min-width: 1280px) {
    body:has(.min-h-\[90vh\]) {
        background: #ffffff;
        overflow-x: hidden;
    }
    /* The two tilted ellipses: a pale rim and the blue gradient on top of it. */
    body:has(.min-h-\[90vh\])::before,
    body:has(.min-h-\[90vh\])::after {
        content: '';
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 57%;
        border-radius: 100%;
        transform: rotate(-4.5deg);
    }
    body:has(.min-h-\[90vh\])::before {
        margin: -28% 0 -16% -13%;
        background: rgba(33, 113, 181, 0.2);
    }
    body:has(.min-h-\[90vh\])::after {
        margin: -20% 0 -13% -13%;
        background: linear-gradient(to bottom, #2171b5, #084594);
    }
    body:has(.min-h-\[90vh\]) #root {
        position: relative;
        z-index: 10;
    }

    #root > div:has(> .min-h-\[90vh\]) {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 1rem;
        align-items: center;
        width: min(1280px, calc(100vw - 4rem));
        margin: 0 auto;
        padding: 0 2.5rem;
    }
    /* Brand, top left. */
    #root > div:has(> .min-h-\[90vh\])::before {
        content: '';
        position: absolute;
        top: 2rem;
        left: 2.5rem;
        width: 172px;
        height: 28px;
        background: url('/custom/brand-white.svg') left center / contain no-repeat;
    }
    /* The document icon with the headline under it, and the line under that: placed around the middle of
       the screen as the portal's flex column does (12px page padding, brand row 48px, block centred below). */
    #root > div:has(> .min-h-\[90vh\])::after {
        content: 'Technical drawings,\A kept up to date.';
        white-space: pre;
        position: absolute;
        top: calc(50vh - 165px);
        left: 2.5rem;
        padding-top: 200px;
        background: url('/custom/file-text.svg') left top / 160px 160px no-repeat;
        font-size: 2.25rem;
        line-height: 1.25;
        font-weight: 500;
        color: #ffffff;
    }
    #root .min-h-\[90vh\]::before {
        content: 'Markups from the field, processed by the drawing office.';
        position: absolute;
        top: calc(50vh + 145px);
        left: 2.5rem;
        max-width: calc(50% - 4rem);
        font-size: 1.125rem;
        line-height: 1.75rem;
        text-align: left;
        color: rgba(255, 255, 255, 0.8);
    }

    #root .min-h-\[90vh\] {
        grid-column: 2;
        justify-content: flex-start !important;
        text-align: left !important;
    }
    #root .min-h-\[90vh\] > div {
        width: auto;
        min-width: 350px;
        max-width: 420px !important;
        margin: 1.5rem 0 0 5rem;
        padding: 0 !important;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
    }
    #root .min-h-\[90vh\] > div > div > div:first-child:has(> img.w-16) {
        display: none;
    }
    #root .min-h-\[90vh\] h5 {
        font-size: 1.875rem;
        line-height: 2.25rem;
    }
    #first-factor-stage form {
        margin-top: 1.5rem;
    }
    /* Sign in and the passkey button side by side, as the portal's two buttons. */
    #first-factor-stage form > div.grid {
        grid-template-columns: 8rem 1fr;
        column-gap: 0.75rem;
    }
    #first-factor-stage form > div.grid > div {
        grid-column: 1 / -1;
    }
    #first-factor-stage form > div.grid > div:has(> #sign-in-button) {
        grid-column: 1;
    }
    #first-factor-stage form > div.grid > div:has(> #passkey-sign-in-button) {
        grid-column: 2;
        justify-self: start;
        width: auto;
        margin-top: 0;
    }
    #root .min-h-\[90vh\] > div > div > div:last-child:has(> a) {
        align-items: flex-start;
        margin-top: 4rem;
    }
}

@media (min-width: 1536px) {
    #root > div:has(> .min-h-\[90vh\]) {
        width: min(1536px, calc(100vw - 4rem));
    }
}
