/* Importar uma fonte do Google Fonts para um visual mais moderno */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300,400,500,700&display=swap');

:root {
    /* Cores atualizadas para um visual mais moderno e suave */
    --primary-color: #0d6efd; /* Azul principal mais vibrante */
    --secondary-color: #0b5ed7; /* Tom um pouco mais escuro para hover/ativo */
    --accent-color: #28a745; /* Cor de destaque (verde) para botões de sucesso ou ícones */
    --background-color: #f8f9fa; /* Fundo muito claro */
    --card-background: #ffffff;
    --text-color: #212529; /* Texto escuro padrão */
    --light-text-color: #6c757d; /* Texto secundário */
    --border-color: #dee2e6; /* Borda sutil */
    --shadow-light: 0 0.5rem 1.2rem rgba(0, 0, 0, 0.08); /* Sombra mais difundida e suave */
    --transition-speed: 0.3s ease;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-weight: 400; /* Peso padrão da fonte */
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 40px 20px; /* Mais padding no header */
    text-align: center;
    box-shadow: var(--shadow-light);
    position: sticky; /* Sticky header */
    top: 0;
    z-index: 1000;
}

header h1 {
    margin: 0;
    font-size: 2.8em; /* Tamanho maior para o título */
    font-weight: 700;
    letter-spacing: -0.5px; /* Ajuste sutil no espaçamento de letras */
}

header p {
    font-size: 1.2em; /* Tamanho maior para a descrição */
    margin-top: 15px;
    font-weight: 300; /* Mais leve para o parágrafo */
    opacity: 0.9;
}

header i.fas {
    margin-right: 10px;
    font-size: 0.9em; /* Tamanho do ícone um pouco menor em relação ao texto */
}

main {
    max-width: 1280px; /* Aumentar um pouco a largura máxima do conteúdo */
    margin: 40px auto; /* Mais margin para um visual arejado */
    padding: 0 25px;
    flex-grow: 1;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

.card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    padding: 35px; /* Mais padding dentro dos cards */
    margin-bottom: 35px; /* Mais espaçamento entre cards */
    border: none; /* Remover borda, a sombra é suficiente */
}

.card h2 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 28px; /* Mais espaço abaixo do título do card */
    font-size: 2em; /* Tamanho maior para títulos de seção */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px; /* Mais espaço entre ícone e texto */
}

.card h2 i.fas {
    color: var(--secondary-color); /* Ícones com a cor secundária */
    font-size: 0.9em; /* Tamanho do ícone um pouco menor em relação ao título */
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* Min-width um pouco maior */
    gap: 20px; /* Mais espaçamento */
    margin-bottom: 25px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filters-grid label {
    margin-bottom: 8px; /* Mais espaço abaixo do label */
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95em;
}

.filters-grid input[type="text"],
.filters-grid select {
    padding: 13px; /* Mais padding nos inputs */
    border: 1px solid var(--border-color);
    border-radius: 10px; /* Cantos mais arredondados */
    font-size: 1em;
    transition: all var(--transition-speed);
    width: 100%;
    box-sizing: border-box;
    background-color: #fefefe; /* Fundo levemente off-white */
    color: var(--text-color);
}

.filters-grid input[type="text"]::placeholder {
    color: var(--light-text-color); /* Placeholder mais suave */
    opacity: 0.7;
}

.filters-grid input[type="text"]:focus,
.filters-grid select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25); /* Sombra de foco mais marcante */
    outline: none;
    background-color: white;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    padding-top: 25px; /* Mais padding para alinhar o botão */
}

.btn-clear {
    background-color: #dc3545; /* Vermelho para limpar */
    color: white;
    padding: 13px 25px; /* Mais padding no botão */
    border: none;
    border-radius: 10px; /* Cantos mais arredondados */
    font-size: 1em;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform 0.1s ease;
    display: flex;
    align-items: center;
    gap: 10px; /* Mais espaço entre ícone e texto */
    font-weight: 500;
}

.btn-clear:hover {
    background-color: #c82333;
    transform: translateY(-2px); /* Efeito sutil ao passar o mouse */
}

.btn-clear:active {
    transform: translateY(0);
}


/* Estilos para estatísticas globais */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px; /* Mais espaçamento */
    font-size: 1.1em;
    font-weight: 500;
    color: var(--light-text-color);
    text-align: center;
}

.stat-item h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3em; /* Tamanho maior */
    color: var(--primary-color);
    font-weight: 600;
}

.stat-item p {
    margin: 0;
    font-size: 2.2em; /* Tamanho maior para os números */
    font-weight: 700;
    color: var(--secondary-color);
    line-height: 1; /* Para evitar quebras de linha estranhas */
}

/* Estilos para Tabelas em Geral (aplicado a top repos, top languages, clusters e todos os repos) */
.table-responsive {
    overflow-x: auto; /* Permite scroll horizontal se a tabela for muito larga */
    -webkit-overflow-scrolling: touch; /* Melhor scroll em dispositivos iOS */
    border-radius: 10px; /* Arredondar cantos do container da tabela */
    border: 1px solid var(--border-color); /* Borda sutil para o container */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0; /* Removido margin-top para que a tabela se ajuste ao card */
    font-size: 0.95em;
    min-width: 700px; /* Garante que a tabela não fique muito estreita em telas menores */
}

th, td {
    border: none; /* Remover bordas internas das células */
    padding: 15px 18px; /* Mais padding para um visual mais limpo */
    text-align: left;
    vertical-align: middle; /* Alinhar texto verticalmente ao centro */
    white-space: normal; /* Permite quebrar linha normalmente */
    word-wrap: break-word; /* Garante que palavras longas quebrem */
}

thead th {
    background-color: #e9ecef; /* Um cinza mais claro para o cabeçalho */
    font-weight: 600;
    color: var(--text-color);
    position: sticky; /* Sticky header para rolagem */
    top: 0;
    z-index: 10;
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* Listra mais sutil para linhas pares */
}

tbody tr:hover {
    background-color: #e2e6ea; /* Destaque mais suave ao passar o mouse */
    transition: background-color var(--transition-speed);
}

td a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

td a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* --- Estilos específicos para a Tabela de Todos os Repositórios (results-section) --- */
#allReposTable {
    table-layout: fixed; /* Isso é crucial para o controle de largura de coluna */
}

#allReposTable th:nth-child(1), /* Nome do Repositório */
#allReposTable td:nth-child(1) {
    width: 20%; 
}

#allReposTable th:nth-child(2), /* Instituição */
#allReposTable td:nth-child(2) {
    width: 10%; 
}

#allReposTable th:nth-child(3), /* Descrição */
#allReposTable_td:nth-child(3) { /* Atenção: TD deve ser uma classe ou regra mais específica */
    width: 25%; 
}

#allReposTable th:nth-child(4), /* Linguagem Principal */
#allReposTable td:nth-child(4) {
    width: 10%;
}

#allReposTable th:nth-child(5), /* Estrelas */
#allReposTable td:nth-child(5) {
    width: 8%;
}

#allReposTable th:nth-child(6), /* Licença */
#allReposTable td:nth-child(6) {
    width: 10%;
}

#allReposTable th:nth-child(7), /* Última Atualização */
#allReposTable td:nth-child(7) {
    width: 10%;
}

#allReposTable th:nth-child(8), /* Cluster ID */
#allReposTable td:nth-child(8) {
    width: 7%;
}


/* Estilos para ordenação */
#allReposTable th {
    cursor: pointer;
    user-select: none; /* Impede seleção de texto ao clicar para ordenar */
    transition: background-color var(--transition-speed);
}

#allReposTable th:hover {
    background-color: #dbe1e6;
}

#allReposTable th i.fas {
    margin-left: 8px;
    color: #999;
    transition: transform 0.2s ease, color var(--transition-speed);
}

#allReposTable th.asc i.fas {
    transform: rotate(0deg);
    color: var(--secondary-color);
}

#allReposTable th.desc i.fas {
    transform: rotate(180deg);
    color: var(--secondary-color);
}

/* --- NOVOS ESTILOS PARA FILTROS DE COLUNA --- */
#allReposTable thead #filterRow th {
    padding: 8px 10px; /* Reduz o padding para os inputs */
    background-color: #f2f2f2;
    border-bottom: 1px solid var(--border-color); /* Uma borda sutil no fundo dos filtros */
}
.filter-input {
    width: calc(100% - 10px); /* Ajusta a largura do input */
    padding: 8px; /* Mais padding */
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Cantos arredondados */
    box-sizing: border-box;
    font-size: 0.9em;
    background-color: #ffffff;
    transition: all var(--transition-speed);
    color: var(--text-color);
}
.filter-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2); /* Sombra de foco mais suave */
}

/* --- Estilos para a Seção de Clusters --- */
.cluster-info-section .disclaimer {
    text-align: center;
    font-style: italic;
    color: var(--light-text-color);
    margin-bottom: 25px;
    padding: 15px;
    background-color: #e0f2f7; /* Um azul muito claro */
    border-left: 5px solid var(--primary-color);
    border-radius: 8px;
    font-size: 0.95em;
    line-height: 1.5;
}

/* --- Estilos para Paginação --- */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px; /* Mais espaço acima dos controles */
    gap: 15px; /* Espaço entre os elementos de paginação */
}

.pagination-controls .btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px; /* Mais padding nos botões */
    border: none;
    border-radius: 10px; /* Cantos mais arredondados */
    font-size: 1em;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.pagination-controls .btn:hover:not(:disabled) {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.pagination-controls .btn:active {
    transform: translateY(0);
}

.pagination-controls .btn:disabled {
    background-color: #e9ecef; /* Cor cinza mais clara para desabilitado */
    color: #a0a0a0;
    cursor: not-allowed;
    opacity: 0.8;
    box-shadow: none;
    transform: none;
}

.pagination-controls #pageInfo {
    font-size: 1.2em; /* Tamanho maior para a informação da página */
    font-weight: 500;
    color: var(--text-color);
    min-width: 140px; /* Garante que o texto da página não quebre muito */
    text-align: center;
}

/* --- Mensagens --- */
.loading-message,
.error-message,
.no-results-message {
    text-align: center;
    padding: 20px;
    font-weight: 500;
    color: var(--light-text-color);
    font-size: 1.1em;
}

.error-message {
    color: #dc3545; /* Vermelho para erro */
    font-weight: 600;
}

.hidden {
    display: none;
}

/* Estilos para o rodapé */
footer {
    text-align: center;
    padding: 30px 20px; /* Mais padding */
    margin-top: 50px; /* Mais espaço acima do rodapé */
    background-color: var(--primary-color);
    color: white;
    font-size: 0.95em;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
    font-weight: 300;
}

footer a {
    color: white;
    text-decoration: underline;
    transition: opacity var(--transition-speed);
}

footer a:hover {
    opacity: 0.8;
}

/* Media Queries para responsividade geral */
@media (max-width: 992px) {
    main {
        margin: 30px auto;
        padding: 0 15px;
    }
    .card {
        padding: 25px;
    }
    .filters-grid {
        gap: 15px;
    }
    .stats-grid {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    header p {
        font-size: 1em;
    }
    .card h2 {
        font-size: 1.7em;
        margin-bottom: 20px;
    }
    .main {
        margin: 20px 10px;
        padding: 0 10px;
    }
    .card {
        padding: 20px;
    }
    .filters-grid,
    .stats-grid {
        grid-template-columns: 1fr; /* Uma coluna em celulares */
    }

    /* Permite scroll horizontal em tabelas pequenas */
    .table-responsive {
        display: block;
        overflow-x: auto;
        white-space: nowrap; /* Impede quebra de linha inicial, mas word-wrap still applies in cells */
    }

    th, td {
        padding: 10px 12px;
        font-size: 0.9em;
    }

    /* Reduzir um pouco mais a largura das colunas em telas menores */
    #allReposTable th:nth-child(1), #allReposTable td:nth-child(1) { width: 22%; } /* Nome */
    #allReposTable th:nth-child(2), #allReposTable td:nth-child(2) { width: 10%; } /* Instituição */
    #allReposTable th:nth-child(3), #allReposTable td:nth-child(3) { width: 28%; } /* Descrição */
    #allReposTable th:nth-child(4), #allReposTable td:nth-child(4) { width: 10%; } /* Linguagem */
    #allReposTable th:nth-child(5), #allReposTable td:nth-child(5) { width: 8%; } /* Estrelas */
    #allReposTable th:nth-child(6), #allReposTable td:nth-child(6) { width: 10%; } /* Licença */
    #allReposTable th:nth-child(7), #allReposTable td:nth-child(7) { width: 10%; } /* Atualização */
    #allReposTable th:nth-child(8), #allReposTable td:nth-child(8) { width: 7%; } /* Cluster */

    .pagination-controls {
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }
    .pagination-controls .btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
    .pagination-controls #pageInfo {
        margin: 0;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }
    .card h2 {
        font-size: 1.5em;
        flex-direction: column;
        text-align: center;
    }
    .card h2 i.fas {
        margin-bottom: 5px;
    }
    .btn-clear {
        width: 100%;
        justify-content: center;
    }
}