/* =====================================================================
   Schermata 6 — "Turno / Smistacode"
   "Prendo un numero, so quanto manca e posso farmi un giro."
   Il numero domina; lo stato "È il tuo turno!" si vede da un metro di distanza.
   Mobile-first 360×800 · 768 · 1024 (sidebar)
   ===================================================================== */

.qt { display: flex; flex-direction: column; gap: var(--space-4); max-width: 620px; padding: var(--space-1) 0 var(--space-7); }
.qt-title {
    font-size: clamp(1.7rem, 1.25rem + 2vw, 2.4rem); font-weight: 900; line-height: 1.05; letter-spacing: -0.02em;
    color: var(--color-primary); outline: none;
}
.qt[data-view="ticket"] .qt-title:has(+ *) { margin-bottom: 0; }
.qt-lead { color: var(--color-text-muted); font-weight: var(--fw-bold); }
.qt-flash {
    display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.qt-flash--ok { background: #E6F4EA; color: #24653A; }
.qt-flash--error { background: #FFF1EF; color: var(--color-danger); }
.qt-flash .icon { margin-top: 2px; }

/* ---------- Scelta della coda ---------- */
.qt-choose { display: flex; flex-direction: column; gap: var(--space-4); }
.qt-services { display: grid; gap: var(--space-3); }
.qt-service {
    display: flex; flex-direction: column; gap: var(--space-3);
    padding: var(--space-4); border-radius: var(--radius-xl);
    background: var(--color-surface); box-shadow: var(--shadow-card), inset 0 0 0 1px var(--color-border);
    animation: qt-in var(--dur-slow) var(--ease-out) both;
}
.qt-service:nth-child(2) { animation-delay: 60ms; }
@keyframes qt-in { from { opacity: 0; transform: translateY(8px); } }
.qt-service.is-preselected { box-shadow: var(--shadow-raised), inset 0 0 0 2px var(--color-caramel); }
.qt-services--single .qt-service { background: linear-gradient(160deg, #FFF3E6 0%, var(--tint-caramel) 100%); padding: var(--space-5); }
.qt-service__head { display: flex; align-items: center; gap: var(--space-3); }
.qt-service__icon {
    display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 15px;
    background: var(--tint-caramel); color: var(--color-caramel-strong); font-size: 1.25rem;
}
.qt-services--single .qt-service__icon { background: #fff; }
.qt-service__text { flex: 1; min-width: 0; }
.qt-service__name { font-size: var(--fs-lg); font-weight: 900; line-height: 1.2; }
.qt-service__desc { font-size: var(--fs-sm); color: var(--color-text-muted); font-weight: var(--fw-bold); }
.qt-service__prefix {
    display: grid; place-items: center; min-width: 46px; height: 46px; padding: 0 8px; border-radius: 14px;
    background: var(--color-primary); color: var(--color-primary-contrast); font-size: 1.4rem; font-weight: 900;
}
.qt-service__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-2); margin: 0; }
.qt-service__stats > div { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 0 0 1px var(--color-border); }
.qt-service__stats dt { font-size: var(--fs-xs); font-weight: var(--fw-heavy); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-caramel-strong); }
.qt-service__stats dd { margin: 0; font-weight: var(--fw-heavy); line-height: 1.25; }
.qt-service__mode { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--fs-sm); color: var(--color-text-muted); font-weight: var(--fw-bold); }
.qt-service__mode .icon { margin-top: 2px; color: var(--color-caramel-strong); }
.qt-take { width: 100%; }
.qt-service__reason {
    display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md); background: var(--tint-butter); color: #6B4A12; font-weight: var(--fw-bold); font-size: var(--fs-sm);
}
.qt-service__reason .icon { margin-top: 2px; }
.qt-empty, .qt-opening { color: var(--color-text-muted); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.qt-opening { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Turno attivo (mockup) ---------- */
.qt-active { display: flex; flex-direction: column; gap: var(--space-4); }
.qt-card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: var(--space-6) var(--space-5) var(--space-5); border-radius: var(--radius-xl);
    background: linear-gradient(170deg, #FFF1E2 0%, #F9DFC6 100%);
    box-shadow: var(--shadow-raised), inset 0 0 0 1px rgba(154, 84, 24, 0.16);
    transition: background var(--dur-slow) ease;
    animation: qt-pop 380ms var(--ease-out) both;
}
@keyframes qt-pop { from { opacity: 0; transform: scale(0.96); } }
.qt-card__service { font-size: var(--fs-xs); font-weight: var(--fw-heavy); text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-caramel-strong); }
.qt-code {
    display: flex; align-items: baseline; justify-content: center; gap: 0.18em;
    margin: var(--space-1) 0 var(--space-2);
    font-size: clamp(4.4rem, 3rem + 9vw, 6.6rem); font-weight: 900; line-height: 0.95; letter-spacing: -0.03em;
    color: var(--color-primary); font-variant-numeric: tabular-nums;
}
.qt-code__num.is-tick { animation: qt-tick 420ms var(--ease-out); }
@keyframes qt-tick { 40% { transform: scale(1.08); } }
.qt-card__ahead { font-size: 1.2rem; font-weight: var(--fw-bold); color: var(--color-text); }
.qt-card__eta {
    display: flex; align-items: center; justify-content: center; gap: var(--space-3);
    width: 100%; margin-top: var(--space-4); padding-top: var(--space-4);
    border-top: 1.5px solid rgba(154, 84, 24, 0.18);
}
.qt-card__eta[hidden] { display: none; }
.qt-card__eta-icon { font-size: 2rem; color: var(--color-primary); }
.qt-card__eta-text { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.2; }
.qt-card__eta-label { font-weight: var(--fw-bold); color: var(--color-text-muted); }
.qt-card__eta-value { font-size: 1.35rem; font-weight: 900; color: var(--color-text); }
.qt-card__recall {
    display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); padding: 6px 14px;
    border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.22); font-weight: var(--fw-heavy);
}

/* quasi il tuo turno */
.qt-card.is-near { background: linear-gradient(170deg, #FFE8D6 0%, #FCC9A6 100%); }
.qt-card.is-near .qt-code { color: var(--color-accent-strong); }

/* È IL TUO TURNO: impossibile non vederlo */
.qt-card.is-called {
    background: linear-gradient(160deg, #F1667A 0%, #E8445A 45%, #B92B41 100%);
    color: #fff; box-shadow: 0 26px 46px -22px rgba(194, 46, 68, 0.95);
}
.qt-card.is-called .qt-code, .qt-card.is-called .qt-card__ahead, .qt-card.is-called .qt-card__service { color: #fff; }
.qt-card.is-called .qt-card__ahead { font-size: 1.35rem; font-weight: 900; }
.qt-card.is-called { animation: qt-pop 380ms var(--ease-out) both, qt-ring 1.8s ease-out 400ms infinite; }
@keyframes qt-ring {
    0% { box-shadow: 0 26px 46px -22px rgba(194, 46, 68, 0.95), 0 0 0 0 rgba(232, 68, 90, 0.55); }
    100% { box-shadow: 0 26px 46px -22px rgba(194, 46, 68, 0.95), 0 0 0 22px rgba(232, 68, 90, 0); }
}
.qt[data-view="ticket"]:has(.qt-card.is-called) .qt-title { color: var(--color-accent-strong); }

/* avanzamento: stadi, non percentuali (niente falsa precisione) */
.qt-track { position: relative; display: flex; justify-content: space-between; margin: var(--space-2) var(--space-2) 0; padding: 0; list-style: none; }
.qt-track::before { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 4px; transform: translateY(-50%); border-radius: 4px; background: #F2D9C2; }
.qt-track__step { position: relative; z-index: 1; }
.qt-track__dot { display: block; width: 18px; height: 18px; border-radius: 50%; background: #F6D8BE; box-shadow: 0 0 0 4px var(--color-bg); transition: background var(--dur-slow) ease, transform var(--dur-slow) var(--ease-out); }
.qt-track__step.is-done .qt-track__dot { background: #F29AA6; }
.qt-track__step.is-current .qt-track__dot { width: 26px; height: 26px; margin-top: -4px; background: var(--color-accent); box-shadow: 0 0 0 4px var(--color-bg), 0 0 0 9px rgba(232, 68, 90, 0.18); }
.qt-track__label { text-align: center; font-size: var(--fs-sm); font-weight: var(--fw-heavy); color: var(--color-accent-strong); }

.qt-checkin {
    display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg); background: var(--tint-butter); color: #6B4A12; font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.qt-checkin .icon { margin-top: 2px; color: var(--color-caramel-strong); }
.qt-notify { align-self: center; }
.qt-cancel {
    width: 100%; min-height: 56px; font-size: 1.05rem;
    background: var(--color-surface-alt); color: var(--color-text);
    box-shadow: inset 0 0 0 1px var(--color-border-strong);
}

/* ---------- Esito ---------- */
.qt-outcome { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; padding: var(--space-6) var(--space-4); border-radius: var(--radius-xl); background: var(--color-surface); box-shadow: var(--shadow-card); }
.qt-outcome__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--tint-rose); color: var(--color-accent-strong); font-size: 1.6rem; }
.qt-outcome__code { font-size: 2.6rem; font-weight: 900; color: var(--color-text-muted); text-decoration: line-through; text-decoration-thickness: 3px; }
.qt[data-outcome="COMPLETED"] .qt-outcome__code { text-decoration: none; color: var(--color-success); }
.qt-outcome__text { font-weight: var(--fw-bold); max-width: 32ch; }
.qt-outcome__actions { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }

/* ---------- Conferma rinuncia (bottom sheet) ---------- */
.qt-confirm { display: flex; flex-direction: column; gap: var(--space-3); padding-bottom: var(--space-2); }
.qt-confirm__title { font-size: var(--fs-xl); font-weight: 900; line-height: 1.2; padding-right: var(--space-7); outline: none; }
.qt-confirm__text { color: var(--color-text-muted); font-weight: var(--fw-bold); }
.qt-confirm__actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.qt-confirm__leave { color: var(--color-danger); }

@media (min-width: 600px) {
    .qt-services:not(.qt-services--single) { grid-template-columns: 1fr 1fr; }
    .qt-outcome__actions { flex-direction: row; justify-content: center; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .qt-card, .qt-service, .qt-code__num.is-tick { animation: none; }
    .qt-card.is-called { animation: none; }
}
