/**
 * Sistema: Mercadinho Mobile-First
 * Arquivo: public_html/assets/css/style.css
 * Descrição: CSS Completo. Contém Login automático, PDV com botões Neon 
 * e estrutura responsiva adaptável para Mobile e Desktop.
 */

/* ==========================================================================
   CONFIGURAÇÕES GERAIS / RESET
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #333333;
    padding: 16px;
    margin: 0 auto;
}

/* ==========================================================================
   ESTILOS ROBUSTOS PARA A TELA DE LOGIN (login.php)
   ========================================================================== */
/* Centraliza e estiliza o corpo da página caso seja o Login */
body:has(form[action*="login"]), 
body:has(input[name="login"]) {
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* Transforma o formulário do login em um Card moderno */
body:has(input[name="login"]) form {
    background: #ffffff;
    padding: 32px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
}

/* Substitui o texto "Mercadinho" pela Logo PNG automaticamente */
body:has(input[name="login"]) h2,
body:has(input[name="login"]) h3,
body:has(input[name="login"]) .titulo {
    display: block;
    content: "";
    text-indent: -9999px;
    width: 100%;
    height: 80px;
    background: url('../img/logo.png') no-repeat center center;
    background-size: contain;
    margin-bottom: 12px;
}

body:has(input[name="login"]) p {
    color: #718096;
    font-size: 14px;
    text-align: center;
    margin-bottom: 24px;
}

body:has(input[name="login"]) label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-top: 12px;
    margin-bottom: 6px;
    text-align: left;
}

body:has(input[name="login"]) input[type="text"],
body:has(input[name="login"]) input[type="password"] {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    background: #f5f6f8;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

body:has(input[name="login"]) input:focus {
    border-color: #00875a;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.14);
}

body:has(input[name="login"]) button,
body:has(input[name="login"]) input[type="submit"] {
    width: 100%;
    height: 50px;
    background-color: #00875a;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

body:has(input[name="login"]) button:hover,
body:has(input[name="login"]) input[type="submit"]:hover {
    background-color: #006c48;
}

/* ==========================================================================
   ESTILOS DO CONTAINER DO APP (PDV - MOBILE POR PADRÃO)
   ========================================================================== */
.app-container {
    background: #ffffff;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 430px; /* Limita ao tamanho de celular no mobile */
    margin: 0 auto;
}

.app-header-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #111111;
}

/* Barra de Pesquisa */
.busca-container {
    position: relative;
    margin-bottom: 16px;
}
.busca-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.busca-input-wrapper input {
    width: 100%;
    height: 48px;
    padding-left: 44px;
    background: #f5f6f8;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    color: #333;
}
.busca-input-wrapper::before {
    content: "🔍";
    position: absolute;
    left: 16px;
    font-size: 16px;
    color: #a0aec0;
}

.resultados-busca {
    position: absolute;
    top: 52px;
    left: 0;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}
.item-busca {
    padding: 14px 16px;
    border-bottom: 1px solid #edf2f7;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

/* Seção do Carrinho */
.carrinho-secao {
    margin-top: 24px;
    margin-bottom: 24px;
}
.carrinho-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.carrinho-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #111111;
}
.btn-limpar-carrinho {
    background: none;
    border: none;
    color: #e53e3e;
    font-size: 18px;
    cursor: pointer;
}
.carrinho-vazio {
    color: #718096;
    font-size: 15px;
    text-align: center;
    padding: 20px 0;
}

/* Itens no Carrinho */
.item-carrinho {
    padding: 14px 0;
    border-bottom: 1px solid #edf2f7;
}
.item-carrinho-linha1 {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
    color: #2d3748;
    margin-bottom: 10px;
}
.item-carrinho-linha1 .item-preco-unitario {
    color: #718096;
    font-weight: 500;
}
.item-carrinho-linha2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Controles de + e - */
.seletor-qtd {
    display: flex;
    align-items: center;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2px;
}
.seletor-qtd button {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    color: #4a5568;
    cursor: pointer;
}
.seletor-qtd span {
    width: 36px;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    color: #2d3748;
}
.item-subtotal {
    font-weight: 700;
    font-size: 15px;
    color: #1a202c;
}

/* Bloco Total */
.total-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 700;
    color: #111111;
}
.total-valor {
    font-size: 24px;
    color: #00875a;
    font-weight: 800;
}

/* Grid de Formas de Pagamento */
.pagamento-titulo {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #111111;
}
.grid-pagamentos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* ==========================================================================
   CONFIGURAÇÃO DOS BOTÕES DE PAGAMENTO (SEMPREACESOS)
   ========================================================================== */
.btn-pagamento {
    height: 46px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 1 !important; /* Sempre acesos e coloridos */
}

/* Cores Oficiais Claras e Vibrantes */
.pag-dinheiro { background-color: #00875a; } 
.pag-pix { background-color: #00b4d8; }      
.pag-debito { background-color: #0056b3; }   
.pag-credito { background-color: #007bff; }  

.btn-fiado {
    grid-column: span 2;
    background-color: #e63946;               
    height: 46px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    margin-top: 10px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    opacity: 1 !important; /* Sempre aceso */
}

/* Animação de clique/seleção */
.btn-pagamento.ativo, .btn-fiado.ativo {
    transform: scale(1.03);
}

/* 🌟 HALO DE LUZ NEON INDIVIDUAL PARA O BOTÃO SELECIONADO */
.pag-dinheiro.ativo { box-shadow: 0 0 15px rgba(0, 135, 90, 0.9), 0 0 5px rgba(0, 135, 90, 0.6); }
.pag-pix.ativo { box-shadow: 0 0 15px rgba(0, 180, 216, 0.9), 0 0 5px rgba(0, 180, 216, 0.6); }
.pag-debito.ativo { box-shadow: 0 0 15px rgba(0, 86, 179, 0.9), 0 0 5px rgba(0, 86, 179, 0.6); }
.pag-credito.ativo { box-shadow: 0 0 15px rgba(0, 123, 255, 0.9), 0 0 5px rgba(0, 123, 255, 0.6); }
.btn-fiado.ativo { box-shadow: 0 0 15px rgba(230, 57, 70, 0.9), 0 0 5px rgba(230, 57, 70, 0.6); }

/* Botões de Ação Inferiores */
.btn-positive {
    width: 100%;
    height: 52px;
    background-color: #00875a;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-acao-caixa {
    width: 100%;
    height: 40px;
    background: none;
    color: #718096;
    font-size: 14px;
    font-weight: 600;
    border: none;
    margin-top: 12px;
    cursor: pointer;
    text-decoration: underline;
}

/* ==========================================================================
   🖥️ RESPONSIVIDADE INTELIGENTE PARA COMPUTADORES (Telas de PC / Tablets)
   ========================================================================== */
@media (min-width: 768px) {
    body {
        max-width: 1200px;
        margin: 0 auto;
        padding: 10px;
        height: 100vh;
        overflow: hidden; 
    }

    .app-container {
        max-width: 100%; 
        padding: 15px 25px; 
        height: calc(100vh - 20px); 
        display: flex;
        flex-direction: column;
    }

    #tela-venda {
        display: grid;
        grid-template-columns: 1.2fr 1fr; 
        gap: 15px 20px; 
        flex-grow: 1; 
        overflow: hidden; 
        align-content: start; 
    }

    /* --- COLUNA ESQUERDA --- */
    .busca-container {
        grid-column: 1;
        grid-row: 1; /* Fixado na linha 1 */
        margin-bottom: 0;
    }

    .carrinho-secao {
        grid-column: 1; 
        grid-row: 2 / 6; /* 🌟 A MÁGICA: O carrinho agora ocupa as linhas de 2 a 5! */
        display: flex;
        flex-direction: column;
        margin: 0;
        height: 100%; 
    }

    #carrinho-itens {
        overflow-y: auto; 
        flex-grow: 1;
        padding-right: 8px;
    }

    #carrinho-itens::-webkit-scrollbar { width: 6px; }
    #carrinho-itens::-webkit-scrollbar-thumb { background-color: #cbd5e0; border-radius: 10px; }

    /* --- COLUNA DIREITA (Botões e Total) --- */
    .total-container {
        grid-column: 2;
        grid-row: 1; /* Fixado na linha 1 */
        margin: 0;
        background: #f8f9fa;
        padding: 15px; 
        border-radius: 10px;
    }

    .pagamento-titulo {
        grid-column: 2;
        grid-row: 2; /* Fixado na linha 2 independente do carrinho */
        margin: 5px 0 0 0;
    }

    .grid-pagamentos {
        grid-column: 2;
        grid-row: 3;
        gap: 8px; 
    }

    .btn-pagamento, .btn-fiado {
        height: 40px; 
        font-size: 14px;
    }
    
    .btn-fiado {
        margin-top: 0;
        margin-bottom: 0; 
    }

    .btn-positive {
        grid-column: 2;
        grid-row: 4;
        margin-top: 5px;
        height: 48px; 
        font-size: 15px;
    }

    .btn-acao-caixa {
        grid-column: 2;
        grid-row: 5;
        margin-top: 5px;
        height: 30px; 
    }
    
    #tela-caixa {
        max-width: 500px;
        margin: 0 auto;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        border-radius: 12px;
        padding: 24px !important;
    }
}