/* ==========================================================================
   Peixaria — mercado do peixe, pago por referência
   Marinho + gelo, amarelo-bóia como destaque. Talão Multicaixa na página do pedido.
   ========================================================================== */

@font-face {
    font-family: "Bricolage Grotesque";
    src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Bricolage Grotesque";
    src: url("fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --ink: #0f2b3d;        /* marinho: texto, cabeçalho */
    --sea: #13617a;        /* links, foco */
    --ice: #eaf3f5;        /* fundo */
    --foam: #ffffff;       /* superfícies */
    --line: #d3e3e8;
    --mist: #5d7684;       /* texto secundário */
    --buoy: #ffc233;       /* destaque: preço, acção principal */
    --buoy-dark: #e6a300;
    --coral: #c93d28;      /* erro / cancelar */
    --coral-bg: #fdebe7;
    --kelp: #1d7d52;       /* sucesso */
    --kelp-bg: #e3f4eb;
    --sand-bg: #fff4d6;    /* aguarda */

    --r-lg: 20px;
    --r-md: 12px;
    --r-pill: 999px;
    --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font: 400 16px/1.55 var(--font);
    font-optical-sizing: auto;
    color: var(--ink);
    background: var(--ice);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--sea); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--buoy); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.1; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); margin: 1.6rem 0 .5rem; font-weight: 800; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 420px; padding-top: 8vh; }
.center { text-align: center; }
.muted { color: var(--mist); }
.small { font-size: .9rem; }

/* ---------- Cabeçalho ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 64px; gap: 12px; }
.topbar a { color: #fff; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; color: inherit; text-decoration: none; }
.brand svg { width: 32px; height: 32px; flex: none; }
.cart-link {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 6px 6px 6px 16px; border-radius: var(--r-pill);
    background: rgba(255,255,255,.1); font-weight: 600;
}
.cart-link:hover { background: rgba(255,255,255,.18); }
.badge {
    display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px;
    border-radius: var(--r-pill); background: var(--buoy); color: var(--ink);
    font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums;
}
.nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.nav a, .nav .btn-link { color: #fff; opacity: .85; text-decoration: none; }
.nav a:hover, .nav .btn-link:hover { opacity: 1; }

/* ---------- Hero (loja) ---------- */
.hero { background: var(--ink); color: #fff; padding-top: 32px; }
.hero-inner { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: end; padding-bottom: 36px; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 4rem); margin: 0 0 16px; letter-spacing: -0.04em; line-height: 1; max-width: 13ch; }
.hero p { color: #c3d6de; max-width: 44ch; margin: 0; font-size: 1.08rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.steps li {
    counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: center;
    padding: 12px 16px 12px 12px; border-radius: var(--r-md); background: rgba(255,255,255,.07); color: #e4eef1;
}
.steps li::before {
    content: counter(step); display: grid; place-items: center; width: 34px; height: 34px;
    border-radius: 50%; background: var(--buoy); color: var(--ink); font-weight: 800;
}
.wave { display: block; width: 100%; height: 44px; background: var(--ink); }
.wave path { fill: var(--ice); }

/* ---------- Produtos ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 12px 0 20px; }
.section-head h2 { font-size: 1.7rem; margin: 0; font-weight: 800; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }

.card { background: var(--foam); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; overflow-x: auto; }
.card-body { padding: 20px; }

.product { display: flex; flex-direction: column; margin: 0; overflow: visible; transition: border-color .15s; }
.product:focus-within { border-color: var(--sea); }
.product-media { position: relative; }
.product-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; background: #cfe3e9; }
.placeholder { display: grid; place-items: center; background: linear-gradient(165deg, #dcedf2 0%, #b5d4de 100%); }
.placeholder svg { width: 46%; height: auto; }
.price-tag {
    position: absolute; left: 16px; bottom: -17px;
    display: inline-flex; align-items: baseline; gap: 3px;
    padding: 6px 14px; border-radius: var(--r-pill);
    background: var(--buoy); color: var(--ink); font-weight: 800; font-size: 1.1rem;
    font-variant-numeric: tabular-nums; box-shadow: 0 2px 0 var(--buoy-dark);
}
.price-tag small { font-weight: 600; font-size: .8rem; }
.product .card-body { display: flex; flex-direction: column; flex: 1; padding-top: 30px; }
.product h3 { font-size: 1.4rem; margin: 0 0 2px; }
.product .desc { color: var(--mist); margin: 0 0 14px; font-size: .95rem; }
.add-form { margin-top: auto; display: grid; gap: 12px; }

/* Peso: − 1,5 kg + */
.stepper { display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--ice); overflow: hidden; }
.stepper button {
    height: 50px; border: 0; background: transparent; color: var(--ink);
    font: 600 1.5rem/1 var(--font); cursor: pointer;
}
.stepper button:hover:not(:disabled) { background: #d8e8ed; }
.stepper button:disabled { opacity: .25; cursor: default; }
.stepper label { display: flex; align-items: baseline; justify-content: center; gap: 4px; font-weight: 700; }
.stepper input {
    width: 4.5ch; border: 0; background: transparent; padding: 0; text-align: right;
    font: 800 1.35rem var(--font); color: var(--ink); font-variant-numeric: tabular-nums;
    -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; }
.stepper:focus-within { outline: 3px solid var(--buoy); outline-offset: 1px; }
.stepper .unit { font-weight: 600; color: var(--mist); }

/* Inteiro | Cortado */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--ice); border: 1px solid var(--line); }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented label {
    display: grid; place-items: center; text-align: center; gap: 0; padding: 8px 6px;
    border-radius: 9px; cursor: pointer; font-weight: 700; line-height: 1.25;
}
.segmented label small { font-weight: 500; font-size: .76rem; color: var(--mist); }
.segmented input:checked + label { background: var(--foam); box-shadow: 0 1px 3px rgba(15,43,61,.18); }
.segmented input:focus-visible + label { outline: 3px solid var(--buoy); }
.whole-only { margin: 0; padding: 12px; border-radius: var(--r-md); background: var(--ice); color: var(--mist); font-size: .9rem; text-align: center; }

.add-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 1px solid #edf3f5; margin-top: 2px; }
.line-preview { margin: 0; line-height: 1.15; padding-top: 8px; }
.line-preview span { display: block; font-size: .8rem; color: var(--mist); }
.line-preview strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.add-row .btn { margin-top: 8px; }

/* ---------- Formulários ---------- */
label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
input, select, textarea {
    font: inherit; padding: 12px 14px; border: 1px solid #bcd2d9; border-radius: var(--r-md);
    background: #fff; width: 100%; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(255,194,51,.65); border-color: var(--sea); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--sea); padding: 0; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 600; padding: 0; margin-bottom: 10px; }
.form { display: grid; gap: 18px; }
.field-error { color: var(--coral); font-weight: 500; font-size: .85rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }

.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-weight: 500; }
.choice:has(input:checked) { border-color: var(--sea); background: #f3f9fa; box-shadow: inset 0 0 0 1px var(--sea); }
.choice strong { display: block; font-weight: 700; }
.choice span { color: var(--mist); font-size: .92rem; }
.choice input { margin-top: 2px; flex: none; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: var(--r-pill); padding: 13px 22px;
    background: var(--buoy); color: var(--ink); font: 700 1rem var(--font);
    cursor: pointer; text-decoration: none; box-shadow: 0 2px 0 var(--buoy-dark);
}
.btn:hover { background: #ffcd55; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--buoy-dark); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn-ghost:hover { background: rgba(15,43,61,.06); }
.btn-ghost:active { box-shadow: inset 0 0 0 2px var(--ink); }
.btn-danger { background: var(--coral); color: #fff; box-shadow: 0 2px 0 #9c2e1d; }
.btn-danger:hover { background: #d94e38; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 1.05rem; }
.btn-link { background: none; border: 0; color: var(--sea); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
form.inline { display: inline; }

/* ---------- Mensagens ---------- */
.alert { padding: 14px 16px; border-radius: var(--r-md); margin: 16px 0; font-weight: 500; }
.alert-success { background: var(--kelp-bg); color: var(--kelp); }
.alert-error { background: var(--coral-bg); color: var(--coral); }
.empty { text-align: center; padding: 48px 20px; }
.empty p { color: var(--mist); margin: 0 0 18px; }

/* ---------- Tabelas ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .82rem; color: var(--mist); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-bottom: 0; border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; }
.table tfoot tr + tr td { border-top: 0; }
.table .total td { font-weight: 800; font-size: 1.15rem; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }
.clickable:hover { background: #f5fafb; }

/* ---------- Checkout ---------- */
.checkout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.summary { position: sticky; top: 84px; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.summary-line.total { font-weight: 800; font-size: 1.25rem; border-bottom: 0; }

/* ---------- Pedido ---------- */
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.order-head h1 { margin-bottom: .3rem; }
.order-layout { display: grid; grid-template-columns: minmax(0, 430px) 1fr; gap: 28px; align-items: start; margin-top: 12px; }

/* Talão Multicaixa: topo marinho, picotado com recortes laterais */
.ticket { position: relative; background: var(--foam); border-radius: var(--r-lg); box-shadow: 0 14px 30px -12px rgba(15,43,61,.28); }
.ticket-top { background: var(--ink); color: #fff; padding: 22px 24px 24px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.ticket-top h2 { margin: 0; font-size: 1.3rem; font-weight: 800; }
.ticket-top p { margin: 4px 0 0; color: #b9cdd5; font-size: .92rem; }
.ticket-perf { position: relative; height: 0; border-top: 2px dashed var(--line); margin: 0 18px; }
.ticket-perf::before, .ticket-perf::after {
    content: ""; position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: var(--ice);
}
.ticket-perf::before { left: -31px; }
.ticket-perf::after { right: -31px; }
.ticket-body { padding: 10px 24px 4px; margin: 0; }
.ticket-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.ticket-row + .ticket-row { border-top: 1px solid #edf3f5; }
.ticket-row dt { color: var(--mist); font-size: .85rem; }
.ticket-row dd { margin: 0; font-size: 1.8rem; font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.ticket-row.amount dd { background: var(--buoy); padding: 2px 10px; border-radius: 8px; margin-left: -10px; }
.copy {
    flex: none; border: 1px solid var(--line); background: var(--ice); color: var(--ink);
    border-radius: var(--r-pill); padding: 7px 14px; font: 600 .85rem var(--font); cursor: pointer;
}
.copy:hover { border-color: var(--sea); }
.copy.done { background: var(--kelp-bg); color: var(--kelp); border-color: transparent; }
.ticket-foot { padding: 14px 24px 22px; font-size: .93rem; color: var(--mist); }
.ticket-foot strong { color: var(--ink); }
.ticket.is-paid .ticket-top { background: var(--kelp); }
.ticket.is-closed .ticket-top { background: #50656f; }
.ticket-state { padding: 20px 24px 24px; }
.ticket-state p { margin: 0 0 14px; }
.polling { display: flex; align-items: center; gap: 10px; margin-top: 4px; color: var(--mist); font-size: .88rem; }
.polling::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--buoy-dark); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.sim { margin-top: 16px; }
.order-side .card { margin-bottom: 18px; }
.delivery-card { display: grid; gap: 2px; }
.delivery-card strong { font-size: 1.05rem; }

/* Estados */
.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: var(--r-pill); font-size: .85rem; font-weight: 700; background: #e3ecef; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-aguarda_pagamento, .status-sem_referencia { background: var(--sand-bg); color: #8a5a00; }
.status-pago, .status-entregue { background: var(--kelp-bg); color: var(--kelp); }
.status-em_preparacao, .status-pronto { background: #e0eefb; color: #0b4f8a; }
.status-expirado, .status-cancelado { background: var(--coral-bg); color: var(--coral); }

/* ---------- Backoffice ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; flex: 1 1 220px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .card { margin: 0; }
.two-col + .card { margin-top: 18px; }
.thumb-row { display: flex; align-items: center; gap: 12px; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-md); }
.pager { display: flex; justify-content: space-between; margin: 8px 0 24px; }
.guest .brand { color: var(--ink); display: flex; justify-content: center; margin-bottom: 18px; }

.footer { color: var(--mist); font-size: .85rem; padding: 48px 20px; text-align: center; }

@media (max-width: 860px) {
    .hero-inner { grid-template-columns: 1fr; gap: 24px; }
    .order-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .checkout, .two-col { grid-template-columns: 1fr; }
    .summary { position: static; }
    .row3 { grid-template-columns: 1fr; }
    .table th, .table td { padding: 10px 8px; font-size: .9rem; }
    .ticket-row dd { font-size: 1.5rem; }
    .hero { padding-top: 20px; }
    .hero-inner { gap: 18px; padding-bottom: 24px; }
    .hero p { font-size: 1rem; }
    .steps { gap: 6px; }
    .steps li { grid-template-columns: 26px 1fr; gap: 10px; padding: 8px 12px 8px 8px; font-size: .92rem; line-height: 1.3; }
    .steps li::before { width: 26px; height: 26px; font-size: .85rem; }
    .cart-link .cart-text { display: none; }
    .cart-link { padding-left: 12px; }
}
/* ---------- Telemóvel ---------- */
@media (max-width: 640px) {
    .wrap { padding: 0 16px; }
    h1 { margin-top: 1.1rem; }
    .topbar-inner { min-height: 56px; }
    .brand { font-size: 1.05rem; }
    .brand svg { width: 28px; height: 28px; }

    /* Backoffice: menu desliza na horizontal em vez de partir em linhas */
    .admin .topbar-inner { flex-wrap: wrap; padding-bottom: 6px; }
    .admin .nav { width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 16px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .admin .nav > * { flex: none; }

    /* Tabelas → cartões: uma linha por campo, rótulo à esquerda */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tfoot { display: block; }
    .table-stack tbody tr { display: grid; grid-template-columns: 1fr auto; padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack tbody td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; grid-column: 1 / -1; text-align: right; }
    .table-stack tbody td[data-label]::before { content: attr(data-label); color: var(--mist); font-size: .85rem; text-align: left; }
    .table-stack tbody td.cell-title { grid-column: 1; font-size: 1.05rem; font-weight: 700; text-align: left; display: block; padding-bottom: 6px; }
    .table-stack tbody td.cell-action { grid-column: 2; grid-row: 1; display: block; }
    .table-stack tbody td.num { text-align: right !important; }
    .table-stack tbody td.hide-sm { display: none; }
    .table-stack tbody td[colspan] { display: block; text-align: center; }
    .table-stack tfoot { border-top: 1px solid var(--line); }
    .table-stack tfoot tr { display: flex; justify-content: space-between; padding: 0 16px; }
    .table-stack tfoot td { border: 0 !important; padding: 8px 0; }
    .table-stack tfoot td:empty { display: none; }
    .table-stack tfoot tr.total td { padding: 12px 0 14px; }
    .card:has(.table-stack) { overflow: visible; }

    /* Botões principais a toda a largura, acção principal em cima */
    .actions-stack { flex-direction: column-reverse; }
    .actions-stack .btn { width: 100%; }
    .order-head .btn { width: 100%; }

    /* Checkout: resumo antes do formulário, para ver o total logo */
    .checkout .summary { order: -1; }
    .checkout .card-body { padding: 16px; }

    /* Talão */
    .ticket-top { padding: 18px 18px 20px; }
    .ticket-body { padding: 6px 18px 2px; }
    .ticket-foot, .ticket-state { padding-left: 18px; padding-right: 18px; }
    .ticket-row dd { font-size: 1.45rem; }
    .ticket-perf { margin: 0 14px; }
    .ticket-perf::before { left: -27px; }
    .ticket-perf::after { right: -27px; }

    /* Backoffice */
    .filters select, .filters input, .filters .btn { flex: 1 1 100%; }
    .two-col { gap: 12px; }
    .admin .actions form, .admin .actions .btn { flex: 1 1 auto; }
    .admin .actions .btn { width: 100%; }

    /* Evitar zoom automático do iOS nos campos */
    input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before { animation: none !important; transition: none !important; }
}
