/* =========================================================
   TABLES.CSS - Sistema de Tabelas e Listagens
   Versão: 4.5 - FINAL: Textos do cabeçalho ajustados
   Projeto: MPPE Caatinga Resiste 2026
========================================================= */

/* ===== TABELA BASE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    background: #ffffff;
}

.data-table th,
.data-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #2c3e50;
    color: #ffffff !important;
    font-weight: 600;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ===== TABELA COMPACTA (LISTAGENS SIDEBAR) ===== */
.list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    background: #ffffff;
    table-layout: fixed;
}

/* Cabeçalho visível */
.list-table thead {
    display: table-header-group;
}

.list-table th {
    background: #2c3e50 !important; /* Azul escuro */
    color: #ffffff !important;
    padding: 10px 8px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 20;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 2px solid #1a2632;
}

/* Larguras específicas para a tabela de alertas */
.list-table th[data-col="id"] {
    width: 20%; /* Reduzido um pouco */
    min-width: 80px;
}

.list-table th[data-col="area"] {
    width: 25%;
    min-width: 90px;
}

.list-table th[data-col="vetor"] {
    width: 45%; /* Aumentado para compensar */
    min-width: 130px;
}

/* Textos personalizados do cabeçalho - via HTML, não precisa de CSS */
/* As alterações foram feitas diretamente no HTML:
   - "Nº Alerta" → "Alerta"
   - "Vetor de Pressão" → "Vetor"
*/

/* Indicador de ordenação */
.list-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 24px;
    position: relative;
}

.list-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 8px;
    opacity: 0.8;
    font-size: 14px;
    color: #ffffff;
}

.list-table th.sortable.asc::after {
    content: '↑';
    opacity: 1;
    color: #ffffff;
}

.list-table th.sortable.desc::after {
    content: '↓';
    opacity: 1;
    color: #ffffff;
}

.list-table th.sortable:hover {
    background: #34495e !important;
}

.list-table td {
    padding: 8px;
    border-bottom: 1px solid #eaecef;
    color: #333333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Número do alerta */
.list-table td:first-child {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 500;
    color: #0066cc;
}

.list-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.list-table tbody tr:hover {
    background-color: #f5f5f5;
}

.list-table tbody tr.ativo {
    background-color: #fff3e0;
    border-left: 4px solid #ff9800;
}

.list-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

/* ===== CONTAINER DE LISTA ===== */
.list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin-top: 10px;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
}

.list-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    text-transform: uppercase;
}

.list-body {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
    background: #ffffff;
}

.list-body .list-table thead th {
    background: #2c3e50 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-bottom: 2px solid #1a2632;
}

/* Badge de contagem */
.badge-count {
    background: #2c3e50;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ===== TABELA DE MUNICÍPIOS (SIDEBAR RIGHT) ===== */
.municipios-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 400px;
}

.municipios-table th,
.municipios-table td {
    border: 1px solid #dee2e6;
    padding: 8px 10px;
    text-align: left;
    word-break: break-word;
}

.municipios-table th {
    background-color: #2c3e50;
    font-weight: 700;
    color: #ffffff !important;
    position: sticky;
    top: 0;
    white-space: nowrap;
    z-index: 15;
}

.municipios-table th.sortable {
    cursor: pointer;
    padding-right: 24px;
    position: relative;
}

.municipios-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 8px;
    opacity: 0.8;
    font-size: 14px;
    color: #ffffff;
}

.municipios-table th.sortable.asc::after {
    content: '↑';
    opacity: 1;
    color: #ffffff;
}

.municipios-table th.sortable.desc::after {
    content: '↓';
    opacity: 1;
    color: #ffffff;
}

/* ===== UTILITÁRIOS ===== */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.empty-row {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
    background: #ffffff;
}

.pagination-indicator {
    text-align: center;
    padding: 8px;
    background: #f8f9fa;
    font-style: italic;
    font-size: 12px;
    color: #6c757d;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .list-table th,
    .list-table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .list-table th[data-col="id"] {
        min-width: 60px;
    }
    
    .list-table th[data-col="area"] {
        min-width: 60px;
    }
    
    .list-table th[data-col="vetor"] {
        min-width: 80px;
    }
}