/* ==================================== */
/* 1. ESTILOS GERAIS COMPACTOS          */
/* ==================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

#mainContent {
    width: 100%;
    background-color: #ffffff;
    padding: 16px 20px; 
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

/* ==================================== */
/* 2. CABEÇALHO SUPER COMPACTO (FLEX)   */
/* ==================================== */
.main-header {
    display: flex;
    flex-wrap: wrap; /* Permite quebrar as linhas (Topo e Baixo) */
    align-items: center; /* Centraliza verticalmente */
    justify-content: space-between; /* Um de cada lado */
    gap: 15px 0; /* 15px de distância entre a linha de cima e a de baixo */
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

/* Container principal da linha do topo */
.header-top-line {
    width: 100%; /* Força a ocupar a 1ª linha inteira sozinho */
    display: flex;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    border-bottom: none;
    padding-bottom: 0;
}

.header-top-line h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    flex-shrink: 0;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* GRUPO DA ESQUERDA (Filtros e Input) */
.filter-group {
    display: flex;
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 10px;
    flex-grow: 1;
    align-items: center;
}

/* ESTILO UNIFICADO PARA OS 3 CAMPOS */
#statusFilter, #agruparPdfSelect, #productSearchInput {
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
    background-color: #fff;
    color: #334155;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 36px;
    margin: 0 !important;
}

#statusFilter, #agruparPdfSelect { 
    cursor: pointer; 
    background-color: #f8fafc; 
    flex-shrink: 0; 
    width: auto !important; 
}

#statusFilter:focus, #agruparPdfSelect:focus, #productSearchInput:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#productSearchInput {
    flex-grow: 1; 
    min-width: 220px;
    width: 100% !important; 
}

/* GRUPO DA DIREITA (Botões de Ação) */
.action-group {
    display: flex;
    flex-direction: row !important;
    gap: 10px;
    flex-shrink: 0; 
}

#openFormBtn {
    padding: 0 16px;
    height: 36px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    background-color: #2563eb;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

#openFormBtn:hover {
    background-color: #1d4ed8;
}

#gerarRelatorioBtn {
    padding: 0 16px;
    height: 36px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

#gerarRelatorioBtn:hover:not(:disabled) {
    background-color: #e2e8f0;
    border-color: #94a3b8;
}

#gerarRelatorioBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ==================================== */
/* 3. ESTATÍSTICAS (ESTILO PÍLULA)      */
/* ==================================== */
.product-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: none;
}

.stat-item {
    font-size: 0.75rem;
    color: #64748b;
    background-color: #f8fafc;
    padding: 4px 10px;
    border-radius: 6px; 
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.stat-item strong {
    font-size: 0.8rem;
    margin-left: 5px;
}

#activeCount { color: #10b981; }
#inactiveCount { color: #ef4444; }
#totalCount { color: #0f172a; }

/* ==================================== */
/* 4. PAGINAÇÃO COLADA NA TABELA        */
/* ==================================== */
.pagination-container {
    display: flex;
    justify-content: flex-end; 
    align-items: center;
    gap: 16px; 
    margin: 0;
    padding: 0;
    border: none;
    margin-left: auto; /* Empurra a paginação perfeitamente para a direita */
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

#pageSizeSelect {
    padding: 4px 10px; 
    height: 30px;      
    min-width: 70px;   
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.85rem; 
    background-color: #fff;
    color: #334155;
    cursor: pointer;
    outline: none;
}

#paginationButtons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    padding: 4px 10px;
    height: 30px; 
    font-size: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background-color: #fff;
    color: #334155;
    cursor: pointer;
    font-weight: 500;
}

.pagination-btn:hover:not(:disabled) { background-color: #f1f5f9; border-color: #94a3b8; }
.pagination-btn:disabled { background-color: #f8fafc; color: #94a3b8; cursor: not-allowed; border-color: #e2e8f0; }

.page-info { font-size: 0.8rem; font-weight: 500; color: #475569; padding: 0 4px; }

/* ==================================== */
/* 5. TABELA COMPACTA                   */
/* ==================================== */
.product-table-wrapper {
    width: 100%;
    overflow-x: auto;
    max-height: 60vh; 
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.product-table-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.product-table-wrapper::-webkit-scrollbar-track { background: #f8fafc; }
.product-table-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

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

.product-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.product-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 10px 14px; 
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.product-table td {
    padding: 8px 14px; 
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

/* Coluna Fixa */
.product-table th:last-child,
.product-table td:last-child {
    position: sticky; right: 0; z-index: 1; background-color: #ffffff;
    border-left: 1px solid #f1f5f9;
}
.product-table th:last-child { background-color: #f8fafc; }
.product-table tr:hover td:last-child { background-color: #f8fafc; }

/* ==================================== */
/* 6. STATUS E BOTÕES DA TABELA         */
/* ==================================== */
.status-dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; }
.status-dot.active { background-color: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
.status-dot.inactive { background-color: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }

.action-btn {
    border: none;
    padding: 4px 10px; 
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 4px;
}

.edit-btn { background-color: #eff6ff; color: #2563eb; }
.edit-btn:hover { background-color: #dbeafe; }

.delete-btn { background-color: #fef2f2; color: #dc2626; }
.delete-btn:hover { background-color: #fee2e2; }

.restore-btn { background-color: #ecfdf5; color: #059669; }
.restore-btn:hover { background-color: #d1fae5; }

/* ==================================== */
/* 7. ADAPTAÇÃO PARA CELULAR            */
/* ==================================== */
@media (max-width: 850px) {
    .main-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .header-top-line, .filter-group {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .action-group {
        justify-content: space-between;
        width: 100%;
    }
    
    #statusFilter, #agruparPdfSelect, #productSearchInput {
        width: 100% !important;
    }
    
    .product-stats {
        justify-content: center;
    }

    .pagination-container { 
        justify-content: space-between; 
        margin-left: 0;
    }
}