/* assets/css/sidebar.css */
:root {
    --sb-width: 220px;
    --sb-bg: #0f172a;
    --sb-text: #ffffff;
    --sb-hover: rgba(255, 255, 255, 0.1);
    --sb-active: #3b82f6;
    --sb-transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* El Sidebar (Drawer) */
.ceo-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sb-width);
    height: 100vh;
    background-color: var(--sb-bg);
    color: var(--sb-text);
    z-index: 11000;
    transform: translateX(-100%);
    transition: var(--sb-transition);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0,0,0,0.3);
}

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

/* Overlay / Backdrop */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Header del Sidebar */
.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-close-sidebar {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

/* Navegación */
.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--sb-hover);
    color: white;
}

.nav-link.active {
    background: var(--sb-active);
    color: white;
}

.nav-icon {
    width: 20px;
    height: 20px;
}

/* Burger Button en Navbar */
.burger-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px; /* Reduced from 8px */
    margin-right: 4px; /* Reduced from 10px */
    border-radius: 4px;
    transition: background 0.2s;
}

.home-btn {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-right: 8px;
    border-radius: 4px;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s;
}
.home-btn svg { width: 20px; height: 20px; }
.home-btn:hover { background: rgba(255, 255, 255, 0.1); }

.burger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.burger-btn svg {
    width: 20px; /* Reduced from 24px */
    height: 20px; /* Reduced from 24px */
}

@media (max-width: 768px) {
    :root {
        --sb-width: 55%;
    }
}


/* Grupos plegables del menú (Empresa / Hogar) */
.nav-group { margin: 2px 0; }
.nav-group-title { list-style: none; cursor: pointer; padding: 14px 20px 6px; font-size: 0.7rem; text-transform: uppercase; color: rgba(255,255,255,0.55); font-weight: 700; letter-spacing: .04em; display: flex; justify-content: space-between; align-items: center; user-select: none; }
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title::after { content: '▸'; font-size: 0.8rem; transition: transform .2s; }
.nav-group[open] > .nav-group-title::after { transform: rotate(90deg); }
.nav-group-title:hover { color: #fff; }

/* ── CONMUTADOR DE ÁMBITO (EMPRESA / AMBOS / HOGAR) ── */
.sidebar-scope-selector {
    padding: 10px 14px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.scope-selector-track {
    display: flex;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
}
.scope-pill-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 2px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}
.scope-pill-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}
.scope-pill-btn.active[data-scope="both"] {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.scope-pill-btn.active[data-scope="empresa"] {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 7px rgba(37, 99, 235, 0.45);
}
.scope-pill-btn.active[data-scope="hogar"] {
    background: #059669;
    color: #ffffff;
    box-shadow: 0 2px 7px rgba(5, 150, 105, 0.45);
}

/* Conmutador Segmentado de Ámbito en Cabecera */
.header-scope-switcher {
    display: inline-flex !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 16px !important;
    padding: 2px !important;
    gap: 2px !important;
    margin-right: 8px !important;
    flex-shrink: 0 !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25) !important;
    height: 28px !important;
    box-sizing: border-box !important;
}
.hscope-btn {
    border: none !important;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.72) !important;
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    padding: 2px 8px !important;
    border-radius: 13px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    transition: all 0.18s ease !important;
    line-height: 1 !important;
    height: 22px !important;
    white-space: nowrap !important;
    outline: none !important;
    box-sizing: border-box !important;
}
.hscope-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.12) !important;
}
.hscope-btn.active[data-scope="both"] {
    background: rgba(255, 255, 255, 0.24) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
}
.hscope-btn.active[data-scope="empresa"] {
    background: #2563eb !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 6px rgba(37, 99, 235, 0.55) !important;
}
.hscope-btn.active[data-scope="hogar"] {
    background: #059669 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 6px rgba(5, 150, 105, 0.55) !important;
}
@media (max-width: 640px) {
    .hscope-btn .hscope-text { display: none !important; }
    .hscope-btn { padding: 2px 6px !important; }
    .hscope-btn .hscope-icon { font-size: 0.82rem !important; }
    .header-scope-switcher { margin-right: 4px !important; }
}

/* FILTRADO DE ÁMBITO: MODO SOLO EMPRESA */
html[data-ceo-scope="empresa"] details.nav-group[data-group="home"],
html[data-ceo-scope="empresa"] a.nav-link[href="puente.php"],
html[data-ceo-scope="empresa"] a[href="puente.php"],
html[data-ceo-scope="empresa"] .drawer-card[data-type="HOGAR"],
html[data-ceo-scope="empresa"] a[href="hogar.php"],
html[data-ceo-scope="empresa"] a[href="datos_hogar.php"],
html[data-ceo-scope="empresa"] a[href="agenda_hogar.php"],
html[data-ceo-scope="empresa"] a[href^="datos_hogar.php#"],
html[data-ceo-scope="empresa"] a[href="comunidad.php"],
html[data-ceo-scope="empresa"] a[href="salud.php"],
html[data-ceo-scope="empresa"] a[href="patrimonio.php"],
html[data-ceo-scope="empresa"] a[href="familia.php"],
html[data-ceo-scope="empresa"] a[href="servicios.php"],
html[data-ceo-scope="empresa"] [data-scope-only="hogar"],
html[data-ceo-scope="empresa"] [data-scope-only="puente"] {
    display: none !important;
}

/* FILTRADO DE ÁMBITO: MODO SOLO HOGAR */
html[data-ceo-scope="hogar"] details.nav-group[data-group="company"],
html[data-ceo-scope="hogar"] a.nav-link[href="puente.php"],
html[data-ceo-scope="hogar"] .drawer-card[data-type="EMPRESA"],
html[data-ceo-scope="hogar"] a[href="empresa.php"],
html[data-ceo-scope="hogar"] a[href="datos_empresa.php"],
html[data-ceo-scope="hogar"] a[href="clientes.php"],
html[data-ceo-scope="hogar"] a[href="proveedores.php"],
html[data-ceo-scope="hogar"] a[href="colaboradores.php"],
html[data-ceo-scope="hogar"] a[href="listas.php"],
html[data-ceo-scope="hogar"] a[href="presupuestos.php"],
html[data-ceo-scope="hogar"] a[href="obras.php"],
html[data-ceo-scope="hogar"] a[href="dashboard.php"],
html[data-ceo-scope="hogar"] a[href="fiscal.php"],
html[data-ceo-scope="hogar"] a[href="finanzas.php"],
html[data-ceo-scope="hogar"] a[href="banco.php"],
html[data-ceo-scope="hogar"] a[href="financiacion.php"],
html[data-ceo-scope="hogar"] a[href="personal.php"],
html[data-ceo-scope="hogar"] a[href="jornada.php"],
html[data-ceo-scope="hogar"] a[href="ayudas.php"],
html[data-ceo-scope="hogar"] a[href="licitaciones.php"],
html[data-ceo-scope="hogar"] a[href="societario.php"],
html[data-ceo-scope="hogar"] [data-scope-only="empresa"],
html[data-ceo-scope="hogar"] [data-scope-only="puente"] {
    display: none !important;
}

