/*
 * context/ui/assets/ext-public.css — คลาสเพิ่มของกลุ่ม "public + system"
 * ใช้กับ: p-01 · p-02 · p-03 · login · scr-21 · scr-33 · scr-34 · scr-36
 * ลิงก์หลัง pp-ui.css เสมอ · ห้าม hardcode สี — ใช้ตัวแปร --pp-* เท่านั้น
 *
 * prefix:  pp-pub-*  = หน้าคนขับ (มือถือก่อน · 375px)
 *          pp-sys-*  = หน้าระบบ (login · error · loading · acting-as · ข่าว · สแกน)
 *
 * สารบัญ: 1 กรอบมือถือ · 2 คูปองสาธารณะ/QR · 3 หน้าแจ้งปัญหา/สำเร็จ · 4 ฟอร์มเซ็นรับ
 *        5 login · 6 หน้า error · 7 สแกน · 8 สวมสิทธิ์ · 9 ข่าว · 10 loading showcase
 */

/* ── 1. กรอบมือถือ (P-01/P-02) ──────────────────────────────────────────── */
.pp-pub-frame .pp-public { max-width: 375px; }
.pp-pub-head__title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pp-pub-head__name { font-weight: 700; font-size: 15px; }
.pp-pub-head__sub { font-size: 12px; color: var(--pp-text-muted); }

/* บนจอจริงที่แคบกว่ากรอบ — ไม่ต้องมีขอบเครื่อง */
@media (max-width: 520px) {
    .pp-pub-frame { padding: 0; }
    .pp-pub-frame .pp-public { max-width: none; min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
}

/* ── 2. คูปองสาธารณะ / QR ──────────────────────────────────────────────── */
.pp-pub-hero { display: flex; flex-direction: column; align-items: center; gap: var(--pp-space-2); text-align: center; }
.pp-pub-no {
    font-size: 32px; font-weight: 700; letter-spacing: .5px;
    font-variant-numeric: tabular-nums; line-height: 1.15;
}
.pp-pub-caption { font-size: 13px; color: var(--pp-text-muted); text-align: center; }

/* QR — modules ใช้ currentColor (ดู shared-request: ควรมี token สีคงที่สำหรับ QR) */
.pp-pub-qr {
    display: block; width: 220px; height: 220px; margin: 0 auto; padding: 10px;
    background: var(--pp-qr-bg); color: var(--pp-qr-fg); /* QR ต้องเข้มบนขาวเสมอ — กลับสีแล้วสแกนเนอร์บางรุ่นอ่านไม่ได้ */
    border: 1px solid var(--pp-border); border-radius: var(--pp-radius);
}
.pp-pub-qr svg { display: block; width: 100%; height: 100%; fill: currentColor; }
.pp-pub-qr--full { width: min(78vw, 320px); height: min(78vw, 320px); border-width: 2px; }

.pp-pub-qty-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── 3. หน้าแจ้งปัญหา / หน้าสำเร็จ (เต็มจอ) ─────────────────────────────── */
.pp-pub-problem {
    flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--pp-space-3); padding: var(--pp-space-6) var(--pp-space-4); text-align: center;
}
.pp-pub-problem__icon {
    display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
    background: var(--pp-surface-alt); font-size: 34px;
}
.pp-pub-problem__icon--danger { background: var(--pp-danger-bg); color: var(--pp-danger); }
.pp-pub-problem__icon--warning { background: var(--pp-warning-bg); color: var(--pp-warning); }
.pp-pub-problem__icon--success { background: var(--pp-success-bg); color: var(--pp-success); }
.pp-pub-problem__icon--info { background: var(--pp-info-bg); color: var(--pp-info); }
.pp-pub-problem__title { font-size: 20px; font-weight: 700; }
.pp-pub-problem__text { color: var(--pp-text-muted); max-width: 300px; }
.pp-pub-problem__actions { display: flex; flex-direction: column; gap: var(--pp-space-2); width: 100%; max-width: 300px; }
.pp-pub-ref {
    padding: var(--pp-space-2) var(--pp-space-4); border-radius: var(--pp-radius);
    background: var(--pp-surface); border: 1px dashed var(--pp-border);
    font-family: var(--pp-font-mono); font-size: 18px; font-weight: 600;
}
.pp-pub-summary { width: 100%; max-width: 300px; text-align: left; }

/* ── 4. ฟอร์มเซ็นรับ (P-02) ───────────────────────────────────────────── */
.pp-pub-stepper { display: grid; grid-template-columns: var(--pp-tap-size) minmax(0, 1fr) var(--pp-tap-size); gap: var(--pp-space-2); align-items: stretch; }
.pp-pub-stepper .pp-input { text-align: center; font-size: 20px; font-weight: 700; min-height: var(--pp-tap-size); }
.pp-pub-stepper .pp-btn { padding: 0; font-size: 20px; font-weight: 700; }

.pp-pub-notice {
    border: 1px solid var(--pp-border); border-radius: var(--pp-radius);
    background: var(--pp-surface-alt); font-size: 13px;
}
.pp-pub-notice > summary { padding: var(--pp-space-3); cursor: pointer; font-weight: 600; }
.pp-pub-notice__body { padding: 0 var(--pp-space-3) var(--pp-space-3); display: flex; flex-direction: column; gap: var(--pp-space-2); }
.pp-pub-notice__body ul { margin: 0; padding-left: 18px; }
.pp-pub-notice__draft { font-size: 12px; color: var(--pp-warning); font-weight: 600; }

/* canvas ที่ล็อกระหว่างส่ง — ภาพนิ่งแทน canvas จริง */
.pp-pub-sign-locked {
    position: relative; display: grid; place-items: center;
    width: 100%; height: var(--pp-sign-pad-height);
    border: 2px dashed var(--pp-border); border-radius: var(--pp-radius);
    background: var(--pp-surface-alt); color: var(--pp-text-muted);
    cursor: not-allowed;
}
.pp-pub-sign-locked svg { width: 70%; height: 60%; fill: none; stroke: var(--pp-text); stroke-width: 2.2; stroke-linecap: round; opacity: .55; }
.pp-pub-sign-locked__tag { position: absolute; top: var(--pp-space-2); right: var(--pp-space-2); }
.pp-pub-sign-row { display: flex; align-items: center; justify-content: space-between; gap: var(--pp-space-2); }

/* spinner บนปุ่มสีเข้ม */
.pp-spinner.pp-sys-spinner--inverse { border-color: var(--pp-primary-text); border-top-color: transparent; opacity: .9; }
.pp-spinner.pp-sys-spinner--lg { width: 40px; height: 40px; border-width: 3px; }

/* ── 5. login ──────────────────────────────────────────────────────────── */
.pp-sys-auth {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--pp-space-4); padding: var(--pp-space-6) var(--pp-space-4);
    background: var(--pp-bg);
}
.pp-sys-auth__card { width: min(440px, 100%); }
.pp-sys-auth__brand { display: flex; flex-direction: column; align-items: center; gap: var(--pp-space-2); text-align: center; }
.pp-sys-auth__mark {
    display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--pp-radius-lg);
    background: var(--pp-accent); color: var(--pp-accent-text);
    font-size: 22px; font-weight: 700; letter-spacing: 1px;
}
.pp-sys-auth__title { font-size: 22px; font-weight: 700; }
.pp-sys-auth__sub { font-size: 14px; color: var(--pp-text-muted); }
.pp-sys-auth__divider { display: flex; align-items: center; gap: var(--pp-space-2); font-size: 12px; color: var(--pp-text-muted); }
.pp-sys-auth__divider::before, .pp-sys-auth__divider::after { content: ""; flex: 1 1 auto; border-top: 1px solid var(--pp-border-soft); }
.pp-sys-auth__foot { width: min(440px, 100%); font-size: 12px; color: var(--pp-text-muted); text-align: center; }
.pp-sys-auth__news { width: min(440px, 100%); }
.pp-sys-auth__spec { width: min(640px, 100%); margin-top: var(--pp-space-2); }

/* ── 6. หน้า error (SCR-34) ────────────────────────────────────────────── */
.pp-sys-error {
    max-width: 640px; margin: var(--pp-space-6) auto; padding: var(--pp-space-6) var(--pp-space-5);
    display: flex; flex-direction: column; align-items: center; gap: var(--pp-space-3); text-align: center;
}
.pp-sys-error__code { font-size: 56px; font-weight: 800; line-height: 1; color: var(--pp-text-muted); font-variant-numeric: tabular-nums; }
.pp-sys-error__code--danger { color: var(--pp-danger); }
.pp-sys-error__code--warning { color: var(--pp-warning); }
.pp-sys-error__code--info { color: var(--pp-info); }
.pp-sys-error__title { font-size: 20px; font-weight: 700; }
.pp-sys-error__text { color: var(--pp-text-muted); max-width: 520px; }
.pp-sys-error__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--pp-space-2); margin-top: var(--pp-space-2); }
.pp-sys-error__body { width: 100%; text-align: left; }
.pp-sys-tech {
    width: 100%; text-align: left; font-size: 13px;
    border: 1px solid var(--pp-border-soft); border-radius: var(--pp-radius-sm); background: var(--pp-surface-alt);
}
.pp-sys-tech > summary { padding: var(--pp-space-2) var(--pp-space-3); cursor: pointer; color: var(--pp-text-muted); }
.pp-sys-tech__body { padding: 0 var(--pp-space-3) var(--pp-space-3); }

/* ── 7. สแกน (P-03) ───────────────────────────────────────────────────── */
.pp-sys-viewfinder {
    position: relative; width: 100%; max-width: 360px; aspect-ratio: 1 / 1; margin: 0 auto;
    display: grid; place-items: center; overflow: hidden;
    border-radius: var(--pp-radius-lg); background: var(--pp-surface-alt); color: var(--pp-text-muted);
    text-align: center; font-size: 14px;
}
.pp-sys-viewfinder__box {
    position: absolute; inset: 18%;
    border: 3px solid var(--pp-accent); border-radius: var(--pp-radius);
}
@keyframes pp-sys-scanline { 0% { top: 20%; } 50% { top: 78%; } 100% { top: 20%; } }
.pp-sys-viewfinder__line {
    position: absolute; left: 20%; right: 20%; height: 2px; top: 20%;
    background: var(--pp-accent); animation: pp-sys-scanline 2.4s ease-in-out infinite;
}
.pp-sys-viewfinder__hint { position: relative; padding: var(--pp-space-3); max-width: 60%; }
.pp-sys-viewfinder--off .pp-sys-viewfinder__box { border-color: var(--pp-border); border-style: dashed; }

/* ── 8. สวมสิทธิ์ (SCR-36) ────────────────────────────────────────────── */
/* ตัวอย่างแถบในหน้า — ยืดเต็มความกว้าง .pp-main และค้างใต้ topbar */
.pp-sys-imp-bar {
    position: sticky; top: var(--pp-bar-height); z-index: 20;
    margin: calc(-1 * var(--pp-space-5)) calc(-1 * var(--pp-space-5)) var(--pp-space-5);
}
@media (max-width: 767px) {
    .pp-sys-imp-bar { margin: calc(-1 * var(--pp-space-4)) calc(-1 * var(--pp-space-4)) var(--pp-space-4); flex-wrap: wrap; }
}
.pp-sys-countdown { font-family: var(--pp-font-mono); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pp-sys-customer-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--pp-border); border-radius: var(--pp-radius-sm); }
.pp-sys-customer-list .pp-radio-card { border: 0; border-bottom: 1px solid var(--pp-border-soft); border-radius: 0; }
.pp-sys-customer-list .pp-radio-card:last-child { border-bottom: 0; }

/* ── 9. ข่าว/ประกาศ (SCR-21) ──────────────────────────────────────────── */
.pp-sys-news { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--pp-space-4); padding: var(--pp-space-4); }
.pp-sys-news + .pp-sys-news { border-top: 1px solid var(--pp-border-soft); }
.pp-sys-news__img {
    display: grid; place-items: center; width: 112px; height: 84px; border-radius: var(--pp-radius-sm);
    background: var(--pp-surface-alt); color: var(--pp-text-muted); font-size: 28px;
}
.pp-sys-news__title { font-size: 16px; font-weight: 600; }
.pp-sys-news__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pp-space-2); font-size: 12px; color: var(--pp-text-muted); }
.pp-sys-news__body { font-size: 14px; margin-top: var(--pp-space-1); }
@media (max-width: 600px) {
    .pp-sys-news { grid-template-columns: minmax(0, 1fr); }
    .pp-sys-news__img { width: 100%; height: 120px; }
}
.pp-sys-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.pp-sys-fieldset > legend { padding: 0; margin-bottom: 6px; }
.pp-sys-rte { border: 1px solid var(--pp-border); border-radius: var(--pp-radius-sm); overflow: hidden; }
.pp-sys-rte__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: var(--pp-surface-alt); border-bottom: 1px solid var(--pp-border); }
.pp-sys-rte .pp-input { border: 0; border-radius: 0; min-height: 140px; }

/* ── 10. loading showcase (SCR-33) ────────────────────────────────────── */
.pp-sys-demo-label {
    display: inline-block; margin-bottom: var(--pp-space-2);
    font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--pp-text-muted);
}
.pp-sys-inline-loading { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pp-space-3); padding: var(--pp-space-3) var(--pp-space-4); border-radius: var(--pp-radius-sm); background: var(--pp-surface-alt); font-size: 14px; }
.pp-sys-progress-row { display: flex; align-items: center; gap: var(--pp-space-3); }
.pp-sys-progress-row .pp-progress { flex: 1 1 auto; }
