/* CSS para Solo Lectura: Oculta botones automáticamente */

/* Cuando el body tiene la clase 'solo-lectura', ocultar botones de acción excepto:
   - Enlaces con href (navegación)
   - Botones que abren modales (data-toggle="modal" o data-target)
   - Botones con clases de excepción (.botonOrientacion, .allow-solo-lectura, .boton-informes)
*/

/* Ocultar botones de acción por defecto */
body.solo-lectura button:not(.botonOrientacion):not(.allow-solo-lectura):not(.boton-informes):not([data-toggle="modal"]):not([data-target]),
body.solo-lectura .btn:not(.botonOrientacion):not(.allow-solo-lectura):not(.boton-informes):not([data-toggle="modal"]):not([data-target]):not(a),
body.solo-lectura .hidden-solo-lectura {
    display: none !important;
}

/* Ocultar botones con iconos de edición/acción incluso si tienen modal o href (excepto .boton-informes) */
body.solo-lectura button:has(.bx-plus):not(.boton-informes),
body.solo-lectura .btn:has(.bx-plus):not(.boton-informes),
body.solo-lectura a.btn:has(.bx-plus):not(.boton-informes),
body.solo-lectura button:has(.bx-edit):not(.boton-informes),
body.solo-lectura .btn:has(.bx-edit):not(.boton-informes),
body.solo-lectura button:has(.bxs-edit-alt):not(.boton-informes),
body.solo-lectura .btn:has(.bxs-edit-alt):not(.boton-informes),
body.solo-lectura button:has(.bx-trash):not(.boton-informes),
body.solo-lectura .btn:has(.bx-trash):not(.boton-informes),
body.solo-lectura button:has(.bx-check):not([href]):not(.boton-informes),
body.solo-lectura .btn:has(.bx-check):not([href]):not(.boton-informes),
body.solo-lectura button:not(.boton-informes) .bx-plus,
body.solo-lectura .btn:not(.boton-informes) .bx-plus {
    display: none !important;
}
body.solo-lectura [class*="bx-plus"]:not(.boton-informes) {
    display: none !important;
}
/* Mantener visible los botones de informes (no ocultarlos en solo-lectura) */
body.solo-lectura .boton-informes {
    display: inline-block !important;
}
body.solo-lectura .boton-informes [class*="bx-"] {
    display: inline-block !important;
}

/* NO ocultar: Enlaces con href (navegación) - excepto botones específicos que deben ocultarse */
body.solo-lectura a[href]:not(.btn-mask):not(#sendPass),
body.solo-lectura a.btn[href]:not(.btn-mask):not(#sendPass) {
    display: inline-block !important;
}

/* NO ocultar: Botones que abren modales SOLO si son de navegación (sin iconos de edición) */
/* Los modales de edición se ocultan por las reglas anteriores */
body.solo-lectura [data-toggle="modal"]:not(:has(.bx-plus)):not(:has(.bx-edit)):not(:has(.bxs-edit-alt)):not(:has(.bx-trash)),
body.solo-lectura [data-target]:not(:has(.bx-plus)):not(:has(.bx-edit)):not(:has(.bxs-edit-alt)):not(:has(.bx-trash)) {
    display: inline-block !important;
}

/* Deshabilitar inputs con onclick submit (en lugar de ocultarlos), excepto .boton-informes */
body.solo-lectura input[onclick*="submit"]:not(.boton-informes),
body.solo-lectura input[onclick*="Submit"]:not(.boton-informes),
body.solo-lectura input[type="submit"]:not(.boton-informes),
body.solo-lectura input[type="button"][onclick*="submit"]:not(.boton-informes),
body.solo-lectura input[type="button"][onclick*="Submit"]:not(.boton-informes) {
    pointer-events: none !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}
body.solo-lectura input[onclick*="submit"]:disabled:not(.boton-informes),
body.solo-lectura input[onclick*="Submit"]:disabled:not(.boton-informes),
body.solo-lectura input[type="submit"]:disabled:not(.boton-informes) {
    opacity: 0.5 !important;
}
/* No deshabilitar inputs dentro de .boton-informes */
body.solo-lectura .boton-informes input,
body.solo-lectura input.boton-informes {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* Deshabilitar switches/checkboxes con onClick submit, excepto dentro de .boton-informes */
body.solo-lectura input[type="checkbox"][onclick*="submit"]:not(.boton-informes),
body.solo-lectura input[type="checkbox"][onClick*="submit"]:not(.boton-informes),
body.solo-lectura .custom-control-input[onclick*="submit"]:not(.boton-informes),
body.solo-lectura .custom-control-input[onClick*="submit"]:not(.boton-informes) {
    pointer-events: none !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}
body.solo-lectura .boton-informes input[type="checkbox"],
body.solo-lectura .boton-informes .custom-control-input {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* También ocultar botones con la clase botonSoloLectura (sistema antiguo) - excepto si tienen href o modal */
body.solo-lectura .botonSoloLectura:not([href]):not([data-toggle="modal"]):not([data-target]),
body.solo-lectura .botonSoloLecturaGeneral:not([href]):not([data-toggle="modal"]):not([data-target]) {
    display: none !important;
}

/* Ocultar botones específicos de gestión de usuarios (tienen prioridad sobre reglas de enlaces) */
body.solo-lectura .btn-mask,
body.solo-lectura a.btn-mask,
body.solo-lectura a.btn-mask[href],
body.solo-lectura #sendPass,
body.solo-lectura a#sendPass,
body.solo-lectura a#sendPass[href] {
    display: none !important;
}

