/* =========================================================
   VARIABLES
   ========================================================= */
:root {
    --sidebar-width: 280px;
    --sidebar-width-collapsed: 40px;
}

/* =========================================================
   BOTÓN LATERAL (toggle-btn)
   ========================================================= */
.toggle-btn {
    position: absolute;
    top: 100px;
    right: -12px;
    /*left: var(--sidebar-width);*/ /* alineado al borde derecho de la sidebar */
    /*transform: translateX(-50%);*/ /* centrado sobre el borde */
    z-index: 1100; /* encima del sidebar */
    width: 30px;
    height: 30px;
    border-radius: 50%;
    /*background: white;*/
    background: #d1e3fd;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s ease;
    border:0;
}

.admintoggle-btn {
    position: absolute;
    top: 100px;
    right: -12px;
    /*left: var(--sidebar-width);*/ /* alineado al borde derecho de la sidebar */
    /*transform: translateX(-50%);*/ /* centrado sobre el borde */
    z-index: 1100; /* encima del sidebar */
    width: 30px;
    height: 30px;
    border-radius: 50%;
    /*background: white;*/
    background: #d1e3fd;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s ease;
    border:0;
}

/* =========================================================
   SIDEBAR (estructura base)
   ========================================================= */
#sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    /*padding-top: 56px;*/ /* altura del header */
    transition: width 0.28s ease, transform 0.28s ease;
    z-index: 100;
    background: var(--bs-body-bg, #fff);
    /*overflow: hidden;*/
    box-sizing: border-box;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

.displaced-menu{
    top: calc(var(--navbar-principal-height) + 30px);
}

/* =========================================================
   ESCRITORIO (>= 992px)
   ========================================================= */
@media (min-width: 992px) {

    #sidebar {
        width: var(--sidebar-width);
        top: 56px;
        height: calc(100% - 56px);
        transition: width 0.28s ease;
    } 
    
    #adminsidebar {
        width: var(--sidebar-width);
        top: 56px;
        height: calc(100% - 56px);
        transition: width 0.28s ease;
    }        

    /* Sidebar colapsado en escritorio */
    #sidebar.is-collapsed {
        width: var(--sidebar-width-collapsed);
    }

    /* Sidebar colapsado en escritorio */
    #adminsidebar.is-collapsed {
        width: var(--sidebar-width-collapsed);
    }    

    /* Main-content alineado al sidebar */
    .main-content {
        margin-left: var(--sidebar-width);
        /*width: calc(100% - var(--sidebar-width));*/
        width: auto;
        transition: margin-left 0.28s ease;
    }

    #sidebar.is-collapsed ~ .main-content {
        margin-left: var(--sidebar-width-collapsed);
        /*width: calc(100% - var(--sidebar-width-collapsed));*/
    }

    /* En escritorio el toggle del header NO se muestra */
    #sidebarToggle { 
        display: none !important;
    }

    /* En escritorio el botón lateral SÍ se muestra */
    /*.toggle-btn {
       display: inline-flex !important;
    }*/
}

/* =========================================================
   MÓVIL (< 992px)
   ========================================================= */
@media (max-width: 991.98px) {

    /* Sidebar como overlay */
    #sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        /*height: 100%;*/
        /*top: 0;*/
        padding-top: 56px;
        box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    
    }

    /* Sidebar como overlay */
    #adminsidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        /*height: 100%;*/
        /*top: 0;*/
        padding-top: 56px;
        box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    
    }    

    #sidebar.is-open {
        transform: translateX(0);
    }

    #adminsidebar.is-open {
        transform: translateX(0);
    }    

    /* Main ocupa todo el ancho en móvil */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        background-color: #f8f9fa;
        transition: none;
    }

    /* El botón del HEADER se muestra en móvil */
    #sidebarToggle {
        display: inline-flex !important;
    }

    /* El botón lateral NO se muestra en móvil */
    .toggle-btn {
        display: none !important;
    }

    .admintoggle-btn {
        display: none !important;
    }    
}

/* =========================================================
   ROTACIÓN ICONO AL COLAPSAR (opcional)
   ========================================================= */
#sidebar.is-collapsed .toggle-btn i,
#sidebar.is-open .toggle-btn i {
    transform: rotate(180deg);
    transition: transform 0.28s ease;
}

#adminsidebar.is-collapsed .admintoggle-btn i,
#adminsidebar.is-open .admintoggle-btn i {
    transform: rotate(180deg);
    transition: transform 0.28s ease;
}

/* =========================================================
   ESTILOS ORIGINALES — Sidebar
   ========================================================= */
body {
    font-size: 0.875rem;
    overflow-x: hidden;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #333;
    padding: 0.5rem 1rem;
}

.sidebar .nav-link.active {
    color: #2470dc;
}

.sidebar .nav-link:hover {
    color: #0056b3;
}

.sidebar-heading {
    font-size: .75rem;
    text-transform: uppercase;
    padding-left: 1rem;
}

@media (max-width: 767.98px) {
    .sidebar {
        top: 5rem;
    }
}

/* =========================================================
   HEADER NAVBAR (tus estilos originales)
   ========================================================= */
.navbar-brand {
    padding-top: .75rem;
    padding-bottom: .75rem;
    padding-left: 1.75rem;
    font-size: 1rem;
}

.navbar .navbar-toggler {
    top: .25rem;
    right: 1rem;
}

.navbar .form-control {
    padding: .75rem 1rem;
    border-width: 0;
    border-radius: 0;
}

.form-control-dark {
    color: #fff;
    background-color: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .1);
}

.form-control-dark:focus {
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}

/* =========================================================
   OTRAS REGLAS ORIGINALES
   ========================================================= */
.bd-placeholder-img {
    font-size: 1.125rem;
    text-anchor: middle;
    user-select: none;
}

@media (min-width: 768px) {
    .bd-placeholder-img-lg {
        font-size: 3.5rem;
    }
}

.b-example-divider {
    height: 3rem;
    background-color: rgba(0, 0, 0, .1);
    border: solid rgba(0, 0, 0, .15);
    border-width: 1px 0;
    box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}

.b-example-vr {
    flex-shrink: 0;
    width: 1.5rem;
    height: 100vh;
}

.bi {
    vertical-align: -.125em;
    fill: currentColor;
}

.nav-scroller {
    position: relative;
    z-index: 2;
    height: 2.75rem;
    overflow-y: hidden;
}

.nav-scroller .nav {
    display: flex;
    flex-wrap: nowrap;
    padding-bottom: 1rem;
    margin-top: -1px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

#app-frame {
    min-height: 600px;
}

.sidebar-category {
    margin-bottom: 1rem;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* =========================================================
   Perfil (sidebar bottom)
   ========================================================= */
.profile-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* =========================================================
   ADMIN SIDEBAR LINKS
   ========================================================= */

#adminsidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    /*padding-top: 56px;*/ /* altura del header */
    transition: width 0.28s ease, transform 0.28s ease;
    z-index: 100;
    background: #232323 !important;
    /*overflow: hidden;*/
    box-sizing: border-box;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    /*color: #ffffff !important;*/
}

/*#adminsidebar,
#adminsidebar * {
    color: white !important;
    fill: white !important;
}
*/

.sidebar-link {
    color: #a0a3bd !important;
    /*transition: all 0.2s ease;*/
    border-radius: 8px;
    margin: 4px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none !important;
    font-size: larger;
}

.sidebar-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1) !important;
    transform: translateX(5px);
}

.sidebar-link.active {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
}

#adminsidebar.is-collapsed .hide-on-collapse {
    opacity: 0;
    visibility: hidden;
}

#adminsidebar.is-collapsed .sidebar-link {
    text-align: left;
    padding: 1rem !important;
    margin: 4px -5px;
}

#adminsidebar.is-collapsed .sidebar-link i {
    margin: 0 !important;
}

#adminsidebar.is-collapsed ~ .main-content {
    margin-left: var(--sidebar-width-collapsed);
}