/* ═══════════════════════════════════════════════════════════
   base.css — sistema di design condiviso
   Il colore primario viene sovrascritto inline da partials/header.php
   leggendo app_config.json → primary_color.
   Personalizzazioni installazione → app_custom.css (caricato dopo).
═══════════════════════════════════════════════════════════ */

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── VARIABILI ───────────────────────────────────────────── */
:root {
    --primary:   #367fb5;
    --primary-d: color-mix(in srgb, var(--primary) 85%, black);
    --bg:        #f5f3f0;
    --card:      #ffffff;
    --text:      #1a1a1a;
    --muted:     #888;
    --border:    #e0ddd9;
    --green:     #2e9e5a;
    --red:       #e8423b;
    --radius:    14px;
    --shadow:    0 2px 12px rgba(0,0,0,.09);
    --safe-top:  env(safe-area-inset-top,    0px);
    --safe-bot:  env(safe-area-inset-bottom, 0px);
}

/* ── BASE ────────────────────────────────────────────────── */
html  { height: 100%; }
body  { min-height: 100%; background: var(--bg); color: var(--text);
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        font-size: 16px; -webkit-tap-highlight-color: transparent; }
a     { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100dvh;
       max-width: 900px; margin: 0 auto; }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar { background: var(--primary); color: #fff;
          padding: calc(14px + var(--safe-top)) 16px 14px;
          display: flex; align-items: center; gap: 12px;
          position: sticky; top: 0; z-index: 100;
          box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar-logo     { font-size: 1.3rem; font-weight: 700; letter-spacing: -.5px; }
.topbar-logo-img { height: 36px; width: auto; object-fit: contain; }
.topbar-sub      { font-size: 16px; opacity: .85; margin-top: 1px; }
.topbar-right    { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── GHOST BUTTON (topbar) ───────────────────────────────── */
.btn-ghost { background: rgba(255,255,255,.2); border: none; color: #fff;
             padding: 9px 14px; border-radius: 8px; cursor: pointer;
             font-size: .88rem; font-weight: 600; transition: background .15s;
             white-space: nowrap; }
.btn-ghost:active { background: rgba(255,255,255,.35); }

/* ── CENTERED CARD ───────────────────────────────────────── */
.center-wrap { flex: 1; display: flex; align-items: center;
               justify-content: center; padding: 24px 20px; }
.auth-card   { background: var(--card); border-radius: var(--radius);
               box-shadow: var(--shadow); padding: 32px 28px;
               width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.auth-card p  { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }

/* ── FORM ────────────────────────────────────────────────── */
.form-group  { margin-bottom: 18px; }
.form-label  { display: block; font-size: .85rem; font-weight: 600;
               color: var(--muted); margin-bottom: 6px;
               text-transform: uppercase; letter-spacing: .4px; }
.form-input  { width: 100%; border: 2px solid var(--border); border-radius: 10px;
               padding: 13px 14px; font-size: 1.1rem; font-weight: 600;
               background: var(--bg); transition: border-color .15s;
               letter-spacing: 2px; -webkit-appearance: none; appearance: none; }
.form-input:focus  { outline: none; border-color: var(--primary); background: #fff; }
.form-select { width: 100%; border: 2px solid var(--border); border-radius: 10px;
               padding: 13px 14px; font-size: 1rem; font-weight: 600;
               background: var(--bg); transition: border-color .15s;
               -webkit-appearance: none; appearance: none;
               background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
               background-repeat: no-repeat; background-position: right 14px center;
               padding-right: 36px; }
.form-select:focus { outline: none; border-color: var(--primary); background-color: #fff; }
.btn-submit  { width: 100%; background: var(--primary); color: #fff; border: none;
               border-radius: 12px; padding: 15px; font-size: 1rem; font-weight: 700;
               cursor: pointer; transition: background .15s; margin-top: 4px; }
.btn-submit:active { background: var(--primary-d); }

/* ── SERVICE BADGES ──────────────────────────────────────── */
.service-info  { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.service-badge { background: #eff6ff; color: var(--primary); font-size: .8rem;
                 font-weight: 600; padding: 5px 12px; border-radius: 100px;
                 border: 1px solid #bfdbfe; }

/* ── ERROR BOX ───────────────────────────────────────────── */
.error-box { background: #fef2f2; border: 1.5px solid #ffc0be; border-radius: 10px;
             padding: 12px 16px; color: var(--red); font-size: .9rem;
             font-weight: 500; margin-bottom: 18px; }

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner { display: none; width: 20px; height: 20px;
           border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
           border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HOME ────────────────────────────────────────────────── */
.home-wrap  { padding: 20px 16px; }
.home-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.home-sub   { color: var(--muted); margin-bottom: 20px; font-size: .9rem; }
.staff-link { display: block; text-align: center; margin-top: 24px;
              color: var(--muted); font-size: .88rem; }
.staff-link a { color: var(--primary); font-weight: 600; }

/* ── ORDER WRAP / TABS ───────────────────────────────────── */
.order-wrap { flex: 1; display: flex; flex-direction: column; }
.page-tabs  { display: flex; border-bottom: 2px solid var(--border);
              background: var(--card); position: sticky; top: 57px; z-index: 95; }
.page-tab   { flex: 1; padding: 14px; text-align: center; font-weight: 600;
              font-size: .9rem; cursor: pointer; border-bottom: 3px solid transparent;
              margin-bottom: -2px; color: var(--muted);
              transition: all .15s; user-select: none; }
.page-tab.active { color: var(--primary); border-color: var(--primary); }

/* ── INFO TAB ────────────────────────────────────────────── */
.info-wrap       { padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.info-card       { background: var(--card); border-radius: var(--radius);
                   padding: 18px 16px; box-shadow: var(--shadow); }
.info-card-title { font-size: .75rem; font-weight: 700; text-transform: uppercase;
                   letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; }
.info-row        { display: flex; justify-content: space-between; align-items: baseline;
                   padding: 8px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: .88rem; color: var(--muted); }
.info-value { font-size: .95rem; font-weight: 600; text-align: right; }
.info-text  { font-size: .9rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; }

/* ── PULL-TO-REFRESH INDICATOR ───────────────────────────── */
#ptr-indicator { position: fixed; top: 0; left: 0; right: 0; z-index: 999;
                 display: flex; align-items: center; justify-content: center;
                 height: 0; overflow: hidden; background: var(--primary); color: #fff;
                 font-size: .85rem; font-weight: 600; gap: 8px;
                 transition: height .15s ease; pointer-events: none; }
#ptr-indicator .ptr-icon { font-size: 1.2rem; transition: transform .3s ease; display: inline-block; }
#ptr-indicator.ptr-ready .ptr-icon { transform: rotate(180deg); }

/* ── CATEGORY TABS ───────────────────────────────────────── */
.cat-tabs { display: flex; overflow-x: auto; gap: 8px; padding: 12px 16px;
            background: var(--card); border-bottom: 1px solid var(--border);
            scrollbar-width: none; position: sticky; top: 108px; z-index: 90; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab  { flex-shrink: 0; border: 2px solid var(--border); background: var(--bg);
            border-radius: 100px; padding: 8px 16px; cursor: pointer;
            font-size: .88rem; font-weight: 600; white-space: nowrap;
            transition: all .15s; user-select: none; }
.cat-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── MENU ────────────────────────────────────────────────── */
.menu-sections { padding: 12px 16px 160px; }
.subcat-label  { font-size: .75rem; font-weight: 700; text-transform: uppercase;
                 letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px 2px;
                 padding-left: 8px; border-left: 3px solid var(--primary); }
.section-title { font-size: .8rem; font-weight: 700; margin: 18px 0 10px;
                 color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.item-grid { display: grid;
             grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* ── EXTRA ITEMS ─────────────────────────────────────────── */
.item-extra          { border-left: 3px solid #f0a500; }
.item-extra.has-qty  { border-color: #f0a500; }
.extra-badge { display: inline-block; font-size: .65rem; font-weight: 700;
               background: #fff3cd; color: #856404; border: 1px solid #f0a500;
               border-radius: 4px; padding: 1px 5px; margin-bottom: 4px;
               text-transform: uppercase; letter-spacing: .03em; }
.item-price  { font-size: .82rem; font-weight: 700; color: #856404; margin-top: 2px; }

/* ── EXTRA CONFIRM BAR ───────────────────────────────────── */
.extra-confirm-bar { position: fixed; bottom: 70px; left: 0; right: 0;
                     max-width: 900px; margin: 0 auto;
                     background: #fff8e6; border-top: 2px solid #f0a500;
                     padding: 10px 16px; display: flex; align-items: center;
                     justify-content: space-between; gap: 12px;
                     transform: translateY(120%); transition: transform .25s ease;
                     z-index: 200; box-shadow: 0 -2px 12px rgba(0,0,0,.08); }
.extra-confirm-bar.show { transform: translateY(0); }
.extra-confirm-msg  { font-size: .9rem; color: #5a4000; flex: 1; line-height: 1.3; }
.extra-confirm-btns { display: flex; gap: 8px; flex-shrink: 0; }
.extra-confirm-btns button { padding: 7px 14px; border-radius: 8px; border: none;
                              font-size: .85rem; font-weight: 600; cursor: pointer; }
.btn-extra-no  { background: #e0ddd9; color: var(--text); }
.btn-extra-yes { background: #f0a500; color: #fff; }

/* ── CONFIRM MODAL — SEZIONI EXTRA ───────────────────────── */
.confirm-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase;
                         letter-spacing: .05em; color: var(--muted);
                         padding: 10px 0 4px; border-bottom: none !important; }
.confirm-extra-item span  { color: #856404; }
.confirm-extra-price      { font-size: .8rem; color: #856404;
                             margin-left: 4px; font-weight: 600; }

/* ── STORICO ROUNDS — EXTRA ──────────────────────────────── */
.round-extras-label { font-size: .72rem; font-weight: 700; text-transform: uppercase;
                      letter-spacing: .05em; color: var(--muted);
                      margin-top: 10px; padding-top: 8px;
                      border-top: 1px solid var(--border); }
.round-extras li    { color: #856404; }

/* ── ITEM CARD ───────────────────────────────────────────── */
.item-card  { background: var(--card); border-radius: var(--radius);
              padding: 14px 12px; box-shadow: var(--shadow);
              display: flex; flex-direction: column; gap: 6px;
              border: 2px solid transparent; transition: border-color .15s; }
.item-card.has-qty { border-color: var(--primary); }
.item-name  { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.item-desc  { font-size: .78rem; color: var(--muted); }
.item-limit { font-size: .72rem; color: var(--muted); font-style: italic; }
.qty-ctrl   { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.qty-btn    { width: 36px; height: 36px; border-radius: 50%;
              border: 2px solid var(--border); background: var(--bg);
              font-size: 1.2rem; font-weight: 700; cursor: pointer;
              display: flex; align-items: center; justify-content: center;
              transition: all .12s; }
.qty-btn:active { background: #eff6ff; border-color: var(--primary); }
.qty-val    { flex: 1; text-align: center; font-weight: 700; font-size: 1rem; }

/* ── BOTTOM BAR ──────────────────────────────────────────── */
.bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 900px;
              margin: 0 auto; background: var(--card);
              border-top: 1px solid var(--border);
              padding: 12px 16px calc(12px + var(--safe-bot));
              box-shadow: 0 -4px 20px rgba(0,0,0,.1);
              display: flex; gap: 10px; align-items: center; z-index: 201; }
.bar-summary strong { font-size: 1rem; display: block; }
.bar-summary small  { color: var(--muted); font-size: .8rem; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn-primary  { background: var(--primary); color: #fff; border: none;
                border-radius: 12px; padding: 14px 20px;
                font-size: 1rem; font-weight: 700; cursor: pointer;
                transition: background .15s; min-width: 140px; text-align: center; }
.btn-primary:active   { background: var(--primary-d); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-secondary { flex: 1; background: var(--bg); border: 2px solid var(--border);
                 border-radius: 12px; padding: 14px;
                 font-size: 1rem; font-weight: 600; cursor: pointer; }

/* ── HISTORY ─────────────────────────────────────────────── */
.history-wrap { padding: 16px; }
.round-card   { background: var(--card); border-radius: var(--radius);
                padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.round-head   { display: flex; justify-content: space-between;
                align-items: center; margin-bottom: 10px; }
.round-badge  { background: var(--primary); color: #fff; font-size: .75rem;
                font-weight: 700; padding: 4px 10px; border-radius: 100px; }
.round-items  { list-style: none; }
.round-items li { display: flex; justify-content: space-between;
                  padding: 5px 0; border-bottom: 1px solid var(--border);
                  font-size: .9rem; }
.round-items li:last-child { border-bottom: none; }
.badge-green  { background: #e8f5ee; color: var(--green); font-size: .75rem;
                font-weight: 700; padding: 3px 8px; border-radius: 100px; }

/* ── STAFF ───────────────────────────────────────────────── */
.staff-wrap        { padding: 16px; }
.staff-grid        { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.staff-table       { background: var(--card); border-radius: var(--radius);
                     padding: 16px; box-shadow: var(--shadow); }
.staff-table-head  { display: flex; justify-content: space-between;
                     align-items: center; margin-bottom: 12px; }
.staff-table-title { font-weight: 700; font-size: 1rem; }
.staff-round-pill  { background: #eff6ff; color: var(--primary); font-size: .75rem;
                     font-weight: 700; padding: 3px 8px; border-radius: 100px; }
.staff-item-row    { display: flex; justify-content: space-between; font-size: .85rem;
                     padding: 4px 0; border-bottom: 1px solid var(--border); }
.staff-item-row:last-child { border-bottom: none; }
.staff-actions { margin-top: 14px; display: flex; gap: 8px; }
.btn-close     { background: #eff6ff; color: var(--primary);
                 border: 2px solid #bfdbfe; border-radius: 8px;
                 padding: 8px 14px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.btn-close:active { background: #ffdad9; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast { position: fixed; top: 80px; left: 50%;
         transform: translateX(-50%) translateY(-10px);
         background: var(--green); color: #fff; padding: 12px 24px;
         border-radius: 100px; font-weight: 600; font-size: .9rem;
         opacity: 0; transition: all .3s; z-index: 1100;
         pointer-events: none; white-space: nowrap;
         box-shadow: 0 4px 20px rgba(0,0,0,.2); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err  { background: var(--red); }

/* ── MODAL ───────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500;
           display: flex; align-items: flex-end; justify-content: center;
           opacity: 0; pointer-events: none; transition: opacity .25s; }
.overlay.show { opacity: 1; pointer-events: all; }
.sheet { background: var(--card); border-radius: var(--radius) var(--radius) 0 0;
         width: 100%; max-width: 900px;
         padding: 24px 20px calc(24px + var(--safe-bot));
         transform: translateY(40px); transition: transform .25s;
         max-height: 80dvh; overflow-y: auto; }
.overlay.show .sheet { transform: translateY(0); }
.sheet-title  { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.confirm-list { list-style: none; margin-bottom: 20px; }
.confirm-list li { display: flex; justify-content: space-between;
                   padding: 9px 0; border-bottom: 1px solid var(--border);
                   font-size: .95rem; }
.confirm-list li:last-child { border-bottom: none; }
.sheet-btns { display: flex; gap: 10px; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state      { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .ico { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ── GOODBYE ─────────────────────────────────────────────── */
.goodbye-wrap { display: flex; flex-direction: column; align-items: center;
                justify-content: center; min-height: calc(100dvh - 60px);
                padding: 32px 24px; text-align: center; }
.goodbye-icon { font-size: 4rem; margin-bottom: 16px; }
.goodbye-msg  { font-size: 1.15rem; font-weight: 700; color: var(--text);
                margin-bottom: 8px; line-height: 1.4; max-width: 320px; }
.goodbye-sub  { font-size: .9rem; color: var(--muted); margin-bottom: 36px; }
.goodbye-btns { display: flex; flex-direction: column; gap: 12px;
                width: 100%; max-width: 340px; }
.goodbye-btn  { display: flex; align-items: center; gap: 12px;
                background: var(--card); border: 2px solid var(--border);
                border-radius: var(--radius); padding: 16px 20px;
                font-size: 1rem; font-weight: 600; color: var(--text);
                text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.goodbye-btn:hover  { border-color: var(--primary); box-shadow: var(--shadow); }
.goodbye-btn-icon   { font-size: 1.4rem; flex-shrink: 0; }

/* ── UTILITY ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (min-width: 600px) {
    .item-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
