/* ==========================================================================
   Insanos MC - Sistema de Vendas (PDV)
   Tema: preto / branco / laranja - identidade do moto clube
   ========================================================================== */

:root {
    --preto: #0d0d0d;
    --preto-suave: #161616;
    --superficie: #1c1c1c;
    --superficie-2: #232323;
    --borda: #2e2e2e;
    --texto: #f2f2f2;
    --texto-muted: #9a9a9a;
    --laranja: #fa8322;
    --laranja-escuro: #e34c02;
    --laranja-fraco: rgba(250, 131, 34, 0.15);
    --verde: #38b26a;
    --vermelho: #de4c4c;
    --amarelo: #d9a441;
    --raio: 10px;
    --sombra: 0 4px 14px rgba(0, 0, 0, 0.45);
    --fonte-titulo: 'Oswald', 'Arial Narrow', sans-serif;
    --fonte-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--preto);
    color: var(--texto);
    font-family: var(--fonte-base);
    -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

h1, h2, h3, h4 {
    font-family: var(--fonte-titulo), var(--fonte-base);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin: 0 0 .5rem;
}

a { color: var(--laranja); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 .75rem; color: var(--texto-muted); }

::selection { background: var(--laranja); color: #111; }

/* Scrollbar discreto */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--preto-suave); }
::-webkit-scrollbar-thumb { background: var(--borda); border-radius: 10px; }

/* ==========================================================================
   Login
   ========================================================================== */
.pagina-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 0%, rgba(250, 131, 34, 0.08), transparent 55%),
        var(--preto);
    padding: 1.5rem;
}

.login-caixa {
    width: 100%;
    max-width: 380px;
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 2rem 1.75rem 1.75rem;
    box-shadow: var(--sombra);
    text-align: center;
}

.login-caixa img.logo {
    width: 110px;
    height: auto;
    margin-bottom: .75rem;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.6));
}

.login-caixa h1 {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: .1rem;
}

.login-caixa .subtitulo {
    color: var(--laranja);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Formulários
   ========================================================================== */
.form-grupo { margin-bottom: 1rem; text-align: left; }

.form-grupo label {
    display: block;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-muted);
    margin-bottom: .35rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    background: var(--preto-suave);
    border: 1px solid var(--borda);
    color: var(--texto);
    padding: .7rem .8rem;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--laranja);
}

select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; padding-right: 2.2rem; }

.form-erro {
    background: rgba(222, 76, 76, 0.12);
    border: 1px solid rgba(222, 76, 76, 0.4);
    color: #ff8b8b;
    padding: .6rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1rem;
    text-align: left;
}

.form-sucesso {
    background: rgba(56, 178, 106, 0.12);
    border: 1px solid rgba(56, 178, 106, 0.4);
    color: #8ee0ae;
    padding: .6rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1rem;
    text-align: left;
}

/* ==========================================================================
   Botões
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .7rem 1.1rem;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform .05s ease, filter .15s, background .15s;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--laranja); color: #171100; }
.btn-primary:hover { background: var(--laranja-escuro); color: #fff; }

.btn-bloco { width: 100%; }

.btn-outline { background: transparent; border-color: var(--borda); color: var(--texto); }
.btn-outline:hover { border-color: var(--laranja); color: var(--laranja); }

.btn-ghost { background: transparent; color: var(--texto-muted); }
.btn-ghost:hover { color: var(--texto); }

.btn-perigo { background: rgba(222,76,76,.12); color: #ff8b8b; border-color: rgba(222,76,76,.35); }
.btn-perigo:hover { background: var(--vermelho); color: #fff; }

.btn-sucesso { background: var(--verde); color: #06210f; }
.btn-sucesso:hover { filter: brightness(1.1); }

.btn-sm { padding: .4rem .7rem; font-size: .8rem; border-radius: 6px; }
.btn-lg { padding: .95rem 1.4rem; font-size: 1.05rem; }
.btn-icone { padding: .5rem; width: 2.3rem; height: 2.3rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ==========================================================================
   Estrutura do app (topbar + sidebar + conteúdo)
   ========================================================================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--superficie);
    border-bottom: 1px solid var(--borda);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 40;
}

.topbar .marca {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-family: var(--fonte-titulo);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: 1rem;
    color: #fff;
}
.topbar .marca img { height: 34px; width: auto; }
.topbar .marca span.sub { color: var(--laranja); }

.topbar .usuario-area {
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: .85rem;
    color: var(--texto-muted);
}
.topbar .usuario-area strong { color: var(--texto); font-weight: 600; }
.topbar .badge-papel {
    text-transform: uppercase;
    font-size: .65rem;
    letter-spacing: .05em;
    background: var(--laranja-fraco);
    color: var(--laranja);
    padding: .18rem .5rem;
    border-radius: 100px;
    border: 1px solid rgba(250,131,34,.3);
}

.sidebar {
    position: fixed;
    top: 60px; left: 0; bottom: 0;
    width: 220px;
    background: var(--superficie);
    border-right: 1px solid var(--borda);
    padding: 1rem .7rem;
    overflow-y: auto;
    z-index: 30;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .8rem;
    border-radius: 8px;
    color: var(--texto-muted);
    font-size: .92rem;
    font-weight: 500;
    margin-bottom: .2rem;
}
.sidebar .nav-link .ic { font-size: 1.1rem; width: 1.4rem; text-align: center; }
.sidebar .nav-link:hover { background: var(--superficie-2); color: var(--texto); text-decoration: none; }
.sidebar .nav-link.ativo { background: var(--laranja-fraco); color: var(--laranja); }

.sidebar .nav-secao {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #6b6b6b;
    margin: 1.1rem .8rem .4rem;
}
.sidebar .nav-secao:first-child { margin-top: 0; }

.conteudo {
    margin-left: 220px;
    margin-top: 60px;
    padding: 1.5rem;
    width: 100%;
    max-width: 1400px;
}

.pagina-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .8rem;
    margin-bottom: 1.4rem;
}
.pagina-topo h1 { font-size: 1.4rem; color: #fff; margin: 0; }
.pagina-topo .desc { color: var(--texto-muted); font-size: .85rem; margin-top: .2rem; }

/* ==========================================================================
   Cards e estatísticas
   ========================================================================== */
.grade-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.1rem 1.2rem;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--laranja);
}
.stat-card .rotulo {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--texto-muted);
    margin-bottom: .4rem;
}
.stat-card .valor {
    font-family: var(--fonte-titulo);
    font-size: 1.7rem;
    color: #fff;
}
.stat-card .valor.laranja { color: var(--laranja); }
.stat-card .comparativo { font-size: .75rem; color: var(--texto-muted); margin-top: .3rem; }

.card {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}
.card h2, .card h3 { font-size: 1rem; color: #fff; margin-bottom: 1rem; }

/* ==========================================================================
   Tabelas
   ========================================================================== */
.tabela-wrap {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
thead th {
    text-align: left;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .06em;
    color: var(--texto-muted);
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--borda);
    white-space: nowrap;
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--borda); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; }
.tabela-vazia { padding: 2.5rem 1rem; text-align: center; color: var(--texto-muted); }

/* ==========================================================================
   Badges / status
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .6rem;
    border-radius: 100px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    white-space: nowrap;
}
.badge-sucesso { background: rgba(56,178,106,.15); color: #6fe0a0; }
.badge-alerta { background: rgba(217,164,65,.15); color: var(--amarelo); }
.badge-perigo { background: rgba(222,76,76,.15); color: #ff8b8b; }
.badge-neutro { background: var(--superficie-2); color: var(--texto-muted); }
.badge-laranja { background: var(--laranja-fraco); color: var(--laranja); }

/* ==========================================================================
   Grade de produtos (venda avulsa / comanda)
   ========================================================================== */
.layout-venda {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

.painel-produtos { min-width: 0; }

.filtro-categorias {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding-bottom: .3rem;
    margin-bottom: 1rem;
}
.filtro-categorias button {
    flex: 0 0 auto;
    background: var(--superficie);
    border: 1px solid var(--borda);
    color: var(--texto-muted);
    padding: .5rem 1rem;
    border-radius: 100px;
    font-size: .82rem;
    cursor: pointer;
    white-space: nowrap;
}
.filtro-categorias button.ativo { background: var(--laranja); border-color: var(--laranja); color: #171100; font-weight: 600; }

.grade-produtos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .8rem;
}

.produto-tile {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1rem .8rem;
    text-align: left;
    cursor: pointer;
    color: var(--texto);
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 92px;
    position: relative;
    font-family: inherit;
    transition: border-color .12s, transform .05s;
}
.produto-tile:active { transform: scale(.97); }
.produto-tile:hover { border-color: var(--laranja); }
.produto-tile .nome { font-weight: 600; font-size: .92rem; line-height: 1.25; }
.produto-tile .preco { color: var(--laranja); font-weight: 700; font-size: 1rem; }
.produto-tile .estoque-baixo { position: absolute; top: .6rem; right: .6rem; width: 8px; height: 8px; border-radius: 50%; background: var(--amarelo); }
.produto-tile:disabled, .produto-tile.esgotado { opacity: .4; cursor: not-allowed; }

/* Carrinho / comanda lateral */
.painel-carrinho {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.1rem;
    align-self: start;
    position: sticky;
    top: 76px;
}
.painel-carrinho h2 { font-size: 1rem; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.painel-carrinho .contador { background: var(--laranja); color: #171100; border-radius: 100px; font-size: .72rem; padding: .1rem .5rem; text-transform: none; letter-spacing: 0; }

.lista-carrinho { list-style: none; margin: 1rem 0; padding: 0; max-height: 45vh; overflow-y: auto; }
.lista-carrinho li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--borda);
}
.lista-carrinho li:last-child { border-bottom: none; }
.item-info { min-width: 0; }
.item-info .nome { font-size: .88rem; font-weight: 600; display: block; }
.item-info .preco-unit { font-size: .75rem; color: var(--texto-muted); }
.item-qtd {
    display: flex; align-items: center; gap: .4rem;
}
.item-qtd button {
    width: 26px; height: 26px; border-radius: 6px;
    background: var(--superficie-2); border: 1px solid var(--borda); color: var(--texto);
    cursor: pointer; font-size: 1rem; line-height: 1;
}
.item-qtd span { min-width: 1.4rem; text-align: center; font-size: .88rem; }
.item-subtotal { font-size: .85rem; font-weight: 700; color: var(--laranja); min-width: 68px; text-align: right; }
.remover-item { color: var(--texto-muted); background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 .2rem; }
.remover-item:hover { color: var(--vermelho); }

.carrinho-vazio { text-align: center; color: var(--texto-muted); font-size: .85rem; padding: 1.5rem 0; }

.carrinho-total {
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--fonte-titulo);
    font-size: 1.3rem;
    color: #fff;
    padding: .8rem 0;
    border-top: 1px dashed var(--borda);
    margin-bottom: .8rem;
}
.carrinho-total .valor { color: var(--laranja); }

.formas-pagamento { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.formas-pagamento label {
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--borda); border-radius: 8px; padding: .6rem .4rem;
    font-size: .82rem; cursor: pointer; color: var(--texto-muted); text-align: center;
    text-transform: none;
}
.formas-pagamento input { display: none; }
.formas-pagamento input:checked + span { color: var(--laranja); }
.formas-pagamento label:has(input:checked) { border-color: var(--laranja); background: var(--laranja-fraco); color: var(--laranja); }

@media (min-width: 960px) {
    .layout-venda { grid-template-columns: 1fr 340px; align-items: start; }
}

/* ==========================================================================
   Comandas (cards de listagem)
   ========================================================================== */
.grade-comandas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.comanda-card {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1rem;
    cursor: pointer;
    transition: border-color .12s;
}
.comanda-card:hover { border-color: var(--laranja); }
.comanda-card .colete {
    font-family: var(--fonte-titulo);
    color: #fff;
    font-size: 1.05rem;
    margin-bottom: .3rem;
    text-transform: uppercase;
}
.comanda-card .meta { font-size: .78rem; color: var(--texto-muted); margin-bottom: .6rem; }
.comanda-card .total { color: var(--laranja); font-weight: 700; font-size: 1.1rem; }

.nova-comanda-card {
    border: 2px dashed var(--borda);
    background: transparent;
    border-radius: var(--raio);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .5rem; color: var(--texto-muted); cursor: pointer;
    min-height: 110px; font-size: .9rem; font-family: inherit;
}
.nova-comanda-card:hover { border-color: var(--laranja); color: var(--laranja); }
.nova-comanda-card .mais { font-size: 1.8rem; line-height: 1; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.65);
    display: none; align-items: center; justify-content: center;
    padding: 1rem; z-index: 100;
}
.modal-overlay.aberto { display: flex; }
.modal {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.4rem;
    width: 100%; max-width: 420px;
    box-shadow: var(--sombra);
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; color: #fff; margin-bottom: 1rem; }
.modal-acoes { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; }
.modal-fechar { position: absolute; }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
    position: fixed; top: 76px; right: 1rem; z-index: 200;
    display: flex; flex-direction: column; gap: .6rem;
    max-width: 320px;
}
.toast {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-left: 4px solid var(--laranja);
    border-radius: 8px;
    padding: .8rem 1rem;
    font-size: .85rem;
    box-shadow: var(--sombra);
    animation: entrar-toast .2s ease;
}
.toast.sucesso { border-left-color: var(--verde); }
.toast.erro { border-left-color: var(--vermelho); }
@keyframes entrar-toast { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ==========================================================================
   Utilidades
   ========================================================================== */
.muted { color: var(--texto-muted); }
.txt-center { text-align: center; }
.txt-right { text-align: right; }
.flex { display: flex; align-items: center; }
.flex-entre { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.mb-0 { margin-bottom: 0 !important; }
.mt-md { margin-top: 1rem; }
.oculto { display: none !important; }
.barra-progresso { background: var(--preto-suave); border-radius: 100px; height: 8px; overflow: hidden; }
.barra-progresso .preenchido { height: 100%; background: var(--laranja); border-radius: 100px; }

/* ==========================================================================
   Mobile: sidebar vira barra inferior
   ========================================================================== */
@media (max-width: 860px) {
    .conteudo { margin-left: 0; padding: 1rem 1rem 5.5rem; }

    .sidebar {
        top: auto; bottom: 0; left: 0; right: 0; height: 66px;
        width: 100%; border-right: none; border-top: 1px solid var(--borda);
        display: flex; flex-direction: row; align-items: center; justify-content: space-around;
        padding: .4rem;
        overflow-x: auto;
    }
    .sidebar .nav-secao { display: none; }
    .sidebar .nav-link {
        flex-direction: column; gap: .15rem; font-size: .62rem; padding: .4rem .5rem;
        margin-bottom: 0; text-align: center; white-space: nowrap;
    }
    .sidebar .nav-link .ic { font-size: 1.25rem; width: auto; }

    .topbar .usuario-area .texto-usuario { display: none; }
    .pagina-topo h1 { font-size: 1.2rem; }
}

@media (max-width: 480px) {
    .grade-produtos { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .formas-pagamento { grid-template-columns: repeat(2, 1fr); }
}
