﻿/* ===== Tema ===== */
:root {
    --cor-primaria: #0a2a8f;
    --cor-primaria-escura: #071f6b;
    --cor-fundo: #f5f7fb;
    --cor-menu: #eef1f8;
    --cor-borda: #e3e7f0;
    --cor-texto: #1b2236;
    --cor-suave: #6b7488;
    --bs-primary: #0a2a8f;
    --bs-primary-rgb: 10, 42, 143;
    --bs-link-color: #0a2a8f;
    --bs-link-hover-color: #071f6b;
    --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --bs-body-color: #1b2236;
    --bs-border-radius: .6rem;
}

html, body {
    font-family: var(--bs-body-font-family);
    background: var(--cor-fundo);
    color: var(--cor-texto);
    font-size: .92rem;
}

.btn-primary { --bs-btn-bg: #0a2a8f; --bs-btn-border-color: #0a2a8f; --bs-btn-hover-bg: #071f6b; --bs-btn-hover-border-color: #071f6b; --bs-btn-active-bg: #071f6b; }
.btn-outline-primary { --bs-btn-color: #0a2a8f; --bs-btn-border-color: #0a2a8f; --bs-btn-hover-bg: #0a2a8f; --bs-btn-hover-border-color: #0a2a8f; }
.card { border: 1px solid var(--cor-borda); border-radius: .85rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .03); }
.form-control, .form-select { border-color: var(--cor-borda); border-radius: .55rem; }
.form-control:focus, .form-select:focus { border-color: #5b73c9; box-shadow: 0 0 0 .2rem rgba(10, 42, 143, .12); }

.btn-primario { background: var(--cor-primaria); color: #fff; border: 1px solid var(--cor-primaria); font-weight: 600; border-radius: .55rem; }
.btn-primario:hover { background: var(--cor-primaria-escura); color: #fff; }
.btn-contorno { background: #fff; color: var(--cor-texto); border: 1px solid var(--cor-borda); font-weight: 500; border-radius: .55rem; }
.btn-contorno:hover { background: #f1f4fb; color: var(--cor-texto); }
.btn-icone { border: 1px solid var(--cor-borda); background: #fff; }

/* ===== Estrutura ===== */
.shell { min-height: 100vh; display: flex; }
.shell-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topo {
    height: 64px; background: #fff; border-bottom: 1px solid var(--cor-borda);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 20;
}
.topo-titulo { display: flex; align-items: center; gap: .6rem; margin-right: auto; min-width: 0; }
.topo-titulo h1 { font-size: 1.25rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-usuario { display: flex; align-items: center; gap: .6rem; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: #dfe6fb; color: var(--cor-primaria);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .75rem;
}
.usuario-nome { font-weight: 600; font-size: .85rem; }

.selo {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600;
    background: #e7ecfb; color: var(--cor-primaria); white-space: nowrap;
}
.selo-vermelho { background: #fde3e3; color: #b42318; }
.selo-amarelo { background: #fff0c2; color: #8a5a00; }
.selo-verde { background: #dcf5e6; color: #107a46; }

.app-conteudo { flex: 1; padding: 1.5rem; min-width: 0; }

/* ===== Menu lateral ===== */
.app-menu {
    width: 252px; flex-shrink: 0; background: var(--cor-menu); border-right: 1px solid var(--cor-borda);
    padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.marca { display: flex; align-items: center; gap: .7rem; padding: .25rem .5rem 1rem; text-decoration: none; color: var(--cor-texto); }
.marca-icone {
    width: 38px; height: 38px; border-radius: .6rem; background: var(--cor-primaria); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.marca-texto { display: flex; flex-direction: column; line-height: 1.15; }
.marca-texto strong { font-size: .95rem; }
.marca-texto small { color: var(--cor-suave); font-size: .72rem; }

.app-menu .nav-link { color: #3a4358; padding: .45rem .75rem; border-radius: .55rem; font-weight: 500; }
.app-menu .nav-link:hover { background: #e2e7f4; }
.app-menu .nav-principal.active { background: var(--cor-primaria); color: #fff; font-weight: 600; }
.app-menu .nav-link.sub { padding: .35rem .75rem .35rem 2.25rem; font-size: .85rem; color: #4a546b; font-weight: 500; }
.app-menu .nav-link.sub.active { background: var(--cor-primaria); color: #fff; font-weight: 600; }
.app-menu details { margin: .15rem 0; }
.app-menu summary {
    cursor: pointer; padding: .5rem .75rem; font-weight: 600; color: var(--cor-texto); border-radius: .55rem;
    list-style: none; display: flex; align-items: center;
}
.app-menu summary::-webkit-details-marker { display: none; }
.app-menu summary::after { content: "\F282"; font-family: "bootstrap-icons"; margin-left: auto; font-size: .7rem; color: var(--cor-suave); transition: transform .15s; }
.app-menu details[open] > summary::after { transform: rotate(180deg); }
.app-menu summary:hover { background: #e2e7f4; }
.app-menu .menu-grupo { padding: .6rem .75rem .1rem 2.25rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #8790a5; font-weight: 700; }

/* ===== Listas ===== */
.barra-lista { margin-bottom: 1rem; }
.barra-lista-corpo { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .75rem; }
.busca { position: relative; flex: 1 1 280px; max-width: 420px; }
.busca i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--cor-suave); }
.busca .form-control { padding-left: 2.1rem; background: #f8f9fd; }

.cartao-lista { overflow: hidden; }
.cartao-lista-corpo { padding: 0; }
.cartao-lista .table { margin: 0; }
.cartao-lista .table > :not(caption) > * > * { padding: .8rem 1rem; border-bottom-color: #eef0f6; }
.table thead th {
    background: #f7f8fc; color: var(--cor-suave); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 700; border-bottom: 1px solid var(--cor-borda);
}
.cartao-lista .table tbody tr:hover > * { background: #f7f9ff; }
.rodape-lista { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .75rem 1rem; border-top: 1px solid var(--cor-borda); }

.table-grade th { white-space: nowrap; }
.table-grade th.ordenavel { cursor: pointer; user-select: none; }
.table-grade td.acoes { white-space: nowrap; width: 1%; text-align: right; }
.table-grade td.acoes .btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-color: var(--cor-borda); border-radius: .5rem; }
.table-grade td.acoes .btn-outline-primary { color: var(--cor-primaria); background: #fff; }
.table-grade td.acoes .btn-outline-primary:hover { background: #e7ecfb; }
.table-grade td.acoes .btn-outline-danger { color: #d92d20; background: #fff; }
.table-grade td.acoes .btn-outline-danger:hover { background: #fde3e3; }

/* ===== Dashboard ===== */
.indicador .card-body { padding: 1rem 1.1rem; }
.indicador-topo { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.indicador-titulo { color: var(--cor-suave); font-size: .82rem; font-weight: 500; }
.indicador-valor { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
.icone-chip { width: 32px; height: 32px; border-radius: .55rem; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; }
.icone-chip.grande { width: 44px; height: 44px; font-size: 1.15rem; }
.chip-amarelo { background: #fff0c2; color: #8a5a00; }
.chip-verde { background: #dcf5e6; color: #107a46; }
.chip-azul { background: #e0e8fc; color: var(--cor-primaria); }
.chip-ciano { background: #daf1fb; color: #0a6d93; }
.chip-vermelho { background: #fde3e3; color: #b42318; }
.chip-neutro { background: #eef1f8; color: #4a546b; }
.valor-verde { color: #107a46; }
.valor-azul { color: var(--cor-texto); }
.valor-ciano { color: #0a6d93; }
.valor-vermelho { color: #b42318; }
.valor-amarelo { color: #a35b00; }

.painel .card-body { padding: 1.1rem 1.25rem; }
.painel-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.painel-cab h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.painel-cab p { margin: .1rem 0 0; font-size: .78rem; color: var(--cor-suave); }
.mini { background: #f2f4fa; border-radius: .6rem; padding: .6rem .8rem; display: flex; flex-direction: column; gap: .15rem; font-size: .78rem; color: #4a546b; }
.mini strong { font-size: 1.35rem; color: var(--cor-texto); }
.mini-verde { background: #e6f8ee; } .mini-verde strong { color: #107a46; }
.mini-amarelo strong { color: #a35b00; }
.mini-vermelho strong { color: #b42318; }
.mini-ciano strong { color: #0a6d93; }
.progresso-fino { height: .5rem; background: #e8ebf4; border-radius: 999px; }
.progresso-fino .progress-bar { background: var(--cor-primaria); border-radius: 999px; }
.progresso-fino .progress-bar.bg-warning { background: #f0a30a !important; }
.progresso-fino .progress-bar.bg-info { background: #1f9bd1 !important; }
.progresso-fino .progress-bar.bg-success { background: #16a05a !important; }

.atalho .card-body { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; color: var(--cor-texto); }
.atalho:hover { border-color: #b8c4ec; }
.vazio { text-align: center; color: var(--cor-suave); padding: 2rem 1rem !important; }
.vazio i { display: block; font-size: 1.6rem; margin-bottom: .4rem; opacity: .6; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 400px; }

.modal-fundo { background: rgba(0, 0, 0, .5); }

.validation-message { color: #dc3545; font-size: .875rem; }
.invalid { outline: 1px solid #dc3545; }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ===== Responsivo ===== */
.app-menu-botao { display: none; }
.app-menu-fundo { display: none; }

@media (max-width: 991.98px) {
    .app-menu-botao { display: inline-flex; }
    .topo { padding: 0 .75rem; height: 56px; }
    .topo .usuario-nome, .topo .btn-contorno:not(:last-child) { display: none; }
    .app-conteudo { padding: .75rem; }

    .app-menu {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 1045; height: auto;
        width: 280px; max-width: 85vw;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .app-menu.aberto { transform: translateX(0); box-shadow: 0 0 20px rgba(0, 0, 0, .35); }
    .app-menu-fundo.aberto { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, .45); }
}

/* Tabelas viram cartões no celular: cada linha é um cartão e cada célula mostra "título: valor".
   Os rótulos (data-label) são preenchidos por wwwroot/tabelas.js a partir do <thead>.
   Para manter uma tabela como tabela, use a classe "tabela-fixa". */
@media (max-width: 767.98px) {
    .table-responsive { overflow: visible; }
    table.table:not(.tabela-fixa) thead { display: none; }
    table.table:not(.tabela-fixa),
    table.table:not(.tabela-fixa) tbody,
    table.table:not(.tabela-fixa) tfoot,
    table.table:not(.tabela-fixa) tr,
    table.table:not(.tabela-fixa) td { display: block; width: 100%; }
    table.table:not(.tabela-fixa) tr {
        background: #fff; border: 1px solid #dee2e6; border-radius: .5rem;
        margin: .6rem; padding: .35rem .75rem; width: auto;
    }
    table.table:not(.tabela-fixa) td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        border: 0; padding: .3rem 0 !important; text-align: right; word-break: break-word;
        background: transparent !important; box-shadow: none;
    }
    table.table:not(.tabela-fixa) td::before {
        content: attr(data-label); font-weight: 600; color: #6c757d; text-align: left; flex: 0 0 38%;
    }
    table.table:not(.tabela-fixa) td[data-label=""]::before,
    table.table:not(.tabela-fixa) td[colspan]::before { content: none; }
    table.table:not(.tabela-fixa) td[data-label=""],
    table.table:not(.tabela-fixa) td[colspan],
    table.table:not(.tabela-fixa) td.acoes { justify-content: flex-end; flex-wrap: wrap; }
    table.table:not(.tabela-fixa) td.acoes { width: 100%; border-top: 1px solid #f0f0f0; margin-top: .25rem; padding-top: .5rem !important; }
    table.table:not(.tabela-fixa) td:empty { display: none; }

    .btn { min-height: 38px; }
    .modal-dialog { margin: .5rem; }
    .busca { max-width: none; }
    .indicador-valor { font-size: 1.25rem; }
}

@media print {
    .topo, .app-menu, .app-menu-fundo, .no-print { display: none !important; }
    .app-conteudo { padding: 0; }
    body { background: #fff; }
}

/* ===== Calendário de entregas ===== */
.cal-nav { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; flex-wrap: wrap; }
.cal-titulo { margin-left: .5rem; font-size: .95rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--cor-borda); border-radius: .6rem; overflow: hidden; }
.cal-cab { background: #f7f8fc; text-align: center; font-size: .72rem; font-weight: 700; color: var(--cor-suave); padding: .5rem 0; border-bottom: 1px solid var(--cor-borda); }
.cal-dia { min-height: 64px; padding: .3rem .4rem; border-right: 1px solid #eef0f6; border-bottom: 1px solid #eef0f6; display: flex; flex-direction: column; gap: .25rem; }
.cal-dia:nth-child(7n) { border-right: 0; }
.cal-dia.fora { background: #fafbfd; color: #b3bacb; }
.cal-dia.hoje { background: #eef3ff; }
.cal-num { font-size: .8rem; font-weight: 600; }
.cal-evento { border: 0; background: var(--cor-primaria); color: #fff; border-radius: .35rem; font-size: .75rem; font-weight: 700; padding: .1rem 0; width: 100%; cursor: pointer; }
.cal-evento:hover { background: var(--cor-primaria-escura); }
@media (max-width: 575.98px) { .cal-dia { min-height: 52px; padding: .2rem; } .cal-num { font-size: .7rem; } }

/* ===== Telas de acesso (login, recuperar senha, cadastro) ===== */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; background: #f8f9fc; }
.auth-marca { text-align: center; margin-bottom: 1.5rem; }
.auth-marca-icone {
    width: 46px; height: 46px; border-radius: .8rem; background: var(--cor-primaria); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; margin-bottom: .9rem;
}
.auth-marca h1 { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.auth-marca small { display: block; color: var(--cor-suave); font-size: .68rem; font-weight: 700; letter-spacing: .03em; margin-top: .15rem; }
.auth-card {
    width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--cor-borda); border-radius: 1.1rem;
    padding: 1.75rem; box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
}
.auth-card.auth-larga { max-width: 640px; }
.auth-card h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .25rem; }
.auth-card .auth-sub { color: var(--cor-suave); font-size: .8rem; margin-bottom: 1.25rem; }
.auth-rotulo { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; font-weight: 700; margin-bottom: .4rem; }
.auth-rotulo a { font-size: .72rem; font-weight: 700; color: var(--cor-primaria); text-decoration: none; }
.auth-campo { position: relative; margin-bottom: 1.1rem; }
.auth-campo > i.bi { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--cor-suave); font-size: .9rem; pointer-events: none; }
.auth-campo .form-control { background: #f1f3f9; border: 1px solid transparent; padding: .65rem .9rem .65rem 2.4rem; font-size: .85rem; }
.auth-campo .form-control:focus { background: #fff; border-color: var(--cor-primaria); box-shadow: 0 0 0 .2rem rgba(10, 42, 143, .12); }
.auth-campo .auth-olho { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--cor-suave); padding: .25rem .45rem; }
.auth-campo .auth-olho + * { }
.auth-campo.com-olho .form-control { padding-right: 2.6rem; }
.auth-card .btn-primario { padding: .7rem; font-size: .85rem; }
.auth-check { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--cor-suave); margin: -.2rem 0 1.1rem; }
.auth-rodape-card { border-top: 1px solid var(--cor-borda); margin-top: 1.4rem; padding-top: 1.1rem; display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--cor-suave); }
.auth-rodape-card a { font-weight: 700; color: var(--cor-primaria); text-decoration: none; }
.auth-rodape { margin-top: 1.5rem; font-size: .68rem; color: var(--cor-suave); text-align: center; }
.auth-rodape strong { font-weight: 700; }
.auth-secao { font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--cor-suave); margin: .4rem 0 .75rem; }
.auth-card .validation-message { margin-top: -.8rem; margin-bottom: .8rem; font-size: .75rem; }

/* ===== Typeahead ===== */
.typeahead { position: relative; }
.typeahead-lista { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; max-height: 280px; overflow-y: auto; margin-top: 2px; }
.typeahead-lista .list-group-item { font-size: .875rem; padding: .45rem .75rem; }

/* Aviso de reconexão do Blazor (em português) */
#components-reconnect-modal { display: none; position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.4); align-items: center; justify-content: center; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: flex; }
#components-reconnect-modal .reconnect-caixa { background: #fff; border-radius: .5rem; padding: 2rem 2.5rem; text-align: center; max-width: 380px; box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.25); }
#components-reconnect-modal .reconnect-caixa > div { display: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-tentando,
#components-reconnect-modal.components-reconnect-failed .reconnect-falhou,
#components-reconnect-modal.components-reconnect-rejected .reconnect-recusado { display: block; }
