@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

:root {
    --body-color: #E4E9F7;
    --sidebar-color: #1e293b;
    --primary-color: #334155;
    --primary-color-light: #F6F5FF;
    --toggle-color: #FFF;
    --text-color: #CCC;
    --tran-03: all 0.3s ease;
    --tran-05: all 0.5s ease;
}

body {
    min-height: 100vh;
    background-color: var(--body-color);
    transition: var(--tran-05);
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    top: 7rem;
    left: 0;
    height: 100%;
    width: 260px;
    background: var(--sidebar-color);
    transition: var(--tran-05);
    z-index: 100;
    overflow-y: auto; /* Permet le scroll si beaucoup de sous-menus */
}

/* Masquer la barre de scroll de la sidebar */
.sidebar::-webkit-scrollbar { display: none; }

.sidebar.close {
    width: 78px;
    overflow: visible; /* Important pour les infobulles si besoin */
}

/* === HEADER === */
.sidebar .image-text {
    display: flex;
    align-items: center;
    padding: 10px 14px;
}
.sidebar header .toggle {
    position: absolute;
    top: 20px;
    right: -25px;
    transform: translateY(-50%) rotate(180deg);
    height: 25px;
    width: 25px;
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: var(--tran-05);
}
.sidebar.close .toggle {
    transform: translateY(-50%) rotate(0deg);
}
.sidebar .text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color);
    transition: var(--tran-03);
    white-space: nowrap;
    opacity: 1;
}
.sidebar.close .text {
    opacity: 0;
    display: none; /* Force le masquage pour éviter les bugs de layout */
}
.sidebar .image { margin-right: 10px; min-width: 45px; display: flex; align-items: center; }

/* === MENU LINKS & DROPDOWN === */
.sidebar li {
    list-style: none;
}

.sidebar .icon-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0 10px;
    margin-top: 10px;
    border-radius: 6px;
    transition: var(--tran-03);
}
.sidebar .icon-link:hover {
    background: #1d1b31;
}

.sidebar .icon-link a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar .icon {
    min-width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-color);
}

/* Flèche du dropdown */
.sidebar .arrow {
    height: 50px;
    min-width: 40px; /* Zone de clic large */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-color);
    transition: var(--tran-03);
    cursor: pointer;
}

/* Rotation de la flèche quand menu ouvert */
.sidebar li.showMenu .arrow {
    transform: rotate(-180deg);
}
.sidebar.close .arrow {
    display: none; /* Cache les flèches quand la sidebar est fermée */
}

/* === SUB MENU (DROPDOWN) === */
.sidebar .sub-menu {
    padding: 6px 6px 14px 60px; /* Décalage pour aligner sous le texte */
    margin-top: -5px;
    background: #1d1b31;
    display: none; /* Caché par défaut */
    border-radius: 0 0 6px 6px;
}

.sidebar li.showMenu .sub-menu {
    display: block; /* Visible quand classe showMenu active */
}

.sidebar .sub-menu a {
    color: var(--text-color);
    font-size: 14px;
    padding: 8px 0;
    white-space: nowrap;
    opacity: 0.8;
    transition: var(--tran-03);
    text-decoration: none;
    display: block;
}
.sidebar .sub-menu a:hover {
    opacity: 1;
    color: #fff;
}

/* Titre du sous-menu (Optionnel, caché ici car redondant) */
.sidebar .sub-menu .link_name {
    display: none;
}

/* === INPUT RECHERCHE DANS LE DROPDOWN === */
.sub-search {
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sub-search input {
    width: 100%;
    padding: 5px;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 13px;
}
.sub-search input::placeholder {
    color: rgba(255,255,255,0.4);
}

/* Sidebar fermée : masquer complètement les sous-menus */
.sidebar.close .sub-menu {
    display: none !important;
}

/* === RESTE DU STYLE (Search box, Bottom) === */
.sidebar .search-box {
    background-color: #1d1b31;
    border-radius: 6px;
    margin: 10px;
    display: flex;
    align-items: center;
}
.search-box input {
    height: 100%;
    width: 100%;
    outline: none;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 16px;
}
.sidebar.close .search-box input { display: none; }

.bottom-content {
    position: absolute;
    bottom: 0;
    width: 100%;
    border-top: 1px solid #333;
    background: var(--sidebar-color);
}
.bottom-content li {
    display: flex;
    align-items: center;
    padding: 10px;
}
.bottom-content a {
    display: flex;
    align-items: center;
    text-decoration: none;
    width: 100%;
}

/* === HOME SECTION === */
.home {
    position: absolute;
    top: 0;
    left: 260px;
    height: 100vh;
    width: calc(100% - 260px);
    background-color: var(--body-color);
    transition: var(--tran-05);
    padding: 20px;
}
.sidebar.close ~ .home {
    left: 78px;
    width: calc(100% - 78px);
}