﻿/* ====== Paleta y base ====== */
:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --border: #e6e8ee;
    --text: #0f172a;
    --muted: #6b7280;
    --accent: #2473de; /*#6d5efc violeta Metis */
    --accent-weak: rgba(109,94,252,.12);
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 12px rgba(16,24,40,.06);
    --nav-width: 248px;
    --z-fixed: 2100;
    --nav-open: 248px;
    --nav-collapsed: 76px;
    --nav-current: var(--nav-open);
    --z-sidebar: 1200; /* sidebar fijo */
    --z-sidebar-backdrop: 1190; /* backdrop del sidebar si lo usas */
    --z-topbar: 2000; /* topbar */
    --z-dropdown: 2100; /* dropdowns/menus que deben quedar SOBRE el sidebar */
    --z-modal-backdrop: 3000; /* bootstrap backdrop */
    --z-modal: 3050; /* bootstrap modal */
    --topbar-h: 64px;
}

* {
    box-sizing: border-box
  }

/*html, body {
    height: 100%
}*/

    /*body.app.app-light {
        background: var(--bg);
        color: var(--text);
    }

.app-layout {
    position: relative;
    min-height: 100dvh;
    overflow-x: hidden;*/ /* evita scroll lateral cuando abre el menú */
/*}*/

/* ====== Topbar ====== */
.app-topbar {
    height: var(--topbar-h); /*64px;*/
    background: #f8f9fa;
    position: fixed; /*sticky;*/
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-topbar);
    /*z-index: 2000;*/ /*1000;*/
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.brand-badge {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    font-weight: 700;
}

.brand-text {
    font-weight: 600;
    color: var(--text);
}

.icon-btn {
    border: none;
    background: #fff;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

    .icon-btn:hover {
        background: #f3f4f6;
    }

.searchbar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    gap: 8px;
    min-width: 280px;
}

    .searchbar .form-control {
        border: none;
        outline: none;
        box-shadow: none;
        background: transparent;
    }

/* 2) Sidebar OFF-CANVAS: siempre por encima y fijado a la pantalla */
/*.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 86vw;
    background: #fff;
    box-shadow: 8px 0 24px rgba(0,0,0,.12);
    transform: translateX(-105%);*/ /* oculto por defecto */
    /*transition: transform .25s ease;
    z-index: 1100;*/ /* por encima del contenido y header */
/*}*/
    /* abierto */
    /*.sidebar.is-open {
        transform: translateX(0);
    }*/

/* 3) Backdrop para bloquear la UI detrás y permitir cerrar al tocar fuera */
.backdrop {
    position: fixed;
    inset: 0; /* top:0;right:0;bottom:0;left:0 */
    background: rgba(0,0,0,.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: var(--z-sidebar-backdrop); /*2050;*/ /* justo debajo del sidebar */
}

    .backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

.modal-backdrop.show {
    z-index: var(--z-modal-backdrop); /* 3000 en tu :root */
}

.modal {
    z-index: var(--z-modal); /* 3050 en tu :root */
}

/* ====== Sidebar ====== */
.app-sidebar {
    position: fixed;
    top: var(--topbar-h); /*64px;*/
    left: 0;
    bottom: 0;
    width: var(--nav-current); /*var(--nav-width);*/
    height: auto; /* <- quita height:100vh aquí */
    background: #f8f9fa; /*#fff;*/
    border-right: 1px solid var(--border);
    padding: 0.5rem 1rem 0 0;
    transition: 0.5s;
    z-index: var(--z-sidebar); /*var(--z-fixed);*/
    overflow: auto;
}

    .app-sidebar nav {
        display: flex;
        flex-direction: column;
    }

@supports (height: 100dvh) {
    .app-sidebar {
        bottom: auto;
        height: calc(100dvh - var(--topbar-h));
    }
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .7rem;
    margin: 2px 4px;
    border-radius: 10px;
    color: #4b5563;
    text-decoration: none;
}

    .nav-link:hover {
        background: #f3f4f6;
        color: #111827;
    }

    .nav-link.active {
        background: var(--accent-weak);
        color: var(--accent);
        font-weight: 600;
    }

.nav-icon {
    width: 1.25rem;
    text-align: center;
}

.nav-label {
    white-space: nowrap;
}

.nav-section {
    color: var(--muted);
    font-size: .74rem;
    padding: .7rem .9rem .3rem;
}

.badge-count {
    background: var(--danger);
    color: #fff;
    font-size: .7rem;
    line-height: 1;
    padding: .25rem .38rem;
    border-radius: 999px;
}

.badge-new {
    background: #e9f3ff;
    color: #2563eb;
    font-size: .68rem;
    padding: .12rem .42rem;
    border-radius: 999px;
}

/* Submenú */
.nav-group .nav-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
}

.nav-sub {
    display: none;
    flex-direction: column;
    margin-left: 2.2rem;
}

.nav-sublink {
    color: #6b7280;
    text-decoration: none;
    padding: .35rem 0;
}

    .nav-sublink:hover {
        color: #111827;
    }

.nav-group.open .nav-sub {
    display: flex;
}

.nav-group .caret {
    transition: transform .2s ease;
}

.nav-group.open .caret {
    transform: rotate(90deg);
}

/* ====== Content ====== */
.app-content {
    margin-left: var(--nav-current); /*248px;*/
    margin-top: 25px; /*calc(64px + 5px);*/ /*deja espacio para la barra */
    padding: 15px;
    min-height: calc(100vh - 64px);
    overflow: visible; /* <- aquí vive el scroll */
    position: relative;
    z-index: 0 !important; /*auto 1;*/
    transition: margin-left .2s ease;

    /*padding-top: 12px;*/ /* ya no necesitamos sumar 64px aquí */
    /*overflow-x: visible;*/
    /*min-height: calc(100vh - 64px);*/
    /*min-height: 100vh;*/ /* ya no restes 64px */
}

/* ====== Usuario / dropdown ====== */
.user-menu .user-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
}

.user-menu .avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
}

.dropdown-menu {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 12px;
    z-index: var(--z-dropdown); /* sube el menú de empresa */
}

/* Notificaciones */
.badge-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 999px;
    margin-left: -10px;
    margin-top: -10px;
}

/* ====== Cards utilitarias (por si las necesitas) ====== */
.card-light {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px;
}

/* ====== Estados: colapsado / móvil ====== */
body.sidebar-collapsed .app-sidebar {
    --nav-current: var(--nav-collapsed);
    /*width: 76px;*/
}

body.sidebar-collapsed .app-content {
    margin-left: 76px;
}

body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .badge-count,
body.sidebar-collapsed .badge-new {
    display: none !important;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-105%); /* oculto por defecto en móvil */
        width: var(--nav-width);
        top: var(--topbar-h); /*64px;*/
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-content {
        margin-left: 0;
        /*height: calc(100vh - 64px);*/
        /*padding-top: calc(64px + 12px);*/
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

/* Scrollbar suavizado */
.app-sidebar::-webkit-scrollbar {
    width: 8px
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 999px
}

/* ====== Topbar align right fix ====== */
.topbar-actions {
    margin-left: auto !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .topbar-actions .icon-btn,
    .topbar-actions .user-btn {
        margin-left: 4px;
    }

        /* Centrado visual del icono de campana y engrane */
        .topbar-actions .icon-btn i {
            font-size: 1rem;
            color: #374151;
        }

