/* 
   Estilos para garantir que elementos com posição fixa,
   como o cabeçalho e a logo do sistema, não sejam afetados por mudanças no layout
   v2.0 - Logo sempre clicável e funcional
*/

/* Preserva as margens e espaços quando formulários são mostrados/ocultados */
body {
    overflow-x: hidden;
    padding-right: 0 !important; /* Evita que o padding seja alterado */
    padding-top: 90px !important; /* Espaço para o cabeçalho fixo */
}

/* Certifica que a logo sempre fica no mesmo lugar, independente de mudanças no layout */
#headerLogo {
    position: absolute !important;
    left: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10000 !important;
    height: 55px !important; /* Altura aumentada */
    width: auto !important;
    display: block !important;
    max-width: none !important;
    vertical-align: middle !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Certifica que o cabeçalho fixo não é afetado por alterações de layout */
.header-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
    padding-right: 0 !important; /* Evita ajustes automáticos de padding */
    height: 70px !important;
    background-color: #1a1e21 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 10px 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Garante que o container flex está posicionado corretamente */
.header-container .d-flex {
    position: relative !important;
    justify-content: space-between !important;
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    align-items: center !important;
}

/* Certifica que o título fica centralizado */
.header-title {
    display: flex !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    text-indent: 0 !important; /* Garante que não haja indentação */
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    z-index: 1002 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 1.5rem !important;
    pointer-events: none !important; /* Impede que o título interfira nos cliques da logo */
}

/* Logo container sempre centralizado verticalmente */
.logo-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 55px !important;
    height: 55px !important;
    position: absolute !important;
    left: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10001 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    text-decoration: none !important;
}

.logo-container:hover {
    opacity: 0.8 !important;
}

.header-logo, #headerLogo {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Centralização específica para telas de formulário */
body.form-active .header-container,
body:has(#formCard[style*="display: block"]) .header-container,
body:has(#formCard:not([style*="display: none"])) .header-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 70px !important;
    z-index: 1000 !important;
    background-color: #1a1e21 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 10px 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Logo e título centralizados quando formulário está ativo */
body.form-active .logo-container,
body.form-active #headerLogo,
body.form-active .header-title,
body:has(#formCard[style*="display: block"]) .logo-container,
body:has(#formCard[style*="display: block"]) #headerLogo,
body:has(#formCard[style*="display: block"]) .header-title,
body:has(#formCard:not([style*="display: none"])) .logo-container,
body:has(#formCard:not([style*="display: none"])) #headerLogo,
body:has(#formCard:not([style*="display: none"])) .header-title {
    position: absolute !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Especificamente para logo quando formulário ativo */
body.form-active .logo-container,
body:has(#formCard[style*="display: block"]) .logo-container,
body:has(#formCard:not([style*="display: none"])) .logo-container {
    left: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10001 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 55px !important;
    height: 55px !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    text-decoration: none !important;
}

/* Garantir que a logo seja clicável em todos os estados */
body.form-active .logo-container:hover,
body:has(#formCard[style*="display: block"]) .logo-container:hover,
body:has(#formCard:not([style*="display: none"])) .logo-container:hover {
    opacity: 0.8 !important;
}

body.form-active .header-logo,
body.form-active #headerLogo,
body:has(#formCard[style*="display: block"]) .header-logo,
body:has(#formCard[style*="display: block"]) #headerLogo,
body:has(#formCard:not([style*="display: none"])) .header-logo,
body:has(#formCard:not([style*="display: none"])) #headerLogo {
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 10000 !important;
}

/* Especificamente para título quando formulário ativo */
body.form-active .header-title,
body:has(#formCard[style*="display: block"]) .header-title,
body:has(#formCard:not([style*="display: none"])) .header-title {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1002 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    text-align: center !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 1.5rem !important;
    pointer-events: none !important; /* Impede que o título interfira nos cliques da logo */
}

/* Quando o formulário está visível, garante que o cabeçalho não seja afetado */
body.form-active .header-container,
body:has(#formCard[style*="display: block"]) .header-container {
    padding-right: 0 !important;
}

/* Impede que o conteúdo do formulário afete o posicionamento do cabeçalho */
#formCard {
    position: relative;
    z-index: 40; /* Menor que o z-index do cabeçalho */
    margin-top: 20px; /* Espaço extra após o cabeçalho fixo */
}

/* Garante que elementos fixos não sejam afetados por formulários modais */
.modal-open .header-container,
.modal-open #headerLogo {
    padding-right: 0 !important;
}

/* Ajustes para diferentes componentes da página com cabeçalho fixo */
.container.mt-4 {
    margin-top: 0 !important; /* Remove margem superior desnecessária */
}

/* Garante espaço adequado para as tabelas com cabeçalho fixo */
.table-responsive {
    margin-top: 10px;
}

/* Centralização específica do rodapé para telas de formulário */
body.form-active .footer,
body:has(#formCard[style*="display: block"]) .footer,
body:has(#formCard:not([style*="display: none"])) .footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 50px !important;
    background-color: #f8f9fa !important;
    border-top: 1px solid #dee2e6 !important;
    z-index: 9999 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05) !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Container do rodapé com centralização perfeita para formulários */
body.form-active .footer .container,
body:has(#formCard[style*="display: block"]) .footer .container,
body:has(#formCard:not([style*="display: none"])) .footer .container {
    padding: 0 !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 1400px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
}

/* Flex do rodapé centralizado para formulários */
body.form-active .footer .d-flex,
body:has(#formCard[style*="display: block"]) .footer .d-flex,
body:has(#formCard:not([style*="display: none"])) .footer .d-flex {
    height: 100% !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: space-between !important;
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Desenvolvedor centralizado verticalmente para formulários */
body.form-active .footer .developer-credit,
body:has(#formCard[style*="display: block"]) .footer .developer-credit,
body:has(#formCard:not([style*="display: none"])) .footer .developer-credit {
    font-size: 0.8rem !important;
    opacity: 0.6 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

/* Empresa centralizada verticalmente para formulários */
body.form-active .footer span.text-muted:not(.developer-credit),
body:has(#formCard[style*="display: block"]) .footer span.text-muted:not(.developer-credit),
body:has(#formCard:not([style*="display: none"])) .footer span.text-muted:not(.developer-credit) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    height: 100% !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle !important;
}

/* Todos os elementos internos do rodapé centralizados para formulários */
body.form-active .footer *,
body:has(#formCard[style*="display: block"]) .footer *,
body:has(#formCard:not([style*="display: none"])) .footer * {
    vertical-align: middle !important;
    line-height: 1 !important;
}

/* Ícones do rodapé centralizados para formulários */
body.form-active .footer i,
body:has(#formCard[style*="display: block"]) .footer i,
body:has(#formCard:not([style*="display: none"])) .footer i {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    margin-right: 0.25rem !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Estilos para links da empresa */
.footer a.text-muted {
    transition: color 0.3s ease !important;
}

.footer a.text-muted:hover {
    color: #007bff !important;
    text-decoration: underline !important;
}

/* Informações do usuário no canto superior direito */
.user-info-header {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1003 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.user-info-header .user-greeting {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.875rem !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    background: none !important;
    border: none !important;
}

.user-info-header span {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.875rem !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    background: none !important;
    border: none !important;
}

.user-info-header strong {
    color: #ffffff !important;
    font-weight: 600 !important;
    margin-left: 4px !important;
}

.user-info-header .btn {
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    border-radius: 4px !important;
    line-height: 1 !important;
    min-width: 32px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    background-color: transparent !important;
    color: rgba(255, 255, 255, 0.8) !important;
}

.user-info-header .btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: #ffffff !important;
}

/* Garantir que apenas o novo estilo apareça */
.user-info-header > span,
.user-info-header > .user-greeting {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Regras específicas para módulos SMT e THT */
body .header-container .user-info-header {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1003 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: transparent !important;
    border: none !important;
}

body .header-container .user-info-header .user-greeting,
body .header-container .user-info-header > span {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.875rem !important;
    display: inline-flex !important;
    align-items: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    white-space: nowrap !important;
}

body .header-container .user-info-header strong {
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* Forçar remoção de estilos conflitantes */
.user-info-header .small,
.user-info-header .text-white-50,
.user-info-header .d-flex.align-items-center.gap-2 {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Ocultar qualquer texto de usuário antigo que possa estar aparecendo */
.header-container *:contains("Usuário:"),
.header-container span[class*="text-white"],
.header-container .small:not(.user-greeting),
.header-container .text-white-50:not(.user-greeting),
header *:contains("admin"),
.header-container .d-flex.align-items-center.gap-2:not(.user-info-header) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Permitir apenas o elemento user-info-header específico */
.header-container .user-info-header.user-info-header {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Garantir que o container flex do cabeçalho funcione corretamente */
.header-container .container .d-flex {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* Remover elementos criados pelos scripts antigos dos módulos */
.user-info,
div[style*="position: fixed"][style*="top: 10px"][style*="right: 10px"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    z-index: -999 !important;
}

/* Estilos específicos para o botão de logout */
.logout-btn {
    transition: all 0.3s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    background-color: transparent !important;
    color: white !important;
    min-width: 40px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.8) !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

.logout-btn:active {
    transform: translateY(0) !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.logout-btn:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.logout-btn .logout-text {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
}

/* Responsividade para o botão de logout */
@media (max-width: 768px) {
    .logout-btn {
        min-width: 36px !important;
        height: 28px !important;
    }
    
    .logout-btn .logout-text {
        display: none !important;
    }
}

/* Forçar remoção de qualquer div que contenha "Usuário:" */
div:contains("Usuário:") {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}