/* ============================================================
   PREORDINE — design system dedicato alle pagine cliente
   Caricato dopo core.css/theme.css: qui vive tutta la grafica
   custom del flusso di preordine (index, menu, riepilogo, conferma)
   ============================================================ */

:root {
    --pre-primary: #2596be;
    --pre-primary-dark: #197a9e;
    --pre-primary-soft: #e2f3f9;
    --pre-accent: #ffab00;
    --pre-accent-soft: #fff2d6;
    --pre-ink: #37474f;
    --pre-ink-soft: #78909c;
    --pre-bg: #f2f6f9;
    --pre-card: #ffffff;
    --pre-border: #e4ecf1;
    --pre-radius: 1rem;
    --pre-shadow: 0 2px 12px rgba(31, 68, 87, 0.08);
    --pre-shadow-up: 0 -6px 24px rgba(31, 68, 87, 0.12);
}

/* Il flusso preordine è solo chiaro: impedisce a Chrome/Safari con tema
   scuro attivo di scurire o invertire la pagina (fondamentale per il QR). */
:root {
    color-scheme: only light;
}

html, body {
    background-color: var(--pre-bg);
    color: var(--pre-ink);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Topbar comune ─────────────────────────────────────────── */

/* Il topbar scorre via con la pagina: a restare fissa è solo la
   barra delle categorie (.pre-cats), sempre visibile durante lo scroll. */
.pre-topbar {
    position: relative;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    padding-top: calc(.75rem + env(safe-area-inset-top));
    background: var(--pre-card);
    box-shadow: 0 2px 10px rgba(31, 68, 87, 0.08);
}

.pre-topbar.fissa {
    position: sticky;
    top: 0;
}

.pre-topbar img {
    height: 36px;
    width: auto;
}

.pre-topbar .pre-topbar-divider {
    width: 1px;
    height: 30px;
    background: var(--pre-border);
}

.pre-topbar h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pre-ink);
    margin: 0;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pre-topbar .pre-topbar-sub {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--pre-primary);
}

.pre-back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--pre-primary-soft);
    color: var(--pre-primary-dark);
    font-size: 1.35rem;
    transition: transform .15s ease, background-color .15s ease;
}

.pre-back:active {
    transform: scale(.9);
    background: #cdeaf5;
}

/* ── Hero (pagina scelta evento) ───────────────────────────── */

.pre-hero {
    position: relative;
    padding: 2.5rem 1.25rem 4.5rem;
    padding-top: calc(2.5rem + env(safe-area-inset-top));
    text-align: center;
    color: #fff;
    background: linear-gradient(140deg, #146d90 0%, var(--pre-primary) 55%, #3db2d8 100%);
    overflow: hidden;
}

.pre-hero::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2.5rem;
    background: var(--pre-bg);
    border-radius: 2.5rem 2.5rem 0 0;
}

/* Bolle decorative sfocate nel gradiente */
.pre-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle 180px at 12% 18%, rgba(255, 255, 255, .16), transparent 70%),
        radial-gradient(circle 220px at 88% 65%, rgba(255, 255, 255, .12), transparent 70%),
        radial-gradient(circle 120px at 70% 10%, rgba(255, 255, 255, .10), transparent 70%);
    pointer-events: none;
}

.pre-hero-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 10px 30px rgba(9, 48, 65, .35);
    margin-bottom: 1rem;
}

.pre-hero-logo img {
    height: 52px;
    width: auto;
}

.pre-hero h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: .14em;
    color: #fff;
    margin-bottom: .25rem;
}

.pre-hero p {
    margin: 0 auto;
    max-width: 30rem;
    color: rgba(255, 255, 255, .85);
    font-size: .95rem;
}

.pre-hero-steps {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-top: 1.5rem;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
}

.pre-hero-step {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .85rem;
    border-radius: 2rem;
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(4px);
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.pre-hero-step i {
    font-size: 1rem;
}

/* ── Contenitore centrale ──────────────────────────────────── */

.pre-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 1rem 7.5rem;
}

.pre-container.wide {
    max-width: 960px;
}

.pre-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pre-ink);
    margin: 1.5rem 0 1rem;
}

/* ── Card evento (index) ───────────────────────────────────── */

.pre-event-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--pre-card);
    border: 1px solid var(--pre-border);
    border-radius: var(--pre-radius);
    box-shadow: var(--pre-shadow);
    padding: .85rem 1rem;
    margin-bottom: .65rem;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.pre-event-card:active {
    transform: scale(.98);
}

@media (hover: hover) {
    .pre-event-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 22px rgba(31, 68, 87, .14);
        border-color: var(--pre-primary);
    }
}

.pre-event-date {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    min-height: 64px;
    padding: .4rem .25rem;
    border-radius: .8rem;
    background: var(--pre-primary-soft);
    color: var(--pre-primary-dark);
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

.pre-event-date .giorni {
    font-size: 1.05rem;
}

.pre-event-date .mese {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.pre-event-body {
    flex: 1 1 auto;
    min-width: 0;
}

.pre-event-body h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pre-ink);
    margin: 0 0 .2rem;
}

.pre-event-body p {
    margin: 0;
    font-size: .85rem;
    color: var(--pre-ink-soft);
    display: flex;
    align-items: center;
    gap: .3rem;
}

.pre-event-card > i {
    flex: 0 0 auto;
    font-size: 1.4rem;
    color: var(--pre-ink-soft);
}

/* Skeleton caricamento eventi */
.pre-event-skeleton {
    height: 96px;
    border-radius: var(--pre-radius);
    margin-bottom: .9rem;
    background: linear-gradient(90deg, #e8eef2 25%, #f3f7fa 50%, #e8eef2 75%);
    background-size: 200% 100%;
    animation: pre-shimmer 1.2s infinite linear;
}

@keyframes pre-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.pre-footer {
    text-align: center;
    font-size: .85rem;
    color: var(--pre-ink-soft);
    padding: 1.5rem 1rem 2.5rem;
}

.pre-footer a {
    color: var(--pre-primary);
    font-weight: 600;
    text-decoration: none;
}

/* ── Barra categorie (menu) ────────────────────────────────── */

.pre-cats {
    position: sticky;
    top: 0;
    z-index: 1040;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: .7rem 0 .6rem;
    padding-top: calc(.7rem + env(safe-area-inset-top));
    box-shadow: 0 6px 16px -10px rgba(31, 68, 87, .35);
}

.pre-cats-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: .4rem;
    overflow-x: auto;
    padding: .2rem 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* sfumatura ai bordi per suggerire lo scroll orizzontale */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1rem, #000 calc(100% - 1rem), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 1rem, #000 calc(100% - 1rem), transparent 100%);
}

.pre-cats-scroll::-webkit-scrollbar {
    display: none;
}

.pre-cat-pill {
    flex: 0 0 auto;
    padding: .5rem 1.05rem;
    border-radius: 2rem;
    border: 1.5px solid var(--pre-border);
    background: var(--pre-card);
    color: var(--pre-ink);
    font-size: .87rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.pre-cat-pill.active {
    background: linear-gradient(135deg, var(--pre-primary) 0%, #3db2d8 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 150, 190, .45);
    transform: translateY(-1px);
}

.pre-cat-pill:active {
    transform: scale(.95);
}

@media (hover: hover) {
    .pre-cat-pill:not(.active):hover {
        border-color: var(--pre-primary);
        color: var(--pre-primary-dark);
    }
}

/* ── Sezioni e card prodotto (menu) ────────────────────────── */

.pre-cat-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.1rem 0 .6rem;
    scroll-margin-top: 80px;
}

.pre-cat-header span {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--pre-primary-dark);
    white-space: nowrap;
}

.pre-cat-header::after {
    content: "";
    flex: 1 1 auto;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--pre-primary-soft), transparent);
}

.pre-products .row {
    row-gap: .5rem;
}

.pre-product {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    height: 100%;
    background: var(--pre-card);
    border: 1.5px solid var(--pre-border);
    border-radius: var(--pre-radius);
    box-shadow: var(--pre-shadow);
    padding: .65rem .9rem;
    transition: border-color .2s ease, background-color .2s ease, transform .15s ease, box-shadow .2s ease;
}

@media (hover: hover) {
    .pre-product:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(31, 68, 87, .13);
    }
}

.pre-product.selected {
    border-color: var(--pre-accent);
    background: #fffdf5;
}

.pre-product-info {
    flex: 1 1 auto;
    min-width: 0;
}

.pre-product-info h3 {
    font-size: .98rem;
    font-weight: 700;
    color: var(--pre-ink);
    margin: 0;
}

.pre-product-info .desc {
    font-size: .8rem;
    color: var(--pre-ink-soft);
    margin: .15rem 0 .3rem;
}

.pre-product-info .price {
    font-size: .95rem;
    font-weight: 800;
    color: var(--pre-primary-dark);
}

/* Stepper quantità */
.pre-stepper {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .1rem;
    border-radius: 2rem;
    background: var(--pre-primary-soft);
    padding: .2rem;
}

.pre-stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--pre-primary-dark);
    font-size: 1.15rem;
    transition: background-color .15s ease, transform .1s ease;
}

.pre-stepper button:active {
    transform: scale(.88);
    background: rgba(37, 150, 190, .18);
}

.pre-stepper .btn-piu {
    background: var(--pre-primary);
    color: #fff;
    box-shadow: 0 3px 8px rgba(37, 150, 190, .4);
}

.pre-stepper .qty {
    min-width: 26px;
    text-align: center;
    font-size: 1rem;
    font-weight: 800;
    color: var(--pre-ink);
}

.pre-stepper.is-empty .btn-meno,
.pre-stepper.is-empty .qty {
    display: none;
}

/* ── Barra inferiore fissa ─────────────────────────────────── */

.pre-bottombar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    padding: .6rem 1rem;
    padding-bottom: calc(.6rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--pre-shadow-up);
}

.pre-bottombar-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    gap: .75rem;
}

.pre-cta {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 54px;
    padding: .5rem 1.25rem;
    border: none;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--pre-primary) 0%, #1e83a8 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(37, 150, 190, .4);
    transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease;
}

.pre-cta:active {
    transform: scale(.97);
    box-shadow: 0 3px 8px rgba(37, 150, 190, .3);
}

.pre-cta:disabled {
    background: #b9cdd7;
    color: #fff;
    box-shadow: none;
    justify-content: center;
}

.pre-cta .pre-cta-label {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.pre-cta .pre-cta-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 .4rem;
    border-radius: 2rem;
    background: rgba(255, 255, 255, .25);
    font-size: .85rem;
    font-weight: 800;
}

.pre-cta .pre-cta-total {
    font-size: 1.05rem;
    font-weight: 800;
    white-space: nowrap;
}

.pre-cta.secondaria {
    background: var(--pre-card);
    color: var(--pre-primary-dark);
    border: 1.5px solid var(--pre-primary);
    box-shadow: none;
    justify-content: center;
}

/* ── Riepilogo ─────────────────────────────────────────────── */

.pre-card {
    background: var(--pre-card);
    border: 1px solid var(--pre-border);
    border-radius: var(--pre-radius);
    box-shadow: var(--pre-shadow);
    padding: 1.1rem 1.15rem;
    margin-top: 1rem;
}

.pre-card > h2 {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1rem;
    font-weight: 800;
    color: var(--pre-ink);
    margin: 0 0 .9rem;
}

.pre-card > h2 i {
    color: var(--pre-primary);
    font-size: 1.2rem;
}

.pre-line {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .45rem 0;
}

.pre-line + .pre-line {
    border-top: 1px dashed var(--pre-border);
}

.pre-line .pre-line-qty {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 .35rem;
    border-radius: .55rem;
    background: var(--pre-accent-soft);
    color: #8a6d1a;
    font-size: .85rem;
    font-weight: 800;
}

.pre-line .pre-line-nome {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .93rem;
    font-weight: 600;
    color: var(--pre-ink);
}

.pre-line .pre-line-nome small {
    display: block;
    font-size: .76rem;
    font-weight: 500;
    color: var(--pre-ink-soft);
}

.pre-line .pre-line-prezzo {
    flex: 0 0 auto;
    font-size: .95rem;
    font-weight: 700;
    color: var(--pre-ink);
}

/* Riga costo servizio (coperto/asporto) nel riepilogo */
.pre-line.extra .pre-line-qty {
    background: var(--pre-primary-soft);
    color: var(--pre-primary-dark);
}

.pre-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .75rem;
    padding-top: .85rem;
    border-top: 2px solid var(--pre-border);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--pre-ink);
}

.pre-total .importo {
    color: var(--pre-primary-dark);
    font-size: 1.25rem;
}

.pre-note {
    font-size: .8rem;
    color: var(--pre-ink-soft);
    margin: .6rem 0 0;
}

/* Scelta tavolo / asporto / banco */
.pre-tipo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
}

.pre-tipo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .9rem .35rem;
    border: 2px solid var(--pre-border);
    border-radius: var(--pre-radius);
    background: var(--pre-card);
    color: var(--pre-ink);
    font-size: .88rem;
    font-weight: 700;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;
}

.pre-tipo-card i {
    font-size: 1.6rem;
    color: var(--pre-ink-soft);
    transition: color .15s ease;
}

.pre-tipo-card small {
    font-size: .7rem;
    font-weight: 500;
    color: var(--pre-ink-soft);
}

.pre-tipo-card .costo {
    font-size: .68rem;
    font-weight: 700;
    color: #8a6d1a;
    background: var(--pre-accent-soft);
    border-radius: 2rem;
    padding: .1rem .5rem;
    margin-top: .15rem;
}

.pre-tipo-card.active {
    border-color: var(--pre-primary);
    background: var(--pre-primary-soft);
    color: var(--pre-primary-dark);
    box-shadow: 0 4px 12px rgba(37, 150, 190, .2);
}

.pre-tipo-card.active i {
    color: var(--pre-primary);
}

.pre-tipo-card:active {
    transform: scale(.97);
}

.pre-opzioni {
    margin-top: .75rem;
}

.pre-opzione-riga {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem 0;
}

.pre-opzione-riga + .pre-opzione-riga {
    border-top: 1px dashed var(--pre-border);
}

.pre-opzione-riga label {
    font-size: .92rem;
    font-weight: 600;
    color: var(--pre-ink);
    margin: 0;
}

.pre-opzione-riga label small {
    display: block;
    font-weight: 500;
    font-size: .76rem;
    color: var(--pre-ink-soft);
}

.pre-opzione-riga input[type="text"] {
    max-width: 180px;
    text-align: right;
    border: 1.5px solid var(--pre-border);
    border-radius: .65rem;
    padding: .5rem .75rem;
    font-size: .92rem;
    color: var(--pre-ink);
    background: var(--pre-card);
}

.pre-opzione-riga input[type="text"]:focus {
    outline: none;
    border-color: var(--pre-primary);
}

/* ── Conferma ──────────────────────────────────────────────── */

.pre-confirm {
    text-align: center;
    padding-top: 1.5rem;
}

.pre-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #e8fadf;
    color: #4caf50;
    font-size: 2.6rem;
    animation: pre-pop .45s cubic-bezier(.18, .89, .32, 1.28);
}

@keyframes pre-pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.pre-confirm h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--pre-ink);
    margin: .9rem 0 .3rem;
}

.pre-confirm > p {
    font-size: .9rem;
    color: var(--pre-ink-soft);
    max-width: 26rem;
    margin: 0 auto;
}

.pre-ticket {
    position: relative;
    max-width: 340px;
    margin: 1.5rem auto 0;
    background: var(--pre-card);
    border-radius: 1.25rem;
    box-shadow: var(--pre-shadow);
    padding: 1.5rem 1.25rem;
}

/* Il QR resta SEMPRE nero su sfondo bianco, anche con dark mode
   o inversione colori attive sullo smartphone. Il contorno bianco
   (quiet zone) è disegnato dentro l'immagine da conferma.js: i dark
   mode invertono i colori CSS ma non i pixel delle immagini. Questo
   sfondo è solo una seconda difesa per il fallback senza canvas. */
.pre-ticket #qrcode {
    display: flex;
    justify-content: center;
    background: #ffffff !important;
    padding: .5rem;
    border-radius: .5rem;
    forced-color-adjust: none;
}

/* 240px = 200px di QR + 20px di quiet zone per lato dentro l'immagine */
.pre-ticket #qrcode img,
.pre-ticket #qrcode canvas {
    max-width: 240px;
    height: auto;
    forced-color-adjust: none;
    filter: none !important;
}

.pre-ticket-divider {
    position: relative;
    border-top: 2px dashed var(--pre-border);
    margin: 1.35rem 0 1rem;
}

.pre-ticket-divider::before,
.pre-ticket-divider::after {
    content: "";
    position: absolute;
    top: -12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--pre-bg);
}

.pre-ticket-divider::before { left: -36px; }
.pre-ticket-divider::after { right: -36px; }

.pre-ticket-number small {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--pre-ink-soft);
}

.pre-ticket-number strong {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--pre-primary-dark);
    line-height: 1.2;
}

.pre-recap {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .75rem;
}

.pre-recap span {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .7rem;
    border-radius: 2rem;
    background: var(--pre-primary-soft);
    color: var(--pre-primary-dark);
    font-size: .8rem;
    font-weight: 700;
}

/* ── Stato vuoto ───────────────────────────────────────────── */

.pre-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pre-ink-soft);
}

.pre-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .5rem;
}
