/* =============================================================================
   Painel admin no celular
   =============================================================================
   Carregado pelas telas do admin (cada <body> tem "adm adm-<tela>") — NUNCA
   pelo PDV (pdv.php), que fica como está. Por isso também não se mexe em
   includes/header_admin.php, que o PDV usa.

   Tudo aqui está dentro de @media (max-width: 760px): no computador o painel
   continua idêntico.

   Cuidados (não remover):
   - .modal-overlay, .tr-pedido, .prod-card, #container-produtos e afins têm
     o `display` controlado por JavaScript (style inline): aqui não se define
     display com !important neles.
   - O <style> do cabeçalho (header_admin.php) vem DEPOIS deste arquivo, então
     as regras do cabeçalho usam seletor mais forte (body.adm header...).
   - Classes com nomes repetidos entre telas (.col, .item, .card...) são
     sempre limitadas pela classe da tela (.adm-agenda, .adm-estatisticas...).
   ============================================================================= */

/* O estilo do menu do admin fica dentro de includes/menu_admin.php (vai junto
   com o menu e não depende de o navegador baixar uma versão nova deste arquivo). */

/* ------------------------------------------------------------- Reativar (Gestão de Encomendas)
   Valem no computador e no celular: são elementos novos, não mudam os que já existiam. */
.adm-encomendas .quadro-prazo {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 20px;
}
.adm-encomendas .quadro-prazo-topo strong { display: block; color: #92400e; font-size: 1rem; }
.adm-encomendas .quadro-prazo-topo span { display: block; color: #a16207; font-size: 0.85rem; font-weight: 600; margin-top: 2px; }
.adm-encomendas .quadro-prazo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 0.92rem;
}
.adm-encomendas .quadro-prazo-item small { display: block; color: #64748b; font-weight: 600; }
.adm-encomendas .quadro-prazo-item form { margin: 0; flex-shrink: 0; }
.adm-encomendas .btn-reativar {
    background: #16a34a;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}
.adm-encomendas .btn-reativar:hover { background: #15803d; }
.adm-encomendas .td-acoes form { margin: 0; }
.adm-encomendas .tag-reativado {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    color: #15803d;
    background: #dcfce7;
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
}

/* ------------------------------------------------------------- Sugestão do sistema (Agenda → Gerir Estoque)
   Elementos novos: valem no computador e no celular. */
.adm-agenda .sugestao-card { margin-bottom: 25px; padding: 20px 22px; background: #f0fdf4; border: 1px solid #bbf7d0; }
.adm-agenda .sugestao-topo { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.adm-agenda .sugestao-topo strong { display: block; color: #166534; font-size: 1.02rem; }
.adm-agenda .sugestao-topo span { display: block; color: #15803d; font-size: 0.84rem; font-weight: 600; margin-top: 2px; }
.adm-agenda .sugestao-link { color: #166534; font-weight: 800; font-size: 0.88rem; white-space: nowrap; }
.adm-agenda .sugestao-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-bottom: 14px; }
.adm-agenda .sugestao-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #dcfce7; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.adm-agenda .sugestao-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: #16a34a; flex-shrink: 0; }
.adm-agenda .sugestao-nome { flex: 1; font-weight: 800; color: #0f172a; font-size: 0.92rem; }
.adm-agenda .sugestao-qtd { width: 72px; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 8px; font-weight: 800; text-align: right; font-size: 0.95rem; }
.adm-agenda .sugestao-btn { background: #16a34a; }

@media (max-width: 760px) {

    /* ------------------------------------------------------------- Geral */
    body.adm header.admin-header { padding: 10px 14px; }
    body.adm header.admin-header .header-right { gap: 12px; }
    body.adm header.admin-header .header-left img { height: 30px; }

    body.adm .container { padding: 18px 14px; }
    body.adm .alerta { display: block; }
    body.adm .alerta a { display: inline-block; margin-top: 6px; }

    /* Modais: cabem na tela e rolam por dentro. */
    body.adm .modal-overlay { padding: 10px; }
    body.adm .modal-content { max-height: 92vh; overflow-y: auto; }
    body.adm .modal-body { padding: 18px; }

    /* Campos com largura mínima fixa (inline) estouravam a tela. */
    body.adm .form-group[style*="min-width"],
    body.adm .input-box[style*="min-width"],
    body.adm .row > .col,
    body.adm .row > .col[style*="min-width"] { min-width: 0 !important; max-width: none !important; }

    /* ------------------------------------------------------------- Menu (admin.php) */
    body.adm-menu .main-content { padding: 22px 14px; }
    body.adm-menu .header-titulos { margin-bottom: 22px; }
    body.adm-menu .header-titulos h1 { font-size: 1.5rem; }
    body.adm-menu .header-titulos p { font-size: 0.92rem; }
    body.adm-menu .menu-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    body.adm-menu .btn-menu { padding: 18px 10px 16px; }
    body.adm-menu .btn-menu:hover { transform: none; }
    body.adm-menu .icon-circle { width: 48px; height: 48px; margin-bottom: 10px; }
    body.adm-menu .icon-circle svg { width: 24px; height: 24px; }
    body.adm-menu .card-title { font-size: 0.95rem; margin-bottom: 0; line-height: 1.25; }
    body.adm-menu .card-desc, body.adm-menu .card-btn { display: none; }

    /* ------------------------------------------------------------- Encomendas */
    /* A tabela de 800px vira uma lista de cartões, um por pedido. */
    body.adm-encomendas .page-header .btn-primary { width: 100%; justify-content: center; }
    body.adm-encomendas .toolbar { padding: 14px; }
    body.adm-encomendas .tabs { flex-wrap: wrap; gap: 6px; }
    body.adm-encomendas .filters { flex-wrap: wrap; width: 100%; }
    body.adm-encomendas .filters .input-box { flex: 1 1 100% !important; min-width: 0 !important; }

    body.adm-encomendas .table-container { overflow: visible; background: transparent; border: 0; box-shadow: none; }
    body.adm-encomendas #tabela-pedidos { min-width: 0; width: 100%; border-collapse: separate; }
    body.adm-encomendas #tabela-pedidos thead { display: none; }
    body.adm-encomendas #tabela-pedidos tbody { display: block; }
    body.adm-encomendas #tabela-pedidos tbody tr { display: block; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px 12px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        padding: 14px;
        margin-bottom: 12px;
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td { display: block; padding: 0; border: 0; }
    /* 1 pedido | 5 situação  /  2 cliente  /  3 itens  /  4 total | 6 ações */
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(1) { grid-column: 1; grid-row: 1; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(5) { grid-column: 2; grid-row: 1; text-align: right; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(3) {
        grid-column: 1 / -1; grid-row: 3;
        background: #f8fafc; border-radius: 10px; padding: 8px 10px;
    }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(4) { grid-column: 1; grid-row: 4; align-self: center; font-size: 1.1rem; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(4)::before { content: 'Total '; font-size: 0.75rem; color: #64748b; font-weight: 800; text-transform: uppercase; }
    body.adm-encomendas #tabela-pedidos tr.tr-pedido > td:nth-child(6) { grid-column: 2; grid-row: 4; align-self: center; }
    body.adm-encomendas #tabela-pedidos .td-acoes { justify-content: flex-end !important; flex-wrap: wrap; }
    body.adm-encomendas #tabela-pedidos .btn-icon { width: 40px; height: 40px; }
    body.adm-encomendas #tabela-pedidos tbody tr:not(.tr-pedido) > td { display: block; background: #fff; border-radius: 14px; }

    body.adm-encomendas .aviso-pago-cancelado { flex-wrap: wrap; }

    /* ------------------------------------------------------------- Agenda */
    body.adm-agenda .agenda-layout > * { min-width: 0; }
    body.adm-agenda .card { padding: 16px 12px; }
    body.adm-agenda .cal-grid { min-width: 0; }
    body.adm-agenda .cal-day-name { padding: 8px 0; font-size: 0.68rem; }
    body.adm-agenda .cal-cell { min-height: 50px; padding: 4px 2px; }
    body.adm-agenda .date-num { width: 26px; height: 26px; font-size: 0.85rem; }
    body.adm-agenda .cal-legend { flex-wrap: wrap; gap: 10px; }
    body.adm-agenda .details-header { flex-wrap: wrap; gap: 8px; }

    /* Estoque do dia: a tabela era cortada (overflow:hidden); vira cartões. */
    body.adm-agenda .table-container { overflow: visible; }
    body.adm-agenda .table-container table { width: 100%; }
    body.adm-agenda .table-container thead { display: none; }
    body.adm-agenda .table-container tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 10px;
        padding: 12px 0;
        border-bottom: 1px solid #e2e8f0;
    }
    body.adm-agenda .table-container tbody td { display: block; padding: 0; border: 0; }
    body.adm-agenda .table-container tbody td:first-child { grid-column: 1 / -1; font-size: 1rem; }
    body.adm-agenda .table-container tbody td:nth-child(2)::before { content: 'Meta inicial: '; color: #64748b; font-weight: 700; font-size: 0.8rem; }
    body.adm-agenda .table-container tbody td:nth-child(3)::before { content: 'Disponível: '; color: #64748b; font-weight: 700; font-size: 0.8rem; }
    body.adm-agenda .table-container tbody td:last-child { grid-column: 1 / -1; display: flex; gap: 8px; }
    body.adm-agenda .table-container tbody td:last-child > * { flex: 1; text-align: center; }
    body.adm-agenda .table-container tbody td[colspan] { grid-column: 1 / -1; }
    body.adm-agenda form[style*="flex-wrap"] .btn-primary { width: 100%; justify-content: center; }
    body.adm-agenda .modal-alerta-botoes { flex-wrap: wrap; }

    /* ------------------------------------------------------------- Produtos */
    body.adm-produtos .filtros-catalogo > * { min-width: 0 !important; flex: 1 1 100%; }
    body.adm-produtos .filtros-catalogo .search-box,
    body.adm-produtos .filtros-catalogo select { min-width: 0; width: 100%; }
    body.adm-produtos .card-form { padding: 20px 16px; }
    body.adm-produtos .botoes-form { flex-wrap: wrap; }
    body.adm-produtos .botoes-form > * { flex: 1 1 100%; }
    body.adm-produtos .prod-img { height: 150px; }
    body.adm-produtos .btn-acao { min-width: 40px; min-height: 40px; }

    /* ------------------------------------------------------------- Dashboard */
    body.adm-dashboard .page-header .live-indicator,
    body.adm-dashboard .page-header .btn-voltar-topo { position: static; transform: none; }
    body.adm-dashboard .page-header { gap: 10px; }
    body.adm-dashboard .page-header h1 { font-size: 1.45rem; line-height: 1.15; }
    body.adm-dashboard .painel-filtros { overflow: visible; }
    body.adm-dashboard .filtros-esq, body.adm-dashboard .filtros-dir { white-space: normal; width: 100%; }
    body.adm-dashboard #container-selects-dinamicos { flex-wrap: wrap !important; width: 100%; }
    body.adm-dashboard select.input-filtro { min-width: 0; max-width: none; width: 100%; }
    body.adm-dashboard .filtros-dir .btn-filtro-acao { flex: 1 1 100%; justify-content: center; }
    body.adm-dashboard .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    body.adm-dashboard .stat-card { padding: 16px 10px; }
    body.adm-dashboard .stat-valor { font-size: 1.15rem; }
    body.adm-dashboard .grafico-container { padding: 14px 10px; }
    body.adm-dashboard .grafico-container > div { height: 260px !important; }

    /* ------------------------------------------------------------- Outras telas */
    body.adm-config .card { padding: 20px 16px; }
    body.adm-pagamentos .painel, body.adm-setup .painel { padding: 18px 14px; }
    body.adm-cortes .page-header > div { flex-wrap: wrap; }
    body.adm-estatisticas .filtros form { margin-left: 0; width: 100%; }
    body.adm-estatisticas .filtros input[type="date"] { flex: 1; min-width: 0; }
    body.adm-estatisticas .kpi b { font-size: 1.4rem; }
    body.adm-login { min-height: 100vh; height: auto; }

    /* ------------------------------------------------------------- Toque e leitura (todas as telas)
       Campo com letra menor que 16px faz o iPhone dar zoom sozinho ao tocar
       (e a tela fica "torta" até a pessoa afastar os dedos). */
    body.adm input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
    body.adm select,
    body.adm textarea { font-size: 16px !important; }
    body.adm input[type="checkbox"], body.adm input[type="radio"] { width: 20px; height: 20px; }

    /* Links pequenos demais para o dedo (WhatsApp do cliente, "Estornar"...). */
    body.adm-encomendas .link-wpp { display: inline-flex; align-items: center; min-height: 36px; }
    body.adm-encomendas #tabela-pedidos td a:not(.btn-icon) { display: inline-flex; align-items: center; min-height: 34px; }

    body.adm-agenda .cal-day-name { font-size: 0.75rem; }

    /* Grades que não encolhiam abaixo do conteúdo (celular pequeno). */
    body.adm-cortes .grade { grid-template-columns: minmax(0, 1fr); }
    body.adm-cortes .grade > * { min-width: 0; }
    body.adm-dashboard .stats-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    body.adm-dashboard .stat-card { min-width: 0; }
    body.adm-dashboard .stat-valor { overflow-wrap: anywhere; }
}

/* Telas bem estreitas: o lado a lado dos formulários da vitrine vira coluna. */
@media (max-width: 420px) {
    body.adm-cortes .lado { grid-template-columns: 1fr; gap: 0; }
}

/* Celular pequeno (até 380px): os quadros do Dashboard um embaixo do outro. */
@media (max-width: 380px) {
    body.adm-dashboard .stats-row { grid-template-columns: minmax(0, 1fr); }
}
