﻿/* wp-pdpa-consent.css (เพิ่ม 29 พ.ย. 2026 / ปรับดีไซน์ v1.01) ใช้คู่กับ _wpPdpaConsent.cshtml
   ทุก class ขึ้นต้น pdpa- เพื่อไม่ชนของเดิม  สีตามธีม PTG (น้ำเงินเข้มของแถบเมนู + เหลืองของปุ่มเข้าสู่ระบบ) */

#pdpa-consent-root {
    --pdpa-navy: #0b0b3b;
    --pdpa-navy-2: #1c1c5e;
    --pdpa-yellow: #fdb813;
    --pdpa-text: #1f2333;
    --pdpa-muted: #5f6578;
    --pdpa-line: #e7e9f0;
    --pdpa-soft: #f5f6fa;
    --pdpa-radius: 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    color: var(--pdpa-text);
}
#pdpa-consent-root *, #pdpa-consent-root *:before, #pdpa-consent-root *:after { box-sizing: border-box; }
#pdpa-consent-root [hidden] { display: none !important; }
#pdpa-consent-root svg { display: inline-block; vertical-align: middle; flex: 0 0 auto; }

@keyframes pdpa-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pdpa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pdpa-pop  { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------- การ์ดขอความยินยอม (ลอยมุมขวาล่าง) */
.pdpa-banner {
    position: fixed; right: 24px; bottom: 24px; z-index: 10500;
    width: 420px; max-width: calc(100vw - 32px);
    padding: 22px 22px 14px;
    background: #fff; border-radius: var(--pdpa-radius);
    border-top: 4px solid var(--pdpa-yellow);
    box-shadow: 0 18px 48px rgba(11, 11, 59, .22), 0 2px 8px rgba(11, 11, 59, .08);
    animation: pdpa-rise .35s ease-out;
}
.pdpa-banner-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pdpa-banner-text { margin: 0 0 16px; color: var(--pdpa-muted); font-size: 13.5px; }
.pdpa-banner-text a, .pdpa-policy-link a { color: var(--pdpa-navy-2); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.pdpa-banner-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pdpa-icon-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
    background: rgba(253, 184, 19, .16); color: #c98a00;
}
.pdpa-title { font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--pdpa-navy); }
.pdpa-subtitle { font-size: 13px; color: var(--pdpa-muted); }

/* ---------------- ปุ่ม (ยอมรับ/ปฏิเสธ ใช้แบบเดียวกัน) */
.pdpa-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 10px 18px; border-radius: 10px;
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    border: 1.5px solid var(--pdpa-navy); background: #fff; color: var(--pdpa-navy);
    transition: background .15s, color .15s, box-shadow .15s, transform .05s;
}
.pdpa-btn:active { transform: translateY(1px); }
.pdpa-btn-main { background: var(--pdpa-navy); color: #fff; }
.pdpa-btn-main:hover { background: var(--pdpa-navy-2); box-shadow: 0 6px 16px rgba(11, 11, 59, .25); }
.pdpa-btn-outline:hover { background: var(--pdpa-soft); }
.pdpa-btn:disabled { opacity: .6; cursor: wait; }

.pdpa-btn-link {
    display: flex; align-items: center; justify-content: center; gap: 2px; width: 100%;
    margin-top: 8px; padding: 8px; border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 13.5px; font-weight: 600; color: var(--pdpa-navy-2);
}
.pdpa-btn-link:hover { text-decoration: underline; }

#pdpa-consent-root button:focus-visible,
#pdpa-consent-root a:focus-visible,
.pdpa-switch input:focus-visible + .pdpa-slider { outline: 3px solid var(--pdpa-yellow); outline-offset: 2px; }

/* ---------------- หน้าต่างตั้งค่า */
.pdpa-modal {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10510;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(11, 11, 59, .55);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    animation: pdpa-fade .2s ease-out;
}
.pdpa-modal-box {
    width: 100%; max-width: 600px; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border-radius: var(--pdpa-radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
    animation: pdpa-pop .25s ease-out;
}
.pdpa-modal-head {
    display: flex; align-items: center; gap: 14px;
    padding: 20px 22px; border-bottom: 1px solid var(--pdpa-line);
}
.pdpa-modal-head > div { flex: 1 1 auto; min-width: 0; }
.pdpa-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
    background: transparent; color: var(--pdpa-muted);
}
.pdpa-close:hover { background: var(--pdpa-soft); color: var(--pdpa-navy); }

.pdpa-modal-body { padding: 16px 22px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.pdpa-purpose {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 16px; margin-bottom: 10px;
    border: 1px solid var(--pdpa-line); border-radius: 12px; background: #fff;
    transition: border-color .15s, background .15s;
}
.pdpa-purpose:hover { border-color: #cfd3e0; }
.pdpa-purpose.is-required { background: var(--pdpa-soft); }
.pdpa-purpose-text { flex: 1 1 auto; min-width: 0; }
.pdpa-purpose-name { font-weight: 700; color: var(--pdpa-navy); }
.pdpa-purpose-desc { margin-top: 2px; font-size: 13px; color: var(--pdpa-muted); }
.pdpa-always {
    flex: 0 0 auto; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: #e3f4ea; color: #1b7f3b;
}
.pdpa-policy-link { padding: 4px 2px 8px; font-size: 13px; }

.pdpa-error { margin: 0 22px 12px; padding: 10px 14px; border-radius: 10px; background: #fdecea; color: #b3261e; font-size: 13px; }

.pdpa-modal-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 14px 22px 18px; border-top: 1px solid var(--pdpa-line); background: #fcfcfe;
}
.pdpa-foot-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pdpa-foot-pair .pdpa-btn { min-width: 140px; }

/* ---------------- สวิตช์ */
.pdpa-switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: 0 0 48px; margin: 0; }
.pdpa-switch input { position: absolute; top: 0; left: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.pdpa-slider { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: #c9ccd6; border-radius: 28px; transition: background .2s; }
.pdpa-slider:before {
    content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.pdpa-switch input:checked + .pdpa-slider { background: var(--pdpa-navy); }
.pdpa-switch input:checked + .pdpa-slider:before { transform: translateX(20px); }

/* ---------------- แจ้งผลหลังบันทึก */
.pdpa-toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 10520; transform: translateX(-50%);
    padding: 10px 18px; border-radius: 999px;
    background: var(--pdpa-navy); color: #fff; font-size: 13.5px; font-weight: 600;
    box-shadow: 0 10px 28px rgba(11, 11, 59, .3);
    animation: pdpa-fade .2s ease-out;
}

/* ---------------- ปุ่มเปิดตั้งค่าภายหลัง (มุมขวาล่าง วางเหนือปุ่ม #back-to-top ของ style.css ที่ right 40px / bottom 20px) */
.pdpa-reopen {
    position: fixed; right: 36px; bottom: 68px; z-index: 10400;
    display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 0;
    height: 44px; padding: 0 11px; border-radius: 999px; cursor: pointer;
    border: 0; background: var(--pdpa-navy); color: var(--pdpa-yellow);
    box-shadow: 0 6px 18px rgba(11, 11, 59, .28);
    font: inherit; font-size: 13px; font-weight: 600;
    transition: gap .2s, padding .2s;
    animation: pdpa-fade .3s ease-out;
}
.pdpa-reopen-label { max-width: 0; overflow: hidden; white-space: nowrap; color: #fff; transition: max-width .25s; }
.pdpa-reopen:hover, .pdpa-reopen:focus-visible { gap: 8px; padding: 0 11px 0 16px; }
.pdpa-reopen:hover .pdpa-reopen-label, .pdpa-reopen:focus-visible .pdpa-reopen-label { max-width: 120px; }

/* ---------------- ปุ่มตั้งค่าคุกกี้ในแถบ copyright ด้านล่าง (JS ย้ายมาไว้ใน #footer .copyright .row) */
.pdpa-reopen[hidden] { display: none !important; }
.pdpa-footer-slot { display: flex; justify-content: flex-end; align-items: center; }
.pdpa-reopen.pdpa-reopen-inline {
    position: static; z-index: auto; height: auto; gap: 8px; padding: 4px 0;
    flex-direction: row; background: transparent; box-shadow: none; animation: none;
    color: #fdb813; opacity: 1; font-family: inherit; font-size: 14px; font-weight: 400;
    transition: color .15s, opacity .15s;
}
/* แสดงไอคอนอย่างเดียว ข้อความ "ตั้งค่าคุกกี้" ยังอยู่ใน title / aria-label (ชี้แล้วขึ้น tooltip) */
.pdpa-reopen.pdpa-reopen-inline .pdpa-reopen-label { display: none; }
.pdpa-reopen.pdpa-reopen-inline:hover, .pdpa-reopen.pdpa-reopen-inline:focus-visible { padding: 4px 0; }
.pdpa-reopen.pdpa-reopen-inline:hover, .pdpa-reopen.pdpa-reopen-inline:focus-visible { color: #ffd257; }
.pdpa-reopen.pdpa-reopen-inline:focus-visible { outline: 2px solid #fdb813; outline-offset: 3px; }
.pdpa-reopen.pdpa-reopen-inline svg { width: 22px; height: 22px; }
@media (max-width: 767px) {
    .pdpa-footer-slot { justify-content: center; margin-top: 6px; }
}

/* ---------------- มือถือ */
@media (max-width: 576px) {
    .pdpa-banner {
        left: 0; right: 0; bottom: 0; width: auto; max-width: none;
        border-radius: 18px 18px 0 0; padding: 18px 16px 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .pdpa-modal { align-items: flex-end; padding: 0; }
    .pdpa-modal-box { max-width: none; max-height: 92vh; border-radius: 18px 18px 0 0; }
    .pdpa-modal-head, .pdpa-modal-body, .pdpa-modal-foot { padding-left: 16px; padding-right: 16px; }
    .pdpa-modal-foot { flex-direction: column-reverse; align-items: stretch; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
    .pdpa-foot-pair .pdpa-btn { min-width: 0; }
    .pdpa-purpose { padding: 12px; }
}
@media (max-width: 767px) {
    .pdpa-reopen { right: 10px; bottom: 60px; }   /* #back-to-top มือถือ right 15px */
}

@media (prefers-reduced-motion: reduce) {
    #pdpa-consent-root *, #pdpa-consent-root *:before { animation: none !important; transition: none !important; }
}

@media print { #pdpa-consent-root { display: none !important; } }
