/* ==================================== */
/* 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;
    }
}



/* ==================================== */
/* 8. MINIATURA DE IMAGEM NA TABELA     */
/* ==================================== */
.img-container {
    position: relative;
    width: 70px;  /* 🌟 Mudou de 40px para 70px */
    height: 70px; /* 🌟 Mudou de 40px para 70px */
    border-radius: 6px;
    overflow: hidden;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    margin: 0 auto;
}


.prod-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fundo escuro que aparece em cima da foto */
.img-actions {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

/* Revela os botões quando passa o mouse */
.img-container:hover .img-actions {
    opacity: 1;
}

/* Botõezinhos minimalistas */
.img-btn-inline {
    background: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 3px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.img-btn-inline:hover {
    transform: scale(1.1);
}


/* ==================================== */
/* 9. MENSAGEM FLUTUANTE (NOTIFICAÇÃO)  */
/* ==================================== */
#floatingMessage {
    position: fixed;
    top: -60px; /* Começa escondido pra cima */
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #ffffff;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

/* Quando o JS adiciona a classe 'show', ele desce */
#floatingMessage.show {
    top: 20px; 
}

/* Cores por tipo de aviso */
#floatingMessage.success { background-color: #10b981; border: 1px solid #059669; } /* Verde */
#floatingMessage.error { background-color: #ef4444; border: 1px solid #dc2626; }   /* Vermelho */
#floatingMessage.info { background-color: #3b82f6; border: 1px solid #2563eb; }    /* Azul */


/* ==================================== */
/* 10. EDIÇÃO INLINE (TEXTO INVISÍVEL)  */
/* ==================================== */
.editable-price {
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    outline: none;
    display: inline-block;
    min-width: 50px;
    transition: all 0.2s;
}

/* Quando passa o mouse, mostra que dá pra clicar */
.editable-price:hover {
    background-color: #f8fafc;
    box-shadow: 0 0 0 1px #cbd5e1;
}

/* Quando clica para digitar */
.editable-price:focus {
    background-color: #ffffff;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Botão 3 Pontinhos */
.kebab-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.kebab-btn:hover { background: #e2e8f0; color: #0f172a; }

/* Menu Flutuante */
/* Container do Menu */
.action-dropdown { 
    position: relative; 
    display: inline-block; 
    text-align: right; 
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 20px; /* 🌟 Bem mais colado nos 3 pontinhos */
    top: 37%;    /* 🌟 Sobrepõe um pouco o botão para não ter nenhum buraco */
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 9999; 
    flex-direction: column;
    overflow: hidden;
}
.action-dropdown .dropdown-menu.show { 
    display: flex; 
}
.dropdown-menu.show { display: flex; }

/* 🌟 TRUQUE DE MESTRE: Quando passa o mouse na linha, ela sobe de nível e não deixa a de baixo cobrir o menu */
.product-table tbody tr:hover td {
    z-index: 10;
}


/* ==================================== */
/* 11. LIMPEZA VISUAL DO MENU FLUTUANTE */
/* ==================================== */
.action-dropdown .dropdown-menu {
    padding: 5px 7px; /* Espacinho em cima e embaixo */
    min-width: 150px;
}

/* Força os botões dentro do menu a perderem a cor e borda global */
.action-dropdown .dropdown-menu button {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #475569 !important;
    padding: 10px 16px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    width: 100% !important;
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
}

/* Efeito Hover Genérico (Cinza clarinho) */
.action-dropdown .dropdown-menu button:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

/* Hover específico pro botão de Desativar (Fica vermelho) */
.action-dropdown .dropdown-menu button.delete:hover {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
}

/* ==================================== */
/* TRAVA O TAMANHO MÍNIMO DA TABELA     */
/* ==================================== */
.product-table-wrapper {
    min-height: 500px; /* 🌟 O SEGREDO: Garante que a caixa branca nunca fique menor que isso */
    max-height: 450px; /* 🌟 O SEGREDO: Garante que a caixa branca nunca fique menor que isso */
    background-color: #ffffff; /* Mantém o fundo branquinho até lá embaixo */
    border-radius: 8px; /* Mantém as bordinhas arredondadas (ajuste se precisar) */
    display: flex;
    flex-direction: column;
}

/* Faz a tabela grudar no topo e o espaço vazio sobrar embaixo, sem esticar as linhas */
.product-table {
    margin-bottom: auto; 
    width: 100%;
}

/* ==================================== */
/* NOME DO PRODUTO EDITÁVEL             */
/* ==================================== */
.editable-text {
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    outline: none;
    display: inline-block;
    min-width: 100px;
    transition: all 0.2s;
    text-transform: uppercase; /* Força maiúsculas na tela pra combinar com o banco */
    font-weight: 600; /* Deixa o nome com um destaque legal */
}
.editable-text:hover { background-color: #f8fafc; box-shadow: 0 0 0 1px #cbd5e1; }
.editable-text:focus { background-color: #ffffff; box-shadow: 0 0 0 2px #3b82f6; }