/*
 * Thème du back-office, aligné sur les couleurs de Plus que pro Solution (clair et sombre).
 *
 * Chargé après adminlte.min.css (pile « css » du layout boilerplate, cf. AppServiceProvider).
 * Les couleurs sont des variables définies sur body, redéfinies sous body.dark-mode : la bascule
 * clair/sombre du boilerplate ne fait qu'ajouter ou retirer cette classe, sans recharger la page.
 *
 * Les sélecteurs commencent par « body.layout-fixed » (classe toujours présente sur le layout) :
 * ce préfixe l'emporte sur les règles « .dark-mode … » d'AdminLTE, de même structure. Les pages de
 * connexion (layout boilerplate::auth.layout) portent « body.login-page » : leurs règles sont
 * regroupées dans la section « Page de connexion ».
 */

/* ---------------------------------------------------------------- Couleurs */

body {
    --pqp-fond: #fafafa;
    --pqp-surface: #ffffff;
    --pqp-surface-survol: #f3f4f6;
    --pqp-bordure: #e5e7eb;
    --pqp-entete: #f4f6fb;
    --pqp-entete-bordure: #e8edf6;
    --pqp-texte: #1c2435;
    --pqp-texte-attenue: #6b7280;
    --pqp-accent: #f98f34;
    --pqp-accent-fond: #fff4ea;
    --pqp-primaire: #1746a2;
    --pqp-primaire-survol: #123a87;
    --pqp-lien: #1746a2;
    --pqp-pastille: #103273;
    --pqp-pastille-texte: #ffffff;
    --pqp-champ: #ffffff;
}

body.dark-mode {
    --pqp-fond: #0b1220;
    --pqp-surface: #111828;
    --pqp-surface-survol: #1a2336;
    --pqp-bordure: #27334b;
    --pqp-entete: #0d1930;
    --pqp-entete-bordure: #20314f;
    --pqp-texte: #e5e7eb;
    --pqp-texte-attenue: #9a9ca6;
    --pqp-accent: #ff9133;
    --pqp-accent-fond: rgba(255, 145, 51, .1);
    --pqp-primaire: #2563eb;
    --pqp-primaire-survol: #1d4ed8;
    --pqp-lien: #7cc0eb;
    --pqp-pastille: #103273;
    --pqp-pastille-texte: #7cc8f2;
    --pqp-champ: #0b1220;
}

/* ------------------------------------------------------- Structure de page */

body.layout-fixed,
body.layout-fixed.dark-mode {
    background-color: var(--pqp-fond) !important;
    color: var(--pqp-texte);
}

body.layout-fixed .content-wrapper {
    background-color: var(--pqp-fond);
    color: var(--pqp-texte);
}

body.layout-fixed .content-wrapper .content-header,
body.layout-fixed .content-wrapper .content-header h1 {
    color: var(--pqp-texte);
}

body.layout-fixed .content-header .breadcrumb-item,
body.layout-fixed .content-header .breadcrumb-item.active,
body.layout-fixed .text-muted {
    color: var(--pqp-texte-attenue) !important;
}

/* Liens de la zone de contenu. AdminLTE les colore en gris ou en blanc par une règle
   « .accent-dark a:not(…) » (resp. accent-light) : la même structure, préfixée, la remplace. Le
   menu et la barre du haut sont hors de .content-wrapper et gardent leurs propres règles. */
body.layout-fixed .content-wrapper:is(.accent-dark, .accent-light) a:not(.dropdown-item):not(.btn-app):not(.nav-link):not(.brand-link):not(.page-link):not(.badge):not(.btn) {
    color: var(--pqp-lien);
}

body.layout-fixed .content-wrapper:is(.accent-dark, .accent-light) a:not(.dropdown-item):not(.btn-app):not(.nav-link):not(.brand-link):not(.page-link):not(.badge):not(.btn):hover {
    color: var(--pqp-primaire-survol);
}

/* Barre du haut */
body.layout-fixed .main-header.navbar,
body.layout-fixed .main-header.navbar-dark {
    background-color: var(--pqp-surface);
    border-bottom: 1px solid var(--pqp-bordure);
}

body.layout-fixed .main-header .nav-link {
    color: var(--pqp-texte-attenue);
}

body.layout-fixed .main-header .nav-link:hover {
    color: var(--pqp-texte);
}

/* --------------------------------------------------------- Menu de gauche */

body.layout-fixed .main-sidebar,
body.layout-fixed .main-sidebar::before {
    background-color: var(--pqp-surface);
    box-shadow: none !important;
}

body.layout-fixed .main-sidebar {
    border-right: 1px solid var(--pqp-bordure);
}

body.layout-fixed .main-sidebar .brand-link {
    background-color: var(--pqp-surface) !important;
    border-bottom: 1px solid var(--pqp-bordure);
    color: var(--pqp-texte);
}

/* Logo : l'étoile Plus que pro Solution, sans la pastille ronde du boilerplate. */
body.layout-fixed .main-sidebar .brand-link .brand-logo {
    background-color: transparent !important;
    border-radius: 0;
    box-shadow: none !important;
}

body.layout-fixed .main-sidebar .brand-link .brand-logo-image {
    display: block;
    height: 1.75rem;
    width: auto;
}

body.layout-fixed .main-sidebar .user-panel {
    border-bottom: 1px solid var(--pqp-bordure);
}

body.layout-fixed .main-sidebar .user-panel a {
    color: var(--pqp-texte);
}

body.layout-fixed .main-sidebar .nav-sidebar .nav-item > .nav-link {
    background-color: transparent;
    border-radius: .375rem;
    box-shadow: none !important;
    color: var(--pqp-texte);
}

body.layout-fixed .main-sidebar .nav-sidebar .nav-item > .nav-link .nav-icon {
    color: var(--pqp-texte-attenue);
}

body.layout-fixed .main-sidebar .nav-sidebar .nav-item > .nav-link:hover,
body.layout-fixed .main-sidebar .nav-sidebar .nav-item > .nav-link:focus {
    background-color: var(--pqp-surface-survol);
    color: var(--pqp-texte);
}

/* Groupe (entrée qui contient un sous-menu) : titre atténué, sans fond, même ouvert ou contenant
   la page courante. Détecté par :has(), les groupes créés par $item->add() n'ayant pas la classe
   has-treeview. */
body.layout-fixed .main-sidebar .nav-sidebar .nav-item:has(> .nav-treeview) > .nav-link,
body.layout-fixed .main-sidebar .nav-sidebar .nav-item:has(> .nav-treeview) > .nav-link.active {
    background-color: transparent;
    color: var(--pqp-texte-attenue);
}

/* Page courante : texte et icône orange, repère vertical à gauche. */
body.layout-fixed .main-sidebar .nav-sidebar .nav-item:not(:has(> .nav-treeview)) > .nav-link.active {
    background-color: var(--pqp-accent-fond);
    color: var(--pqp-accent);
    position: relative;
}

body.layout-fixed .main-sidebar .nav-sidebar .nav-item:not(:has(> .nav-treeview)) > .nav-link.active .nav-icon {
    color: var(--pqp-accent);
}

body.layout-fixed .main-sidebar .nav-sidebar .nav-item:not(:has(> .nav-treeview)) > .nav-link.active::before {
    background-color: var(--pqp-accent);
    border-radius: 0 3px 3px 0;
    bottom: .4rem;
    content: "";
    left: -.5rem;
    position: absolute;
    top: .4rem;
    width: 3px;
}

/* ------------------------------------------------------------------ Cartes */

body.layout-fixed .card {
    background-color: var(--pqp-surface);
    border: 1px solid var(--pqp-bordure);
    border-radius: .5rem;
    box-shadow: none;
    color: var(--pqp-texte);
}

/* Le liseré de couleur des cartes « outline » est conservé pour les couleurs porteuses de sens
   (danger, warning, success). Celui des couleurs par défaut redevient une bordure neutre. */
body.layout-fixed .card.card-outline.card-info,
body.layout-fixed .card.card-outline.card-primary,
body.layout-fixed .card.card-outline.card-secondary,
body.layout-fixed .card.card-outline.card-default {
    border-top: 1px solid var(--pqp-bordure);
}

body.layout-fixed .card > .card-header {
    background-color: var(--pqp-entete);
    border-bottom: 1px solid var(--pqp-entete-bordure);
    border-radius: .5rem .5rem 0 0;
    color: var(--pqp-texte);
}

body.layout-fixed .card > .card-footer {
    background-color: var(--pqp-surface);
    border-top: 1px solid var(--pqp-bordure);
}

body.layout-fixed .card .card-title {
    color: var(--pqp-texte);
    font-weight: 600;
}

/* ---------------------------------------------------- Tableaux et listes */

body.layout-fixed .table {
    color: var(--pqp-texte);
}

body.layout-fixed .table td,
body.layout-fixed .table th,
body.layout-fixed .table thead th {
    border-color: var(--pqp-bordure);
}

body.layout-fixed .table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--pqp-entete);
}

body.layout-fixed .table-hover tbody tr:hover {
    background-color: var(--pqp-surface-survol);
    color: var(--pqp-texte);
}

body.layout-fixed .list-group-item {
    background-color: var(--pqp-surface);
    border-color: var(--pqp-bordure);
    color: var(--pqp-texte);
}

body.layout-fixed .page-item .page-link {
    background-color: var(--pqp-surface);
    border-color: var(--pqp-bordure);
    color: var(--pqp-lien);
}

body.layout-fixed .page-item.active .page-link {
    background-color: var(--pqp-primaire);
    border-color: var(--pqp-primaire);
    color: #ffffff;
}

body.layout-fixed .page-item.disabled .page-link {
    background-color: var(--pqp-surface) !important;
    border-color: var(--pqp-bordure) !important;
    color: var(--pqp-texte-attenue);
}

/* ---------------------------------------------------------------- Onglets */

body.layout-fixed .nav-tabs {
    border-bottom-color: var(--pqp-bordure);
}

body.layout-fixed .nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--pqp-texte-attenue);
}

body.layout-fixed .nav-tabs .nav-link:hover {
    color: var(--pqp-texte);
}

body.layout-fixed .nav-tabs .nav-link.active,
body.layout-fixed .nav-tabs .nav-item.show .nav-link {
    background-color: transparent;
    border-bottom-color: var(--pqp-accent);
    color: var(--pqp-texte);
    font-weight: 600;
}

/* ------------------------------------------------------------- Formulaires */

body.layout-fixed .form-control:not(.form-control-navbar):not(.form-control-sidebar),
body.layout-fixed .custom-select,
body.layout-fixed .input-group-text,
body.layout-fixed .select2-container--default .select2-selection,
body.layout-fixed .select2-dropdown,
body.layout-fixed .select2-search__field {
    background-color: var(--pqp-champ);
    border-color: var(--pqp-bordure);
    color: var(--pqp-texte);
}

body.layout-fixed .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--pqp-texte);
}

/* En sombre, AdminLTE pose la bordure par « .dark-mode .form-control:not(…) ×4 », plus spécifique
   que la règle ci-dessus : même structure, préfixée, pour l'emporter. */
body.layout-fixed .form-control:not(.form-control-navbar):not(.form-control-sidebar):not(.is-invalid):not(:focus) {
    border-color: var(--pqp-bordure);
}

/* Focus : sélecteur au moins aussi spécifique que les règles de bordure ci-dessus. */
body.layout-fixed .form-control:not(.form-control-navbar):not(.form-control-sidebar):focus,
body.layout-fixed .custom-select:focus {
    border-color: var(--pqp-primaire);
    box-shadow: 0 0 0 .15rem color-mix(in srgb, var(--pqp-primaire) 25%, transparent);
}

body.layout-fixed .form-control::placeholder {
    color: var(--pqp-texte-attenue);
}

/* ------------------------------------------------ Boutons, pastilles, menus */

body.layout-fixed .btn-primary {
    background-color: var(--pqp-primaire);
    border-color: var(--pqp-primaire);
    color: #ffffff;
}

body.layout-fixed .btn-primary:hover,
body.layout-fixed .btn-primary:focus {
    background-color: var(--pqp-primaire-survol);
    border-color: var(--pqp-primaire-survol);
}

body.layout-fixed .btn-default,
body.layout-fixed .btn-outline-secondary {
    background-color: var(--pqp-surface);
    border-color: var(--pqp-bordure);
    color: var(--pqp-texte);
}

body.layout-fixed .btn-default:hover,
body.layout-fixed .btn-outline-secondary:hover {
    background-color: var(--pqp-surface-survol);
    color: var(--pqp-texte);
}

body.layout-fixed .badge-primary {
    background-color: var(--pqp-pastille);
    color: var(--pqp-pastille-texte);
}

body.layout-fixed .dropdown-menu,
body.layout-fixed .modal-content {
    background-color: var(--pqp-surface);
    border-color: var(--pqp-bordure);
    color: var(--pqp-texte);
}

body.layout-fixed .modal-header,
body.layout-fixed .modal-footer {
    border-color: var(--pqp-bordure);
}

body.layout-fixed .dropdown-item {
    color: var(--pqp-texte);
}

body.layout-fixed .dropdown-item:hover,
body.layout-fixed .dropdown-item:focus {
    background-color: var(--pqp-surface-survol);
    color: var(--pqp-texte);
}

/* ------------------------------------------------------- Page de connexion */

/*
 * Connexion Azure, simulation locale et message d'erreur : tous étendent boilerplate::auth.layout.
 * Le préfixe « body.login-page » l'emporte sur les règles « .dark-mode .login-… » d'AdminLTE.
 */
body.login-page,
body.login-page.dark-mode {
    background-color: var(--pqp-fond) !important;
    color: var(--pqp-texte);
}

body.login-page .login-box {
    max-width: calc(100% - 2rem);
}

body.login-page .login-logo {
    align-items: center;
    color: var(--pqp-texte);
    display: flex;
    font-size: 1.9rem;
    gap: .6rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

body.login-page .login-logo .brand-logo-image {
    height: 2.4rem;
    width: auto;
}

body.login-page .login-box .card {
    background-color: var(--pqp-surface);
    border: 1px solid var(--pqp-bordure);
    border-radius: .5rem;
    box-shadow: none;
}

body.login-page .login-card-body {
    background-color: var(--pqp-surface);
    border-radius: .5rem;
    color: var(--pqp-texte);
    padding: 1.75rem 1.5rem;
}

body.login-page .login-box-msg {
    color: var(--pqp-texte);
}

body.login-page .text-muted {
    color: var(--pqp-texte-attenue) !important;
}

body.login-page .btn-primary {
    background-color: var(--pqp-primaire);
    border-color: var(--pqp-primaire);
    color: #ffffff;
}

body.login-page .btn-primary:hover,
body.login-page .btn-primary:focus {
    background-color: var(--pqp-primaire-survol);
    border-color: var(--pqp-primaire-survol);
}

/* Mêmes structures que les règles « .dark-mode .form-control:not(…) » d'AdminLTE, pour l'emporter :
   le champ et son suffixe (@plus-que-pro.fr) partagent la même bordure, au repos comme au focus. */
body.login-page .form-control:not(.form-control-navbar):not(.form-control-sidebar),
body.login-page .form-control:not(.form-control-navbar):not(.form-control-sidebar):not(.is-invalid):not(:focus),
body.login-page .input-group-text,
body.login-page .login-card-body .input-group .input-group-text {
    background-color: var(--pqp-champ);
    border-color: var(--pqp-bordure);
    color: var(--pqp-texte);
}

/* Suffixe (@plus-que-pro.fr) atténué, pour ne pas se confondre avec la saisie. */
body.login-page .login-card-body .input-group .input-group-text {
    color: var(--pqp-texte-attenue);
}

/* Focus : plus spécifique que les règles de bordure ci-dessus et que « .dark-mode … :focus » d'AdminLTE. */
body.login-page .login-card-body .form-control:not(.form-control-navbar):not(.form-control-sidebar):focus,
body.login-page .login-card-body .input-group .form-control:focus ~ .input-group-append .input-group-text {
    border-color: var(--pqp-primaire);
}

body.login-page .form-control::placeholder {
    color: var(--pqp-texte-attenue);
}

/* ------------------------------------- Menu plus large sur écrans extra-larges */

/*
 * AdminLTE fixe la colonne du menu à 250px. Ne s'applique qu'au menu déplié : replié, le menu
 * garde la largeur réduite d'AdminLTE et son déploiement au survol (250px). Chaque sélecteur
 * reprend celui d'AdminLTE en ajoutant body:not(.sidebar-collapse), pour l'emporter.
 */
@media (min-width: 1600px) {
    body:not(.sidebar-collapse) {
        --largeur-menu: 300px;
    }

    body:not(.sidebar-collapse) .main-sidebar,
    body:not(.sidebar-collapse) .main-sidebar::before {
        width: var(--largeur-menu);
    }

    body:not(.sidebar-collapse):not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .content-wrapper,
    body:not(.sidebar-collapse):not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .main-footer,
    body:not(.sidebar-collapse):not(.sidebar-mini-md):not(.sidebar-mini-xs):not(.layout-top-nav) .main-header {
        margin-left: var(--largeur-menu);
    }

    body.layout-fixed:not(.sidebar-collapse) .brand-link,
    body.layout-navbar-fixed:not(.sidebar-collapse) .wrapper .brand-link,
    body.layout-navbar-fixed:not(.sidebar-collapse) .wrapper .main-sidebar:hover .brand-link {
        width: var(--largeur-menu);
    }

    body.sidebar-mini:not(.sidebar-collapse) .main-sidebar .nav-link {
        width: calc(var(--largeur-menu) - 1rem);
    }

    body.sidebar-mini:not(.sidebar-collapse) .main-sidebar .nav-child-indent .nav-treeview .nav-link {
        width: calc(var(--largeur-menu) - 2rem);
    }
}
