/* ========================================================
   Estilos Principais (Baseados no novo padrão visual)
   ======================================================== */
.mop-container, 
.mop-container * {
    box-sizing: border-box;
}

.mop-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 24px 0;
    font-size: 13px;
    color: #333;
}

/* --- Mapa --- */
#mop-mapa {
    width: 100%;
    height: 450px;
    background: #fff;
    border: 1px solid #e0e8eb;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
    z-index: 1;
}

/* --- Container da Tabela (Estilo Card) --- */
.mop-tabela-container {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e0e8eb;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
}

/* --- Tabela --- */
#mop-tabela {
    width: 100%;
    min-width: 800px; /* Previne esmagamento no desktop */
    border-collapse: collapse;
    background: #fff;
    text-align: left;
}

/* Células Gerais */
#mop-tabela th, 
#mop-tabela td {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e8eb;
    vertical-align: middle;
    font-size: 14px;
}

/* Alinhamentos Específicos Desktop */
#mop-tabela th:nth-child(2),
#mop-tabela td:nth-child(2) {
    white-space: nowrap;
    text-align: right;
}

#mop-tabela th:nth-child(3), #mop-tabela td:nth-child(3),
#mop-tabela th:nth-child(4), #mop-tabela td:nth-child(4),
#mop-tabela th:nth-child(5), #mop-tabela td:nth-child(5) {
    white-space: nowrap;
    text-align: center;
}

/* Cabeçalho */
#mop-tabela th {
    background: #f6f8f9;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #444;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background-color 0.2s;
}

#mop-tabela th:first-child { border-top-left-radius: 12px; }
#mop-tabela th:last-child { border-top-right-radius: 12px; }

#mop-tabela th:hover {
    background: #e2e8eb;
    color: #0d6efd;
}

/* Linhas do Corpo da Tabela */
#mop-tabela tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease, border-left 0.2s ease;
    border-left: 4px solid transparent; /* Espaço reservado para borda ativa */
}

#mop-tabela tbody tr:hover {
    background: #fafbfc;
}

/* Remove a borda da última linha no card */
#mop-tabela tbody tr:last-child td {
    border-bottom: none;
}

/* Linha Selecionada/Ativa */
#mop-tabela tbody tr.ativo {
    background-color: #f0f7ff;
    border-left: 4px solid #0d6efd;
}

/* Tags de Situação */
.mop-badge {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    background: #f6f8f9;
    color: #555;
    border: 1px solid #e0e8eb;
}

/* Setas de Ordenação */
#mop-tabela th::after {
    content: '↕';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #cbd5e1;
    font-size: 14px;
}
#mop-tabela th.sort-asc::after { content: '↑'; color: #0d6efd; font-weight: bold; }
#mop-tabela th.sort-desc::after { content: '↓'; color: #0d6efd; font-weight: bold; }

/* ========================================================
   Adaptação para Celulares (Layout em Cards)
   ======================================================== */
@media (max-width: 768px) {
    .mop-tabela-container {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }
    
    #mop-tabela, 
    #mop-tabela tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    /* Esconde o cabeçalho no mobile */
    #mop-tabela thead {
        display: none;
    }

    /* Transforma a linha em um card */
    #mop-tabela tbody tr {
        display: flex;
        flex-direction: column;
        background: #fff;
        border: 1px solid #e0e8eb;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .06);
        margin-bottom: 20px;
        overflow: hidden;
    }
    
    #mop-tabela tbody tr:hover { background: #fff; }

    /* Estilo das células dentro do card */
    #mop-tabela td {
        display: block;
        border: none !important;
        padding: 10px 20px;
        text-align: left !important;
        white-space: normal !important;
    }

    /* 1. Nome da Obra (vira o cabeçalho do card) */
    #mop-tabela td:nth-child(1) {
        background: #f6f8f9;
        border-bottom: 1px solid #e0e8eb !important;
        padding: 14px 20px;
    }

    /* 2. Investimento */
    #mop-tabela td:nth-child(2) {
        padding-top: 18px;
        font-size: 16px;
        color: #0d6efd;
        font-weight: bold;
    }

    /* 5. Situação (último item do card) */
    #mop-tabela td:nth-child(5) {
        padding-bottom: 20px;
    }

    /* Injeção de Rótulos usando ::before */
    #mop-tabela td:nth-child(2)::before { 
        content: "Investimento: "; 
        font-weight: 700; 
        color: #111; 
        font-size: 14px; 
    }
    #mop-tabela td:nth-child(3)::before { 
        content: "Início Previsto: "; 
        font-weight: 700; 
        color: #111; 
    }
    #mop-tabela td:nth-child(4)::before { 
        content: "Conclusão Prevista: "; 
        font-weight: 700; 
        color: #111; 
    }
    #mop-tabela td:nth-child(5)::before { 
        content: "Situação: "; 
        font-weight: 700; 
        color: #111; 
        margin-right: 8px;
    }
}

/* Reset dos botões no cabeçalho da tabela */
#mop-tabela th button {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    cursor: pointer;
    width: 100%;
    text-align: inherit;
    outline: none;
    box-shadow: none !important;
}

#mop-tabela th button:hover,
#mop-tabela th button:focus {
    color: #0d6efd; /* Azul ao passar o rato */
}