/* =========================================================
   ADICIONAR / EDITAR PRODUTO
   Modal do desktop (#modalAddProduto, Views/Produto/_ModalAddProduto) e página do celular
   (Views/Produto/Detalhes). Identidade do site: marrom #4A2C17, creme #F3EBE0/#F6F1EA,
   linhas #EADFD1, fonte Inter — a mesma do carrinho, checkout e Meus pedidos.
   ========================================================= */

.ap {
    --ap-text: #2B1A0E;
    --ap-muted: #6F5A46;
    --ap-brown: #4A2C17;
    --ap-brown-hover: #3A2111;
    --ap-link: #7A4A24;
    --ap-line: #EADFD1;
    --ap-chip: #F3EBE0;
    --ap-soft: #F6F1EA;
    --ap-selected: #FBF6EF;
    --ap-gold: #C9A46A;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ap-text);
}

/* ---------- topo (título + fechar/voltar) ---------- */
.ap-topo {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px 12px;
}
.ap-topo__textos { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ap-topo__titulo { margin: 0; font-size: 18px; font-weight: 700; color: var(--ap-text); line-height: 1.2; }
.ap-topo__sub { font-size: 13px; color: var(--ap-muted); }
.ap-redondo {
    width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%;
    background: var(--ap-soft); color: var(--ap-brown);
    display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
    transition: background-color .2s ease;
}
.ap-redondo:hover { background: var(--ap-chip); color: var(--ap-brown); }

/* ---------- imagem e informações ---------- */
.ap-foto {
    position: relative; overflow: hidden; border-radius: 18px;
    background: var(--ap-chip); aspect-ratio: 16 / 10; max-height: 300px; width: 100%;
}
.ap-foto img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s cubic-bezier(.15, 1, .3, 1); }
.ap-foto:hover img { transform: scale(1.05); }

.ap-info { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.ap-nome { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; line-height: 1.25; color: var(--ap-text); }
.ap-desc { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ap-muted); }
.ap-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.ap-preco {
    display: inline-flex; align-items: baseline; gap: 2px;
    color: var(--ap-brown); font-weight: 800; letter-spacing: -.5px;
}
.ap-preco .currency { font-size: 14px; font-weight: 700; margin-right: 2px; }
.ap-preco .amount { font-size: 28px; line-height: 1; }
.ap-preco .decimals { font-size: 16px; }
.ap-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
    border-radius: 999px; background: var(--ap-chip); color: var(--ap-brown);
    font-size: 12px; font-weight: 600;
}

/* ---------- grupos de adicionais ---------- */
.ap-grupos { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.ap-grupo { border: 1px solid var(--ap-line); border-radius: 16px; overflow: hidden; background: #fff; }
.ap-grupo__topo {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; background: var(--ap-soft);
}
.ap-grupo__nome { font-size: 15px; font-weight: 700; color: var(--ap-text); }
.ap-grupo__regra { font-size: 12px; color: var(--ap-muted); margin-top: 2px; }
.ap-tag {
    flex-shrink: 0; height: 24px; padding: 0 10px; border-radius: 999px;
    display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .2px;
    background: #fff; color: var(--ap-muted); border: 1px solid var(--ap-line);
}
.ap-tag--obrigatorio { background: var(--ap-brown); color: #fff; border-color: var(--ap-brown); }

.ap-opcoes { max-height: 320px; overflow-y: auto; }
.ap-opcao {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px; margin: 0; cursor: pointer;
    transition: background-color .15s ease;
}
.ap-opcao + .ap-opcao { border-top: 1px solid var(--ap-line); }
.ap-opcao:hover { background: #FCFAF7; }
.ap-opcao:has(.acomp-input:checked) { background: var(--ap-selected); }
.ap-opcao__textos { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ap-opcao__nome { font-size: 14px; font-weight: 600; color: var(--ap-text); }
.ap-opcao__desc { font-size: 12px; color: var(--ap-muted); line-height: 1.4; }
.ap-opcao__fim { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.ap-opcao__preco { font-size: 13px; font-weight: 700; color: var(--ap-link); white-space: nowrap; }
.ap-opcao__preco.is-gratis { font-weight: 500; color: var(--ap-muted); font-size: 12px; }

/* caixa de seleção no estilo do site (o input continua o mesmo para o JS) */
.ap .acomp-input {
    appearance: none; -webkit-appearance: none; margin: 0; flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 7px; border: 2px solid #CDBBA6; background: #fff;
    cursor: pointer; display: grid; place-content: center;
    transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.ap .acomp-input.is-unico { border-radius: 50%; }
.ap .acomp-input:checked {
    background: var(--ap-brown) no-repeat center / 14px
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E");
    border-color: var(--ap-brown);
    transform: scale(1.04);
}
.ap .acomp-input:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(201, 164, 106, .35); }
.ap-erro { padding: 0 14px 12px; font-size: 12px; font-weight: 600; color: #A3352A; }

/* ---------- observação ---------- */
.ap-campo { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; }
.ap-campo__rotulo { font-size: 14px; font-weight: 700; color: var(--ap-text); margin: 0; }
.ap-campo__rotulo small { font-weight: 500; color: var(--ap-muted); }
.ap-textarea {
    width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--ap-line); border-radius: 12px;
    padding: 10px 12px; font: 400 14px/1.45 Inter, system-ui, sans-serif; color: var(--ap-text); background: #fff;
}
.ap-textarea::placeholder { color: #A8977F; }
.ap-textarea:focus { outline: none; border-color: var(--ap-gold); box-shadow: 0 0 0 3px rgba(201, 164, 106, .2); }

#feedback-alerts:empty { display: none; }
#feedback-alerts { margin-top: 14px; }
#feedback-alerts .alert { border-radius: 12px; font-size: 13px; font-weight: 600; }

/* ---------- rodapé: quantidade + botão ---------- */
.ap-rodape {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; background: #fff; border-top: 1px solid var(--ap-line);
}
.ap-qtd {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
    padding: 4px; border-radius: 999px; background: var(--ap-chip);
}
.ap-qtd .qty-btn {
    width: 36px; height: 36px; border: 0; border-radius: 50%; background: #fff; color: var(--ap-brown);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 1px 3px rgba(74, 44, 23, .12); transition: transform .1s ease;
}
.ap-qtd .qty-btn:active { transform: scale(.92); }
.ap-qtd .qty-btn i { font-size: 12px; margin: 0 !important; }
.ap-qtd .qty-input {
    width: 34px; border: 0; background: transparent; text-align: center; outline: none;
    font: 700 16px/1 Inter, system-ui, sans-serif; color: var(--ap-text);
    -moz-appearance: textfield;
}
.ap-qtd .qty-input::-webkit-outer-spin-button,
.ap-qtd .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ap-cta {
    flex: 1; min-width: 0; height: 52px; border: 0; border-radius: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 18px;
    background: var(--ap-brown); color: #fff; font: 600 15px/1 Inter, system-ui, sans-serif; cursor: pointer;
    box-shadow: 0 6px 16px rgba(74, 44, 23, .22); transition: background-color .2s ease, transform .1s ease;
}
.ap-cta:hover { background: var(--ap-brown-hover); color: #fff; }
.ap-cta:active { transform: scale(.99); }
.ap-cta #valorTotalProduto { font-weight: 700; white-space: nowrap; }

/* =========================================================
   MODAL (desktop)
   ========================================================= */
#modalAddProduto .modal-dialog { max-width: 580px; }
#modalAddProduto .modal-content {
    border: 0; border-radius: 22px; overflow: hidden; background: #fff;
    display: flex; flex-direction: column; max-height: calc(100vh / var(--app-zoom, 1) - 64px);
    box-shadow: 0 2px 12px rgba(74, 44, 23, .06), 0 24px 60px rgba(42, 21, 8, .18);
}
#modalAddProduto form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
/* overflow-y: scroll: a barra fica sempre à mostra (mesmo antes de rolar) */
#modalAddProduto .ap-corpo { flex: 1; min-height: 0; overflow-y: scroll; padding: 0 14px 20px 20px; }
/* Rolagem marrom (corpo do modal e lista de adicionais) */
/* Firefox (não tem ::-webkit-scrollbar). No Chrome/Edge/Safari estas propriedades desligariam o
   ::-webkit-scrollbar e a barra voltaria a sumir quando não está rolando (barra do macOS). */
@supports not selector(::-webkit-scrollbar) {
    #modalAddProduto .ap-corpo,
    .ap .ap-opcoes { scrollbar-width: thin; scrollbar-color: #4A2C17 #F3EBE0; }
}
#modalAddProduto .ap-corpo::-webkit-scrollbar,
.ap .ap-opcoes::-webkit-scrollbar { width: 8px; }
#modalAddProduto .ap-corpo::-webkit-scrollbar-track,
.ap .ap-opcoes::-webkit-scrollbar-track { background: #F3EBE0; border-radius: 10px; }
#modalAddProduto .ap-corpo::-webkit-scrollbar-thumb,
.ap .ap-opcoes::-webkit-scrollbar-thumb { background: #4A2C17; border-radius: 10px; }
#modalAddProduto .ap-corpo::-webkit-scrollbar-thumb:hover,
.ap .ap-opcoes::-webkit-scrollbar-thumb:hover { background: #3A2111; }

/* =========================================================
   PÁGINA (celular)
   ========================================================= */
.ap-pagina { background: #fff; min-height: calc(100vh / var(--app-zoom, 1)); padding-bottom: 100px; }
.ap-pagina .ap-topo { position: sticky; top: 0; z-index: 5; background: #fff; }
.ap-pagina .ap-corpo { padding: 0 16px 20px; }
.ap-pagina .ap-rodape {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(42, 21, 8, .08);
}

@media (min-width: 768px) {
    .ap-pagina { max-width: 640px; margin: 24px auto; min-height: 0; border-radius: 22px; padding-bottom: 0; overflow: hidden;
                 box-shadow: 0 2px 12px rgba(74, 44, 23, .06), 0 24px 60px rgba(42, 21, 8, .12); }
    .ap-pagina .ap-corpo { padding: 0 24px 24px; }
    .ap-pagina .ap-rodape { position: sticky; box-shadow: none; padding: 14px 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .ap-foto img, .ap .acomp-input, .ap-cta { transition: none; }
}

/* Aviso de adicionar/editar produto: aparece acima do nome do produto */
.ap-feedback:empty { display: none; }
.ap-feedback__alerta { display: flex; align-items: flex-start; gap: .5rem; border: 0; border-radius: 12px; padding: .6rem .8rem; font-size: .88rem; font-weight: 600; line-height: 1.35; }
.ap-feedback__alerta i { margin-top: .15rem; }
