/**
 * ---------------------------------------------------------------------
 *
 * HGK Brand - GLPI plugin
 *
 * Styles of the pages without login. Free to edit: nothing here depends
 * on Bootstrap / Tabler, the login page uses only the hgkb-login__*
 * classes of templates/override/pages/login.html.twig.
 *
 * Values set on the plugin config page come from front/brand.css.php as
 * CSS custom properties (defaults below are used if it is missing):
 *   --hgkb-bg-image         url("...") or none
 *   --hgkb-bg-color         colour behind the image
 *   --hgkb-overlay-rgb      overlay colour as "r g b"
 *   --hgkb-overlay-opacity  0 .. .9
 *   --hgkb-accent           sign-in button background
 *   --hgkb-accent-text      sign-in button text
 *
 * Sections:
 *   1. Variables
 *   2. Page background (all pages without login)
 *   3. Login page layout
 *   4. Login form
 *   5. Other pages without login (GLPI card layout: lost password, errors...)
 *   6. Small screens, reduced motion / transparency
 *
 * Based on the design of Colorlib "login-page-04".
 *
 * ---------------------------------------------------------------------
 */

/* 1. Variables ------------------------------------------------------- */

:root {
    --hgkb-bg-image: none;
    --hgkb-bg-color: #231a52;
    --hgkb-overlay-rgb: 10 8 40;
    --hgkb-overlay-opacity: .55;
    --hgkb-accent: #ffffff;
    --hgkb-accent-text: #1e1250;
}

.welcome-anonymous {
    --hgkb-font: var(--tblr-font-sans-serif, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    --hgkb-ink: #ffffff;                          /* main text */
    --hgkb-soft: rgba(255, 255, 255, .86);        /* secondary text */
    --hgkb-glass: rgba(255, 255, 255, .14);       /* glass panel */
    --hgkb-edge: rgba(255, 255, 255, .34);        /* glass panel border */
    --hgkb-field: rgba(255, 255, 255, .16);       /* input background */
    --hgkb-field-edge: rgba(255, 255, 255, .3);   /* input border */
    --hgkb-solid: #231a52;                        /* panel without blur support */
    --hgkb-error-bg: rgba(159, 18, 57, .75);
    --hgkb-error-text: #ffe4e6;
    --hgkb-radius-panel: 28px;
    --hgkb-radius-field: 14px;
}

/* 2. Page background -------------------------------------------------- */

body.welcome-anonymous {
    position: relative;
    min-height: 100vh;
    margin: 0;
    background: var(--hgkb-bg-color);
    color: var(--hgkb-ink);
    font-family: var(--hgkb-font);
    isolation: isolate;
}

/* Image */
body.welcome-anonymous::before,
body.welcome-anonymous::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body.welcome-anonymous::before {
    z-index: -2;
    background: var(--hgkb-bg-image) center / cover no-repeat;
}

/* Overlay: darker on the left (text) and on the right (form) */
body.welcome-anonymous::after {
    z-index: -1;
    background: linear-gradient(
        100deg,
        rgb(var(--hgkb-overlay-rgb) / var(--hgkb-overlay-opacity)),
        rgb(var(--hgkb-overlay-rgb) / calc(var(--hgkb-overlay-opacity) * .27)) 60%,
        rgb(var(--hgkb-overlay-rgb) / calc(var(--hgkb-overlay-opacity) * .64))
    );
}

/* 3. Login page layout ------------------------------------------------ */

.hgkb-login {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(32px, 6vw, 96px);
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
    padding: 48px clamp(16px, 7vw, 120px);
    color: var(--hgkb-ink);
    font-family: var(--hgkb-font);
    line-height: 1.5;
}

.hgkb-login *,
.hgkb-login *::before,
.hgkb-login *::after {
    box-sizing: border-box;
}

.hgkb-login:focus {
    outline: none;
}

.hgkb-login [hidden] {
    display: none !important;
}

/* Left column */
.hgkb-login__intro {
    flex: 1 1 0;
    min-width: 0;
}

.hgkb-login__logo {
    display: inline-block;
}

.hgkb-login__kicker {
    margin: 48px 0 10px;
    color: var(--hgkb-soft);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.hgkb-login__headline {
    max-width: 15ch;
    margin: 0 0 28px;
    font-size: clamp(34px, 5vw, 64px);
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1.02;
    text-shadow: 0 2px 30px rgba(0, 0, 0, .3);
}

.hgkb-login__text {
    max-width: 52ch;
    margin: 0;
    color: var(--hgkb-soft);
    font-size: 17px;
    text-shadow: 0 1px 12px rgba(0, 0, 0, .3);
}

/* Right column: glass panel */
.hgkb-login__glass {
    flex: 0 1 440px;
    min-width: 0;
    padding: clamp(24px, 5vw, 40px);
    border: 1px solid var(--hgkb-edge);
    border-radius: var(--hgkb-radius-panel);
    background: var(--hgkb-glass);
    box-shadow: 0 30px 60px -20px rgba(8, 6, 30, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .hgkb-login__glass {
        background: var(--hgkb-solid);
    }
}

.hgkb-login__title {
    margin: 0 0 4px;
    color: var(--hgkb-ink);
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.hgkb-login__sub {
    margin: 0 0 8px;
    color: var(--hgkb-soft);
    font-size: 16px;
}

.hgkb-login__note {
    margin: 8px 0 0;
    color: var(--hgkb-soft);
    font-size: 14px;
}

.hgkb-login__note a {
    color: var(--hgkb-ink);
}

.hgkb-login__extra:not(:empty) {
    margin-top: 16px;
}

.hgkb-login__foot {
    margin: 22px 0 0;
    color: var(--hgkb-soft);
    font-size: 12px;
    text-align: center;
}

.hgkb-login__foot a {
    color: var(--hgkb-soft);
}

/* 4. Login form -------------------------------------------------------
 *
 * Fields are prefixed with #hgkb-login-form: GLPI styles every <input>
 * with a long input:not(...):not(...) selector, which a class alone
 * cannot override.
 */

.hgkb-login__form {
    margin-top: 22px;
}

.hgkb-login__field {
    margin-bottom: 16px;
}

.hgkb-login__label {
    display: block;
    margin-bottom: 6px;
    color: var(--hgkb-ink);
    font-size: 14px;
    font-weight: 500;
}

#hgkb-login-form .hgkb-login__input,
#hgkb-login-form .hgkb-login__source select {
    display: block;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 12px 16px;
    border: 1px solid var(--hgkb-field-edge);
    border-radius: var(--hgkb-radius-field);
    background: var(--hgkb-field);
    color: var(--hgkb-ink);
    font: inherit;
    font-size: 16px;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

#hgkb-login-form .hgkb-login__input::placeholder {
    color: rgba(255, 255, 255, .72);
}

#hgkb-login-form .hgkb-login__input:hover {
    border-color: rgba(255, 255, 255, .5);
}

#hgkb-login-form .hgkb-login__input:focus,
#hgkb-login-form .hgkb-login__source select:focus {
    outline: none;
    border-color: #ffffff;
    background: rgba(255, 255, 255, .22);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .22);
}

/* Browser autofill keeps the glass look */
#hgkb-login-form .hgkb-login__input:-webkit-autofill {
    -webkit-text-fill-color: var(--hgkb-ink);
    transition: background-color 9999s ease 0s;
    box-shadow: inset 0 0 0 100px rgba(255, 255, 255, .16);
}

/* Login source: native select or GLPI select2 */
.hgkb-login__source select option {
    color: #1e1250;
}

.hgkb-login__source .select2-container {
    width: 100% !important;
}

#hgkb-login-form .hgkb-login__source .select2-container .select2-selection--single {
    display: flex;
    align-items: center;
    height: 50px;
    border: 1px solid var(--hgkb-field-edge);
    border-radius: var(--hgkb-radius-field);
    background: var(--hgkb-field);
}

#hgkb-login-form .hgkb-login__source .select2-container .select2-selection__rendered {
    padding-left: 16px;
    color: var(--hgkb-ink);
}

#hgkb-login-form .hgkb-login__source .select2-container .select2-selection__arrow {
    top: 12px;
    right: 8px;
}

/* Password with show/hide button */
.hgkb-login__pw {
    position: relative;
}

#hgkb-login-form .hgkb-login__pw .hgkb-login__input {
    padding-right: 54px;
}

.hgkb-login__eye {
    position: absolute;
    top: 5px;
    right: 5px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--hgkb-ink);
    cursor: pointer;
}

.hgkb-login__eye:hover {
    background: rgba(255, 255, 255, .16);
}

.hgkb-login__eye-off,
.hgkb-login__eye[aria-pressed="true"] .hgkb-login__eye-on {
    display: none;
}

.hgkb-login__eye[aria-pressed="true"] .hgkb-login__eye-off {
    display: block;
}

/* Remember me / lost password */
.hgkb-login__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 4px 0 22px;
}

.hgkb-login__check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--hgkb-ink);
    font-size: 14px;
    cursor: pointer;
}

.hgkb-login__check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #ffffff;
}

.hgkb-login__link {
    color: var(--hgkb-ink);
    font-size: 14px;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, .5);
    text-underline-offset: 3px;
    border-radius: 4px;
}

.hgkb-login__link:hover {
    color: var(--hgkb-ink);
    text-decoration-color: #ffffff;
}

/* Sign in */
.hgkb-login__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    margin-top: 6px;
    border: 0;
    border-radius: var(--hgkb-radius-field);
    background: var(--hgkb-accent);
    color: var(--hgkb-accent-text);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .45);
    transition: transform .15s ease, box-shadow .15s ease;
}

.hgkb-login__submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 34px -10px rgba(0, 0, 0, .5);
}

.hgkb-login__submit svg {
    transition: transform .15s ease;
}

.hgkb-login__submit:hover svg {
    transform: translateX(3px);
}

/* "or" separator and secondary button (FAQ) */
.hgkb-login__or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    color: var(--hgkb-soft);
    font-size: 13px;
}

.hgkb-login__or::before,
.hgkb-login__or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, .3);
}

.hgkb-login__ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: var(--hgkb-radius-field);
    background: rgba(255, 255, 255, .12);
    color: var(--hgkb-ink);
    font-weight: 500;
    text-decoration: none;
}

.hgkb-login__ghost:hover {
    background: rgba(255, 255, 255, .22);
    color: var(--hgkb-ink);
}

/* Keyboard focus */
.hgkb-login__eye:focus-visible,
.hgkb-login__check input:focus-visible,
.hgkb-login__link:focus-visible,
.hgkb-login__submit:focus-visible,
.hgkb-login__ghost:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

/* 5. Other pages without login (GLPI card layout) --------------------- */

.welcome-anonymous .page-anonymous {
    background: transparent;
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous .card {
    border: 1px solid var(--hgkb-edge);
    border-radius: var(--hgkb-radius-panel);
    background: var(--hgkb-glass);
    color: var(--hgkb-ink);
    box-shadow: 0 30px 60px -20px rgba(8, 6, 30, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
}

.welcome-anonymous .page-anonymous .card-header {
    border-bottom-color: rgba(255, 255, 255, .2);
    background: transparent;
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous .card-header:empty {
    display: none;
}

.welcome-anonymous .page-anonymous :is(h1, h2, h3, h4, .card-title, .form-label, label) {
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous :is(.text-muted, .text-secondary, .form-hint) {
    color: var(--hgkb-soft) !important;
}

.welcome-anonymous .page-anonymous a:not(.btn) {
    color: var(--hgkb-ink);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, .5);
    text-underline-offset: 3px;
}

.welcome-anonymous .page-anonymous :is(.form-control, .form-select) {
    min-height: 46px;
    border: 1px solid var(--hgkb-field-edge);
    border-radius: var(--hgkb-radius-field);
    background-color: var(--hgkb-field);
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous :is(.form-control, .form-select):focus {
    border-color: #ffffff;
    background-color: rgba(255, 255, 255, .22);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .22);
}

.welcome-anonymous .page-anonymous .btn-primary {
    min-height: 46px;
    border: 0;
    border-radius: var(--hgkb-radius-field);
    background: var(--hgkb-accent);
    color: var(--hgkb-accent-text);
    font-weight: 600;
}

.welcome-anonymous .page-anonymous .btn:not(.btn-primary) {
    border-radius: var(--hgkb-radius-field);
}

.welcome-anonymous .page-anonymous .btn-outline-secondary {
    border-color: rgba(255, 255, 255, .45);
    background: rgba(255, 255, 255, .12);
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous .alert {
    border: 0;
    border-radius: 12px;
    background: rgb(20 16 60 / .55);
    color: var(--hgkb-ink);
}

.welcome-anonymous .page-anonymous .alert-danger {
    background: var(--hgkb-error-bg);
    color: var(--hgkb-error-text);
}

/* 6. Small screens, reduced motion / transparency --------------------- */

@media (max-width: 900px) {
    .hgkb-login {
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 32px;
        padding-top: 32px;
    }

    .hgkb-login__intro,
    .hgkb-login__glass {
        flex: none;
    }

    .hgkb-login__kicker {
        margin-top: 28px;
    }

    .hgkb-login__headline {
        margin-bottom: 18px;
        font-size: 34px;
    }

    .hgkb-login__text {
        display: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .hgkb-login__glass,
    .welcome-anonymous .page-anonymous .card {
        background: var(--hgkb-solid);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hgkb-login *,
    .hgkb-login *::before,
    .hgkb-login *::after {
        transition: none !important;
        animation: none !important;
    }
}
