:root {
    --sidebar-width: 250px;
    --topbar-height: 60px;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
}

.form-floating>.form-control-plaintext::placeholder,
.form-floating>.form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating>.form-control-plaintext:focus::placeholder,
.form-floating>.form-control:focus::placeholder {
    text-align: start;
}



body {
    overflow-x: hidden;
}

/* Barra superior */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--topbar-height);
    background-color: white;
    /*border-bottom: 1px solid #e3e6f0;
        background: linear-gradient(90deg, #b27dca 0%, #5a2377 100%);
    */
    border-bottom: 2px solid var(--bs-primary);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    box-shadow: 0 2px 8px rgba(116, 44, 148, 0.2);
}

.topbar-toggle {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    color: black;
    transition: color 0.3s ease;
}

.topbar-toggle:hover {
    color: #b27dca;
}

/* Barra superior - Usuario */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /*background-color: whitesmoke;*/
}

.user-name {
    font-weight: 600;
    font-size: 0.75rem;
    color: #333;
    line-height: 1.2;
    padding: 2rem 0 0 0;
}

.user-role {
    font-size: 0.75rem;
    color: #858796;
    line-height: 1.2;
    padding: 0 0 1.2rem 0
}

/* Menú lateral */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background-color: var(--bs-primary);
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
    z-index: 999;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-brand {
    padding: 0.5rem 0 0.5rem 0;
    text-align: center;
    /*border-bottom: 1px solid rgba(255, 255, 255, 0.1);*/
    background-color: white;
    border-right: var(--bs-primary);
}

.sidebar-brand img {
    width: 200px;
    height: auto;
    max-width: 100%;
    display: block;
    margin: 0 auto;
    object-fit: contain;
    /* Mejorar calidad de renderizado */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: bicubic;
    filter: contrast(1.01);
    /* Forzar GPU rendering */
    transform: translateZ(0);
    will-change: transform;
    background-color: white;
}

@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .sidebar-brand img {
        image-rendering: auto;
    }
}

.sidebar-brand-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    position: relative;
}

.nav-link:hover {
    color: white;
    background-color: var(--bs-primary-dark);
    text-decoration: none;
}

/* Estilos para items de submenú cuando están activos */
.collapse .nav-link.active {
    color: var(--bs-font-color) !important;
    background-color: var(--bs-primary-dark) !important;
    font-weight: 700 !important;
    border-left: 4px solid var(--bs-font-color);
    padding-left: calc(3rem - 4px);
}

.collapse .nav-link.active .material-icons {
    color: var(--bs-font-color) !important;
}

.nav-link[aria-expanded="true"] {
    color: var(--bs-font-color) !important;
    background-color: var(--bs-primary-dark) !important;
    font-weight: 700 !important;
    border-left: 4px solid var(--bs-font-color);
    padding-left: calc(2.5rem - 4px);
}

.nav-link[aria-expanded="true"] .material-icons,
.nav-link[aria-expanded="true"] .bi {
    color: var(--bs-font-color) !important;
}

/* Estilos para menú colapsable cuando está colapsado (volver a normal) */
.nav-link[aria-expanded="false"] {
    color: rgba(255, 255, 255, 0.8) !important;
    background-color: transparent !important;
    font-weight: normal !important;
    border-left: none;
    padding-left: 2.5rem;
}

.nav-link[aria-expanded="false"] .material-icons,
.nav-link[aria-expanded="false"] .bi {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Submenú (items dentro del collapse) */
.collapse .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
}

.collapse .nav-link .material-icons {
    left: 1.5rem;
    font-size: 1.1rem;
}

.nav-link .material-icons {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
}

.nav-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-heading {
    padding: 0.5rem 1rem;
    font-size: 0.80rem;
    font-weight: 700;
    color: black;
    text-transform: uppercase;
}

/* Contenido principal */
.content-wrapper {
    margin-top: var(--topbar-height);
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease-in-out;
    min-height: calc(100vh - var(--topbar-height));
}

.content-wrapper.expanded {
    margin-left: 0;
}

/* Footer */
.footer {
    background-color: var(--bs-primary) !important;
    border-radius: 5px !important;
    padding: 1.5rem;
    margin-top: auto;
}

/* Icono del usuario en topbar */
.topbar-user .material-icons {
    font-size: 1.5rem;
}


/* Dropdown del usuario */
.topbar-user.dropdown {
    position: relative;
}

.user-avatar.dropdown-toggle {
    cursor: pointer;
}

.user-avatar.dropdown-toggle::after {
    display: none;
    /* Ocultar la flecha por defecto de Bootstrap */
}

.dropdown-menu {
    min-width: 200px;
}

.user-dropdown {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bs-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar:hover {
    background-color: var(--bs-primary-dark);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar:active {
    transform: scale(0.98);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1100;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Flecha del dropdown */
.user-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);
}

.dropdown-menu.show {
    background-color: var(--bs-primary) !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 1.25rem;
    /*color: #333;*/
    color: white;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    font-size: 0.75rem;
}

.dropdown-item:hover {
    background-color: #f8f9fc;
    color: var(--bs-primary);
    text-decoration: none;
}

.dropdown-item .material-icons {
    font-size: 20px;
    color: white;
}

.dropdown-item:hover .material-icons {
    color: var(--bs-primary);
}

.dropdown-divider {
    height: 1px;
    margin: 0.5rem 0;
    background-color: #e3e6f0;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0;
    }

    .user-info {
        display: none;
    }

    .user-dropdown-menu {
        right: -10px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

.btn {
    text-decoration: none !important;
}

.btn:hover {
    text-decoration: none !important;
}