/* KESUMA — glassmorphism biru lembut, gaya iOS, responsif */
:root {
  --bg1: #eef3ff; --bg2: #e9e4ff;
  --ink: #1d2a44; --ink-soft: #5b6782; --line: rgba(120, 140, 190, .22);
  --blue: #3a6df0; --blue2: #6b8cff; --lilac: #9a8cff;
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .82);
  --shadow: 0 10px 40px rgba(60, 90, 170, .14);
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: linear-gradient(135deg, var(--bg1), var(--bg2));
  display: flex; justify-content: center; align-items: stretch; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.bg-orb { position: fixed; border-radius: 50%; filter: blur(60px); opacity: .55; z-index: 0; pointer-events: none; }
.orb1 { width: 380px; height: 380px; background: #b9cdff; top: -120px; left: -80px; }
.orb2 { width: 320px; height: 320px; background: #d6ccff; bottom: -100px; right: -60px; }
.orb3 { width: 220px; height: 220px; background: #c7f0ff; top: 40%; left: 60%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.chat {
  position: relative; z-index: 1; width: 100%; max-width: 760px; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--glass); backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border-left: 1px solid rgba(255,255,255,.6); border-right: 1px solid rgba(255,255,255,.6);
  box-shadow: var(--shadow);
}
@media (min-width: 800px) {
  body { align-items: center; padding: 24px; }
  .chat { height: calc(100dvh - 48px); border-radius: 28px; border: 1px solid rgba(255,255,255,.7); overflow: hidden; }
}

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--glass-strong); border-bottom: 1px solid var(--line);
}
.avatar {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--lilac)); box-shadow: 0 6px 16px rgba(58, 109, 240, .35);
object-fit: cover;
}
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 17px; letter-spacing: .3px; }
.who p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #34c77b; margin-right: 6px; vertical-align: 1px; }
.icon-btn {
  border: 0; background: rgba(255,255,255,.7); color: var(--ink-soft); width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--blue); }

.messages { flex: 1; overflow-y: auto; padding: 18px 14px 8px; scroll-behavior: smooth; }
.row { display: flex; margin: 10px 0; animation: pop .22s ease-out; }
.row.user { justify-content: flex-end; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bubble {
  max-width: 86%; padding: 11px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bot .bubble { background: var(--glass-strong); border: 1px solid rgba(255,255,255,.9); border-top-left-radius: 6px; box-shadow: 0 2px 10px rgba(60,90,170,.08); }
.user .bubble { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue2)); border-top-right-radius: 6px; box-shadow: 0 6px 14px rgba(58,109,240,.25); }
.bubble a { color: var(--blue); }
.user .bubble a { color: #fff; }
.note { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }

.extras { margin: 2px 0 0 4px; max-width: 92%; }
.label { font-size: 12px; color: var(--ink-soft); margin: 10px 2px 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid rgba(58,109,240,.28); background: rgba(255,255,255,.75); color: #2a55c9;
  padding: 8px 13px; border-radius: 999px; font-size: 13.5px; cursor: pointer; text-align: left; line-height: 1.3;
  transition: background .15s, transform .1s;
}
.chip:hover { background: #fff; }
.chip:active { transform: scale(.97); }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.topics .chip { border-radius: 14px; padding: 11px 12px; font-weight: 600; }

.attach {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-top: 8px;
}
.attach:hover { border-color: var(--blue2); }
.attach .ic { width: 34px; height: 34px; border-radius: 10px; background: #e7eeff; color: var(--blue); display: grid; place-items: center; flex: none; }
.attach .t { font-size: 14px; font-weight: 600; }
.attach .s { font-size: 12px; color: var(--ink-soft); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.fb { border: 1px solid var(--line); background: rgba(255,255,255,.6); border-radius: 10px; padding: 4px 9px; font-size: 14px; cursor: pointer; }
.fb[aria-pressed="true"] { background: #e7eeff; border-color: var(--blue2); }
.fb:disabled { cursor: default; opacity: .8; }
.contact { font-size: 13px; text-decoration: none; color: #2a55c9; border: 1px solid rgba(58,109,240,.28); border-radius: 10px; padding: 5px 10px; background: rgba(255,255,255,.75); }

.typing .bubble { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa8c8; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; margin: 0 10px;
  background: var(--glass-strong); border: 1px solid rgba(255,255,255,.9); border-radius: 22px; box-shadow: 0 4px 18px rgba(60,90,170,.10);
}
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; font: inherit; font-size: 16px; color: var(--ink);
  max-height: 120px; padding: 6px 4px; line-height: 1.4;
}
.send {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; flex: none; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--lilac)); display: grid; place-items: center;
}
.send:disabled { opacity: .5; cursor: default; }
.disclaimer { margin: 6px 16px; padding-bottom: env(safe-area-inset-bottom); font-size: 11px; color: var(--ink-soft); text-align: center; }
.noscript { position: fixed; bottom: 0; left: 0; right: 0; text-align: center; background: #fff; padding: 12px; z-index: 2; }
@media (prefers-reduced-motion: reduce) { .row { animation: none; } .messages { scroll-behavior: auto; } }


/* Mod popup — KESUMA dipaparkan dalam tetingkap chat di portal mpsegamat.gov.my (index.php?embed=1) */
body.embed { padding: 0 !important; align-items: stretch !important; }
body.embed .bg-orb { display: none; }
body.embed .chat { max-width: none; height: 100dvh !important; border-radius: 0 !important; border: 0 !important; box-shadow: none; }

/* Avatar gambar KESUMA */
.avatar { overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
