/* ==================================== */
/* 1. ESTILOS GERAIS E CONTAINER PRINCIPAL */
/* ==================================== */

/* Opcional: Adiciona estilos para o body, caso não estejam em outro lugar */
/* body {
    font-family: Arial, sans-serif;
    background-color: #f4f7f6;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    font-size: 16px;
} */

#mainContent {
    width: 100%;
    /* max-width: 1100px; */
    background-color: #ffffff;
    padding: 40px 50px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-top: 23px;
}

/* ==================================== */
/* 2. CABEÇALHO E CONTROLES (Busca, Novo Produto e Paginação) */
/* ==================================== */

.main-header {
    /* O container principal usa flexbox para organizar as duas linhas (Topo e Paginação) */
    display: flex;
    flex-direction: column; /* Coloca a linha superior e a paginação em colunas */
    margin-bottom: 20px;
}

.header-top-line {
    /* 💡 NOVO: Container para Título, Busca e Botão Novo (Mesma linha) */
    display: flex;
    align-items: center; /* Alinha verticalmente os elementos (h2, input, button) */
    gap: 94px; /* Espaço entre os elementos */
    flex-wrap: wrap; /* Permite quebrar em telas menores, se necessário */
    margin-bottom: 10px; /* Espaço entre a linha superior e a paginação */
}

/* Ajusta o título para ocupar o espaço mínimo necessário */
.header-top-line h2 {
    flex-shrink: 0; /* Impede que o título encolha */
    margin: 0;
}
.product-stats {
    display: flex;
    gap: 25px; /* Espaçamento entre as estatísticas */
    margin-top: 15px; /* Separa da paginação */
    padding-top: 5px;
    border-top: 1px solid #eee; /* Linha de separação suave */
    flex-wrap: wrap;
}
.stat-item {
    font-size: 0.95em;
    color: #555;
    font-weight: 500;
}

.stat-item strong {
    font-weight: bold;
    color: #333;
    margin-left: 5px;
}

/* Opcional: Cores para o status */
#activeCount {
    color: #28a745; /* Verde */
}

#inactiveCount {
    color: #dc3545; /* Vermelho */
}
/* .header-top-line */
#productSearchInput {
    /* Permite que o campo de busca ocupe a maior parte do espaço disponível */
    flex-grow: 1; 
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    width: auto; /* Usado para flex-grow funcionar */
    max-width: 60%;
}

#openFormBtn {
    /* Impede que o botão encolha/cresça */
    flex-shrink: 0;
    padding: 12px 25px;
    font-size: 1em;
    font-weight: bold;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#openFormBtn:hover {
    background-color: #0056b3;
}
/* Estilo para o grupo de filtros (Label + Select) */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Impede que encolha */
}

.filter-controls label {
    font-weight: bold;
    color: #333;
}

#statusFilter {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    background-color: #f8f9fa;
    transition: border-color 0.2s;
}

#statusFilter:hover {
    border-color: #007bff;
}
/* REMOVIDO: as classes '.pagination-controls-top' e '.header-left-controls' foram substituídas pela nova estrutura '.header-top-line' e '.pagination-container' */


/* ==================================== */
/* 3. TABELA DE PRODUTOS */
/* ==================================== */

.product-table-wrapper {
    width: 100%;
    overflow-x: auto; /* Mantém a rolagem horizontal */
    
    /* 💡 ADICIONADO: Rolagem vertical para fixar o cabeçalho */
    max-height: 60vh; /* Define uma altura máxima para a rolagem (ex: 60% da altura da viewport) */
    overflow-y: auto; 
    
    border: 1px solid #ddd;
    border-radius: 8px;
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

/* 💡 NOVO: Fixa o cabeçalho da tabela */
.product-table thead {
    position: sticky;
    top: 0; /* Fixa o thead no topo do seu container pai (product-table-wrapper) */
    z-index: 5; /* Garante que fique acima das linhas do tbody */
}

.product-table .col-produto { min-width: 250px; }
.product-table .col-categoria { min-width: 150px; }
.product-table .col-marca { min-width: 150px; }

.product-table th, .product-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.product-table tbody tr:last-child td {
    border-bottom: none;
}

.product-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
}

.product-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* Sticky Column (Ações) */
.product-table th:last-child,
.product-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background-color: #ffffff;
}

.product-table th:last-child {
    background-color: #f8f9fa;
}

.product-table tr:hover td:last-child {
    background-color: #f1f1f1;
}

/* ==================================== */
/* 4. STATUS E AÇÕES (Dots, Botões) */
/* ==================================== */

.status-dot {
    height: 12px;
    width: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background-color: #28a745; /* Verde */
}

.status-dot.inactive {
    background-color: #dc3545; /* Vermelho */
}

.action-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-size: 0.9em;
    margin: 0 4px;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 0.85;
}

.edit-btn { background-color: #007bff; }
.delete-btn { background-color: #dc3545; }

/* ==================================== */
/* 5. ESTILOS DE PAGINAÇÃO */
/* ==================================== */

/* 🚀 Contêiner que agora alinha todos os elementos (seletor e botões) */
.pagination-container {
    display: flex;
    /* 🚀 CORRIGIDO: Usa space-between para colocar o seletor à esquerda e os botões à direita. */
    justify-content: space-between; 
    align-items: center; 
    gap: 15px; /* Espaço entre o seletor e os botões de navegação */
    padding: 10px 0;
    border-bottom: 1px solid #eee; 
    margin-bottom: 15px; 
}

/* 🆕 Estiliza o contêiner do seletor (label + select) */
.page-size-selector {
    display: flex;
    align-items: center;
    gap: 5px; 
    font-size: 0.95em;
    color: #333;
    flex-shrink: 0; /* Impede que o seletor encolha */
}

#pageSizeSelect {
    padding: 8px; 
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    background-color: #f8f9fa;
    transition: border-color 0.2s;
}

#pageSizeSelect:hover {
    border-color: #007bff;
}

/* 💡 NOVO: Estilo para o contêiner de botões injetado */
#paginationButtons {
    display: flex; /* Garante que os botões e a info de página fiquem alinhados */
    align-items: center;
    gap: 10px; /* Espaço entre os botões e a info */
}

.pagination-btn {
    padding: 8px 15px;
    margin: 0; 
    border: 1px solid #007bff;
    border-radius: 4px;
    background-color: #ffffff;
    color: #007bff;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #007bff;
    color: white;
}

.pagination-btn:disabled {
    background-color: #f0f0f0;
    color: #999;
    border-color: #ddd;
    cursor: not-allowed;
}

.page-info {
    padding: 0 5px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}
/* ==================================== */
/* 6. ESTILOS DO MODAL */
/* ==================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease-in-out, visibility 0s 0.3s;
}

.modal-overlay.show {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.modal {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
}

.modal h3 {
    margin-top: 0;
    font-size: 1.2em;
    color: #333;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.header-submit-btn, .header-close-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1em;
    font-weight: bold;
}

.header-submit-btn {
    background-color: #007bff;
    color: white;
}

.header-close-btn {
    background-color: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
}