/* Purnank live chat widget (uses the design tokens from corporate.css) */
.pkc {
    --pkc-brand: var(--brand, #1a3fd6);
    --pkc-brand-600: var(--brand-600, #1535b8);
    --pkc-navy: var(--navy-900, #0a1b3d);
    --pkc-ink: var(--ink, #0d1728);
    --pkc-ink-2: var(--ink-2, #334155);
    --pkc-muted: var(--muted, #5b6478);
    --pkc-line: var(--line, #e2e7f0);
    --pkc-surface: var(--surface, #f5f7fb);
    --pkc-online: #12a150;
    --pkc-away: #e0a100;
    position: fixed; right: 20px; bottom: 20px; z-index: 110; /* above the sticky site header (100) */
    font-family: var(--font-body, system-ui, sans-serif); color: var(--pkc-ink-2);
}
.pkc [hidden] { display: none !important; }
.pkc svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-open .pkc, .modal-open .pkc { display: none; }

/* ---------- Launcher ---------- */
.pkc-launcher {
    position: relative; display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 18px;
    border: 0; border-radius: 999px; background: var(--pkc-brand); color: #fff; cursor: pointer;
    font: 600 .98rem/1 var(--font-body, system-ui, sans-serif);
    box-shadow: 0 14px 32px rgba(26, 63, 214, .32), 0 2px 6px rgba(13, 23, 40, .12);
    transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.pkc-launcher:hover { background: var(--pkc-brand-600); transform: translateY(-2px); }
.pkc-launcher:focus-visible { outline: 3px solid #fff; box-shadow: 0 0 0 6px var(--pkc-brand); }
.pkc-launcher svg { width: 24px; height: 24px; }
.pkc-launcher-close { display: none; }
.pkc.is-open .pkc-launcher { width: 56px; padding: 0; justify-content: center; }
.pkc.is-open .pkc-launcher-label, .pkc.is-open .pkc-launcher-icon { display: none; }
.pkc.is-open .pkc-launcher-close { display: block; }
.pkc-badge {
    position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
    background: var(--gov, #c3262e); color: #fff; font-size: .75rem; font-weight: 700; line-height: 22px; text-align: center;
    box-shadow: 0 0 0 2px #fff;
}
.pkc-online { position: absolute; left: 40px; top: 12px; width: 11px; height: 11px; border-radius: 50%; background: var(--pkc-online); box-shadow: 0 0 0 2px var(--pkc-brand); }
.pkc.is-open .pkc-online { display: none; }
.pkc-launcher.is-nudge { animation: pkc-nudge 1s ease 2; }
@keyframes pkc-nudge { 0%, 100% { transform: none; } 30% { transform: translateY(-6px); } 60% { transform: translateY(0); } 80% { transform: translateY(-2px); } }

/* ---------- Panel ---------- */
.pkc-panel {
    position: absolute; right: 0; bottom: 72px; width: 380px; height: min(620px, calc(100vh - 100px));
    display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border: 1px solid var(--pkc-line); border-radius: 20px;
    box-shadow: 0 30px 70px rgba(10, 27, 61, .22), 0 4px 14px rgba(10, 27, 61, .08);
    transform-origin: bottom right; animation: pkc-in .22s ease;
}
@keyframes pkc-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.pkc-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; background: var(--pkc-navy); color: #fff; }
.pkc-avatar {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    background: rgba(255, 255, 255, .14); color: #fff; font: 700 1rem/1 var(--font-head, system-ui, sans-serif);
}
.pkc-head-text { flex: 1; min-width: 0; }
.pkc-head-text strong { display: block; font: 700 1rem/1.25 var(--font-head, system-ui, sans-serif); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pkc-head-text small { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: .8rem; color: rgba(255, 255, 255, .78); }
.pkc-head-btn { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; font: 600 .8rem/1 var(--font-body, system-ui, sans-serif); }
.pkc-head-btn:hover { background: rgba(255, 255, 255, .12); }
.pkc-head-btn svg { width: 18px; height: 18px; }
.pkc-end { border: 1px solid rgba(255, 255, 255, .28); }

.pkc-presence { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b8; flex-shrink: 0; }
.pkc-presence.is-online { background: var(--pkc-online); box-shadow: 0 0 0 3px rgba(18, 161, 80, .2); }
.pkc-presence.is-away { background: var(--pkc-away); }

/* ---------- Pre-chat form ---------- */
.pkc-start { flex: 1; overflow-y: auto; padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.pkc-hello { margin: 0; padding: 12px 14px; border-radius: 14px 14px 14px 4px; background: var(--pkc-surface); color: var(--pkc-ink); font-size: .92rem; line-height: 1.5; }
.pkc-depts { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pkc-depts legend { padding: 0; margin-bottom: 6px; font-size: .8rem; font-weight: 600; color: var(--pkc-ink); }
.pkc-depts label { position: relative; cursor: pointer; }
.pkc-depts input { position: absolute; opacity: 0; pointer-events: none; }
.pkc-depts label > span { display: block; height: 100%; padding: 10px 12px; border: 1.5px solid var(--pkc-line); border-radius: 12px; transition: border-color .15s, background .15s; }
.pkc-depts strong { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: .9rem; color: var(--pkc-ink); }
.pkc-depts small { display: block; margin-top: 3px; font-size: .74rem; line-height: 1.35; color: var(--pkc-muted); }
.pkc-depts input:checked + span { border-color: var(--pkc-brand); background: var(--brand-50, #eef2ff); }
.pkc-depts input:focus-visible + span { outline: 3px solid var(--pkc-brand); outline-offset: 2px; }

.pkc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pkc-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pkc-field > span { font-size: .8rem; font-weight: 600; color: var(--pkc-ink); }
.pkc-field em { font-style: normal; font-weight: 400; color: var(--pkc-muted); }
.pkc-field input, .pkc-field select, .pkc-field textarea, .pkc-compose textarea {
    width: 100%; padding: 9px 12px; border: 1.5px solid var(--pkc-line); border-radius: 10px; background: #fff;
    color: var(--pkc-ink); font: 400 .92rem/1.4 var(--font-body, system-ui, sans-serif);
}
.pkc-field textarea { resize: vertical; min-height: 70px; }
.pkc-field input:focus, .pkc-field select:focus, .pkc-field textarea:focus, .pkc-compose textarea:focus { outline: none; border-color: var(--pkc-brand); box-shadow: 0 0 0 3px rgba(26, 63, 214, .14); }
.pkc-field [aria-invalid="true"] { border-color: var(--gov, #c3262e); }
.pkc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.pkc-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
    border: 0; border-radius: 12px; background: var(--pkc-brand); color: #fff; cursor: pointer; font: 600 .95rem/1 var(--font-body, system-ui, sans-serif);
    transition: background .18s;
}
.pkc-btn:hover { background: var(--pkc-brand-600); }
.pkc-btn:disabled { opacity: .65; cursor: progress; }
.pkc-btn svg { width: 17px; height: 17px; }
.pkc-btn-ghost { background: #fff; color: var(--pkc-brand); border: 1.5px solid var(--pkc-line); }
.pkc-btn-ghost:hover { background: var(--brand-50, #eef2ff); border-color: var(--pkc-brand); }
.pkc-note { margin: 0; font-size: .75rem; color: var(--pkc-muted); text-align: center; }
.pkc-note a { color: inherit; text-decoration: underline; }
.pkc-error { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--gov-soft, #fdeced); color: var(--gov, #c3262e); font-size: .85rem; }
.pkc-error-compose { margin: 0 12px 10px; }

/* ---------- Conversation ---------- */
.pkc-convo { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--pkc-surface); }
.pkc-log { flex: 1; overflow-y: auto; margin: 0; padding: 16px 14px 8px; list-style: none; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.pkc-msg { display: flex; flex-direction: column; max-width: 82%; }
.pkc-msg-body {
    padding: 9px 13px; border-radius: 16px; font-size: .92rem; line-height: 1.45;
    white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.pkc-msg-body a { color: inherit; text-decoration: underline; }
.pkc-msg-meta { margin: 3px 6px 6px; font-size: .7rem; color: var(--pkc-muted); }
.pkc-msg-name { margin: 8px 6px 3px; font-size: .72rem; font-weight: 600; color: var(--pkc-muted); }
.pkc-msg.is-visitor { align-self: flex-end; align-items: flex-end; }
.pkc-msg.is-visitor .pkc-msg-body { background: var(--pkc-brand); color: #fff; border-bottom-right-radius: 5px; }
.pkc-msg.is-agent, .pkc-msg.is-bot { align-self: flex-start; }
.pkc-msg.is-agent .pkc-msg-body, .pkc-msg.is-bot .pkc-msg-body { background: #fff; color: var(--pkc-ink); border: 1px solid var(--pkc-line); border-bottom-left-radius: 5px; }
.pkc-msg.is-system { align-self: center; max-width: 92%; margin: 8px 0; }
.pkc-msg.is-system .pkc-msg-body { padding: 4px 12px; border-radius: 999px; background: rgba(13, 23, 40, .06); color: var(--pkc-muted); font-size: .76rem; text-align: center; }
.pkc-msg.is-pending .pkc-msg-body { opacity: .6; }
.pkc-day { align-self: center; margin: 10px 0 4px; font-size: .72rem; font-weight: 600; color: var(--pkc-muted); }

.pkc-typing { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 18px 8px; font-size: .78rem; color: var(--pkc-muted); }
.pkc-dots { display: inline-flex; gap: 3px; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--pkc-line); }
.pkc-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--pkc-muted); animation: pkc-blink 1.2s infinite ease-in-out; }
.pkc-dots i:nth-child(2) { animation-delay: .15s; }
.pkc-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pkc-blink { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.pkc-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; background: #fff; border-top: 1px solid var(--pkc-line); }
.pkc-compose textarea { flex: 1; resize: none; max-height: 120px; padding: 10px 12px; border-radius: 12px; }
.pkc-compose button { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border: 0; border-radius: 12px; background: var(--pkc-brand); color: #fff; cursor: pointer; }
.pkc-compose button:hover { background: var(--pkc-brand-600); }
.pkc-compose button svg { width: 19px; height: 19px; }

.pkc-ended { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 16px 16px; background: #fff; border-top: 1px solid var(--pkc-line); text-align: center; }
.pkc-ended p { margin: 0; font-size: .88rem; color: var(--pkc-ink-2); }

/* ---------- Small screens: full-height sheet ---------- */
@media (max-width: 560px) {
    .pkc { right: 14px; bottom: 14px; }
    .pkc-launcher { height: 52px; padding: 0 18px 0 15px; }
    .pkc.is-open .pkc-launcher { display: none; }
    .pkc-panel { position: fixed; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; animation: none; }
    .pkc-head { padding-top: max(14px, env(safe-area-inset-top)); }
    .pkc-compose, .pkc-ended { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .pkc-grid { grid-template-columns: 1fr; }
    .pkc-field input, .pkc-field select, .pkc-field textarea, .pkc-compose textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .pkc-panel, .pkc-launcher.is-nudge, .pkc-dots i { animation: none; }
    .pkc-launcher { transition: none; }
}
