/* ============================================================
   pro/popup.css : ป๊อปอัปยืนยัน / แจ้งเตือนของ i-TEST (ใช้คู่กับ pro/popup.js)
   ------------------------------------------------------------
   ใช้แทน confirm() / alert() ของเบราว์เซอร์ ให้หน้าตาเข้ากับเว็บ (ทอง / ครีม / น้ำตาลเข้ม)
     <link rel="stylesheet" href="pro/popup.css">  <script src="pro/popup.js"></script>
     itPop.confirm({ title: 'ส่งคำตอบ?', html: '...', ok: 'ยืนยัน', cancel: 'ยกเลิก', icon: 'fa-solid fa-paper-plane', tone: 'gold' })
       .then(function (yes) { if (yes) { ... } });
   ไม่ขึ้นกับ .pp : ป๊อปอัปต่อท้าย <body> ใช้ได้ทุกหน้า  ต้องมี Font Awesome + ฟอนต์ Noto Sans Thai ในหน้า (it_head / pro_head มีแล้ว)
   สีตาม tone : gold (ค่าเริ่ม) · ok (เขียว) · warn (ส้ม) · bad (แดง)
   จอไม่เกิน 480px เป็นแผ่นเลื่อนขึ้นจากขอบล่าง ปุ่มเรียงแนวตั้ง
   ชิ้นส่วนเนื้อหาสำเร็จรูป : .it-pop-sum (ตัวเลขใหญ่) .it-pop-meter (แถบ) .it-pop-warn + .it-pop-chips (รายการที่ต้องดู) .it-pop-ok .it-pop-note
   ============================================================ */

.it-pop {
    --pop-gold: #D6B172;
    --pop-gold-dark: #a8844a;
    --pop-ink: #1f1f1f;
    --pop-muted: #857b6c;
    --pop-line: #eee4d3;
    --pop-tone: #D6B172;
    --pop-tone-2: #c49a55;
    --pop-tone-soft: rgba(214, 177, 114, 0.18);

    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(24, 18, 10, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    font-family: 'Noto Sans Thai', 'Sarabun', sans-serif;
    animation: it-pop-fade .18s ease-out;
}

.it-pop.out {
    animation: it-pop-fade .16s ease-in reverse forwards;
}

.it-pop *,
.it-pop *::before,
.it-pop *::after {
    box-sizing: border-box;
}

body.it-pop-lock {
    overflow: hidden;
}

/* สีตามชนิด */
.it-pop.tone-ok   { --pop-tone: #3f9a64; --pop-tone-2: #2f7d50; --pop-tone-soft: rgba(63, 154, 100, 0.16); }
.it-pop.tone-warn { --pop-tone: #e0a340; --pop-tone-2: #c9861f; --pop-tone-soft: rgba(209, 143, 30, 0.16); }
.it-pop.tone-bad  { --pop-tone: #e05b5b; --pop-tone-2: #c84444; --pop-tone-soft: rgba(224, 91, 91, 0.15); }

/* กล่อง */
.it-pop-box {
    position: relative;
    width: min(440px, 100%);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    padding: 34px 28px 24px;
    overflow-y: auto;
    border-radius: 28px;
    background:
        radial-gradient(circle at 50% -10%, var(--pop-tone-soft), transparent 55%),
        #fff;
    color: var(--pop-ink);
    text-align: center;
    box-shadow: 0 30px 80px rgba(20, 14, 6, 0.35), inset 0 0 0 1px rgba(214, 177, 114, 0.25);
    animation: it-pop-in .24s cubic-bezier(.2, .9, .3, 1.2);
    outline: none;
}

.it-pop.out .it-pop-box {
    animation: it-pop-in .16s ease-in reverse forwards;
}

/* ปุ่มปิดมุมขวาบน */
.it-pop-x {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f5f0e7;
    color: #8a7a60;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.it-pop-x:hover {
    background: #efe5d3;
    color: var(--pop-ink);
}

/* ไอคอนวงกลม + วงแสงรอบ */
.it-pop-ic {
    display: inline-grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pop-tone), var(--pop-tone-2));   /* เบราว์เซอร์เก่าที่ไม่มี color-mix() */
    background: linear-gradient(135deg, color-mix(in srgb, var(--pop-tone) 70%, #fff), var(--pop-tone) 50%, var(--pop-tone-2));
    color: #fff;
    font-size: 28px;
    box-shadow: 0 0 0 9px var(--pop-tone-soft), 0 12px 26px rgba(60, 42, 16, 0.18);
    box-shadow: 0 0 0 9px var(--pop-tone-soft), 0 12px 26px color-mix(in srgb, var(--pop-tone) 45%, transparent);
}

.it-pop-t {
    margin: 0;
    font-size: 23px;
    font-weight: 600;
    line-height: 1.35;
}

.it-pop-b {
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--pop-muted);
}

.it-pop-b > :first-child {
    margin-top: 0;
}

.it-pop-b > :last-child {
    margin-bottom: 0;
}

/* ปุ่ม */
.it-pop-acts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 24px;
}

.it-pop-acts.one {
    grid-template-columns: minmax(0, 1fr);
}

.it-pop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 0;
    height: 50px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, background .15s, color .15s;
}

.it-pop-btn:active {
    transform: scale(0.98);
}

.it-pop-btn:focus-visible {
    outline: 3px solid rgba(214, 177, 114, 0.6);
    outline-offset: 2px;
}

/* ยืนยัน : พื้นเข้ม + วงไอคอนทอง (แบบปุ่มส่งคำตอบบนแถบเมนู) */
.it-pop-btn.main {
    padding-left: 7px;
    background: linear-gradient(135deg, #3b2f21, #1f1a13);
    color: #f6e7c8;
    box-shadow: 0 10px 22px rgba(43, 35, 25, 0.28), inset 0 0 0 1px rgba(214, 177, 114, 0.4);
}

.it-pop-btn.main:hover {
    box-shadow: 0 14px 28px rgba(43, 35, 25, 0.34), inset 0 0 0 1px rgba(214, 177, 114, 0.7);
    transform: translateY(-1px);
}

.it-pop-btn.main i {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ecd3a4, var(--pop-gold) 50%, #c49a55);
    color: #2b2319;
    font-size: 14px;
}

.it-pop-btn.main.no-ic {
    padding-left: 18px;
}

/* ยกเลิก / กลับไป : ขอบทอง พื้นขาว */
.it-pop-btn.line {
    background: #fff;
    color: var(--pop-gold-dark);
    box-shadow: inset 0 0 0 2px var(--pop-gold);
}

.it-pop-btn.line:hover {
    background: #fff8ec;
}

/* ---------------- ชิ้นส่วนเนื้อหาสำเร็จรูป ---------------- */

/* ตัวเลขใหญ่ เช่น 18/20 ข้อที่ตอบแล้ว */
.it-pop-sum {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    margin: 6px 0 10px;
}

.it-pop-sum b {
    font-size: 44px;
    font-weight: 700;
    line-height: 1;
    color: var(--pop-ink);
    font-variant-numeric: tabular-nums;
}

.it-pop-sum b small {
    font-size: 22px;
    font-weight: 500;
    color: var(--pop-muted);
}

.it-pop-sum span {
    font-size: 14px;
    color: var(--pop-muted);
}

/* แถบความคืบหน้า */
.it-pop-meter {
    height: 8px;
    margin: 0 8px 16px;
    border-radius: 999px;
    background: #f1ebe0;
    overflow: hidden;
}

.it-pop-meter span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #e3c48e, var(--pop-gold) 60%, var(--pop-gold-dark));
}

.it-pop.tone-ok .it-pop-meter span {
    background: linear-gradient(90deg, #7cc59a, #3f9a64);
}

/* กล่องเตือน + รายการที่ต้องดู (แตะเพื่อไปยังจุดนั้น) */
.it-pop-warn {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid rgba(209, 143, 30, 0.3);
    border-radius: 16px;
    background: #fff8ea;
    text-align: left;
}

.it-pop-warn p {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #8a5a0e;
}

.it-pop-warn p i {
    margin-top: 4px;
    color: #d18f1e;
}

.it-pop-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.it-pop-chips a {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border: 1px solid rgba(209, 143, 30, 0.35);
    border-radius: 999px;
    background: #fff;
    color: #8a5a0e;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition: background .15s, border-color .15s;
}

.it-pop-chips a:hover {
    border-color: #d18f1e;
    background: #fff1d6;
}

.it-pop-ok {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(63, 154, 100, 0.12);
    color: #2f7d50;
    font-size: 14px;
    font-weight: 500;
}

.it-pop-note {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--pop-muted);
}

.it-pop-note i {
    margin-right: 6px;
    color: var(--pop-gold-dark);
}

/* ---------------- ภาพเคลื่อนไหว ---------------- */

@keyframes it-pop-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes it-pop-in {
    from { opacity: 0; transform: translateY(14px) scale(0.95); }
    to   { opacity: 1; transform: none; }
}

@keyframes it-pop-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
}

/* ---------------- จอมือถือ : แผ่นขึ้นจากขอบล่าง ---------------- */

@media screen and (max-width: 480px) {
    .it-pop {
        place-items: end center;
        padding: 0;
    }
    .it-pop-box {
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        padding: 30px 20px calc(18px + env(safe-area-inset-bottom));
        border-radius: 26px 26px 0 0;
        animation: it-pop-up .26s cubic-bezier(.2, .9, .3, 1);
    }
    .it-pop.out .it-pop-box {
        animation: it-pop-up .18s ease-in reverse forwards;
    }
    .it-pop-box::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        width: 44px;
        height: 5px;
        margin-left: -22px;
        border-radius: 999px;
        background: #e6dccb;
    }
    .it-pop-acts {
        grid-template-columns: minmax(0, 1fr);
    }
    .it-pop-acts .main {
        order: -1;
    }
    .it-pop-sum b {
        font-size: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .it-pop,
    .it-pop-box,
    .it-pop.out,
    .it-pop.out .it-pop-box {
        animation: none;
    }
}

/* แจ้งข้อผิดพลาดข้อสอบ (../q_report_lib.php) : คำอธิบายสั้น + ช่องรายละเอียด (ไม่บังคับ) ชิดซ้าย */
.it-pop .qr-sub {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.it-pop .qr-l {
    display: block;
    margin: 14px 0 6px;
    color: var(--pop-ink);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}

.it-pop .qr-l small {
    color: var(--pop-muted);
    font-size: 12.5px;
    font-weight: 400;
}

.it-pop .qr-note {
    display: block;
    width: 100%;
    min-height: 104px;
    padding: 10px 12px;
    border: 1px solid var(--pop-line);
    border-radius: 14px;
    background: #fffdf9;
    color: var(--pop-ink);
    font-family: inherit;
    font-size: 16px;   /* 16px : iPhone ไม่ซูมหน้าตอนแตะช่องพิมพ์ */
    line-height: 1.6;
    resize: vertical;
}

.it-pop .qr-note:focus {
    border-color: var(--pop-gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(214, 177, 114, 0.22);
}
