/*
 * Plugin GLPI « loginhost » — style moderne des pages publiques (connexion, mot de passe oublié…)
 * Actif seulement si « Style moderne » est coché et que le script du plugin a ajouté la classe
 * « lh-modern » : si le script ne se charge pas, la page GLPI d'origine reste intacte.
 * Éditeur : LaPetiteRuche.com — Licence : GPLv3+
 */

html.lh-modern {
    --lh-accent: var(--tblr-primary, #2563eb);
    --lh-accent-fg: #ffffff;
    --lh-bg: #f3f5f9;
    --lh-card: #ffffff;
    --lh-text: #0f172a;
    --lh-muted: #64748b;
    --lh-border: #e2e8f0;
    --lh-input: #ffffff;
    --lh-radius: 18px;
    --lh-radius-sm: 10px;
    --lh-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 18px 48px -16px rgba(15, 23, 42, .22);
}

html.lh-modern[data-glpi-theme-dark="1"] {
    --lh-bg: #0b1120;
    --lh-card: #111827;
    --lh-text: #e5e7eb;
    --lh-muted: #94a3b8;
    --lh-border: #253041;
    --lh-input: #0f172a;
    --lh-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 48px -16px rgba(0, 0, 0, .6);
}

html.lh-modern[data-lh-size="s"] { --lh-logo-h: 56px; }
html.lh-modern[data-lh-size="m"] { --lh-logo-h: 84px; }
html.lh-modern[data-lh-size="l"] { --lh-logo-h: 120px; }

/* ---------------------------------------------------------------- Fond */
html.lh-modern body.welcome-anonymous {
    min-height: 100vh;
    color: var(--lh-text);
    background:
        radial-gradient(60rem 40rem at 0% 0%, color-mix(in srgb, var(--lh-accent) 20%, transparent), transparent 70%),
        radial-gradient(50rem 36rem at 100% 100%, color-mix(in srgb, var(--lh-accent) 13%, transparent), transparent 70%),
        var(--lh-bg) !important;
    background-attachment: fixed !important;
}

html.lh-modern .page-anonymous {
    background: transparent !important;
}

html.lh-modern .page-anonymous > .flex-fill {
    min-height: 100vh;
    margin-top: 0 !important;
    padding: 2.5rem 1rem !important;
}

html.lh-modern .page-anonymous .container-tight {
    width: 100%;
    max-width: 27rem !important;
    padding: 0 !important;
}

/* ---------------------------------------------------------------- Logo et titre */
html.lh-modern .page-anonymous .glpi-logo {
    display: block;
    margin: 0 auto 1.5rem !important;
    height: var(--lh-logo-h, 84px);
    width: auto;
    max-width: min(320px, 100%);
    object-fit: contain;
}

html.lh-modern[data-glpi-theme-dark="1"] .page-anonymous .glpi-logo {
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, .25));
}

.lh-title {
    margin: -.5rem 0 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.35;
    color: var(--lh-text, inherit);
}

/* ---------------------------------------------------------------- Carte */
html.lh-modern .page-anonymous .main-content-card {
    border: 1px solid var(--lh-border) !important;
    border-radius: var(--lh-radius) !important;
    background: var(--lh-card) !important;
    box-shadow: var(--lh-shadow) !important;
    overflow: hidden;
    animation: lh-in .35s ease-out both;
}

html.lh-modern .page-anonymous .main-content-card > .card-body {
    padding: 2rem 2rem 1.75rem !important;
}

/* Les colonnes « formulaire » et « Microsoft 365 » sont empilées sur toute la largeur */
html.lh-modern .page-anonymous .main-content-card .row {
    --tblr-gutter-x: 0;
    row-gap: 0;
}

html.lh-modern .page-anonymous .main-content-card .row > .col-md-5,
html.lh-modern .page-anonymous .main-content-card .row > .col-auto {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

html.lh-modern .page-anonymous .main-content-card > .card-header:empty {
    display: none !important;
}

html.lh-modern .page-anonymous .main-content-card .card-header {
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    margin-bottom: 1.5rem !important;
}

html.lh-modern .page-anonymous .main-content-card h2 {
    margin: 0 auto;
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: -.015em;
    color: var(--lh-text);
    text-align: center;
}

/* En mode « Microsoft 365 uniquement », le titre « Connexion à votre compte » est masqué
   avec le formulaire : on garde de l'air autour du bouton. */
html.lh-modern.lh-sso-only .page-anonymous .main-content-card > .card-body {
    padding: 1.75rem 2rem !important;
}

/* ---------------------------------------------------------------- Champs */
html.lh-modern .page-anonymous .form-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--lh-text);
    margin-bottom: .375rem;
}

html.lh-modern .page-anonymous .form-control,
html.lh-modern .page-anonymous .form-select {
    min-height: 2.75rem;
    border-radius: var(--lh-radius-sm) !important;
    border: 1px solid var(--lh-border);
    background-color: var(--lh-input);
    color: var(--lh-text);
    font-size: .9375rem;
    transition: border-color .15s, box-shadow .15s;
}

html.lh-modern .page-anonymous .input-group > .form-control {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

html.lh-modern .page-anonymous .input-group > .btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

html.lh-modern .page-anonymous .select2-container .select2-selection--single {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    border-radius: var(--lh-radius-sm) !important;
    border-color: var(--lh-border) !important;
    background-color: var(--lh-input) !important;
}

html.lh-modern .page-anonymous .select2-container .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
}

html.lh-modern .page-anonymous .form-control:focus,
html.lh-modern .page-anonymous .form-select:focus,
html.lh-modern .page-anonymous .select2-container--focus .select2-selection,
html.lh-modern .page-anonymous .select2-container--open .select2-selection {
    border-color: var(--lh-accent) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--lh-accent) 18%, transparent) !important;
    outline: 0;
}

html.lh-modern .page-anonymous .form-check-input:checked {
    background-color: var(--lh-accent);
    border-color: var(--lh-accent);
}

/* ---------------------------------------------------------------- Boutons */
html.lh-modern .page-anonymous .btn {
    border-radius: var(--lh-radius-sm);
    font-weight: 600;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s;
}

html.lh-modern .page-anonymous .btn:active {
    transform: translateY(1px);
}

html.lh-modern .page-anonymous .btn-primary {
    min-height: 2.75rem;
    background-color: var(--lh-accent) !important;
    border-color: var(--lh-accent) !important;
    color: var(--lh-accent-fg) !important;
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--lh-accent) 70%, transparent);
}

html.lh-modern .page-anonymous .btn-primary:hover,
html.lh-modern .page-anonymous .btn-primary:focus-visible {
    background-color: color-mix(in srgb, var(--lh-accent) 88%, #000) !important;
    border-color: color-mix(in srgb, var(--lh-accent) 88%, #000) !important;
}

html.lh-modern .page-anonymous .form-footer {
    margin-top: 1.5rem;
}

html.lh-modern .page-anonymous a:not(.btn) {
    color: var(--lh-accent);
    text-decoration: none;
}

html.lh-modern .page-anonymous a:not(.btn):hover {
    text-decoration: underline;
}

/* ---------------------------------------------------------------- Bloc Microsoft 365 (plugin lprentrasso) */
html.lh-modern .page-anonymous .lprentrasso-login {
    min-width: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

html.lh-modern .page-anonymous .lprentrasso-login > .card-body {
    padding: 0 !important;
}

/* Bouton Microsoft 365 à côté du formulaire local : bouton secondaire, sobre */
html.lh-modern .page-anonymous .lprentrasso-login .btn-outline-primary {
    min-height: 2.75rem;
    background: var(--lh-card);
    color: var(--lh-text);
    border: 1px solid var(--lh-border);
}

html.lh-modern .page-anonymous .lprentrasso-login .btn-outline-primary:hover,
html.lh-modern .page-anonymous .lprentrasso-login .btn-outline-primary:focus-visible {
    border-color: var(--lh-accent);
    background: color-mix(in srgb, var(--lh-accent) 7%, var(--lh-card));
    color: var(--lh-text);
}

html.lh-modern .page-anonymous .lprentrasso-login .btn-outline-primary .ti {
    color: var(--lh-accent);
    font-size: 1.15rem;
}

/* Microsoft 365 uniquement : le bouton devient l'action principale */
html.lh-modern.lh-sso-only .page-anonymous .lprentrasso-login .btn-outline-primary {
    background: var(--lh-accent);
    border-color: var(--lh-accent);
    color: var(--lh-accent-fg);
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--lh-accent) 70%, transparent);
}

html.lh-modern.lh-sso-only .page-anonymous .lprentrasso-login .btn-outline-primary .ti {
    color: inherit;
}

html.lh-modern.lh-sso-only .page-anonymous .lprentrasso-login .btn-outline-primary:hover {
    background: color-mix(in srgb, var(--lh-accent) 88%, #000);
    color: var(--lh-accent-fg);
}

html.lh-modern .page-anonymous .lprentrasso-login details {
    margin-top: .75rem !important;
}

html.lh-modern .page-anonymous .lprentrasso-login summary {
    list-style: none;
    cursor: pointer;
    text-align: center;
    font-size: .8125rem;
    color: var(--lh-muted) !important;
}

html.lh-modern .page-anonymous .lprentrasso-login summary::-webkit-details-marker {
    display: none;
}

html.lh-modern .page-anonymous .lprentrasso-login summary::after {
    content: "›";
    display: inline-block;
    margin-left: .35rem;
    transition: transform .15s;
}

html.lh-modern .page-anonymous .lprentrasso-login details[open] summary::after {
    transform: rotate(90deg);
}

/* Séparateur « ou » entre le formulaire local et Microsoft 365 */
html.lh-modern:not(.lh-sso-only) .page-anonymous .main-content-card .row > .col-auto:has(.lprentrasso-login)::before {
    content: "ou";
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0 1rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--lh-muted);
    background:
        linear-gradient(var(--lh-border), var(--lh-border)) left center / calc(50% - 1.5rem) 1px no-repeat,
        linear-gradient(var(--lh-border), var(--lh-border)) right center / calc(50% - 1.5rem) 1px no-repeat;
    justify-content: center;
}

/* ---------------------------------------------------------------- Divers */
html.lh-modern .page-anonymous .alert {
    border-radius: var(--lh-radius-sm);
}

html.lh-modern .page-anonymous .main-content-card hr {
    border-color: var(--lh-border);
    opacity: 1;
}

html.lh-modern .page-anonymous .container-tight > .text-center.text-muted {
    margin-top: 1.5rem !important;
    font-size: .75rem;
    color: var(--lh-muted) !important;
}

html.lh-modern .page-anonymous .container-tight > .text-center.text-muted a,
html.lh-modern .page-anonymous .container-tight > .text-center:last-child a {
    color: var(--lh-muted) !important;
}

html.lh-modern .page-anonymous .container-tight > .text-center:last-child {
    margin-top: .5rem !important;
    font-size: .8125rem;
}

@keyframes lh-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    html.lh-modern .page-anonymous .main-content-card {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    html.lh-modern .page-anonymous > .flex-fill {
        padding: 1.5rem .75rem !important;
    }

    html.lh-modern .page-anonymous .main-content-card > .card-body {
        padding: 1.5rem 1.25rem !important;
    }
}
