/* stylesAcao.css - Versão Final Limpa (Anti-Loop) */

:root {
    --dash-bg: #f4f6f9;
    --dash-card-bg: #ffffff;
    --dash-primary: #2c3e50;
    --dash-accent: #3498db;
    --dash-danger: #e74c3c;
    --dash-text: #333;
    --dash-text-light: #7f8c8d;
}

/* Botão no Header Principal */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.btn-dashboard-top {
    background-color: var(--dash-accent);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.btn-dashboard-top:hover { background-color: #2980b9; }

/* Modal Dashboard */
.modal-dashboard {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-dashboard.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-dashboard-content {
    background: var(--dash-bg);
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cabeçalho */
.dash-header {
    background: var(--dash-primary);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Impede encolhimento */
}

.dash-title-area {
    display: flex;
    align-items: center;
    gap: 20px;
}

.dash-header h2 { margin: 0; font-size: 1.2rem; }

.dash-select {
    padding: 5px 10px;
    border-radius: 4px;
    border: none;
    background: white;
    color: var(--dash-primary);
    font-weight: bold;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Corpo */
.dash-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* KPIs */
.dash-grid-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    flex-shrink: 0;
}

.kpi-card.small {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--dash-card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.kpi-card.small .kpi-info label { font-size: 0.75rem; margin-bottom: 2px; color: var(--dash-text-light); }
.kpi-card.small .kpi-info span { font-size: 1.2rem; font-weight: bold; color: var(--dash-text); }
.kpi-card.small .kpi-info { display: flex; flex-direction: column; }
.kpi-card.small i { font-size: 1.5rem; opacity: 0.8; color: var(--dash-accent); }
.kpi-card.alert i { color: var(--dash-danger); }

/* Layout Principal: Mapa vs Gráficos */
.dash-grid-main {
    display: grid;
    grid-template-columns: 1.5fr 1fr; 
    gap: 20px;
    height: 400px; /* ALTURA FIXA CRÍTICA */
    flex-shrink: 0;
}

/* Mapa */
.map-card {
    position: relative;
    height: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--dash-card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.map-card h3 {
    position: absolute;
    top: 10px; left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 4px;
    z-index: 1000;
    font-size: 0.9rem;
    margin: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.dash-map-container {
    width: 100%;
    height: 100%;
    background: #eef2f5;
}

/* Coluna de Gráficos - ALTURAS FIXAS */
.dash-charts-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.chart-card.chart-fixed-height {
    height: 190px; /* Fixo */
    position: relative;
    padding: 10px;
    box-sizing: border-box;
    background: var(--dash-card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.chart-card.small-chart {
    height: 170px; /* Fixo menor */
}

.chart-card h3 {
    margin: 0 0 5px 0;
    padding-bottom: 5px;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
    color: var(--dash-primary);
}

/* Canvas fixo */
.chart-card canvas {
    width: 100% !important;
    height: calc(100% - 25px) !important;
}

/* Tabela */
.dash-grid-table {
    flex-shrink: 0;
}

.table-container {
    max-height: 250px;
    overflow-y: auto;
    background: var(--dash-card-bg);
    border-radius: 8px;
}

#tabela-vistorias-dash {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#tabela-vistorias-dash th, 
#tabela-vistorias-dash td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#tabela-vistorias-dash th {
    background: #f8f9fa;
    position: sticky;
    top: 0;
}

/* Responsividade */
@media (max-width: 1024px) {
    .dash-grid-main {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .map-card { height: 300px; }
    .dash-charts-column { margin-top: 20px; height: auto; }
    .chart-card.chart-fixed-height { height: 220px; }
    .chart-card.small-chart { height: 200px; }
}