/*
==============================================================
IA NEURON — RESPONSIVIDADE GLOBAL
==============================================================
Aplicado somente após o JavaScript adicionar:
html.neuron-responsive-ready
body.neuron-responsive-ready
==============================================================
*/

html.neuron-responsive-ready,
body.neuron-responsive-ready {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

html.neuron-responsive-ready *,
html.neuron-responsive-ready *::before,
html.neuron-responsive-ready *::after {
    box-sizing: border-box;
}

body.neuron-responsive-ready img,
body.neuron-responsive-ready video,
body.neuron-responsive-ready canvas,
body.neuron-responsive-ready svg {
    max-width: 100%;
    height: auto;
}

body.neuron-responsive-ready input,
body.neuron-responsive-ready select,
body.neuron-responsive-ready textarea,
body.neuron-responsive-ready button {
    max-width: 100%;
}

/* Evita que containers internos ultrapassem a tela */
body.neuron-responsive-ready main,
body.neuron-responsive-ready .main,
body.neuron-responsive-ready .content,
body.neuron-responsive-ready .main-content,
body.neuron-responsive-ready .page-content,
body.neuron-responsive-ready .content-wrapper,
body.neuron-responsive-ready .page-wrapper,
body.neuron-responsive-ready .produto-content,
body.neuron-responsive-ready .product-content,
body.neuron-responsive-ready .produto-wrapper,
body.neuron-responsive-ready .product-wrapper,
body.neuron-responsive-ready .container,
body.neuron-responsive-ready .container-fluid,
body.neuron-responsive-ready .dashboard-content,
body.neuron-responsive-ready .historico-container,
body.neuron-responsive-ready .robot-history-main-content {
    min-width: 0;
    max-width: 100%;
}

/* Tabelas ganham rolagem própria, sem arrastar a página inteira */
body.neuron-responsive-ready .neuron-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #243b61 #07101f;
    border-radius: inherit;
}

body.neuron-responsive-ready .neuron-table-scroll::-webkit-scrollbar {
    height: 6px;
}

body.neuron-responsive-ready .neuron-table-scroll::-webkit-scrollbar-track {
    background: #07101f;
    border-radius: 20px;
}

body.neuron-responsive-ready .neuron-table-scroll::-webkit-scrollbar-thumb {
    background: #243b61;
    border-radius: 20px;
}

body.neuron-responsive-ready .neuron-table-scroll table {
    margin: 0;
}

/* Modais nunca ultrapassam a tela */
body.neuron-responsive-ready [role="dialog"],
body.neuron-responsive-ready .modal,
body.neuron-responsive-ready .modal-content,
body.neuron-responsive-ready .nxm-modal,
body.neuron-responsive-ready .nz-modal,
body.neuron-responsive-ready .z2-modal,
body.neuron-responsive-ready .wizard-modal {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
}

/* Menu mobile global */
#neuron-global-mobile-menu-button {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    z-index: 100050;
    width: 44px;
    height: 44px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(71, 137, 230, .55);
    border-radius: 11px;
    background: #0b172a;
    color: #ffffff;
    font-size: 19px;
    line-height: 1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .30);
    cursor: pointer;
}

#neuron-global-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99980;
    background: rgba(2, 8, 18, .72);
    backdrop-filter: blur(2px);
}

/* ==========================================================
   TABLET
   ========================================================== */
@media (max-width: 1100px) {
    body.neuron-responsive-ready .cards,
    body.neuron-responsive-ready .cards-grid,
    body.neuron-responsive-ready .top-cards,
    body.neuron-responsive-ready .dashboard-grid,
    body.neuron-responsive-ready .dados-grid,
    body.neuron-responsive-ready .nexus-grid,
    body.neuron-responsive-ready .zion-grid,
    body.neuron-responsive-ready .summary-grid,
    body.neuron-responsive-ready .resumo-grid,
    body.neuron-responsive-ready .filter-grid,
    body.neuron-responsive-ready .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ==========================================================
   CELULAR E TABLET ESTREITO
   ========================================================== */
@media (max-width: 900px) {
    html.neuron-responsive-ready,
    body.neuron-responsive-ready {
        overflow-x: hidden !important;
    }

    #neuron-global-mobile-menu-button {
        display: flex;
    }

    /* Sidebar identificada pelo JS */
    body.neuron-responsive-ready .neuron-global-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        z-index: 100000 !important;
        width: min(286px, 86vw) !important;
        min-width: min(286px, 86vw) !important;
        max-width: min(286px, 86vw) !important;
        height: 100vh !important;
        margin: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        transform: translateX(-105%) !important;
        transition: transform .24s ease !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: #07101f !important;
        box-shadow: 18px 0 40px rgba(0, 0, 0, .42) !important;
    }

    body.neuron-responsive-ready.neuron-mobile-menu-open
    .neuron-global-sidebar {
        transform: translateX(0) !important;
    }

    body.neuron-responsive-ready.neuron-mobile-menu-open
    #neuron-global-mobile-overlay {
        display: block;
    }

    /* Área principal passa a ocupar toda a tela */
    body.neuron-responsive-ready .neuron-global-main-content,
    body.neuron-responsive-ready .robot-history-main-content,
    body.neuron-responsive-ready main,
    body.neuron-responsive-ready .main-content,
    body.neuron-responsive-ready .page-content,
    body.neuron-responsive-ready .content-wrapper,
    body.neuron-responsive-ready .produto-content,
    body.neuron-responsive-ready .product-content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
    }

    body.neuron-responsive-ready .neuron-global-main-content {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-top: 70px !important;
    }

    /* Cabeçalhos */
    body.neuron-responsive-ready header,
    body.neuron-responsive-ready .header,
    body.neuron-responsive-ready .page-header,
    body.neuron-responsive-ready .produto-header,
    body.neuron-responsive-ready .product-header,
    body.neuron-responsive-ready .topbar,
    body.neuron-responsive-ready .top-bar {
        max-width: 100% !important;
        min-width: 0 !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    /* Todos os grids principais viram uma coluna */
    body.neuron-responsive-ready .cards,
    body.neuron-responsive-ready .cards-grid,
    body.neuron-responsive-ready .top-cards,
    body.neuron-responsive-ready .dashboard-grid,
    body.neuron-responsive-ready .dados-grid,
    body.neuron-responsive-ready .nexus-grid,
    body.neuron-responsive-ready .zion-grid,
    body.neuron-responsive-ready .summary-grid,
    body.neuron-responsive-ready .resumo-grid,
    body.neuron-responsive-ready .filter-grid,
    body.neuron-responsive-ready .filters-grid,
    body.neuron-responsive-ready .historico-filtros,
    body.neuron-responsive-ready .historico-resumo,
    body.neuron-responsive-ready .nxm-grid,
    body.neuron-responsive-ready .nz-grid,
    body.neuron-responsive-ready .z2-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Cards não mantêm largura de desktop */
    body.neuron-responsive-ready .card,
    body.neuron-responsive-ready [class*="-card"],
    body.neuron-responsive-ready [class*="_card"],
    body.neuron-responsive-ready .panel,
    body.neuron-responsive-ready .box {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Linhas flexíveis */
    body.neuron-responsive-ready .row,
    body.neuron-responsive-ready .actions,
    body.neuron-responsive-ready .action-row,
    body.neuron-responsive-ready .button-row,
    body.neuron-responsive-ready .buttons,
    body.neuron-responsive-ready .nexus-actions,
    body.neuron-responsive-ready .zion-actions,
    body.neuron-responsive-ready .nxm-actions,
    body.neuron-responsive-ready .nz-actions,
    body.neuron-responsive-ready .z2-actions {
        max-width: 100% !important;
        flex-wrap: wrap !important;
    }

    /* Formulários */
    body.neuron-responsive-ready form,
    body.neuron-responsive-ready fieldset {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    body.neuron-responsive-ready input:not([type="checkbox"]):not([type="radio"]),
    body.neuron-responsive-ready select,
    body.neuron-responsive-ready textarea {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Botões de ação em largura confortável */
    body.neuron-responsive-ready .btn-main,
    body.neuron-responsive-ready .btn-primary,
    body.neuron-responsive-ready .btn-iniciar,
    body.neuron-responsive-ready .btn-iniciar-ia,
    body.neuron-responsive-ready #btn-nexus-start,
    body.neuron-responsive-ready #btn-zion-start {
        width: 100% !important;
        max-width: 100% !important;
        justify-content: center !important;
    }

    /* Tabelas preservam colunas, mas rolam dentro do card */
    body.neuron-responsive-ready .neuron-table-scroll table {
        width: max-content !important;
        min-width: 880px !important;
    }

    /* Modais */
    body.neuron-responsive-ready [role="dialog"],
    body.neuron-responsive-ready .modal,
    body.neuron-responsive-ready .modal-content,
    body.neuron-responsive-ready .nxm-modal,
    body.neuron-responsive-ready .nz-modal,
    body.neuron-responsive-ready .z2-modal,
    body.neuron-responsive-ready .wizard-modal {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 20px) !important;
        margin: 10px auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body.neuron-responsive-ready .modal-body,
    body.neuron-responsive-ready .nxm-body,
    body.neuron-responsive-ready .nz-body,
    body.neuron-responsive-ready .z2-body {
        max-height: calc(100vh - 170px) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* Títulos */
    body.neuron-responsive-ready h1 {
        font-size: clamp(25px, 8vw, 34px) !important;
        line-height: 1.12 !important;
        overflow-wrap: anywhere;
    }

    body.neuron-responsive-ready h2 {
        font-size: clamp(21px, 6vw, 29px) !important;
        line-height: 1.15 !important;
        overflow-wrap: anywhere;
    }

    body.neuron-responsive-ready h3 {
        overflow-wrap: anywhere;
    }
}

/* ==========================================================
   CELULAR PEQUENO
   ========================================================== */
@media (max-width: 520px) {
    body.neuron-responsive-ready .neuron-global-main-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body.neuron-responsive-ready .card,
    body.neuron-responsive-ready [class*="-card"],
    body.neuron-responsive-ready [class*="_card"],
    body.neuron-responsive-ready .panel,
    body.neuron-responsive-ready .box {
        border-radius: 12px !important;
    }

    body.neuron-responsive-ready button,
    body.neuron-responsive-ready .btn {
        min-height: 44px;
    }

    body.neuron-responsive-ready .neuron-table-scroll table {
        min-width: 820px !important;
    }
}

/* NEURON_MOBILE_REAL_FIX_START */

/*
==============================================================
CORREÇÃO REAL DE RESPONSIVIDADE
NEXUS / ZION / HISTÓRICO / PAINEL
==============================================================
*/

html,
body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
}

/* Impede elementos internos de forçarem largura desktop */
body *,
body *::before,
body *::after {
    box-sizing: border-box !important;
    min-width: 0;
}

/* Tabelas ficam roláveis dentro do próprio bloco */
.neuron-table-scroll {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(73, 94, 160, .55) transparent;
}

.neuron-table-scroll::-webkit-scrollbar {
    height: 4px;
}

.neuron-table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.neuron-table-scroll::-webkit-scrollbar-thumb {
    background: rgba(73, 94, 160, .55);
    border-radius: 999px;
}

@media screen and (max-width: 768px) {

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    /*
    ==========================================================
    CONTEÚDO PRINCIPAL
    ==========================================================
    */

    body > main,
    body > .main,
    body > .content,
    body > .container,
    body > .page,
    body > .wrapper,
    main,
    .main,
    .main-content,
    .content,
    .content-area,
    .page,
    .page-content,
    .page-wrapper,
    .app-content,
    .dashboard-content,
    .produto-content,
    .produto-main,
    .layout-content,
    .neuron-main,
    #main,
    #main-content,
    #content,
    #app {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        transform: none !important;
        overflow-x: hidden !important;
    }

    /*
    ==========================================================
    CABEÇALHO
    ==========================================================
    */

    header,
    .header,
    .topbar,
    .produto-header,
    .page-header,
    .header-content,
    .top-header,
    .neuron-header {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .produto-header,
    .page-header,
    .header-content,
    .topbar,
    .top-header {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        align-items: flex-start !important;
    }

    /*
    ==========================================================
    CARDS DO TOPO
    ==========================================================
    */

    .cards,
    .cards-grid,
    .top-cards,
    .produto-cards,
    .dashboard-grid,
    .summary-grid,
    .resumo-grid,
    .stats-grid,
    .metric-grid,
    .nexus-top-grid,
    .zion-top-grid,
    [class*="cards-topo"],
    [class*="top-cards"] {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 10px !important;
    }

    .card,
    .produto-card,
    .summary-card,
    .stat-card,
    .metric-card,
    .neuron-card,
    .nexus-card,
    .zion-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /*
    ==========================================================
    PAINEL PRINCIPAL DOS ROBÔS
    ==========================================================
    */

    .panel,
    .main-panel,
    .produto-panel,
    .produto-box,
    .nexus-panel,
    .zion-panel,
    .nexus-main-box,
    .zion-main-box,
    #nexus-live-box,
    #zion-live-box,
    #nexus-contract-info,
    #zion-contract-info {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow: hidden !important;
    }

    /*
    ==========================================================
    BOTÕES
    ==========================================================
    */

    #btn-nexus-start,
    #btn-zion-start,
    #nxl-stop,
    #zion-live-box button,
    #nexus-live-box button,
    .btn-main,
    .nexus-actions button,
    .zion-actions button {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        justify-content: center !important;
        align-items: center !important;
        white-space: normal !important;
        text-align: center !important;
    }

    /*
    ==========================================================
    TABELAS
    ==========================================================
    */

    table {
        width: max-content !important;
        min-width: 880px !important;
        max-width: none !important;
        margin: 0 !important;
    }

    table th,
    table td {
        white-space: nowrap !important;
    }

    .table-container,
    .table-wrapper,
    .historico-table,
    .historico-wrapper,
    .tabela-container,
    .responsive-table {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /*
    ==========================================================
    MODAIS
    ==========================================================
    */

    .modal,
    .modal-content,
    .nxm-modal,
    .nz-modal,
    .z2-modal,
    [role="dialog"] {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        min-width: 0 !important;
        max-height: calc(100vh - 20px) !important;
        margin: 10px auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /*
    ==========================================================
    TEXTOS LONGOS
    ==========================================================
    */

    p,
    span,
    strong,
    small,
    div,
    td,
    th {
        overflow-wrap: anywhere;
        word-break: normal;
    }
}

@media screen and (max-width: 480px) {

    main,
    .main,
    .main-content,
    .content,
    .content-area,
    .page-content,
    .produto-content,
    .produto-main {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .card,
    .produto-card,
    .summary-card,
    .stat-card,
    .metric-card,
    .panel,
    .produto-panel,
    #nexus-live-box,
    #zion-live-box {
        border-radius: 12px !important;
    }

    h1 {
        font-size: 26px !important;
        line-height: 1.15 !important;
    }

    h2 {
        font-size: 20px !important;
        line-height: 1.2 !important;
    }

    h3 {
        font-size: 17px !important;
    }
}

/* NEURON_MOBILE_REAL_FIX_END */


/* IANEURON_UNIFIED_DRAWER_MENU_V1 */
@media (max-width: 900px) {
  body.neuron-responsive-ready { padding-left:0 !important; padding-bottom:0 !important; }
  body.neuron-responsive-ready .neuron-global-sidebar { display:block !important; top:0 !important; right:auto !important; bottom:0 !important; left:0 !important; width:min(286px,86vw) !important; min-width:min(286px,86vw) !important; max-width:min(286px,86vw) !important; height:100dvh !important; padding:0 !important; border-top:0 !important; border-right:1px solid rgba(0,255,208,.18) !important; overflow-y:auto !important; overflow-x:hidden !important; background:linear-gradient(180deg,#071426,#030a14) !important; }
  body.neuron-responsive-ready .neuron-global-sidebar .neuron-brand { display:flex !important; min-height:86px !important; justify-content:flex-start !important; padding:18px !important; }
  body.neuron-responsive-ready .neuron-global-sidebar .neuron-brand > div:not(.neuron-brand-icon), body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu-section, body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu a span, body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu-disabled span, body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu-disabled small { display:block !important; }
  body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu { display:block !important; height:auto !important; min-height:0 !important; padding:14px 10px 24px !important; }
  body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu a, body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu a:nth-of-type(n+6) { display:flex !important; width:100% !important; min-height:44px !important; justify-content:flex-start !important; padding:10px 12px !important; }
  body.neuron-responsive-ready .neuron-global-sidebar .neuron-menu a i { flex:0 0 22px !important; width:22px !important; font-size:1rem !important; }
  body.neuron-responsive-ready.neuron-mobile-menu-open { overflow:hidden !important; }
  body.neuron-responsive-ready.neuron-mobile-menu-open #neuron-global-mobile-menu-button { left:min(230px,calc(86vw - 56px)) !important; }
}
