/* [4C-IA | 2026-03-26 | architecture-v15 | IFRAME-MODULAR]
   Set Independente de Estilos para Iframes e Modais Sniper.
   Carregado em iframe_modern.blade.php e layouts principais.
*/

/* Reset de Layout para No Sidebar (Iframes) */
body.be-nosidebar-left .be-wrapper {
    background-color: var(--color-bg-page) !important;
}

body.be-nosidebar-left .be-content {
    margin-left: 0 !important;
    padding: var(--sniper-gutter) !important;
}

html.sniper-modal-scroll-lock {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    height: 100% !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    min-height: -webkit-fill-available !important;
}

html.sniper-modal-scroll-lock body {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none;
    margin: 0 !important;
}

html.sniper-modal-scroll-lock .sniper-modal-iframe-show,
html.sniper-modal-scroll-lock .custom_calculator_modal_show,
html.sniper-modal-scroll-lock .custom_iframe_modal_show,
html.sniper-modal-scroll-lock .custom_notifications_modal_show {
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    touch-action: auto !important;
    -webkit-overflow-scrolling: touch;
}

html.sniper-modal-scroll-lock .sniper-modal-iframe-show .sniper-modal-iframe-box,
html.sniper-modal-scroll-lock .custom_calculator_modal_show .custom_calculator_modal_box,
html.sniper-modal-scroll-lock .custom_iframe_modal_show .custom_iframe_modal_box,
html.sniper-modal-scroll-lock .custom_notifications_modal_show .custom_notifications_modal_box {
    touch-action: auto !important;
}

/* Container do Modal de Iframe */
.sniper-modal-iframe,
.custom_calculator_modal,
.custom_iframe_modal,
.custom_notifications_modal {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    will-change: opacity, visibility;

    z-index: 20000 !important;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    display: none; /* Sniper V16: Permite JQuery .show() legado */
    justify-content: center !important;
    align-items: center !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    padding: 20px !important;
}

.sniper-modal-iframe.sniper-modal-iframe-show,
.custom_calculator_modal.custom_calculator_modal_show,
.custom_iframe_modal.custom_iframe_modal_show,
.custom_notifications_modal.custom_notifications_modal_show {
    display: flex !important; /* Sniper V16: Força contexto Flex no Show */
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    isolation: isolate !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
}

.sniper-modal-iframe.sniper-modal-stack-buried,
.custom_calculator_modal.sniper-modal-stack-buried,
.custom_iframe_modal.sniper-modal-stack-buried,
.custom_notifications_modal.sniper-modal-stack-buried {
    padding: 0 !important;
}

.sniper-modal-stack-buried.sniper-modal-iframe .sniper-modal-iframe-box,
.sniper-modal-stack-buried.custom_calculator_modal .custom_calculator_modal_box,
.sniper-modal-stack-buried.custom_iframe_modal .custom_iframe_modal_box,
.sniper-modal-stack-buried.custom_notifications_modal .custom_notifications_modal_box {
    box-shadow: none !important;
    border-radius: 0 !important;
}

.sniper-modal-iframe:not(.sniper-modal-stack-buried)::before,
.custom_calculator_modal:not(.sniper-modal-stack-buried)::before,
.custom_iframe_modal:not(.sniper-modal-stack-buried)::before,
.custom_notifications_modal:not(.sniper-modal-stack-buried)::before {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    min-height: var(--sniper-modal-vh, 100%) !important;
    background: rgba(0, 20, 60, 0.35) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 0 !important;
    pointer-events: none !important;
}

html.sniper-modal-nested-active .sniper-modal-iframe.sniper-modal-stack-buried,
html.sniper-modal-nested-active .custom_iframe_modal.sniper-modal-stack-buried,
html.sniper-modal-nested-active .custom_calculator_modal.sniper-modal-stack-buried {
    isolation: isolate !important;
}

html.sniper-modal-nested-active .sniper-modal-iframe.sniper-modal-stack-buried::after,
html.sniper-modal-nested-active .custom_iframe_modal.sniper-modal-stack-buried::after,
html.sniper-modal-nested-active .custom_calculator_modal.sniper-modal-stack-buried::after {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    min-height: var(--sniper-modal-vh, 100%) !important;
    background: rgba(0, 20, 60, 0.35) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 0 !important;
    pointer-events: none !important;
}

.sniper-modal-iframe:not(.sniper-modal-stack-buried) .sniper-modal-iframe-box,
.custom_calculator_modal:not(.sniper-modal-stack-buried) .custom_calculator_modal_box,
.custom_iframe_modal:not(.sniper-modal-stack-buried) .custom_iframe_modal_box,
.custom_notifications_modal:not(.sniper-modal-stack-buried) .custom_notifications_modal_box,
html.sniper-modal-nested-active .sniper-modal-stack-buried .sniper-modal-iframe-box,
html.sniper-modal-nested-active .sniper-modal-stack-buried .custom_iframe_modal_box,
html.sniper-modal-nested-active .sniper-modal-stack-buried .custom_calculator_modal_box {
    position: relative !important;
    z-index: 2 !important;
}

.sniper-modal-iframe-box .sniper-modal-iframe-close,
.sniper-modal-iframe-box .custom_calculator_modal_close,
.sniper-modal-iframe-box .custom_calculator_modal_close_style,
.custom_calculator_modal_box .custom_calculator_modal_close,
.custom_calculator_modal_box .custom_calculator_modal_close_style,
.custom_iframe_modal_box .custom_iframe_modal_close,
.custom_notifications_modal_box .custom_notifications_modal_header {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    z-index: 10 !important;
    pointer-events: auto !important;
}

.sniper-modal-iframe-close.sniper-modal-close-hidden,
.custom_calculator_modal_close.sniper-modal-close-hidden,
.custom_calculator_modal_close_style.sniper-modal-close-hidden,
.custom_iframe_modal_close.sniper-modal-close-hidden,
.custom_notifications_modal_header.sniper-modal-close-hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}


.btn-block-floating-close,
.sniper-modal-iframe-close button,
.custom_calculator_modal_close button,
.custom_iframe_modal_close button,
.custom_calculator_modal_close_style.custom_calculator_modal_close_alt button,
.custom_notifications_modal_header button {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    z-index: 1 !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: var(--color-bg-white) !important;
    color: var(--color-text-muted) !important;
    border: 1px solid var(--color-border-soft) !important;
    border-radius: 50% !important;
    font-weight: 500 !important;
    text-transform: none !important;
    font-size: 0 !important;
    line-height: 0 !important;
    gap: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

.btn-block-floating-close:hover,
.btn-block-floating-close:focus,
.sniper-modal-iframe-close button:hover,
.sniper-modal-iframe-close button:focus,
.custom_calculator_modal_close button:hover,
.custom_calculator_modal_close button:focus,
.custom_iframe_modal_close button:hover,
.custom_iframe_modal_close button:focus,
.custom_calculator_modal_close_style.custom_calculator_modal_close_alt button:hover,
.custom_calculator_modal_close_style.custom_calculator_modal_close_alt button:focus,
.custom_notifications_modal_header button:hover,
.custom_notifications_modal_header button:focus {
    background: var(--color-bg-hover) !important;
    color: var(--color-text-strong) !important;
    border-color: var(--color-border) !important;
    transform: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.btn-block-floating-close .mdi,
.sniper-modal-iframe-close button .mdi,
.custom_calculator_modal_close button .mdi,
.custom_iframe_modal_close button .mdi,
.custom_calculator_modal_close_style.custom_calculator_modal_close_alt button .mdi,
.custom_notifications_modal_header button .mdi {
    font-size: 18px !important;
    line-height: 1 !important;
    color: inherit !important;
    margin: 0 !important;
}

/* Conteúdo interno do Iframe */
.sniper-modal-iframe-box,
.custom_calculator_modal_box,
.custom_iframe_modal_box,
.custom_notifications_modal_box {
    width: 100% !important;
    height: 100% !important;
    max-width: 1600px !important;
    max-height: 95vh !important;
    background: var(--color-bg-page) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
    overflow: hidden !important;
    position: relative !important;
}

.sniper-iframe-body {
    background-color: var(--color-bg-page) !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Títulos internos de modal (Notificações etc) */
.custom_iframe_modal_header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-bg-light);
}

/* [4C-IA | 2026-03-26 | architecture-v18 | IFRAME-BRIDGE]
   Neutralização de Layout Dashboard dentro de Iframe Sniper.
   Elimina sidebar e header quando o modo dashboard é usado em modal.
*/
.sniper-is-iframe .be-top-header,
.sniper-is-iframe .be-left-sidebar {
    display: none !important;
}

.sniper-is-iframe .be-content {
    margin-left: 0 !important;
    padding-top: 0 !important;
}

.sniper-is-iframe .be-wrapper.be-collapsible-sidebar .be-content {
    margin-left: 0 !important;
}

.sniper-is-iframe .main-content {
    padding: 10px 0 !important;
    margin: 0 !important;
}

html.sniper-is-iframe,
html.sniper-is-iframe body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100% !important;
    position: static !important;
    touch-action: auto !important;
}

html.sniper-is-iframe.sniper-modal-scroll-lock,
html.sniper-is-iframe.sniper-modal-scroll-lock body {
    overflow-y: auto !important;
    position: static !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    min-height: 100% !important;
    touch-action: pan-y !important;
}

html.sniper-modal-iframe-content,
html.sniper-modal-iframe-content body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100% !important;
    position: static !important;
    touch-action: pan-y !important;
    overscroll-behavior: contain;
}

.sniper-modal-iframe-show iframe,
.custom_calculator_modal_show iframe,
.custom_iframe_modal_show iframe {
    pointer-events: auto !important;
}

html.sniper-is-iframe .be-content {
    overflow-y: visible !important;
    min-height: 0 !important;
}

.sniper-is-iframe .be-wrapper {
    padding-top: 0 !important;
}

.j_hmodalifrm_modal__webhook4cShowRequests.sniper-modal-iframe-show .sniper-modal-iframe-box {
    width: min(96vw, 1200px) !important;
    max-width: 1200px !important;
    height: min(92vh, 900px) !important;
    max-height: 92vh !important;
}

.j_hmodalifrm_modal__webhook4cShowRequests.sniper-modal-iframe-show .sniper-modal-iframe-box iframe {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 400px !important;
}

.sniper-is-iframe .j_webhook4c_container .card {
    margin-bottom: 12px !important;
}

.sniper-is-iframe .j_webhook4c_container pre {
    max-height: 200px !important;
    overflow: auto !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
}
