/* --- ESTILOS GERAIS E MODO DARK --- */
body {
    font-family: 'Inter', sans-serif;
    background-color: #F8F9FA;
    transition: background-color 0.3s ease, color 0.3s ease;
}
html.dark body {
    background-color: #111827; /* bg-gray-900 */
    color: #d1d5db; /* text-gray-300 */
}
.panel {
    background-color: white;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
html.dark .panel {
    background-color: #1f2937; /* bg-gray-800 */
    border-color: #374151; /* border-gray-700 */
}
html.dark .text-gray-900 { color: #f9fafb; }
html.dark .text-gray-800 { color: #d1d5db; }
html.dark .text-gray-700 { color: #9ca3af; }
html.dark .text-gray-600 { color: #9ca3af; }
html.dark .text-gray-500 { color: #a1a1aa; }
html.dark .bg-gray-100 { background-color: #374151; }
html.dark .bg-gray-200 { background-color: #4b5563; }
html.dark .hover\:bg-gray-200:hover { background-color: #374151; }
html.dark .divide-y > :not([hidden]) ~ :not([hidden]) { border-color: #4b5563; }
html.dark .border, html.dark .border-t, html.dark .border-l { border-color: #4b5563; }
html.dark input, html.dark select {
    background-color: #374151;
    border-color: #4b5563;
    color: white;
}
html.dark input::placeholder { color: #9ca3af; }

/* Controla a visibilidade das telas principais */
.view { display: none; }
.view.active { display: block; animation: viewFadeIn 0.5s ease-in-out; }
@keyframes viewFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- CABEÇALHO E MENUS --- */
.card { transition: transform 0.3s ease, box-shadow 0.3s ease; }
.card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); }
.header-bg {
    background-size: cover;
    background-position: center;
    min-height: 256px;
    display: flex;
    align-items: center;
    transition: min-height 0.4s ease-in-out;
}
body.is-rotating .header-bg {
    min-height: 128px;
}

.menu-button { transition: all 0.2s ease-in-out; }
.menu-button.active { background-color: #4f46e5; color: white; }
html.dark .menu-button.active { background-color: #6366f1; }

/* Estilo para o Toggle Switch de Rotação */
.toggle-checkbox:checked {
  right: 0;
  border-color: #4f46e5;
}
.toggle-checkbox:checked + .toggle-label {
  background-color: #4f46e5;
}

/* Lógica para ocultar/mostrar elementos durante a rotação */
body.is-rotating #filter-panel { display: none; }
body.is-rotating #minimal-header { display: block; }
body.is-rotating #main-portal-title { display: none; }

/* --- ESTILOS MÓDULO DE ALARMES --- */
#dashboard-menu { 
    position: -webkit-sticky; 
    position: sticky; 
    top: 0; 
    z-index: 20; 
}
/* NOVO: Adiciona uma margem acima do container da tabela para criar o espaçamento */
/*#table-container {
    margin-top: 1rem;  16px de espaço 
}*/

.group-separator th {
    font-weight: 600;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    background-color: #eef2ff;
    color: #312e81;
    text-align: left;
}
html.dark .group-separator th { background-color: #312e81; color: #e0e7ff; }


.filter-input:disabled { background-color: #e5e7eb; cursor: not-allowed; }
html.dark .filter-input:disabled { background-color: #4b5563; }
.alarme-recente { animation: pulse-bg 2s infinite; }
@keyframes pulse-bg {
    0%, 100% { background-color: rgba(254, 249, 195, 0.7); }
    50% { background-color: rgba(254, 249, 195, 1); }
}
html.dark .alarme-recente {
    0%, 100% { background-color: rgba(133, 77, 14, 0.7); }
    50% { background-color: rgba(133, 77, 14, 1); }
}

.copy-btn {
    opacity: 0.5;
    transition: opacity 0.2s ease-in-out;
}
.copy-btn:hover { opacity: 1; }
.copy-btn.copied svg { color: #16a34a !important; }

#temp-card-container { position: absolute; top: -9999px; left: -9999px; }
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 50; }

@media (max-width: 768px) {
    #btn-copiar-imagem {
        display: none;
    }
    #action-buttons-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #tabela-alarmes th, #tabela-alarmes td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    #filter-panel .grid {
        grid-template-columns: 1fr; /* Força os filtros a empilhar */
    }
    #dashboard-menu .container {
        flex-direction: column;
        gap: 0.5rem;
    }
}

body.is-rotating #regional-context-title {
    font-size: 4rem; /* ~text-5xl */
    font-weight: 700;
    transition: font-size 0.3s ease;
}

body:not(.is-rotating) #regional-context-title {
    font-size: 1.5rem; /* ~text-2xl padrão */
    font-weight: 500;
}

#dashboard-header {
  position: relative;
  background-size: cover;
  background-position: center;
}

/* Container onde está o botão e as datas — prioridade maior */
#dashboard-header {
  position: relative;
  background-size: cover;
  background-position: center;
}

/* ALERTA: fixo no rodapé da imagem */
/* Estilo base da caixa de alerta */
#alerta-atualizacao-global {
  position: absolute;
  right: 24px;
  bottom: 8px; /* ou 12px */
  transform: none;
  font-size: 1rem;              /* Aumenta o tamanho da fonte */
  padding: 12px 20px;           /* Aumenta o espaço interno */
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  max-width: none;              /* Remove o limite de largura */
  white-space: nowrap;          /* Impede quebra de linha */
  z-index: 5;
}

/* Estilo para alerta vermelho (alarme desatualizado) */
.alerta-vermelho {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Estilo para alerta verde (sistema atualizado) */
.alerta-verde {
  background-color: transparent !important;
  color: white !important;
  font-size: 0.875rem;
  padding: 0 !important;
  font-weight: 500;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.btn-traducao {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 6px;
    font-size: 1rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-overlay.hidden {
    display: none;
}


#alerta-status-offline {
    position: fixed;
    bottom: 12px;
    right: 12px;
    background-color: rgba(212, 210, 195, 0.377); /* branco translúcido */
    color: #b91c1c; /* vermelho discreto */
    border: 1px solid #fca5a5;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(4px); /* suaviza o fundo */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    z-index: 20;
    pointer-events: none; /* não bloqueia clique nos elementos atrás */
    transition: all 0.3s ease;
}

#popup-info-arquivos.hidden {
  display: none !important;
}


/* ✅ Fallback para cabeçalho da tabela (thead) */
thead {
  background-color: #f3f4f6 !important; /* cinza claro */
  color: #1f2937 !important;           /* texto escuro */
}

/* ✅ Suporte ao modo escuro real */
html.dark thead {
  background-color: #1f2937 !important; /* cinza escuro (bg-gray-800) */
  color: #e5e7eb !important;            /* texto claro (text-gray-200) */
}


.alarme-recente {
    background-color: #ecc86b !important; /* Laranja tipo amber-400 */
    color: #1f2937 !important; /* Cinza escuro - ótimo contraste */
}


/* Remove highlight azul/escuro em Android e Safari */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Neutraliza qualquer fundo no clique */
tr:active,
td:active,
tr:focus,
td:focus,
table:active,
table:focus {
  background-color: inherit !important;
  outline: none !important;
}

/* Garante que tr vazia ou com colSpan fique com fundo claro sempre */
tr td[colspan] {
  background-color: #ffffff !important;
  -webkit-tap-highlight-color: transparent;
}


tr {
  background-color: #ffffff; /* sempre claro no modo padrão */
  transition: background-color 0.3s ease;
}

html.dark tr {
  background-color: #1f2937; /* escuro só no modo dark */
}

/* ✅ Reforça o fundo claro no cabeçalho da tabela em qualquer navegador */
#data-table thead,
#data-table thead tr,
#data-table thead th {
  background-color: #f3f4f6 !important;
  color: #1f2937 !important;
}

html.dark #data-table thead,
html.dark #data-table thead tr,
html.dark #data-table thead th {
  background-color: #1f2937 !important;
  color: #e5e7eb !important;
}

/* ✅ Ajusta a cor do destaque de alarme recente com melhor visibilidade */
.alarme-recente {
  background-color: #f9f78c !important; /* Orange-400 */
  color: #1f2937 !important;
  animation: pulse-bg 2s infinite;
}

html.dark .alarme-recente {
  background-color: #f27e40 !important; /* Orange-600 para modo escuro */
  color: #ffffff !important;
}

/* ✅ Garante que todas as linhas de tabela fiquem claras no modo padrão */
#data-table tr,
#data-table tr td {
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

html.dark #data-table tr,
html.dark #data-table tr td {
  background-color: #1f2937 !important;
  color: #e5e7eb !important;
}

#tabela-alarmes thead,
#tabela-alarmes thead tr,
#tabela-alarmes thead th {
  background-color: #f3f4f6 !important;
  color: #1f2937 !important;
}
html.dark #tabela-alarmes thead,
html.dark #tabela-alarmes thead tr,
html.dark #tabela-alarmes thead th {
  background-color: #1f2937 !important;
  color: #e5e7eb !important;
}

/* Linha selecionada visualmente clara */
tr.linha-selecionada {
  background-color: #ebe9e5c3 !important; /* gray-200 */
}

html.dark tr.linha-selecionada {
  background-color: #374151 !important; /* gray-700 */
}
