/* =========================================================
   DASHBOARD.CSS - Sistema de Dashboards Modais
   Projeto: MPPE Caatinga Resiste 2026
========================================================= */

/* =========================================================
   1. CONTAINER MODAL BASE
========================================================= */

.dashboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: var(--z-dashboard);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: var(--spacing-sm);
    box-sizing: border-box;
}

.dashboard-modal.active {
    display: flex;
}

.dashboard-content {
    background-color: var(--bg-primary);
    width: min(95%, 1200px);
    max-height: min(90vh, 800px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: clamp(15px, 3vw, 20px);
    overflow-y: auto;
    position: relative;
    margin: auto;
}

/* =========================================================
   2. CABEÇALHO DO DASHBOARD
========================================================= */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(15px, 3vw, 20px);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: var(--spacing-sm);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.dashboard-title {
    font-size: clamp(18px, 3vw, 24px);
    font-weight: bold;
    color: var(--color-primary);
    margin: 0;
    flex: 1;
    min-width: 250px;
}

.dashboard-subtitle {
    font-size: clamp(14px, 2vw, 16px);
    color: var(--text-secondary);
    margin: 5px 0 0 0;
    width: 100%;
}

.dashboard-close {
    background: none;
    border: none;
    font-size: clamp(20px, 4vw, 24px);
    cursor: pointer;
    color: var(--text-primary);
    transition: color var(--transition-base);
    min-width: 40px;
    text-align: center;
}

.dashboard-close:hover {
    color: var(--color-error);
}

/* =========================================================
   3. SEÇÕES DO DASHBOARD
========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: clamp(15px, 2vw, 20px);
    margin-bottom: clamp(15px, 2vw, 20px);
}

.dashboard-section {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: clamp(12px, 2vw, 15px);
    box-shadow: var(--shadow-sm);
}

.dashboard-section.full-width {
    grid-column: 1 / -1;
}

.section-title {
    font-size: clamp(16px, 2vw, 18px);
    font-weight: bold;
    color: var(--color-primary);
    margin-bottom: clamp(10px, 2vw, 15px);
    text-align: center;
}

/* =========================================================
   4. CONTAINER DE GRÁFICO
========================================================= */

.chart-container {
    height: min(300px, 40vh);
    position: relative;
    padding: var(--spacing-sm);
    background-color: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chart-lg {
    height: min(400px, 50vh);
}

/* =========================================================
   5. MINI DASHBOARD (SIDEBAR RIGHT)
========================================================= */

.mini-dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-family: var(--font-primary);
    margin-top: var(--spacing-sm);
    max-height: 400px;
}

.mini-dash-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--text-light);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.mini-dash-header h3 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mini-dash-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.mini-dash-body {
    padding: var(--spacing-md);
    flex: 1;
    overflow-y: auto;
    max-height: 350px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) var(--bg-tertiary);
}

/* =========================================================
   6. VETORES DE PRESSÃO
========================================================= */

.vetores-container {
    margin-top: var(--spacing-md);
}

.vetores-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.vetor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px dashed var(--border-light);
}

.vetor-nome {
    font-weight: 500;
    color: var(--text-primary);
    text-transform: capitalize;
}

.vetor-stats {
    display: flex;
    gap: var(--spacing-sm);
    color: var(--text-secondary);
}

.vetor-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    margin: 2px 0 6px 0;
    width: 100%;
}

.vetor-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
}

/* =========================================================
   7. RESUMO FINAL
========================================================= */

.dash-resumo {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-light);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 5px;
}

/* =========================================================
   8. TABELA DE CUSTOS (PORTARIA 118)
========================================================= */

.custos-container {
    margin-top: 25px;
    border: 1px solid #e0e0e0;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.custos-titulo-bioma {
    margin: 0 0 5px 0;
    color: #0d5d2e;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
}

.custos-fonte {
    font-size: 11px;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.tabela-custos-portaria {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabela-custos-portaria th {
    background-color: #f5f5f5;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #0d5d2e;
    color: #333;
    font-weight: 600;
}

.tabela-custos-portaria td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    color: #444;
}

.tabela-custos-portaria .custo-total {
    color: #d32f2f;
    font-weight: bold;
}

/* Responsividade da Tabela */
@media (max-width: 600px) {
    .tabela-custos-portaria thead { display: none; }
    .tabela-custos-portaria tr { display: block; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 4px; }
    .tabela-custos-portaria td { display: flex; justify-content: space-between; padding: 8px; border-bottom: 1px solid #eee; }
    .tabela-custos-portaria td::before { content: attr(data-label); font-weight: bold; margin-right: 10px; color: #555; }
    .tabela-custos-portaria td:last-child { border-bottom: none; background: #f9f9f9; }
}

/* =========================================================
   9. RESPONSIVIDADE
========================================================= */

@media (max-width: 1400px) {
    .dashboard-content {
        width: 92%;
        max-height: 85vh;
    }
}

@media (max-width: 1200px) {
    .dashboard-content {
        width: 94%;
    }
    
    .dashboard-section {
        min-width: min(100%, 280px);
    }
    
    .chart-container {
        height: 250px;
    }
    
    .chart-lg {
        height: 350px;
    }
}

@media (max-width: 992px) {
    .dashboard-content {
        width: 96%;
        padding: var(--spacing-md);
        max-height: 92vh;
    }
    
    .dashboard-grid {
        flex-direction: column;
    }
    
    .chart-container {
        height: 220px;
    }
    
    .chart-lg {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .dashboard-content {
        width: 98%;
        padding: var(--spacing-sm);
        max-height: 95vh;
    }
    
    .dashboard-header {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
    }
    
    .dashboard-title {
        min-width: 100%;
        font-size: 20px;
    }
    
    .dashboard-close {
        align-self: flex-end;
        margin-top: -10px;
    }
    
    .mini-dash-body {
        max-height: 300px;
    }
    
    .metric-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .dashboard-content {
        padding: var(--spacing-sm);
        width: 99%;
    }
    
    .dashboard-title {
        font-size: 18px;
    }
    
    .section-title {
        font-size: 15px;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .chart-lg {
        height: 250px;
    }
}

@media (max-height: 700px) {
    .dashboard-content {
        max-height: 95vh;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .chart-lg {
        height: 250px;
    }
}