/*
 * Thème Amical — surcouche moderne chargée après volt.css.
 * Toutes les couleurs passent par les variables ci-dessous :
 * pour changer l'identité, modifier uniquement :root.
 */
:root {
    --am-primary: #1f8a4c;
    --am-primary-600: #18733e;
    --am-primary-700: #125c31;
    --am-primary-50: #e9f6ee;
    --am-primary-100: #cfead9;
    --am-accent: #1c7ed6;
    --am-accent-50: #e7f1fb;
    --am-warm: #e8590c;
    --am-warm-600: #c94d0a;
    --am-warm-50: #fdf0e8;

    --am-bg: #f3f6f4;
    --am-surface: #ffffff;
    --am-surface-2: #f8faf9;
    --am-border: #e2e8e4;
    --am-text: #18241d;
    --am-muted: #66756c;

    --am-sidebar: #0e2a1f;
    --am-sidebar-2: #12382a;
    --am-sidebar-text: #b9cbc1;
    --am-sidebar-hover: rgba(255, 255, 255, .07);
    --am-sidebar-active: rgba(108, 194, 111, .16);
    --am-sidebar-accent: #6cc26f;

    --am-radius: 14px;
    --am-radius-sm: 10px;
    --am-shadow: 0 1px 2px rgba(16, 40, 28, .04), 0 4px 16px rgba(16, 40, 28, .06);
    --am-shadow-lg: 0 12px 40px rgba(16, 40, 28, .14);
    --am-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
body {
    font-family: var(--am-font);
    background-color: var(--am-bg);
    color: var(--am-text);
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--am-font);
    color: var(--am-text);
    font-weight: 700;
    letter-spacing: -.01em;
}
a { color: var(--am-primary-600); }
a:hover { color: var(--am-primary-700); }
.text-muted, .text-gray-600, .text-gray-500 { color: var(--am-muted) !important; }
::selection { background: var(--am-primary-100); }

* { scrollbar-width: thin; scrollbar-color: #c3cfc8 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #c3cfc8; border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

@media (min-width: 992px) {
    .content { margin-left: 260px; padding: 0 1.75rem 2rem; }
}

/* ---------- Sidebar ---------- */
#sidebarMenu.sidebar,
#sidebarMenu.sidebar.bg-gray-800 {
    background: linear-gradient(180deg, var(--am-sidebar) 0%, var(--am-sidebar-2) 100%) !important;
    color: var(--am-sidebar-text) !important;
    box-shadow: 1px 0 0 rgba(255, 255, 255, .04);
}
@media (min-width: 768px) {
    #sidebarMenu.sidebar { max-width: 260px; }
}
.sidebar .sidebar-inner { padding: 1.25rem .85rem 2rem !important; }
.sidebar .nav-item.text-center:first-child {
    padding: .25rem 0 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .nav-item.text-center:first-child img {
    width: 84px !important;
    background: #fff;
    padding: 4px;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .08);
}
.sidebar .nav-item { margin-bottom: 2px; }
.sidebar .nav-link,
.sidebar .nav-item .nav-link {
    color: var(--am-sidebar-text);
    font-weight: 500;
    font-size: .875rem;
    padding: .6rem .8rem;
    border-radius: var(--am-radius-sm);
    display: flex;
    align-items: center;
    gap: .65rem;
    transition: background-color .15s ease, color .15s ease;
    position: relative;
}
.sidebar .nav-link .sidebar-icon,
.sidebar .nav-item .nav-link .sidebar-icon {
    color: inherit;
    opacity: .85;
    margin-right: 0;
    display: inline-flex;
}
.sidebar .nav-item .nav-link:hover {
    color: #fff;
    background-color: var(--am-sidebar-hover);
}
.sidebar .nav-item.active > .nav-link,
.sidebar .nav-link.active {
    color: #fff;
    background-color: var(--am-sidebar-active);
    font-weight: 600;
}
.sidebar .nav-item.active > .nav-link::before {
    content: "";
    position: absolute;
    left: -.85rem;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--am-sidebar-accent);
}
.sidebar .nav-item.active > .nav-link .sidebar-icon { color: var(--am-sidebar-accent); opacity: 1; }
.sidebar .sidebar-arrow { transition: transform .2s ease; opacity: .6; display: inline-flex; }
.sidebar .nav-link[aria-expanded="true"] .sidebar-arrow { transform: rotate(180deg); }
.sidebar .nav-link[aria-expanded="true"] { color: #fff; }
.sidebar .btn-toggle-nav {
    margin: 2px 0 6px .9rem;
    padding-left: .55rem;
    border-left: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .btn-toggle-nav .nav-link { font-size: .84rem; padding: .45rem .7rem; }
.sidebar-heading { color: rgba(255, 255, 255, .45); letter-spacing: .06em; }

/* Barre mobile */
.navbar-theme-primary,
.navbar-theme-primary:not(.headroom) {
    background: var(--am-sidebar) !important;
}

/* ---------- Topbar ---------- */
.navbar-dashboard {
    position: sticky;
    top: 0;
    z-index: 50;
    margin: 0 -1rem 1rem;
    padding: .65rem 1rem !important;
    background: rgba(243, 246, 244, .85);
    backdrop-filter: saturate(160%) blur(10px);
    border-radius: 0;
    border-bottom: 1px solid var(--am-border);
}
@media (min-width: 992px) {
    .navbar-dashboard { margin: 0 -1.75rem 1rem; padding: .65rem 1.75rem !important; }
}
.navbar-dashboard .avatar { width: 36px; height: 36px; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--am-primary-100); }

/* ---------- En-têtes de page ---------- */
.breadcrumb { font-size: .8rem; margin-bottom: .35rem; }
.breadcrumb-item a { color: var(--am-muted); }
.breadcrumb-item.active { color: var(--am-primary-600); font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { color: #b5c2ba; }
main > .d-flex > .d-block > h2.h4,
main h2.h4 { font-size: 1.45rem; margin-bottom: 0; }

/* ---------- Cartes ---------- */
.card {
    border: 1px solid var(--am-border) !important;
    border-radius: var(--am-radius) !important;
    background-color: var(--am-surface);
    box-shadow: var(--am-shadow) !important;
}
.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--am-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}
.card .card-header.border-0 { border-bottom: 0 !important; }
.card-body { padding: 1.25rem; }
.shadow { box-shadow: var(--am-shadow) !important; }
.table-wrapper { padding: 1.25rem !important; }

/* ---------- Tableaux ---------- */
.table { color: var(--am-text); margin-bottom: 0; border-color: var(--am-border); }
.table > :not(caption) > * > * {
    padding: .7rem .85rem;
    border-bottom-color: var(--am-border);
}
.table thead th,
.table th {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--am-muted);
    background-color: var(--am-surface-2);
    border-bottom: 1px solid var(--am-border);
    white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: var(--am-radius-sm); }
.table thead th:last-child { border-top-right-radius: var(--am-radius-sm); }
.table > :not(:first-child) { border-top: 0; }
.table-hover > tbody > tr:hover > * { background-color: var(--am-primary-50); --bs-table-accent-bg: transparent; }
.table-sm > :not(caption) > * > * { padding: .5rem .6rem; }
.user-table td .fw-normal, .user-table td .fw-bold { color: var(--am-text); }
.table-danger { --bs-table-bg: #fdecec; }
.table-warning { --bs-table-bg: #fff6e0; }
.table-info { --bs-table-bg: var(--am-accent-50); }

/* ---------- Boutons ---------- */
.btn {
    border-radius: var(--am-radius-sm);
    font-weight: 600;
    font-size: .85rem;
    padding: .55rem 1rem;
    box-shadow: none;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .4rem .75rem; font-size: .8rem; border-radius: 8px; }
.btn:focus, .btn.focus { box-shadow: 0 0 0 3px var(--am-primary-100); }

.btn-primary,
.btn-gray-800 {
    color: #fff;
    background-color: var(--am-primary);
    border-color: var(--am-primary);
}
.btn-primary:hover, .btn-primary:focus,
.btn-gray-800:hover, .btn-gray-800:focus {
    color: #fff;
    background-color: var(--am-primary-600);
    border-color: var(--am-primary-600);
}
.btn-primary:active, .btn-gray-800:active { background-color: var(--am-primary-700) !important; border-color: var(--am-primary-700) !important; }

.btn-secondary {
    color: #fff;
    background-color: var(--am-warm);
    border-color: var(--am-warm);
}
.btn-secondary:hover, .btn-secondary:focus {
    color: #fff;
    background-color: var(--am-warm-600);
    border-color: var(--am-warm-600);
}
.btn-success { background-color: var(--am-primary); border-color: var(--am-primary); }
.btn-info { background-color: var(--am-accent); border-color: var(--am-accent); color: #fff; }

.btn-outline-gray-600,
.btn-outline-primary {
    color: var(--am-text);
    background-color: var(--am-surface);
    border: 1px solid var(--am-border);
}
.btn-outline-gray-600:hover, .btn-outline-primary:hover {
    color: var(--am-primary-700);
    background-color: var(--am-primary-50);
    border-color: var(--am-primary-100);
}
.btn-outline-primary { color: var(--am-primary-600); }
.btn-link { color: var(--am-primary-600); font-weight: 600; text-decoration: none; }
.btn-close:focus { box-shadow: 0 0 0 3px var(--am-primary-100); }

/* ---------- Formulaires ---------- */
.form-control,
.form-select,
select.form-control {
    border-radius: var(--am-radius-sm);
    border: 1px solid var(--am-border);
    background-color: var(--am-surface);
    color: var(--am-text);
    font-size: .875rem;
    padding: .55rem .85rem;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-select { padding-right: 2.25rem; }
.form-control:focus,
.form-select:focus {
    border-color: var(--am-primary);
    box-shadow: 0 0 0 3px var(--am-primary-100);
    outline: 0;
}
.form-control::placeholder { color: #9aa8a0; }
.input-group-text {
    background-color: var(--am-surface-2);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius-sm);
    color: var(--am-muted);
}
.input-group > .form-control:not(:first-child),
.input-group > .input-group-text + .form-control { border-left: 0; }
.input-group:focus-within .input-group-text { border-color: var(--am-primary); color: var(--am-primary); }
.form-check-input:checked { background-color: var(--am-primary); border-color: var(--am-primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--am-primary-100); border-color: var(--am-primary); }
label, .form-label { font-weight: 600; font-size: .82rem; color: var(--am-text); margin-bottom: .35rem; }
.invalid-feedback { display: block; }
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--am-border) !important;
    border-radius: var(--am-radius-sm) !important;
    min-height: 38px;
}

/* ---------- Menus, modales, offcanvas ---------- */
.dropdown-menu {
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius-sm);
    box-shadow: var(--am-shadow-lg);
    padding: .35rem;
}
.dropdown-item { border-radius: 8px; font-size: .85rem; padding: .5rem .75rem; }
.dropdown-item:hover, .dropdown-item:focus { background-color: var(--am-primary-50); color: var(--am-primary-700); }

.modal-content {
    border: 0;
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow-lg);
}
.modal-header, .modal-footer { border-color: var(--am-border); padding: 1rem 1.25rem; }
.modal-body { padding: 1.25rem; }
.modal-backdrop.show { opacity: .4; }

.offcanvas {
    border-left: 0 !important;
    box-shadow: var(--am-shadow-lg);
}
.offcanvas-end { width: 420px; max-width: 100%; }
.offcanvas-header { border-bottom: 1px solid var(--am-border); padding: 1.1rem 1.5rem; }
.offcanvas-body { padding: 1.25rem 1.5rem; }

/* ---------- Badges, alertes, pagination ---------- */
.badge { border-radius: 999px; font-weight: 600; padding: .35em .7em; letter-spacing: .01em; }
.badge.bg-danger { background-color: #fdecec !important; color: #c92a2a; }
.badge.bg-warning { background-color: #fff3d6 !important; color: #a35c00; }
.badge.bg-success { background-color: var(--am-primary-50) !important; color: var(--am-primary-700); }
.badge.bg-info { background-color: var(--am-accent-50) !important; color: #1864ab; }
.badge.bg-primary { background-color: var(--am-primary-50) !important; color: var(--am-primary-700); }

.alert { border-radius: var(--am-radius-sm); border: 1px solid transparent; }
.alert-warning { background-color: #fff6e0; border-color: #ffe3a3; color: #7a4a00; }
.alert-danger { background-color: #fdecec; border-color: #f8c9c9; color: #a51d1d; }
.alert-success { background-color: var(--am-primary-50); border-color: var(--am-primary-100); color: var(--am-primary-700); }

.progress { background-color: #e7ece9; border-radius: 999px; }
.progress-bar.bg-success { background-color: var(--am-primary) !important; }

.pagination { gap: 4px; }
.page-link {
    border-radius: 8px !important;
    border: 1px solid var(--am-border);
    color: var(--am-text);
    font-weight: 500;
    font-size: .85rem;
}
.page-link:hover { background-color: var(--am-primary-50); color: var(--am-primary-700); border-color: var(--am-primary-100); }
.page-item.active .page-link { background-color: var(--am-primary); border-color: var(--am-primary); color: #fff; }

.text-success { color: var(--am-primary) !important; }
.text-primary { color: var(--am-primary-600) !important; }
.bg-primary { background-color: var(--am-primary) !important; }

/* ---------- Page de connexion ---------- */
section.vh-lg-100.bg-soft {
    background: radial-gradient(1200px 600px at 10% 10%, #d9f0c9 0%, transparent 60%),
                radial-gradient(900px 500px at 90% 90%, #cfe6f7 0%, transparent 60%),
                var(--am-bg) !important;
    min-height: 100vh;
}
section.vh-lg-100 .shadow-soft {
    border: 1px solid var(--am-border) !important;
    border-radius: 20px !important;
    box-shadow: var(--am-shadow-lg) !important;
}
section.vh-lg-100 .shadow-soft img { max-width: 170px; height: auto; }
section.vh-lg-100 .btn { padding: .7rem 1rem; }

/* ==========================================================================
   Menu latéral : fixe sur grand écran (≥ 992 px), tiroir sur mobile et
   tablette (bouton ☰ de la barre du haut, voile, fermeture par Échap).
   ========================================================================== */
#sidebarMenu.sidebar {
    width: 260px;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--am-sidebar) 0%, var(--am-sidebar-2) 100%) !important;
    color: var(--am-sidebar-text);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1040;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
/* Volt met overflow-y: hidden sur .sidebar-inner : dans le conteneur flex, il
   rétrécissait à la hauteur de l'écran et coupait le bas du menu sans défilement. */
#sidebarMenu .sidebar-inner { flex: 0 0 auto; overflow: visible; }
#sidebarMenu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); }
#sidebarMenu .nav { white-space: normal; }
@media (min-width: 992px) {
    .content { margin-left: 260px; }
}
@media (max-width: 991.98px) {
    #sidebarMenu.sidebar {
        width: 290px;
        max-width: 86vw;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: none;
    }
    body.menu-ouvert #sidebarMenu.sidebar {
        transform: none;
        box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    }
    body.menu-ouvert { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    #sidebarMenu.sidebar { transition: none; }
}
.sidebar-voile {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(10, 25, 18, .5);
}
@media (max-width: 991.98px) {
    body.menu-ouvert .sidebar-voile { display: block; }
}

/* En-tête du menu : logo */
.sidebar .sidebar-entete {
    position: relative;
    display: flex;
    justify-content: center;
    padding: .5rem 0 1rem;
    margin-bottom: .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .sidebar-marque img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 50%;
    background: #fff;
    padding: 4px;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .08);
}
.sidebar .sidebar-fermer { position: absolute; top: .25rem; right: 0; opacity: .7; }

/* Recherche dans le menu */
.sidebar .sidebar-recherche { position: relative; margin-bottom: .75rem; }
.sidebar .sidebar-recherche .fa-search {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    font-size: .8rem; color: rgba(255, 255, 255, .45);
}
.sidebar .sidebar-recherche input {
    width: 100%;
    padding: .5rem .75rem .5rem 2.1rem;
    font-size: .85rem;
    color: #fff;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--am-radius-sm, 8px);
    outline: none;
}
.sidebar .sidebar-recherche input::placeholder { color: rgba(255, 255, 255, .45); }
.sidebar .sidebar-recherche input:focus { border-color: var(--am-sidebar-accent); background: rgba(255, 255, 255, .1); }

/* Titres de rubrique */
.sidebar .sidebar-rubrique {
    list-style: none;
    margin: 1rem 0 .3rem;
    padding: 0 .8rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .42);
}
.sidebar .sidebar-vide { list-style: none; padding: .75rem .8rem; font-size: .8rem; color: rgba(255, 255, 255, .55); }

/* Liens : zone cliquable confortable au doigt */
.sidebar .nav-item .nav-link { min-height: 40px; }
.sidebar .btn-toggle-nav .nav-link { min-height: 36px; }
.sidebar .btn-toggle-nav .nav-item.active > .nav-link::before { left: -.6rem; }
.sidebar .nav-link.collapsed .sidebar-arrow,
.sidebar .nav-link[aria-expanded="false"] .sidebar-arrow { transform: none; }

/* Barre du haut */
.navbar-dashboard .btn-menu {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--am-border); border-radius: 10px; background: #fff; color: var(--am-text, #18241d);
}
.navbar-dashboard .topbar-marque img { width: 32px; height: 32px; object-fit: cover; background: #fff; }
.avatar-initiales-topbar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
    background: var(--am-primary-50, #e9f6ee); color: var(--am-primary-700, #125c31);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--am-primary-100, #cdebd8);
}
@media (max-width: 575.98px) {
    .navbar-dashboard .topbar-marque span { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
