/* ============ FKDM Chat: widget pojok kanan bawah + halaman FKDM AI ============ */
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ---- Pesan ---- */
.chat-messages{flex:1;min-height:0;overflow-y:auto;padding:18px 16px;display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth;background:#f5f8fd}
.chat-msg{display:flex;gap:8px;align-items:flex-end;max-width:100%}
.chat-msg.user{justify-content:flex-end}
.chat-avatar{width:28px;height:28px;border-radius:50%;background:linear-gradient(135deg,#2b82e6,#0a4a9a);color:#fff;display:grid;place-items:center;flex:none}
.chat-bubble{position:relative;max-width:min(82%,520px);padding:10px 13px;border-radius:16px;font-size:13px;line-height:1.6;word-wrap:break-word;overflow-wrap:anywhere}
.chat-msg.bot .chat-bubble{background:#fff;color:#22334a;border:1px solid #e3eaf4;border-bottom-left-radius:5px;box-shadow:0 1px 2px rgba(15,37,64,.04);padding-right:32px}
.chat-msg.user .chat-bubble{background:var(--primary);color:#fff;border-bottom-right-radius:5px}
.chat-msg.error .chat-bubble{background:#fff4f3;border-color:#f3c9c6;color:#8f2a24}
.chat-bubble p{margin:0}.chat-bubble p+p,.chat-bubble ul+p,.chat-bubble ol+p,.chat-bubble p+ul,.chat-bubble p+ol{margin-top:8px}
.chat-bubble ul,.chat-bubble ol{margin:6px 0;padding-left:20px}.chat-bubble li{margin:2px 0}
.chat-bubble a{color:var(--primary);font-weight:700;text-decoration:underline;text-underline-offset:2px}
.chat-msg.user .chat-bubble a{color:#fff}
.chat-bubble code{background:#eef3fa;padding:1px 5px;border-radius:5px;font-size:12px}
.chat-copy{position:absolute;right:6px;top:6px;width:22px;height:22px;border:0;border-radius:6px;background:transparent;color:#9aa8bd;display:grid;place-items:center;opacity:0;transition:opacity .15s}
.chat-bubble:hover .chat-copy,.chat-copy:focus-visible{opacity:1}.chat-copy:hover{background:#eef3fa;color:var(--primary)}.chat-copy.done{opacity:1;color:#239b75}
.chat-retry{display:inline-flex;align-items:center;gap:5px;margin-top:8px;border:1px solid #e6b5b1;background:#fff;color:#8f2a24;border-radius:8px;padding:5px 9px;font-size:11px;font-weight:700}
.chat-bubble.typing{display:flex;gap:4px;align-items:center;padding:14px 14px}
.chat-bubble.typing i{width:6px;height:6px;border-radius:50%;background:#9db4d3;animation:chatDot 1.1s infinite ease-in-out}
.chat-bubble.typing i:nth-child(2){animation-delay:.15s}.chat-bubble.typing i:nth-child(3){animation-delay:.3s}
@keyframes chatDot{0%,60%,100%{transform:translateY(0);opacity:.5}30%{transform:translateY(-4px);opacity:1}}

/* ---- Saran cepat + input ---- */
.chat-suggest{display:flex;flex-wrap:wrap;gap:7px;padding:0 16px 12px;background:#f5f8fd}
.chat-suggest button{border:1px solid #cfdcf0;background:#fff;color:var(--primary-dark);border-radius:20px;padding:7px 12px;font-size:12px;font-weight:600;text-align:left;transition:.15s}
.chat-suggest button:hover{background:var(--primary-3);border-color:#9cc0ef}
.chat-form{display:flex;align-items:flex-end;gap:8px;padding:12px 14px;background:#fff;border-top:1px solid #e6ecf5;position:relative}
.chat-input{flex:1;border:1px solid #d6e0ef;border-radius:14px;padding:10px 13px;resize:none;max-height:130px;line-height:1.5;font-size:13px;outline:none;background:#fff;color:var(--ink);transition:.15s}
.chat-input:focus{border-color:var(--primary);box-shadow:var(--focus)}
.chat-send{width:42px;height:42px;border-radius:13px;border:0;background:var(--primary);color:#fff;display:grid;place-items:center;flex:none;transition:.15s}
.chat-send:hover:not(:disabled){background:var(--primary-dark)}.chat-send:disabled{opacity:.5;cursor:progress}
.chat-count{position:absolute;right:68px;bottom:16px;font-size:10px;color:var(--muted);pointer-events:none}.chat-count.over{color:#c83c3c;font-weight:700}
.chat-dot{width:7px;height:7px;border-radius:50%;background:#f0a12e;display:inline-block;margin-right:6px}
[data-mode=ai] .chat-dot{background:#2ecc8f}

/* ---- Widget ---- */
.cw{position:fixed;right:22px;bottom:22px;z-index:140;font-family:inherit}
.cw-fab{display:flex;align-items:center;gap:10px;height:56px;padding:0 20px 0 16px;border:0;border-radius:30px;background:linear-gradient(135deg,#2b82e6,#0a4a9a);color:#fff;font-weight:700;font-size:13px;box-shadow:0 10px 28px rgba(10,74,154,.4);transition:transform .2s,box-shadow .2s}
.cw-fab:hover{transform:translateY(-2px);box-shadow:0 14px 32px rgba(10,74,154,.48)}
.cw-fab-ico{display:grid;place-items:center}
.cw.open .cw-fab{display:none}
.cw.hint .cw-fab{animation:cwPulse 1.6s ease-out 2}
@keyframes cwPulse{0%{box-shadow:0 10px 28px rgba(10,74,154,.4),0 0 0 0 rgba(43,130,230,.55)}100%{box-shadow:0 10px 28px rgba(10,74,154,.4),0 0 0 18px rgba(43,130,230,0)}}
.cw-panel{position:absolute;right:0;bottom:0;width:min(392px,calc(100vw - 28px));height:min(620px,calc(100vh - 44px));display:flex;flex-direction:column;background:#fff;border-radius:20px;box-shadow:0 24px 70px rgba(10,37,80,.32);overflow:hidden;opacity:0;transform:translateY(14px) scale(.98);transform-origin:bottom right;transition:opacity .2s,transform .2s;border:1px solid #d9e4f3}
.cw.open .cw-panel{opacity:1;transform:none}
.cw-head{display:flex;align-items:center;gap:11px;padding:14px 14px;background:linear-gradient(135deg,#0f64c8,#0a4a9a);color:#fff}
.cw-bot{width:38px;height:38px;border-radius:12px;background:rgba(255,255,255,.18);display:grid;place-items:center;flex:none}
.cw-title{flex:1;min-width:0}.cw-title strong{display:block;font-size:14px;line-height:1.25}
.cw-status{font-size:11px;color:rgba(255,255,255,.85);display:flex;align-items:center}
.cw-actions{display:flex;gap:2px}
.cw-icon{width:32px;height:32px;border-radius:9px;border:0;background:transparent;color:#fff;display:grid;place-items:center}
.cw-icon:hover{background:rgba(255,255,255,.18)}
.cw-body{flex:1;min-height:0;display:flex;flex-direction:column}
.cw-note{margin:0;padding:7px 14px 9px;font-size:10px;color:var(--muted);text-align:center;background:#fff;border-top:1px solid #eef2f8}
.cw .chat-bubble{max-width:86%}
@media(max-width:850px){.cw.in-app{bottom:calc(82px + env(safe-area-inset-bottom))}}
@media(max-width:600px){
 .cw{right:14px;bottom:14px}.cw.in-app{bottom:calc(78px + env(safe-area-inset-bottom))}
 .cw-fab{height:54px;padding:0 17px}.cw-fab-label{display:none}
 .cw.open{inset:0}
 .cw-panel{position:fixed;inset:0;width:100%;height:100%;border-radius:0;border:0}
}

/* ---- Halaman FKDM AI ---- */
.ai-shell{display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:18px;align-items:start}
.ai-main{display:flex;flex-direction:column;height:calc(100vh - 76px - 27px - 112px);min-height:520px;padding:0;overflow:hidden}
.ai-main-head{display:flex;align-items:center;gap:12px;padding:15px 18px;border-bottom:1px solid #e6ecf5;background:#fff}
.ai-main-head .cw-bot{background:linear-gradient(135deg,#2b82e6,#0a4a9a);color:#fff}
.ai-main-head strong{display:block;color:var(--navy);font-size:15px}
.ai-main-head .chat-status{font-size:11px;color:var(--muted);display:flex;align-items:center}
.ai-main .ai-body{flex:1;min-height:0;display:flex;flex-direction:column}
.ai-main .chat-messages{padding:22px 22px}
.ai-main .chat-bubble{font-size:14px;max-width:min(78%,640px)}
.ai-main .chat-suggest{padding:0 22px 14px}
.ai-side{display:grid;gap:16px}
.ai-topic{display:flex;align-items:center;gap:10px;width:100%;text-align:left;border:1px solid #e3eaf4;background:#fff;border-radius:12px;padding:10px 12px;font-size:12px;font-weight:600;color:#33465f;margin-top:8px;transition:.15s}
.ai-topic:hover{background:var(--primary-3);border-color:#9cc0ef;color:var(--primary-dark)}
.ai-topic .icon{color:var(--primary);flex:none}
.ai-tips{margin:10px 0 0;padding-left:18px;font-size:12px;color:#51627a;line-height:1.7}
@media(max-width:1100px){.ai-shell{grid-template-columns:1fr}.ai-side{grid-template-columns:repeat(2,minmax(0,1fr))}.ai-main{height:calc(100vh - 300px)}}
@media(max-width:850px){.ai-main{height:calc(100vh - 330px);min-height:460px}}
@media(max-width:600px){.ai-side{grid-template-columns:1fr}.ai-main .chat-messages{padding:16px 12px}.ai-main .chat-bubble{max-width:88%}}

/* ---- Tooltip grafik ---- */
.chart-tip{position:absolute;left:0;top:0;z-index:5;pointer-events:none;opacity:0;transition:opacity .12s;background:#0f2540;color:#fff;border-radius:10px;padding:8px 11px;font-size:11px;line-height:1.5;box-shadow:0 8px 22px rgba(10,24,48,.28);white-space:nowrap}
.chart-tip b{display:block;font-size:11px;margin-bottom:2px}
.chart-tip span{display:flex;align-items:center;gap:6px;color:#dbe7f7}
.chart-tip i{width:8px;height:8px;border-radius:50%;display:inline-block}

/* ---- Logo FKDM AI (ikon semua fitur AI dan CS virtual) ---- */
.ai-logo{object-fit:contain;display:inline-block}
.chat-avatar,.cw-bot{background:#fff!important;box-shadow:0 0 0 1px rgba(15,100,200,.14)}
.cw-bot{width:40px;height:40px}.cw-bot .ai-logo{width:26px;height:26px}
.chat-avatar .ai-logo{width:18px;height:18px}
.cw-fab{padding-left:10px}.cw-fab-ico{width:40px;height:40px;border-radius:50%;background:#fff}.cw-fab-ico .ai-logo{width:28px;height:28px}
.ai-main-head .cw-bot{background:#fff!important}
