/* ============================================================
   Ricarica rapida e pannello admin – foglio di stile autonomo.
   Per cambiare aspetto basta modificare i colori qui sotto;
   per usare la grafica del sito esistente vedi lib/View.php (cartella tema/).
   ============================================================ */
:root {
  --plum: #2a1b5e; --plum-dark: #1d1340; --gold: #e8a317; --gold-light: #f6d365;
  --bg: #faf8ff; --card: #ffffff; --text: #1f1b2e; --muted: #5b566d; --line: #e4e0f1;
  --ok: #1f9d55; --warn: #b45309; --err: #d93b3b; --accent: #1a73e8;
}
/* ---- base (in origine arrivava dal foglio di stile del sito principale) ---- */
/* limitato a .app-body: con la grafica del sito (cartella tema/) la classe sta su <main>, e il resto della pagina non viene toccato */
.app-body, .app-body *, .app-body *::before, .app-body *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.app-body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.55; background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100vh; }
.app-body .container { width: min(100% - 32px, 1160px); margin-inline: auto; }
.app-body a { color: #4b32a8; }
.app-body h1, .app-body h2, .app-body h3 { font-family: Georgia, "Times New Roman", serif; color: var(--plum-dark); line-height: 1.2; margin: 0 0 12px; }
.app-body img { max-width: 100%; height: auto; }
.app-body code { background: #f1eefb; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.small { font-size: .85rem; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(42,27,94,.06); }
.site-header .container.app-wide { width: min(100% - 32px, 1400px); }
.site-header .header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; }
.site-header .logo { display: inline-flex; align-items: center; text-decoration: none; color: var(--plum-dark); }
.site-header .logo-img { max-height: 48px; width: auto; display: block; }
.site-header .logo-text { font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 700; }
.site-header .btn { display: inline-flex; align-items: center; gap: .5em; padding: .6em 1.2em; border-radius: 999px; font-weight: 700; text-decoration: none; white-space: nowrap; background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--plum-dark); box-shadow: 0 6px 18px rgba(232,163,23,.3); }
.site-footer { background: var(--plum-dark); color: #d9d4ee; padding: 26px 0; font-size: .9rem; text-align: center; }
.site-footer p { margin: 6px 0; }
.site-footer a { color: #fff; }
.site-footer .legal-note { font-size: .8rem; opacity: .85; }
main.app-main { flex: 1; padding: 32px 0 48px; }
.app-narrow { max-width: 980px; }
.app-wide { max-width: 1240px; }
.app-body .app-main .container.app-wide { max-width: 1400px; width: min(100% - 32px, 1400px); }   /* pannello admin: un po' più largo delle pagine del sito */
.app-main h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 18px; }
.app-main h2 { font-size: 1.2rem; }
p.lead { color: var(--muted); margin-top: -8px; }

/* pulsanti dell'app (coerenti con quelli del sito) */
.app-main .btn { border-radius: 999px; padding: .7em 1.3em; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .5em; background: var(--plum); color: #fff; }
.app-main .btn:hover { background: var(--plum-dark); color: #fff; }
.app-main .btn.gold { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--plum-dark); box-shadow: 0 6px 18px rgba(232,163,23,.35); }
.app-main .btn.small { padding: .5em 1em; font-size: .9rem; }
.app-main .btn.block { display: flex; width: 100%; }
.app-main .btn.danger { background: var(--err); }
.app-main .btn[disabled] { opacity: .5; cursor: not-allowed; }
.app-main form .btn { margin-top: 20px; }

.app-main .card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: 0 10px 30px rgba(42,27,94,.08); }
.app-main .card + .card { margin-top: 18px; }
.app-main .card h2 { margin: 0 0 14px; }
.narrow { max-width: 480px; margin: 0 auto; }

.app-main label { display: block; font-size: .85rem; font-weight: 600; margin: 14px 0 6px; }
.app-main input[type=text], .app-main input[type=search], .app-main input[type=email], .app-main input[type=password], .app-main input[type=tel], .app-main input[type=number], .app-main textarea, .app-main select {
  width: 100%; font-size: 1rem; padding: 12px; border: 1px solid #cfc9e3; border-radius: 10px; background: #fff; color: inherit; font: inherit;
}
.app-main input:focus { outline: 2px solid #5a3fb3; border-color: transparent; }
.help { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.flash.ok { background: #e3f6ea; color: #157a40; }
.flash.err { background: #fde6e6; color: #a32b2b; }
.flash.warn { background: #fff0db; color: #9a5a00; }
.flash.info { background: #e8eefb; color: #1558b8; }

/* saldo in primo piano */
.balance { background: linear-gradient(135deg, var(--plum-dark) 0%, #3b2a7a 100%); color: #fff; border-radius: 16px; padding: 28px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; box-shadow: 0 10px 30px rgba(42,27,94,.18); }
.balance .lbl { font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.balance .val { font-family: Georgia, "Times New Roman", serif; font-size: 2.8rem; font-weight: 700; line-height: 1.1; color: var(--gold-light); }
.balance .val small { font-size: 1rem; font-family: Inter, sans-serif; font-weight: 500; color: #fff; opacity: .85; margin-left: 6px; }
.balance .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.balance.low .val { color: #ffb4b4; }
.balance.compact { padding: 16px 22px; margin-bottom: 18px; }
.balance.compact .val { font-size: 1.8rem; }
.balance .btn.call-green { background: var(--ok); color: #fff; }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.app-main .grid > .card, .app-main .call-layout > .card { margin-top: 0; }

/* offerte */
.opts { display: grid; gap: 10px; }
.opt { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; background: #f7f5fd; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,163,23,.2); background: #fff; }
.opt .min { font-weight: 700; font-size: 1.05rem; } .opt .min small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.opt .eur { font-weight: 800; font-size: 1.25rem; white-space: nowrap; color: var(--plum); }

table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.app-main .tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eee; color: #444; text-transform: none; letter-spacing: 0; }
.app-main .tag.paid, .app-main .tag.ok, .app-main .tag.completed { background: #e3f6ea; color: #157a40; }
.app-main .tag.pending, .app-main .tag.started, .app-main .tag.answered { background: #fff0db; color: #9a5a00; }
.app-main .tag.paypal { background: #e8f0fb; color: #1f4f9c; }
.app-main .tag.dpay { background: #eeeaf7; color: #4b3a8a; }
.app-main .tag.failed, .app-main .tag.error, .app-main .tag.revoking, .app-main .tag.revoked { background: #fde6e6; color: #a32b2b; }
.app-main .tag.abandoned, .app-main .tag.no_answer { background: #ececec; color: #666; }
.right { text-align: right; }
.muted { color: var(--muted); }
.center { text-align: center; }
.note { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 14px; }

/* offerta evidenziata ("Il più richiesto") */
.opt-hl { border-color: rgba(232,163,23,.6); }
.opt-badge { position: absolute; top: -11px; left: 14px; background: var(--gold); color: #1d1340; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.opts { margin-top: 8px; }

/* ---- pannello admin ---- */
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 6px 0 20px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.admin-nav a { padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: .92rem; color: var(--plum); text-decoration: none; }
.admin-nav a:hover { background: #f3f0fb; }
.admin-nav a.active { background: var(--plum); color: #fff; }
.admin-nav .admin-search { margin-left: auto; display: flex; gap: 6px; }
.admin-nav .admin-search input { width: 280px; max-width: 50vw; padding: 8px 12px; font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--gold); }
.kpi-l { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-v { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.kpi-s { font-size: .8rem; color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; margin-bottom: 14px; }
.filters label { margin: 0 0 4px; font-size: .8rem; }
.filters-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.table-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.pager { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.user-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.user-balance { background: linear-gradient(135deg, var(--plum-dark) 0%, #3b2a7a 100%); color: #fff; border-radius: 14px; padding: 12px 22px; display: flex; flex-direction: column; min-width: 180px; }
.user-balance .lbl { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.user-balance .val { font-family: Georgia, "Times New Roman", serif; font-size: 1.9rem; font-weight: 700; color: var(--gold-light); line-height: 1.15; }
.user-balance.zero .val { color: #ffb4b4; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.two-col > .card { margin-top: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { margin: 0 0 4px; font-size: .8rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.subcard { margin: 14px 0 0; padding: 14px 16px; background: #fffaf0; border: 1px solid #f1dfae; border-radius: 10px; }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #2ecc71; margin-right: 8px; animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(46,204,113,.6); } 70% { box-shadow: 0 0 0 9px rgba(46,204,113,0); } 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); } }
.app-main .card + .card { margin-top: 18px; }

/* tabelle admin: pulsanti impilati e id lunghi spezzabili, cosi' la tabella non sborda */
table.list td.acts { white-space: nowrap; }
table.list td.acts form { display: inline-block; margin: 0 4px 4px 0; }
table.list td.dpay { word-break: break-all; max-width: 180px; }

/* pulsante PayPal */
.app-main form .btn.btn-paypal { background: #ffc439; color: #111; margin-top: 10px; border: 1px solid #e0a800; }
.app-main form .btn.btn-paypal:hover { background: #f2b61d; color: #111; }
.app-main .btn.btn-paypal[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; }
.app-main .btn.btn-paypal[disabled] { flex-wrap: wrap; row-gap: 0; padding-top: .55em; padding-bottom: .55em; }
.app-main .btn.btn-paypal[disabled] small { flex-basis: 100%; text-align: center; font-weight: 500; font-size: .78em; opacity: .85; }
.app-main .btn.btn-paypal::before { content: 'P'; display: inline-flex; align-items: center; justify-content: center; width: 1.3em; height: 1.3em; border-radius: 50%; background: #003087; color: #fff; font-weight: 800; font-size: .85em; }
