/* 1. Garante que html e body não passem da altura da tela */
html, body {
    height: 100vh;       /* Força altura exata da viewport */
    overflow: hidden;    /* PROIBE qualquer barra de rolagem */
}

/* 3. Impede que a Nav encolha ou cresça */
.top-nav {
    flex-shrink: 0;
    /* Sugestão: reduza a margem inferior para ganhar espaço */
    margin-bottom: 1rem; 
}

/* 4. Faz o Grid ocupar EXATAMENTE o espaço que sobra */
.dashboard-grid {
    flex-grow: 1;    /* Ocupa todo o espaço restante abaixo da nav */
    height: 100%;    /* Garante que use a altura disponível */
    overflow: hidden; /* Garante que não role internamente também */
    /* Se o conteúdo for maior que a tela, ele será CORTADO aqui.
       Se quiser permitir rolagem SÓ DENTRO DOS CARDS (caso extremo),
       mude para 'overflow: auto;' */
}



/* * =============================================
 * RESET BÁSICO E ESTILOS GLOBAIS
 * =============================================
 */
:root {
    --bg-color: #e3e3e3;
    --card-bg: #FFFFFF;
    --border-color: #DDE3E8;
    --text-primary: #333;
    --text-secondary: #555;
    --text-light: #777;
    --accent-cyan: #28B8A9;
    --accent-blue: #00A2E8;
    --accent-blue-dark: #007ABF;
    --font-family: 'Roboto', sans-serif;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --light-grey-bg: #E0E0E0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-image: linear-gradient(to bottom, #fefefe 0%, #e7e7e7 100%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
}

/* * =============================================
 * NAVEGAÇÃO SUPERIOR (COMPACTA E COM HOVER)
 * =============================================
 */

.nav-title-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 1rem; /* Espaço entre a logo e o texto */
    line-height: 1.3;   /* Deixa as linhas de texto mais próximas */
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 700; /* Negrito */
    color: var(--text-primary); /* Cor escura principal */
}

.nav-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light); /* Cor cinza claro */
    text-transform: uppercase; /* Fica mais profissional para códigos de obra */
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 0 24px;
    box-shadow: var(--shadow);
    position: relative;
    margin-bottom: 1.5rem;
    height: 6rem;
}

.top-nav::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0; 
    width: 100%;        
    height: 0.5rem;    
    background: linear-gradient(
        90deg,         
        var(--accent-cyan),
        var(--accent-blue)
    );
}

.nav-left, .nav-right {
    flex: 1;
    display: flex;
    align-items: center;
}
.nav-right { justify-content: flex-end; gap: 1rem; }
.nav-center {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Espaço entre os botões um pouco menor */
}

.nav-logo-img {
    height: 4.5rem;  /* Altura do logo reduzida */
    width: auto;
}

/* --- BOTÕES PRINCIPAIS (CLIMA / DADOS) --- */
.nav-button.principal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background-color: var(--bg-color); /* Cor base cinza claro */
    color: var(--text-secondary);
    
    /* NOVAS MEDIDAS MAIS COMPACTAS */
    width: 6.55rem;
    height: 3.7rem;
    border-radius: 0.625rem;

    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.nav-button.principal .nav-icon {
    width: 24px;   /* Ícone menor */
    height: 24px;
    margin-bottom: 3px;
    opacity: 0.7;
    transition: all 0.2s ease;
}
.nav-button.principal .nav-icon img {
    width: 100%; height: 100%; object-fit: contain;
}

.nav-button.principal span {
    font-size: 0.85rem; /* Texto menor */
    font-weight: 600;
}

/* --- EFEITO HOVER (QUANDO PASSA O MOUSE) --- */
.nav-button.principal:hover {
    background-color: #e6e9ed; /* Cinza um pouco mais escuro */
    transform: translateY(-3px); /* O botão "pula" para cima */
    color: var(--accent-blue);
}
/* O ícone cresce um pouquinho no hover para dar um "charme" */
.nav-button.principal:hover .nav-icon {
    opacity: 1;
    transform: scale(1.15); 
}

/* --- ESTADO ATIVO (PÁGINA ATUAL) --- */
.nav-button.principal.active {
    background-color: var(--accent-blue) !important;
    color: white !important;
    box-shadow: 0 6px 15px rgba(0, 162, 232, 0.3);
    transform: translateY(-2px); /* Mantém levemente elevado */
}
.nav-button.principal.active .nav-icon {
    opacity: 1;
    filter: brightness(0) invert(1); /* Garante ícone branco */
}

.refresh-button {
    background: var(--bg-color); 
    border: 1px solid var(--border-color);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 1rem;
}

.refresh-button img {
    width: 1.5rem; 
    height: 1.5rem;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.refresh-button:hover {
    
    transform: rotate(180deg);
}
.last-update-text {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.rem;
    color: var(--text-light);
    background: var(--bg-color);
    padding: 0.165rem 0.313rem;
    border-radius: 0.625rem;
    border: 1px solid var(--border-color);
}
/* * =============================================
 * LAYOUT PRINCIPAL
 * =============================================
 */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
        "conforto vento radiacao"
        "acumulado vento status";
    gap: 1.5rem;
    padding: 0.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.widget-card {
    background: linear-gradient(to bottom, var(--card-bg) 0%, #eeeeee 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.widget-card::after {
    content: ""; 
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
        
    background-color: var(--border-color, #c4c9ce); 
        
    height: 0.9rem;       /* Altura da "linha" de sombra */
    filter: blur(0.5rem); /* Desfoca a linha, criando o efeito suave */
}

.widget-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

/* * =============================================
 * Card 1: Sliders de Conforto
 * =============================================
 */
.gauge-slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.gauge-icon {
    width: 46px;
    height: 46px;   
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-radius: 50%;
}

.gauge-slider {
    flex-grow: 1;
}

.gauge-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 4px;
}

.slider-track {    
    width: 100%;
    height: 28px;
    background: var(--light-grey-bg, #E0E0E0);
    border-radius: 28px;
    overflow: hidden;
    border: 6px solid white;
    padding: 1px;
    box-sizing: border-box;    
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-fill {
    height: 100%;
    background: var(--accent-cyan);
    border-radius: 6px;
}

.gauge-value {
    flex-shrink: 0;
    margin-left: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-top: 14px;
    text-align: right;
    width: 80px;
}

.gauge-value span {
    display: block;
}

.accumulated-values {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    align-items: self-start;
}

.accum-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    flex-basis: 0;
}

.accum-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: 100%;
}

.accum-label {
    font-size: 1rem; 
    font-weight: 500;
    color: var(--text-secondary, #333); 
    margin-bottom: 1rem; 
}

.accum-value {
    font-size: 1.1rem; 
    font-weight: 700;    
    color: var(--accent-blue);
}

.gauge-icon.temp-icon img {
    width: 46px;
    height: 46px;
}

.gauge-icon.humidity-icon img {
    width: 32px;
    height: 32px;
}

.gauge-icon.rain-icon img {
    width: 42px;
    height: 42px;
}

.column-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;     
}

.accumulated-data {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.accumulated-title {
    font-size: 1.2rem; 
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.card-fundo-nuvem {
    background-image:
        url('../sprites/nuvem-fundo.png'),
        linear-gradient(to bottom, var(--card-bg) 0%, #e3e3e3 100%);
    background-repeat: no-repeat, no-repeat;
    background-position: -530px -160px, 0 0;
    background-size: 1100px, cover;
}

/* * =============================================
 * Card 2: Medidor Triplo (Vento/Pressão) - REFATORADO
 * =============================================
 */

/* O container principal que define o layout triangular */
.tri-gauge {
    position: relative;
    /* Ajuste o tamanho conforme necessidade */
    width: 300px; 
    height: 260px;
    margin: 2rem auto 0;
    /* Adicionado para os rótulos não cortarem */
    padding-top: 2rem; 
    padding-bottom: 1rem;
}

/* O círculo azul decorativo no centro (mantido como original) */
.tri-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: var(--card-bg, #FFFFFF);
    border: 12px solid var(--accent-blue, #00A2E8); 
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(0, 162, 232, 0.3);
    z-index: 1; 
}

.tri-gauge-bg-image {
    position: absolute;
    top: 95%;
    left: 50%;
    transform: translate(-50%, -50%);

    max-width: 4000px;         
    width: 550%; 
    height: auto;
    z-index: 0; 
    opacity: 0.9; 
}

.tri-node {
    position: absolute; 
    display: flex;
    flex-direction: column; 
    align-items: center;
    z-index: 2; 
    white-space: nowrap;
}

.tri-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light, #777);
    margin-bottom: 0.9rem;
    line-height: 1.2;
    text-align: center;
}

.tri-label-med-vento {       
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light, #777);
    margin-bottom: 0.1rem;
    line-height: 1.2;
    text-align: center;
    transform: rotate(-30deg) translateX(-10px);
    transform-origin: left center;
}

.tri-label-vel-raj {    
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light, #777);
    margin-bottom: 1.5rem;
    line-height: 1.2;
    text-align: center;
    transform: rotate(30deg) translateX(18px);
}

.tri-gauge-circular {
    width: 115px;
    height: 115px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: var(--shadow, 0 4px 12px rgba(0,0,0,0.08));
    
    /* --- REGRAS VITAIS PARA A BARRA DE PROGRESSO --- */
    border: 8px solid transparent; 
    background-origin: border-box;
    background-clip: padding-box, border-box; 
    /* ----------------------------------------------- */

    transition: transform 0.2s ease, --progress 1s ease;
    padding: 10px;
    text-align: center;
}

/* 2. OS NÓS ESPECÍFICOS (AS CORES) */

/* Pressão */
.node-pressure .tri-gauge-circular {
    background-image: 
        linear-gradient(135deg, var(--accent-blue, #00A2E8), var(--accent-cyan, #28B8A9)),
        conic-gradient(#44d4c5 var(--progress, 0%), #ffffff 0%);
}

/* Vento (Média) - Teste com AMARELO/VERMELHO para você ver funcionando */
.node-wind-speed .tri-gauge-circular {
    background-image: 
        linear-gradient(135deg, var(--accent-blue, #00A2E8), var(--accent-cyan, #28B8A9)),
        conic-gradient(#44d4c5 var(--progress, 0%), #ffffff 0%);
}

/* Vento (Rajada) */
.node-wind-gust .tri-gauge-circular {
    background-image: 
        linear-gradient(135deg, var(--accent-blue, #00A2E8), var(--accent-cyan, #28B8A9)),
        conic-gradient(#44d4c5 var(--progress, 0%), #ffffff 0%);
}
.tri-node:hover .tri-gauge-circular {
    transform: translateY(-5px); 
}

.tri-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    margin-top: 0; 
    line-height: 1.1;
}

.tri-unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px; 
}

.node-pressure {
    top: 42px;
    left: 150px;
    transform: translateX(-50%); 
}

.node-wind-speed {
    bottom: -134px;
    left: -32px; 
}

.node-wind-gust {
    bottom: -134px;
    right: -34px; 
}

.status-boxes {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-top: 6rem;
}

.status-box {
    padding: 0.75rem 1rem;
    width: 135px; 
    text-align: center;
    border-radius: 8px;
    background: var(--bg-color, #F0F2F5);
    border: 1px solid var(--border-color, #DDE3E8);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light, #777);
}

/* O container principal das barras */
.signal-strength-meter {
    display: flex;
    align-items: flex-end;
    gap: 5px;              /* AUMENTADO (de 3px) */
    width: 52px;           /* AUMENTADO (de 36px) */
    height: 40px;          /* AUMENTADO (de 24px) */
    margin: 0px auto 0;   /* Mantém o 'auto' para centralizar como base */
    
    /* 👇 ESTA LINHA MOVE O MEDIDOR PARA A DIREITA */
    transform: translateX(5px); /* Ajuste 50px para mais ou menos */
}
/* Estilo base de CADA barra (cinza/desligada) */
.signal-bar {
    width: 10px;                 
    background-color: #ffffff;  
    border-radius: 2px;
    transition: background-color 0.3s ease;
}

.signal-bar:nth-child(1) { height: 10px; }
.signal-bar:nth-child(2) { height: 20px; }
.signal-bar:nth-child(3) { height: 30px; }
.signal-bar:nth-child(4) { height: 40px; }



.signal-strength-meter.sem-sinal .signal-bar:nth-child(1) {
    background-color: #e74c3c;
}

.signal-strength-meter.medio .signal-bar:nth-child(1),
.signal-strength-meter.medio .signal-bar:nth-child(2) {
    background-color: #f39c12;
}

.signal-strength-meter.bom .signal-bar {
    background-color: #2ecc71; 
}

#system-status {
    width: 160px;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    border: 1px solid transparent;
    
    display: flex;
    justify-content: center;
    align-items: center;     
}

#system-status.status-ok {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

#system-status.status-warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}

#system-status.status-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}




/* * =============================================
 * Card 3: Medidor em V (Luz/UV)
 * =============================================
 */
.v-gauge {
    position: relative;
    width: 100%;
    height: 290px; 
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.v-gauge-center {
    position: absolute;
    bottom: 30px;     
    width: 70px; 
    height: 70px;
    transform: translateX(0px);
}

.v-gauge-center img {
    width: 130%;
    height: 130%;
    object-fit: contain;
}

.v-gauge-top-cluster {
    position: absolute;
    top: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    height: 42px;
}

.cluster-left {
    left: 40px;
}

.cluster-right {
    right: -5px;
}

.gauge-icon.indice-uv,
.gauge-icon.luminosidade-icon {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-radius: 50%;
}

.gauge-icon.indice-uv img,
.gauge-icon.luminosidade-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.v-gauge-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-top: 0; 
}

.cluster-left .v-gauge-value {
    text-align: left;
}

.cluster-right .v-gauge-value {
    text-align: right;
}

.v-gauge-arm {
    position: absolute;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    transform-origin: bottom center; 
}

.v-gauge-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    position: absolute;
    bottom: 120px; 
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.v-gauge-track {
    width: 20px;
    height: 280px; 
    background: var(--light-grey-bg);
    border: 6px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse; 
}

.v-gauge-fill {
    width: 100%;
    background: var(--accent-cyan);
    border-radius: 9px;
}

.arm-left {
    transform: translateX(-190px) rotate(30deg);
}

.arm-right {
    transform: translateX(190px) rotate(-30deg);
}

.arm-left .v-gauge-label {
    right: -5px; 
    transform: rotate(-90deg);
}

.arm-right .v-gauge-label {
    left: -20px; 
    transform: rotate(90deg);
}

/* =========================================
   NOVO CARD: STATUS DO SISTEMA
   ========================================= */

.system-info-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1.5rem 0;
    gap: 2rem;
}

.info-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.info-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

#system-status {
    width: 160px;
    height: 62px;
}

.signal-wrapper {
    background: var(--bg-color);
    padding: 0.5rem 1.5rem; 
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px; 
    width: 160px;
}

/* =============================================
 * NOVAS CLASSES DE ESTRUTURA (SUBSTITUINDO INLINE STYLES)
 * =============================================
 */

.dashboard-grid {

    height: calc(100vh - 120px);
    min-height: 800px; 
}

.column-wrapper {
    height: 100%;
}

.widget-full {
    height: 100%;
}

.widget-major {
    flex: 5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.widget-minor {
    flex: 3; 
    display: flex;
    flex-direction: column;
}

/* * =============================================
 * RESPONSIVIDADE
 * =============================================
 */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .top-nav {
        display: none; 
    }
}


/* =========================================
   PÁGINA DE DADOS (DADOS.HTML)
   ========================================= */

.data-page-grid {
    display: grid;
    grid-template-columns: 1fr;
    padding: 1rem 2rem;
    max-width: 1800px;
    margin: 0 auto;
    height: calc(100vh - 100px);
}

@media (min-width: 1200px) {
    .data-page-grid {
        grid-template-columns: 1fr 2fr; 
        grid-template-rows: 1fr; 
    }
}

#map-container {
    height: 400px;
    width: 100%;
    border-radius: 16px; 
    border: none; 
    box-shadow: 0 4px 20px rgba(0, 162, 232, 0.15);
    overflow: hidden; 
}


.table-card {
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

.data-container-wrapper {
    flex-grow: 1;
    overflow: auto;
}

.map-info {
    margin-top: 1rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    justify-content: center;
    background: var(--bg-color);
    padding: 0.5rem;
    border-radius: 8px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.table-stats {
    font-size: 0.9rem;
    color: var(--text-light);
}

.data-table thead th {
    position: sticky;
    top: 0;
    background-color: #ffffff; 
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase; 
    font-size: 0.75rem; 
    padding: 1rem 1.2rem;
    text-align: left;
    border-bottom: 3px solid var(--accent-cyan); 
    z-index: 2;
    white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f8faff; 
}

.data-table tbody tr:hover {
    background-color: #eef6fc; 
}

.data-table tbody td {
    padding: 0.75rem 1.2rem; 
    white-space: nowrap;
    font-size: 0.9rem;
}

td.status-cell {
    text-align: center;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.good, .status-badge.ok {
    background-color: #d4edda; color: #155724; 
}
.status-badge.bad, .status-badge.error, .status-badge.not_found {
    background-color: #f8d7da; color: #721c24; /
}


/* =========================================
   POP-UP DE NOTIFICAÇÃO (TOAST)
   ========================================= */
.toast {
    visibility: hidden; 
    min-width: 250px;
    background-color: #333; 
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed; 
    z-index: 2000;  
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px; 
    font-size: 1rem;
    opacity: 0;
    transition: visibility 0.5s, opacity 0.5s, bottom 0.5s;
}

.toast.warn {
    background-color: var(--accent-cyan); 
    color: #fff;
}


.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px; 
}