/* ==========================================================================
   SEGURIDAD ACUA - SISTEMA DE PROTECCIÓN Y CONTROL DE FRAUDE (CSS)
   ========================================================================== */

/* Bloqueo de copia y selección de texto en todo el body exceptuando elementos de entrada */
body.usuario-restringido *:not(input):not(textarea):not(select):not(option):not([contenteditable="true"]):not(.select2-search__field) {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Excluir campos de formulario editables para no afectar usabilidad y asegurar selección */
body.usuario-restringido input, 
body.usuario-restringido textarea, 
body.usuario-restringido select, 
body.usuario-restringido [contenteditable="true"], 
body.usuario-restringido .select2-search__field {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Permitir selección de texto en SweetAlert2 popups, inputs y textareas de SweetAlert */
.swal2-container,
.swal2-popup,
.swal2-textarea,
.swal2-input,
.swal2-html-container,
.swal2-content {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Asegurar selección de texto explícita en las zonas permitidas (presupuesto, filtros y creación de producto) */
body.usuario-restringido #tabla-presupuesto-contenedor, 
body.usuario-restringido #tabla-presupuesto-contenedor *,
body.usuario-restringido .acuaWOO, 
body.usuario-restringido .acuaWOO *,
body.usuario-restringido #form-nuevo-producto,
body.usuario-restringido #form-nuevo-producto *,
body.usuario-restringido #mensaje-cotizar,
body.usuario-restringido #mensaje-cotizar * {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Blindar la impresión directa del presupuesto (a menos que se permita explícitamente) */
@media print {
    body.usuario-restringido:not(.permitir-impresion) {
        display: none !important;
    }
}

/* Estilos de la marca de agua dinámica en overlay */
#marca-agua-seguridad {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: 2147483647 !important;
    background-repeat: repeat !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Geometría interactiva y visual de la vista previa del PDF */
#preview-pdf-container {
    max-height: 850px;
    overflow-y: auto !important;
    position: relative;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #525659; /* Fondo clásico para contraste de PDF */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Cabecera del visor con controles flotantes premium */
.pdf-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2b303b;
    padding: 10px 15px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    position: sticky;
    top: 0;
    z-index: 1000000;
}

/* Controles de Zoom en HTML */
.pdf-zoom-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-zoom {
    background: #4f5b66;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-zoom:hover {
    background: #65737e;
}

.btn-zoom:active {
    transform: scale(0.95);
}

/* Ajustes de transiciones de escala de hardware para el zoom */
#preview-pdf {
    transform-origin: top center;
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.25s ease;
}

#pdf-blocker {
    transform-origin: top center;
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.25s ease;
}

/* ==========================================================================
   RESTRICCIONES PARA MODO RÉPLICA PROTEGIDA (PRESUPUESTOS COMPARTIDOS)
   ========================================================================== */

/* Bloqueo total de interacción para los datos de cliente (PARA TODOS, INCLUYENDO EXENTOS/ADMINS) */
body.modo-replica-activo #empresa,
body.modo-replica-activo #rif_numero,
body.modo-replica-activo #direccion,
body.modo-replica-activo #telefono,
body.modo-replica-activo #persona_contacto,
body.modo-replica-activo #apellido_contacto,
body.modo-replica-activo #email_contacto {
    pointer-events: none !important;
    background-color: #f1f1f1 !important;
    cursor: not-allowed !important;
}

/* Bloqueo de Select2 de Google Contacts (PARA TODOS, INCLUYENDO EXENTOS/ADMINS) */
body.modo-replica-activo #contacto_google {
    pointer-events: none !important;
}
body.modo-replica-activo .select2-container {
    pointer-events: none !important;
    opacity: 0.65 !important;
}

/* Ocultar botones de acción de contactos en modo réplica (PARA TODOS, INCLUYENDO EXENTOS/ADMINS) */
body.modo-replica-activo #refrescar-contactos,
body.modo-replica-activo #crear-contacto,
body.modo-replica-activo #actualizar-contacto,
body.modo-replica-activo #limpiarFormulario,
body.modo-replica-activo .btn-refrescar-contactos,
body.modo-replica-activo .btn-crear-contacto,
body.modo-replica-activo .btn-actualizar-contacto {
    display: none !important;
}

/* Bloqueo de Adición de Productos (Buscador, Tienda, acuaWoo, Creación) (SOLO PARA ASESORES RESTRINGIDOS) */
body.modo-replica-bloqueo-catalogo .dg-wt-container,
body.modo-replica-bloqueo-catalogo .dg-wt-search-form,
body.modo-replica-bloqueo-catalogo .fibo-search-wrapper,
body.modo-replica-bloqueo-catalogo [class*="fibosearch"],
body.modo-replica-bloqueo-catalogo .boton-ir-tienda1,
body.modo-replica-bloqueo-catalogo #toggleNuevoProducto,
body.modo-replica-bloqueo-catalogo #form-nuevo-producto,
body.modo-replica-bloqueo-catalogo .acuaWOO {
    display: none !important;
}

/* Bloqueo de Modificación de la Tabla (Cantidades, Eliminación y Vaciado) (SOLO PARA ASESORES RESTRINGIDOS) */
body.modo-replica-bloqueo-catalogo .cantidad-producto {
    pointer-events: none !important;
    background-color: #f1f1f1 !important;
    cursor: not-allowed !important;
}
body.modo-replica-bloqueo-catalogo .boton-eliminar,
body.modo-replica-bloqueo-catalogo .btn-limpiar:not(#vaciar-replica-btn),
body.modo-replica-bloqueo-catalogo #vaciar-tabla-btn,
body.modo-replica-bloqueo-catalogo td.col-accion,
body.modo-replica-bloqueo-catalogo th.col-accion {
    display: none !important;
}

/* Bloqueo de Opciones Financieras y Checkboxes Adicionales (Flete y Revendedor) (SOLO PARA ASESORES RESTRINGIDOS) */
body.modo-replica-bloqueo-catalogo .checkbox-flete,
body.modo-replica-bloqueo-catalogo #revendedor {
    pointer-events: none !important;
    opacity: 0.65 !important;
}
body.modo-replica-bloqueo-catalogo .flete-label,
body.modo-replica-bloqueo-catalogo label[for="revendedor"] {
    pointer-events: none !important;
    cursor: not-allowed !important;
}

