/* ==========================================================================
   1. VARIÁVEIS DE SISTEMA & CORES (IDENTIDADE VISUAL ESTOQUELV)
   ========================================================================== */
:root {
    /* Cores Principais */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --background: #f8fafc;
    --surface: #ffffff;
    --sidebar-bg: #0f172a;
    
    /* Cores de Status (Estoque) */
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --purple: #8b5cf6;
    --purple-light: #f5f3ff;

    /* Textos */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #f1f5f9;

    /* Estrutura e Efeitos */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. RESET & CONFIGURAÇÕES GERAIS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Animação de entrada suave ao carregar a página */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   3. LAYOUT ESTRUTURAL (CONTAINER PRINCIPAL)
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* BARRA LATERAL (SIDEBAR) */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #1e293b;
}

.brand-icon {
    font-size: 1.8rem;
    color: var(--primary);
}

.sidebar-brand h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-brand h2 span {
    color: var(--primary);
}

/* Menu de Navegação */
.sidebar-menu {
    flex: 1;
    margin-top: 2rem;
}

.sidebar-menu ul {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 0.5rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.sidebar-menu li.active a, 
.sidebar-menu a:hover {
    background-color: var(--primary);
    color: var(--surface);
}

.sidebar-menu a i {
    font-size: 1.1rem;
    width: 20px;
}

/* Rodapé do Usuário na Sidebar */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid #1e293b;
}

.user-avatar {
    width: 45px;
    height: 45px;
    background-color: #1e293b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.user-info .user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* CONTEÚDO PRINCIPAL (DIREITA) */
.main-content {
    flex: 1;
    margin-left: 260px; /* Alinhado para não ficar embaixo da sidebar */
    padding: 2.5rem;
    max-width: 1400px;
    animation: fadeIn 0.6s ease-out;
}

/* ==========================================================================
   4. CABEÇALHO (TOP HEADER)
   ========================================================================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.header-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.notification-badge {
    position: relative;
    background: var(--surface);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
}

.notification-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.notification-badge .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: var(--surface);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

.current-date {
    background: var(--surface);
    padding: 0.75rem 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ==========================================================================
   5. CARTÕES DE MÉTRICAS (KPI CARDS)
   ========================================================================== */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.kpi-icon {
    width: 55px;
    height: 55px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Variações de Cores dos Ícones KPI */
.icon-blue { background-color: var(--primary-light); color: var(--primary); }
.icon-green { background-color: var(--success-light); color: var(--success); }
.icon-warning { background-color: var(--warning-light); color: var(--warning); }
.icon-purple { background-color: var(--purple-light); color: var(--purple); }

.kpi-data h3 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-data p {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ==========================================================================
   6. SEÇÃO DE BUSCA RÁPIDA (O CORE DO PEDIDO DO CLIENTE)
   ========================================================================== */
.section-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.section-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.search-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    background: var(--background);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    background: var(--surface);
}

.barcode-input-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}

#search-input {
    width: 100%;
    padding: 1.1rem 1rem 1.1rem 3.5rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
}

/* BOTÕES GERAIS */
.btn {
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--surface);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: scale(1.02);
}

.btn-success {
    background-color: var(--success);
    color: var(--surface);
}

.btn-success:hover {
    background-color: #047857;
    transform: scale(1.02);
}

.btn-secondary {
    background-color: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

#search-button {
    margin-right: 0.5rem;
}

/* ==========================================================================
   7. TABELA DE PRODUTOS RESPONSIVA
   ========================================================================== */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto; /* Garante scroll se a tabela for maior que a tela do celular */
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.inventory-table th {
    background-color: var(--background);
    color: var(--text-muted);
    padding: 1rem 1.25rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.inventory-table td {
    padding: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-main);
}

/* Destacar a linha do Cream Cracker requisitado pelo cliente */
.highlight-row {
    background-color: #fffbeb;
    animation: pulseHighlight 2s infinite ease-in-out;
}

@keyframes pulseHighlight {
    0% { background-color: #fffbeb; }
    50% { background-color: #fef3c7; }
    100% { background-color: #fffbeb; }
}

.product-name-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.product-name-cell i {
    font-size: 1.5rem;
}

.text-amber { color: var(--warning); }
.text-blue { color: var(--primary); }
.text-yellow { color: #eab308; }

.p-name {
    font-weight: 600;
    color: var(--text-main);
}

.product-name-cell small {
    color: var(--text-muted);
    display: block;
}

/* Badges e Tags de Alerta */
.category-tag {
    background-color: #f1f5f9;
    color: #475569;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.stock-qty-badge {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
}

.qty-ok { background-color: var(--success-light); color: var(--success); }
.qty-low { background-color: var(--danger-light); color: var(--danger); }

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
}

.status-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-green { color: var(--success); }
.status-green::before { background-color: var(--success); }

.status-red { color: var(--danger); }
.status-red::before { background-color: var(--danger); }

/* Botões de Ações na Linha */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-edit { background-color: var(--primary-light); color: var(--primary); }
.btn-edit:hover { background-color: var(--primary); color: var(--surface); }

.btn-history { background-color: #f1f5f9; color: #475569; }
.btn-history:hover { background-color: #475569; color: var(--surface); }


/* ==========================================================================
   8. JANELA MODAL (AJUSTE DE ESTOQUE)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.modal-header {
    background-color: var(--background);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-top: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    outline: none;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus, 
.form-group select:focus {
    border-color: var(--primary);
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    background-color: var(--background);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid #e2e8f0;
}


/* ==========================================================================
   9. RESPONSIVIDADE (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 2rem 0.5rem;
    }
    .sidebar-brand h2, 
    .sidebar-menu span, 
    .sidebar-footer .user-info {
        display: none; /* Esconde textos na barra lateral em tablets */
    }
    .sidebar-brand {
        justify-content: center;
    }
    .sidebar-menu a {
        justify-content: center;
        padding: 1rem;
    }
    .main-content {
        margin-left: 80px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column; /* Joga a barra lateral para cima ou vira topo */
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1rem;
        flex-direction: row;
        align-items: center;
    }
    .sidebar-brand {
        border-bottom: none;
        padding-bottom: 0;
    }
    .sidebar-menu {
        display: none; /* Em telas muito pequenas o menu some para dar espaço (padrão mobile de teste) */
    }
    .sidebar-footer {
        border-top: none;
        padding-top: 0;
    }
    .main-content {
        margin-left: 0;
        padding: 1.2rem;
    }
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .search-wrapper {
        flex-direction: column;
        gap: 0.5rem;
        background: transparent;
    }
    #search-input {
        background: var(--surface);
        border-radius: var(--radius-md);
        border: 2px solid #e2e8f0;
        padding: 1rem 1rem 1rem 3rem;
    }
    #search-button {
        width: 100%;
        margin-right: 0;
        justify-content: center;
        padding: 1rem;
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    #btn-add-product {
        width: 100%;
        justify-content: center;
    }
    .modal-card {
        width: 90%;
    }
}