/* =========================================================================
   PROPOSITION 2 – Panneau dock collé à droite de la sidebar
   -------------------------------------------------------------------------
   Le sous-menu s'ouvre comme un SECOND PANNEAU, collé bord-à-bord avec la
   sidebar (pas de gap, pas de flèche, slide-in horizontal).
   Look : deux panneaux juxtaposés, comme VS Code / JetBrains / Figma.
   ========================================================================= */

body.kc-enhanced-sidebar {
    --kc-sb-bg: #ffffff;
    --kc-sb-border: #e6eaf0;
    --kc-text: #1f2937;
    --kc-text-muted: #64748b;
    --kc-primary: #0b6bcb;
    --kc-primary-soft: #e8f1fc;
    --kc-primary-soft-2: #f3f7fd;
    --kc-hover-bg: #f5f7fa;
    --kc-section: #94a1b2;
    --kc-radius: 10px;
    --kc-radius-sm: 8px;
    --kc-shadow-sidebar: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
    --kc-ease: cubic-bezier(.2,.8,.2,1);
    --kc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --kc-dock-width: 320px;
}

/* ---------- 1) Sidebar principale (inchangé / style natif) ---------- */
body.kc-enhanced-sidebar .axe-sidebar.nax-side-bar-menu {
    padding: 10px !important;
    background: var(--kc-sb-bg) !important;
    box-shadow: var(--kc-shadow-sidebar) !important;
    border-right: 0 !important;
    transition: left .28s var(--kc-ease), box-shadow .28s var(--kc-ease) !important;
    font-family: var(--kc-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    z-index: 900;
    overflow: visible !important; /* CRUCIAL: permet au dock panel de dépasser */
}
body.kc-enhanced-sidebar .nax-side-bar-menu-box-shadow {
    background-color: rgba(15, 23, 42, 0.32) !important;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

/* ---------- 2) Header "Contexte comptable" ---------- */
body.kc-enhanced-sidebar .axe-sidebar .nax-whiteframe-lite {
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ---------- 3) Bloc Menu (visuel, pas de width/margin forcé) ---------- */
body.kc-enhanced-sidebar .axe-sidebar .nax-box-shadow-wrapper {
    background: #ffffff !important;
    border: 1px solid #dfe5ee !important;
    border-radius: var(--kc-radius) !important;
    box-shadow:
        0 1px 2px rgba(15,23,42,.04),
        0 4px 12px rgba(15,23,42,.08) !important;
    overflow: hidden;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-box-shadow-wrapper-inner {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-side-bar-content-head {
    background-color: #ffffff !important;
    color: #1f2937 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    border: 0 !important;
    border-bottom: 1px solid var(--kc-sb-border) !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    padding: 0 20px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
    border-radius: 0 !important;
    display: flex !important;
    align-items: center !important;
    line-height: 54px !important;
    margin: 0 !important;
    text-transform: none;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-box-shadow-wrapper-inner > div > div[style*="lightgrey"] {
    display: none !important;
}

/* ---------- 4) Items principaux ---------- */
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 10px;
    height: 40px !important;
    line-height: 1.25 !important;
    padding: 0 10px !important;
    margin: 2px 0;
    background: transparent !important;
    border: 0 !important;
    border-radius: var(--kc-radius-sm) !important;
    color: #111827 !important;
    font-family: var(--kc-font);
    font-size: 13.5px !important;
    font-weight: 500 !important;
    letter-spacing: .1px;
    cursor: pointer;
    transition: background-color 160ms var(--kc-ease),
                color 160ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item > span {
    width: auto !important;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item > i.menu-item-icon {
    width: 22px;
    text-align: center;
    font-size: 14px;
    color: var(--kc-text-muted);
    flex: 0 0 22px;
    transition: color 160ms var(--kc-ease), transform 160ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item > i.carret-bundle {
    color: var(--kc-text-muted);
    font-size: 11px !important;
    opacity: .55;
    transition: transform 180ms var(--kc-ease), opacity 180ms var(--kc-ease), color 180ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item:hover {
    background: var(--kc-hover-bg) !important;
    color: var(--kc-text) !important;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item:hover > i.menu-item-icon {
    color: var(--kc-primary);
    transform: scale(1.08);
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item:hover > i.carret-bundle {
    opacity: .75;
    color: var(--kc-primary);
}

/* État actif (panneau dock ouvert sur ce parent) */
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-item-active {
    background: var(--kc-primary-soft) !important;
    color: var(--kc-primary) !important;
    font-weight: 600 !important;
    border-right: 3px solid var(--kc-primary) !important;
    border-radius: var(--kc-radius-sm) 0 0 var(--kc-radius-sm) !important;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-item-active > i.menu-item-icon {
    color: var(--kc-primary);
    transform: scale(1.05);
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-item-active > i.carret-bundle {
    opacity: 0;
    transform: translateX(6px);
}

/* Indicateur tab(s) ouvert(s) — petit dot bleu sur l'icône */
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-has-open-tab > i.menu-item-icon {
    color: var(--kc-primary);
    opacity: 1;
    position: relative;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-has-open-tab > i.menu-item-icon::after {
    content: "";
    position: absolute;
    top: -1px;
    right: -3px;
    width: 7px;
    height: 7px;
    background: var(--kc-primary);
    border-radius: 50%;
    border: 1.5px solid #ffffff;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-has-open-tab {
    box-shadow: none;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-item-active.kc-has-open-tab {
    box-shadow: none;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item.kc-item-active.kc-has-open-tab > i.menu-item-icon::after {
    display: none;
}

/* Cache sous-menu inline natif */
body.kc-enhanced-sidebar .axe-sidebar .nax-sub-menu-item-container {
    display: none !important;
}

/* Scrollbars */
body.kc-enhanced-sidebar .axe-sidebar *::-webkit-scrollbar { width: 6px; height: 6px; }
body.kc-enhanced-sidebar .axe-sidebar *::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.14);
    border-radius: 3px;
}
body.kc-enhanced-sidebar .axe-sidebar *::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   5) PANNEAU DOCK — Collé au bord droit de la sidebar
   ==========================================================================
   Design : panneau vertical pleine hauteur, même fond blanc, séparé par
   une bordure fine. Slide-in de 0px vers la droite.
   ========================================================================== */
.kc-dock-panel {
    position: absolute;
    left: 100%;          /* TOUJOURS collé au bord droit de la sidebar */
    z-index: 899;
    width: var(--kc-dock-width, 320px);
    background: #ffffff;
    border: 0;
    border-radius: 0 var(--kc-radius, 10px) 0 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .9),
        0 -1px 3px rgba(15, 23, 42, .04),
        4px 0 20px rgba(15, 23, 42, .10),
        2px 4px 12px rgba(15, 23, 42, .06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--kc-font, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
    -webkit-font-smoothing: antialiased;

    /* Animation */
    transform: scaleX(0);
    opacity: 0;
    pointer-events: none;
    transform-origin: left center;
    transition: transform 260ms cubic-bezier(.2,.8,.2,1),
                opacity 220ms cubic-bezier(.2,.8,.2,1);
    will-change: transform, opacity;
}
.kc-dock-panel.kc-visible {
    transform: scaleX(1);
    opacity: 1;
    pointer-events: auto;
}

/* ---- Encoche de liaison — élément DOM dédié (.kc-dock-notch) ---- */
/* Positionné en dehors du panel (overflow:hidden) pour ne pas être clippé.
   Position verticale dynamique via JS. */
.kc-dock-notch {
    position: absolute;
    left: calc(100% - 11px);   /* au bord droit de la sidebar */
    z-index: 900;
    width: 0;
    height: 0;
    pointer-events: none;
    transition: top 200ms cubic-bezier(.2,.8,.2,1),
                opacity 200ms ease;
    opacity: 0;
}
.kc-dock-notch.kc-visible {
    opacity: 1;
}
/* Ombre du triangle */
.kc-dock-notch::before {
    content: "";
    position: absolute;
    left: 0;
    top: -12px;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 11px solid rgba(0, 0, 0, .08);
}
/* Triangle blanc */
.kc-dock-notch::after {
    content: "";
    position: absolute;
    left: 2px;
    top: -11px;
    width: 0;
    height: 0;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-right: 9px solid #ffffff;
}

/* ---- Header du dock — gradient bleu + aligné 54px ---- */
.kc-dock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 54px;
    min-height: 54px;
    background: linear-gradient(135deg, #303e89 0%, #1b83e3 100%);
    color: #ffffff;
    border-bottom: none;
    border-radius: 0;  /* pas de radius propre — le panel gère le coin */
}
.kc-dock-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.kc-dock-title-icon {
    font-size: 16px;
    color: rgba(255, 255, 255, .85);
    flex: 0 0 auto;
}
.kc-dock-close {
    background: rgba(255, 255, 255, .15);
    border: 0;
    color: #ffffff;
    font-size: 18px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 160ms ease;
    flex: 0 0 28px;
    line-height: 1;
}
.kc-dock-close:hover {
    background: rgba(255, 255, 255, .3);
}

/* ---- Liste des sous-items ---- */
.kc-dock-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 8px;
}

/* Scrollbar du dock */
.kc-dock-list::-webkit-scrollbar { width: 5px; }
.kc-dock-list::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 3px;
}
.kc-dock-list::-webkit-scrollbar-track { background: transparent; }

/* ---- Section title ---- */
.kc-dock-section {
    font-weight: 700;
    text-transform: uppercase;
    color: #3b5fc0;
    font-size: 11.5px;
    padding: 12px 10px 5px;
    letter-spacing: .7px;
}

/* ---- Item ---- */
.kc-dock-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    color: #1f2937;
    user-select: none;
    transition: background-color 140ms ease,
                color 140ms ease,
                padding-left 140ms ease;
    animation: kcDockFadeIn 200ms ease both;
}
.kc-dock-item:nth-child(1)  { animation-delay: 20ms; }
.kc-dock-item:nth-child(2)  { animation-delay: 40ms; }
.kc-dock-item:nth-child(3)  { animation-delay: 60ms; }
.kc-dock-item:nth-child(4)  { animation-delay: 80ms; }
.kc-dock-item:nth-child(5)  { animation-delay: 100ms; }
.kc-dock-item:nth-child(6)  { animation-delay: 120ms; }
.kc-dock-item:nth-child(n+7){ animation-delay: 140ms; }

.kc-dock-item:hover {
    background: #f3f7fd;
    color: #0b6bcb;
    padding-left: 16px;
}
.kc-dock-item.kc-active {
    background: var(--kc-primary-soft, #e8f1fc);
    color: #0b6bcb;
    font-weight: 600;
    border-left: 3px solid #0b6bcb;
    padding-left: 9px;  /* compense le border de 3px */
}
.kc-dock-item.kc-open {
    background: rgba(11, 107, 203, .04);
    color: #0b6bcb;
    font-weight: 500;
    border-left: 2px solid rgba(11, 107, 203, .35);
    padding-left: 10px;
}
.kc-dock-item.kc-open .kc-dock-icon {
    opacity: .85;
}

.kc-dock-icon {
    width: 18px;
    text-align: center;
    color: inherit;
    opacity: .7;
    font-size: 13px;
    flex: 0 0 18px;
}
.kc-dock-item:hover .kc-dock-icon { opacity: 1; }
.kc-dock-item.kc-active .kc-dock-icon { opacity: 1; }

.kc-dock-label {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes kcDockFadeIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---- a11y / reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .kc-dock-panel,
    .kc-dock-item,
    body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item,
    body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item > i {
        transition: none !important;
        animation: none !important;
    }
}
body.kc-enhanced-sidebar .axe-sidebar .nax-main-menu-item:focus-visible,
.kc-dock-item:focus-visible {
    outline: 2px solid var(--kc-primary, #0b6bcb);
    outline-offset: 2px;
}

/* =========================================================================
   6) CHAMP DE RECHERCHE — intégré DANS le header "Menu"
   -------------------------------------------------------------------------
   Le champ est injecté à l'intérieur de .nax-side-bar-content-head, à droite
   du titre "Menu" (qui reçoit .kc-has-search). Pas d'ajout de hauteur :
   tout reste dans les 54px du header existant.
   ========================================================================= */

/* Quand le header contient le champ de recherche, le titre "Menu" ne prend
   plus toute la largeur : il partage l'espace avec le champ. */
body.kc-enhanced-sidebar .axe-sidebar .nax-side-bar-content-head.kc-has-search {
    gap: 10px;
    justify-content: flex-start;
}
body.kc-enhanced-sidebar .axe-sidebar .nax-side-bar-content-head.kc-has-search > :first-child,
body.kc-enhanced-sidebar .axe-sidebar .nax-side-bar-content-head.kc-has-search {
    /* le nœud texte "Menu" est le premier enfant — on le laisse shrink-to-fit */
}

body.kc-enhanced-sidebar .axe-sidebar .kc-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;   /* pousse à droite du titre "Menu" */
    padding: 0 8px 0 28px;
    height: 30px;
    flex: 0 1 180px;     /* largeur cible, peut rétrécir */
    min-width: 120px;
    background: #f3f5f9;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    transition: background-color 160ms var(--kc-ease),
                border-color 160ms var(--kc-ease),
                box-shadow 160ms var(--kc-ease),
                flex-basis 200ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search:hover {
    background: #eef1f6;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search:focus-within {
    background: #ffffff;
    border-color: rgba(11, 107, 203, .45);
    box-shadow: 0 0 0 3px rgba(11, 107, 203, .12);
    flex-basis: 220px;   /* expand on focus */
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a1b2;
    font-size: 11px;
    pointer-events: none;
    transition: color 160ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search:focus-within .kc-search-icon,
body.kc-enhanced-sidebar .axe-sidebar .kc-search.kc-has-value .kc-search-icon {
    color: var(--kc-primary, #0b6bcb);
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-input {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #1f2937;
    font-family: var(--kc-font);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0;
    padding: 0;
    text-transform: none;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-input::placeholder {
    color: #94a1b2;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-clear {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, .08);
    color: #64748b;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    line-height: 1;
    transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search.kc-has-value .kc-search-clear {
    display: inline-flex;
    animation: kcSearchClearIn 160ms var(--kc-ease) both;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-clear:hover {
    background: var(--kc-primary, #0b6bcb);
    color: #ffffff;
    transform: rotate(90deg);
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-clear i {
    font-size: 9px;
    line-height: 1;
}
@keyframes kcSearchClearIn {
    from { opacity: 0; transform: scale(.6); }
    to   { opacity: 1; transform: scale(1); }
}

/* "Aucun résultat" — état vide intégré, minimal et pro */
body.kc-enhanced-sidebar .axe-sidebar .kc-search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 28px 16px 24px;
    background: transparent;
    border: 0;
    border-radius: 0;
    animation: kcEmptyIn 220ms var(--kc-ease) both;
    text-align: center;
    color: #64748b;
    user-select: none;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-empty-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f3f5f9;
    color: #94a1b2;
    font-size: 15px;
    margin-bottom: 4px;
    transition: background-color 200ms var(--kc-ease);
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-empty-title {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    letter-spacing: -.01em;
    line-height: 1.2;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-empty-sub {
    font-size: 12px;
    font-weight: 400;
    color: #94a1b2;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}
body.kc-enhanced-sidebar .axe-sidebar .kc-search-empty-q {
    color: var(--kc-primary, #0b6bcb);
    font-weight: 600;
}

@keyframes kcEmptyIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

