/* ==========================================================================
   Sistema de Controle de Vendas e Estoque - Estilos gerais
   ========================================================================== */

:root {
    --azul: #2563eb;
    --azul-escuro: #1d4ed8;
    --azul-claro: #eff6ff;
    --verde: #16a34a;
    --verde-claro: #f0fdf4;
    --vermelho: #dc2626;
    --vermelho-claro: #fef2f2;
    --amarelo: #d97706;
    --amarelo-claro: #fffbeb;
    --roxo: #7c3aed;
    --roxo-claro: #f5f3ff;

    --texto: #1e293b;
    --texto-suave: #64748b;
    --fundo: #f4f6fb;
    --superficie: #ffffff;
    --borda: #e2e8f0;
    --sombra: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --sombra-media: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    --raio: 12px;
    --raio-sm: 8px;
    --sidebar-largura: 250px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--fundo);
    color: var(--texto);
    font-size: 15px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Layout geral ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-largura);
    background: #111827;
    color: #e5e7eb;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar .marca {
    padding: 22px 20px 16px;
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .marca .ponto {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--azul);
    box-shadow: 0 0 0 4px rgba(37,99,235,.25);
}

.sidebar nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--raio-sm);
    color: #cbd5e1;
    font-size: .93rem;
    margin-bottom: 3px;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.ativo { background: var(--azul); color: #fff; }
.sidebar nav a .icone { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar .rodape-sidebar {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .82rem;
    color: #94a3b8;
}
.sidebar .rodape-sidebar button {
    margin-top: 8px;
    width: 100%;
    background: rgba(255,255,255,.08);
    border: none;
    color: #e5e7eb;
    padding: 8px 10px;
    border-radius: var(--raio-sm);
    cursor: pointer;
}
.sidebar .rodape-sidebar button:hover { background: rgba(255,255,255,.15); }

.conteudo {
    margin-left: var(--sidebar-largura);
    flex: 1;
    padding: 26px 32px 60px;
    width: calc(100% - var(--sidebar-largura));
}

.topo-pagina {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.topo-pagina h1 {
    font-size: 1.5rem;
    margin: 0 0 4px;
}
.topo-pagina p.subtitulo {
    margin: 0;
    color: var(--texto-suave);
    font-size: .9rem;
}

.btn-menu-mobile {
    display: none;
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    width: 40px; height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
}

/* ---------- Botões ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--raio-sm);
    border: 1px solid transparent;
    font-size: .89rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .12s, background .12s, transform .05s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-escuro); }
.btn-secundario { background: var(--superficie); color: var(--texto); border-color: var(--borda); }
.btn-secundario:hover { background: #f8fafc; }
.btn-perigo { background: var(--vermelho-claro); color: var(--vermelho); }
.btn-perigo:hover { filter: brightness(0.95); }
.btn-sucesso { background: var(--verde-claro); color: var(--verde); }
.btn-sucesso:hover { filter: brightness(0.95); }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.btn-icone {
    width: 34px; height: 34px; padding: 0;
    justify-content: center;
    border-radius: var(--raio-sm);
    background: transparent;
    border: 1px solid var(--borda);
    color: var(--texto-suave);
}
.btn-icone:hover { background: #f1f5f9; color: var(--texto); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards do Dashboard ---------- */

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.card {
    background: var(--superficie);
    border-radius: var(--raio);
    padding: 18px 20px;
    box-shadow: var(--sombra);
    border: 1px solid var(--borda);
}

.card-stat { display: flex; flex-direction: column; gap: 8px; }
.card-stat .rotulo {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--texto-suave);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-stat .valor { font-size: 1.6rem; font-weight: 700; }
.card-stat .valor.pequeno { font-size: 1.3rem; }
.card-stat .icone-badge {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
}
.bg-azul { background: var(--azul-claro); color: var(--azul); }
.bg-verde { background: var(--verde-claro); color: var(--verde); }
.bg-vermelho { background: var(--vermelho-claro); color: var(--vermelho); }
.bg-amarelo { background: var(--amarelo-claro); color: var(--amarelo); }
.bg-roxo { background: var(--roxo-claro); color: var(--roxo); }

.grid-graficos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}
.painel-grafico {
    background: var(--superficie);
    border-radius: var(--raio);
    padding: 18px 20px;
    box-shadow: var(--sombra);
    border: 1px solid var(--borda);
}
.painel-grafico h3 { margin: 0 0 14px; font-size: .98rem; }
.painel-grafico .grafico-wrap { position: relative; height: 260px; }

/* ---------- Painel / seção de conteúdo ---------- */

.painel {
    background: var(--superficie);
    border-radius: var(--raio);
    box-shadow: var(--sombra);
    border: 1px solid var(--borda);
    overflow: hidden;
    margin-bottom: 22px;
}
.painel-cabecalho {
    padding: 16px 20px;
    border-bottom: 1px solid var(--borda);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.painel-cabecalho h2 { margin: 0; font-size: 1.05rem; }
.painel-corpo { padding: 18px 20px; }

/* ---------- Barra de filtros ---------- */

.barra-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 20px;
    background: #fafbfd;
    border-bottom: 1px solid var(--borda);
}
.barra-filtros input,
.barra-filtros select {
    padding: 8px 12px;
    border-radius: var(--raio-sm);
    border: 1px solid var(--borda);
    font-size: .86rem;
    background: #fff;
}
.barra-filtros input[type="text"] { min-width: 220px; flex: 1; }

/* ---------- Tabelas ---------- */

.tabela-wrap { overflow-x: auto; }

table.tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: .87rem;
    min-width: 900px;
}
table.tabela thead th {
    text-align: left;
    padding: 11px 14px;
    background: #f8fafc;
    color: var(--texto-suave);
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--borda);
    white-space: nowrap;
}
table.tabela tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
table.tabela tbody tr:hover { background: #f8fafc; }
table.tabela tbody tr:last-child td { border-bottom: none; }
.col-numero { text-align: right; font-variant-numeric: tabular-nums; }
.texto-suave { color: var(--texto-suave); }
.texto-negrito { font-weight: 700; }
.texto-verde { color: var(--verde); font-weight: 600; }
.texto-vermelho { color: var(--vermelho); font-weight: 600; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-verde { background: var(--verde-claro); color: var(--verde); }
.badge-vermelho { background: var(--vermelho-claro); color: var(--vermelho); }
.badge-amarelo { background: var(--amarelo-claro); color: var(--amarelo); }
.badge-azul { background: var(--azul-claro); color: var(--azul); }
.badge-cinza { background: #f1f5f9; color: var(--texto-suave); }

.acoes-linha { display: flex; gap: 6px; }

.estado-vazio {
    text-align: center;
    padding: 50px 20px;
    color: var(--texto-suave);
}
.estado-vazio .emoji { font-size: 2rem; display: block; margin-bottom: 10px; }

/* ---------- Formulários / Modais ---------- */

.overlay-modal {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 100;
}
.overlay-modal.aberto { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--raio);
    width: 100%;
    max-width: 620px;
    box-shadow: var(--sombra-media);
    animation: entrada-modal .15s ease;
}
.modal.modal-largo { max-width: 880px; }
@keyframes entrada-modal {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-cabecalho {
    padding: 18px 22px;
    border-bottom: 1px solid var(--borda);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-cabecalho h3 { margin: 0; font-size: 1.05rem; }
.modal-fechar {
    background: none; border: none; font-size: 1.3rem;
    cursor: pointer; color: var(--texto-suave); line-height: 1;
}
.modal-corpo { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-rodape {
    padding: 16px 22px;
    border-top: 1px solid var(--borda);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.campo { margin-bottom: 16px; }
.campo label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #334155;
}
.campo .dica { font-size: .76rem; color: var(--texto-suave); margin-top: 4px; }
.campo input[type="text"],
.campo input[type="number"],
.campo input[type="date"],
.campo input[type="password"],
.campo input[type="email"],
.campo select,
.campo textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    font-size: .89rem;
    background: #fff;
    color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.campo textarea { resize: vertical; min-height: 70px; }
.linha-campos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.checkbox-linha { display: flex; align-items: center; gap: 8px; }
.checkbox-linha input { width: auto; }

.mensagem-erro-form {
    background: var(--vermelho-claro);
    color: var(--vermelho);
    padding: 10px 14px;
    border-radius: var(--raio-sm);
    font-size: .85rem;
    margin-bottom: 14px;
    display: none;
}
.mensagem-erro-form.mostrar { display: block; }

/* ---------- Toasts ---------- */

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: #1e293b;
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--raio-sm);
    box-shadow: var(--sombra-media);
    font-size: .87rem;
    max-width: 340px;
    animation: entrada-toast .2s ease;
}
.toast.sucesso { background: #166534; }
.toast.erro { background: #991b1b; }
@keyframes entrada-toast {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Login ---------- */

.pagina-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 20px;
}
.caixa-login {
    background: #fff;
    border-radius: var(--raio);
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--sombra-media);
}
.caixa-login .marca-login {
    text-align: center;
    margin-bottom: 22px;
}
.caixa-login .marca-login .ponto {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--azul);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 10px;
}
.caixa-login h1 { font-size: 1.15rem; margin: 0 0 4px; text-align: center; }
.caixa-login p { text-align: center; color: var(--texto-suave); font-size: .85rem; margin: 0 0 20px; }
.aviso-senha-padrao {
    background: var(--amarelo-claro);
    color: #92400e;
    padding: 10px 12px;
    border-radius: var(--raio-sm);
    font-size: .78rem;
    margin-top: 16px;
}

/* ---------- Responsividade ---------- */

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--sombra-media); }
    .sidebar.aberta { transform: translateX(0); }
    .conteudo { margin-left: 0; width: 100%; padding: 20px 16px 50px; }
    .btn-menu-mobile { display: inline-flex; align-items:center; justify-content:center; }
    table.tabela { min-width: 760px; }
}

@media (max-width: 520px) {
    .painel-corpo, .painel-cabecalho { padding-left: 14px; padding-right: 14px; }
    .modal { max-width: 100%; }
}

.overlay-sidebar {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 30;
}
.overlay-sidebar.aberto { display: block; }

.skeleton {
    background: linear-gradient(90deg, #eef1f6 25%, #e4e8f0 37%, #eef1f6 63%);
    background-size: 400% 100%;
    animation: brilho 1.4s ease infinite;
    border-radius: 6px;
}
@keyframes brilho {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
