/* ===========================================
   SUPERMERCADO - CSS MODERNO
   =========================================== */

:root {
    --cor-primaria: #3b82f6;
    --cor-sucesso: #10b981;
    --cor-perigo: #ef4444;
    --cor-aviso: #f59e0b;
    --cor-texto: #1f2937;
    --cor-texto-secundario: #6b7280;
    --cor-borda: #e5e7eb;
    --cor-fundo: #f9fafb;
    --radius: 8px;
}

.supermercado-container {
    padding: 0;
    width: 100%;
    background: var(--cor-fundo);
    min-height: 100vh;
}

/* ===========================================
   HEADER
   =========================================== */

.page-header {
    padding: 24px 28px 16px;
    background: white;
    border-bottom: 1px solid var(--cor-borda);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--cor-texto);
    margin: 0;
    letter-spacing: -0.02em;
}

/* ===========================================
   BARRA DE AÇÕES
   =========================================== */

.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: white;
    border-bottom: 1px solid var(--cor-borda);
}

.actions-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.import-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-input {
    display: none;
}

.btn-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--cor-texto);
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-file:hover {
    background: var(--cor-fundo);
    border-color: #d1d5db;
}

.file-name {
    font-size: 0.8rem;
    color: var(--cor-texto-secundario);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-import {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--cor-primaria);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-import:hover {
    background: #2563eb;
}

/* ===========================================
   STATS BOX
   =========================================== */

.stats-box {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
}

.stat-item {
    color: var(--cor-texto-secundario);
}

.stat-item strong {
    color: var(--cor-texto);
    font-weight: 600;
}

.stat-divider {
    color: var(--cor-borda);
}

.stat-warning {
    color: var(--cor-aviso);
}

.stat-warning strong {
    color: #d97706;
}

/* ===========================================
   VARIAÇÕES POR CATEGORIA
   =========================================== */

.variacoes-categorias-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: white;
    border-bottom: 1px solid var(--cor-borda);
    overflow-x: auto;
}

.var-cat-label {
    font-size: 0.8rem;
    color: var(--cor-texto-secundario);
    font-weight: 500;
    white-space: nowrap;
}

.var-cat-items {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.var-cat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: var(--cor-fundo);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: default;
    white-space: nowrap;
    transition: transform 0.15s ease;
}

.var-cat-item:hover {
    transform: scale(1.03);
}

.var-cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.var-cat-item.var-alta {
    color: #dc2626;
    background: #fef2f2;
}

.var-cat-item.var-baixa {
    color: #16a34a;
    background: #f0fdf4;
}

.var-cat-item.var-igual {
    color: #6b7280;
    background: #f3f4f6;
}

.var-cat-item.var-nova {
    color: #7c3aed;
    background: #f5f3ff;
}

.var-cat-seta {
    font-size: 0.8rem;
}

/* ===========================================
   BARRA DE FILTROS
   =========================================== */

.filters-bar {
    padding: 14px 28px;
    background: white;
    border-bottom: 1px solid var(--cor-borda);
}

.filters-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
}

.filter-select {
    padding: 9px 12px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius);
    font-size: 0.85rem;
    min-width: 180px;
    background: white;
    color: var(--cor-texto);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--cor-primaria);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-group {
    display: flex;
    gap: 0;
}

.filter-input {
    padding: 9px 12px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.85rem;
    width: 180px;
    color: var(--cor-texto);
}

.filter-input:focus {
    outline: none;
    border-color: var(--cor-primaria);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-search {
    padding: 9px 14px;
    background: var(--cor-primaria);
    color: white;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-search:hover {
    background: #2563eb;
}

.btn-clear {
    padding: 9px 14px;
    background: var(--cor-fundo);
    color: var(--cor-texto-secundario);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-clear:hover {
    background: #e5e7eb;
    color: var(--cor-texto);
}

/* ===========================================
   MENSAGENS
   =========================================== */

.messages {
    padding: 0 28px 16px;
    background: white;
}

.message {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.message-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ===========================================
   TABELA
   =========================================== */

.table-container {
    background: white;
    margin: 0;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--cor-borda);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.items-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
    color: var(--cor-texto);
}

.items-table tbody tr:hover {
    background: #fafbfc;
}

/* ===========================================
   COLUNAS DA TABELA
   =========================================== */

.col-data { 
    width: 85px;
    white-space: nowrap;
    color: var(--cor-texto-secundario) !important;
    font-size: 0.8rem !important;
}

.col-codigo { 
    width: 65px;
    text-align: center;
    color: #94a3b8 !important;
    font-size: 0.8rem !important;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.col-descricao { 
    min-width: 180px;
    max-width: 280px;
}

.col-qtd { 
    width: 65px;
    text-align: right;
}

.col-un { 
    width: 40px;
    text-align: center;
    color: var(--cor-texto-secundario) !important;
}

.col-unit { 
    width: 80px;
    text-align: right;
    white-space: nowrap;
}

.col-variacao {
    width: 70px;
    text-align: center;
}

.col-total { 
    width: 85px;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

.col-categoria { 
    width: 130px;
}

.col-acoes { 
    width: 50px;
    text-align: center;
}

/* ===========================================
   BADGE DE VARIAÇÃO
   =========================================== */

.variacao-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.variacao-alta {
    background: #fef2f2;
    color: #dc2626;
}

.variacao-baixa {
    background: #f0fdf4;
    color: #16a34a;
}

.variacao-igual {
    background: #f8fafc;
    color: #94a3b8;
}

.variacao-neutro {
    background: transparent;
    color: #cbd5e1;
}

/* ===========================================
   BADGE DE CATEGORIA
   =========================================== */

.categoria-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #e5e7eb;
    color: white;
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sem-categoria {
    color: #b0b8c4;
    font-style: normal;
    font-weight: 400;
}

/* ===========================================
   BOTÃO CATEGORIZAR
   =========================================== */

.btn-categorizar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.btn-categorizar:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

/* ===========================================
   EMPTY MESSAGE
   =========================================== */

.empty-message {
    text-align: center;
    padding: 48px 24px !important;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* ===========================================
   PAGINAÇÃO
   =========================================== */

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: white;
    border-top: 1px solid var(--cor-borda);
}

.pagination-info {
    color: var(--cor-texto-secundario);
    font-size: 0.85rem;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-link {
    padding: 8px 14px;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.pagination-link:hover {
    background: #e5e7eb;
}

.pagination-current {
    color: var(--cor-texto-secundario);
    font-size: 0.85rem;
}

/* ===========================================
   MODAL
   =========================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 440px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--cor-borda);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--cor-texto);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.modal-close:hover {
    color: var(--cor-texto);
}

.modal-body {
    padding: 20px;
}

.item-descricao {
    font-size: 0.95rem;
    color: var(--cor-texto);
    margin-bottom: 16px;
    padding: 12px;
    background: var(--cor-fundo);
    border-radius: var(--radius);
    word-break: break-word;
    border: 1px solid var(--cor-borda);
}

.item-codigo {
    font-size: 0.8rem;
    color: var(--cor-texto-secundario);
    margin-bottom: 16px;
}

/* ===========================================
   GRID DE CATEGORIAS
   =========================================== */

.categorias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.categoria-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--cor-fundo);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.categoria-option:hover {
    background: var(--cat-color, #e5e7eb);
    color: white;
    border-color: var(--cat-color, #e5e7eb);
}

.categoria-option .cat-icone {
    font-size: 1.3rem;
}

.categoria-option .cat-nome {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.modal-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--cor-borda);
    text-align: center;
}

.btn-remover-cat {
    padding: 10px 20px;
    background: #fef2f2;
    color: var(--cor-perigo);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-remover-cat:hover {
    background: #fee2e2;
}

.no-categorias {
    grid-column: 1 / -1;
    text-align: center;
    color: #94a3b8;
    padding: 24px;
    font-size: 0.9rem;
}

/* ===========================================
   OPÇÕES DE REGRA
   =========================================== */

.regra-options {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--cor-borda);
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--cor-texto);
}

.checkbox-label input,
.radio-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--cor-primaria);
}

.regra-tipo {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    padding-left: 24px;
}

.regra-tipo.hidden {
    display: none;
}

/* ===========================================
   RESPONSIVO
   =========================================== */

@media (max-width: 1024px) {
    .col-descricao {
        min-width: 150px;
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .page-header,
    .actions-bar,
    .variacoes-categorias-bar,
    .filters-bar,
    .pagination-bar {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .actions-left {
        width: 100%;
    }
    
    .import-form {
        flex-wrap: wrap;
    }
    
    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-select,
    .filter-input {
        width: 100%;
        min-width: unset;
    }
    
    .search-group {
        width: 100%;
    }
    
    .search-group .filter-input {
        flex: 1;
    }
    
    .items-table th,
    .items-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }
    
    .col-descricao {
        min-width: 120px;
        max-width: 160px;
    }
    
    .pagination-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .stats-box {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}
