:root {
    --csdi-sidebar-width: 260px;
    --csdi-sidebar-collapsed: 76px;

    --csdi-sidebar-bg: #111a24;
    --csdi-sidebar-bg-2: #172331;
    --csdi-sidebar-text: #d7dee7;
    --csdi-sidebar-muted: #8996a5;

    --csdi-primary: #2f6fed;
    --csdi-primary-dark: #1f5dd1;

    --csdi-border: #e6eaf0;
    --csdi-bg: #f5f7fa;
    --csdi-text: #18212b;
}


/* ============================================================
   SIDEBAR (COMPACTA POR DEFECTO CON AUTO-EXPAND)
============================================================ */

.csdi-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;

    /* Tamaño compacto por defecto */
    width: var(--csdi-sidebar-collapsed);

    display: flex;
    flex-direction: column;

    background:
        linear-gradient(
            180deg,
            var(--csdi-sidebar-bg) 0%,
            var(--csdi-sidebar-bg-2) 100%
        );

    color: var(--csdi-sidebar-text);

    z-index: 1040;

    overflow-x: hidden;
    overflow-y: auto;
    white-space: nowrap;

    scrollbar-width: thin;

    /* Transición fluida al pasar el mouse */
    transition:
        width .25s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow .25s ease;
}

/* EFECTO HOVER: SE AGRANDA AUTOMÁTICAMENTE AL PASAR EL CURSOR */
.csdi-sidebar:hover {
    width: var(--csdi-sidebar-width);
    box-shadow: 6px 0 25px rgba(0, 0, 0, .35);
}


/* ============================================================
   BRAND (LOGO)
============================================================ */

.csdi-brand {
    min-height: 72px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 14px 10px;

    border-bottom: 1px solid rgba(255,255,255,.06);

    transition: padding .20s ease;
}

.csdi-brand-link {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 11px;

    color: #fff;
    text-decoration: none;
}

.csdi-brand-mark {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: var(--csdi-primary);

    color: #fff;

    box-shadow:
        0 5px 15px rgba(47,111,237,.28);
}

.csdi-brand-mark i {
    font-size: 19px;
}

.csdi-brand-text {
    display: flex;
    flex-direction: column;

    min-width: 0;

    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s ease;
}

.csdi-brand-text strong {
    font-size: 16px;
    line-height: 18px;
    font-weight: 700;
}

.csdi-brand-text small {
    margin-top: 2px;

    font-size: 10px;
    line-height: 12px;

    color: var(--csdi-sidebar-muted);

    letter-spacing: .08em;
}

/* Al pasar el mouse, el logo se alinea y aparece el texto */
.csdi-sidebar:hover .csdi-brand {
    justify-content: flex-start;
    padding: 14px 16px;
}

.csdi-sidebar:hover .csdi-brand-link {
    justify-content: flex-start;
}

.csdi-sidebar:hover .csdi-brand-text {
    opacity: 1;
    visibility: visible;
}


/* ============================================================
   NAV
============================================================ */

.csdi-nav {
    flex: 1 1 auto;

    padding: 14px 10px 18px;
}

.csdi-nav-link {
    width: 100%;

    min-height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 12px;

    padding: 9px 0;

    margin-bottom: 3px;

    border: 0;
    border-radius: 7px;

    background: transparent;

    color: var(--csdi-sidebar-text);

    text-decoration: none;
    text-align: left;

    font-size: 14px;

    cursor: pointer;

    transition:
        background .15s ease,
        color .15s ease,
        padding .20s ease,
        justify-content .20s ease;
}

.csdi-nav-link span {
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s ease;
}

.csdi-nav-link i:first-child {
    width: 20px;
    min-width: 20px;

    flex: 0 0 20px;

    text-align: center;

    font-size: 18px;
}

.csdi-nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.csdi-nav-link.active {
    background:
        linear-gradient(
            90deg,
            #2f6fed,
            #3c7bf1
        );

    color: #fff;

    box-shadow:
        0 4px 12px rgba(47,111,237,.20);
}

/* Al expandirse, los enlaces recuperan su alineación completa */
.csdi-sidebar:hover .csdi-nav-link {
    justify-content: flex-start;
    padding: 9px 12px;
}

.csdi-sidebar:hover .csdi-nav-link span {
    opacity: 1;
    visibility: visible;
}


/* ============================================================
   HEADER DE SECCIÓN Y SUBMENÚS
============================================================ */

.csdi-nav-header {
    width: 100%;

    display: block;

    min-width: 0;
}

.csdi-nav-header > .csdi-nav-link {
    width: 100%;
}

.csdi-nav-toggle {
    display: none;
}

.csdi-subnav {
    display: none;
}

/* En hover reaparecen las flechas y submenús */
.csdi-sidebar:hover .csdi-nav-header {
    display: flex;
}

.csdi-sidebar:hover .csdi-nav-header > .csdi-nav-link {
    width: auto;
}

.csdi-sidebar:hover .csdi-nav-toggle {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    margin: 0 5px 3px 2px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--csdi-sidebar-muted);
    cursor: pointer;
}

.csdi-nav-toggle .csdi-chevron {
    width: 12px;
    height: 12px;
    font-size: 10px;
    transition: transform .20s ease;
}

.csdi-nav-section.open .csdi-chevron {
    transform: rotate(180deg);
}

.csdi-sidebar:hover .csdi-nav-section.open .csdi-subnav {
    display: block;
    padding: 2px 0 7px 44px;
}

.csdi-subnav a {
    display: block;
    padding: 7px 10px;
    color: #aeb9c6;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: background .15s ease, color .15s ease;
}

.csdi-subnav a:hover,
.csdi-subnav a.active {
    color: #fff;
    background: rgba(255,255,255,.07);
}


/* ============================================================
   FOOTER SIDEBAR
============================================================ */

.csdi-sidebar-footer {
    flex: 0 0 auto;

    padding: 10px;

    border-top: 1px solid rgba(255,255,255,.06);
}

.csdi-collapse-btn {
    width: 100%;

    min-height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 9px 0;

    border: 0;
    border-radius: 7px;

    background: rgba(255,255,255,.04);

    color: var(--csdi-sidebar-muted);

    font-size: 13px;

    cursor: pointer;
}

.csdi-collapse-btn span {
    display: none;
}

.csdi-collapse-btn i {
    font-size: 18px;
}

.csdi-sidebar:hover .csdi-collapse-btn {
    justify-content: flex-start;
    padding: 9px 12px;
    gap: 10px;
}

.csdi-sidebar:hover .csdi-collapse-btn span {
    display: inline;
}


/* ============================================================
   CONTENIDO PRINCIPAL (CORRECCIÓN DE MARGEN DEFINITIVA)
============================================================ */

body {
    background: var(--csdi-bg);
    color: var(--csdi-text);
}

/* El contenido principal SIEMPRE tiene el margen de la sidebar compacta */
.csdi-main,
.csdi-content,
#main,
main {
    margin-left: var(--csdi-sidebar-collapsed) !important;
    min-height: 100vh;
    transition: margin-left .25s ease;
}


/* ============================================================
   RESPONSIVE (MÓVILES)
============================================================ */

@media (max-width: 991.98px) {

    .csdi-sidebar {
        width: var(--csdi-sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform .25s ease !important;
    }

    body.csdi-sidebar-mobile-open .csdi-sidebar {
        transform: translateX(0);
    }

    .csdi-main,
    .csdi-content,
    main {
        margin-left: 0 !important;
    }

    /* En móvil se ven los textos directamente cuando se abre */
    .csdi-brand-text,
    .csdi-nav-link span,
    .csdi-collapse-btn span {
        opacity: 1 !important;
        visibility: visible !important;
        display: initial !important;
    }

    .csdi-nav-toggle {
        display: inline-flex !important;
    }
}

.csdi-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1020;
}

@media (max-width: 991.98px) {
    body.csdi-sidebar-mobile-open .csdi-sidebar-overlay {
        display: block;
    }
}