/* BondaDigital: widget chat. Gaya zinc gelap + kecerunan indigo→ungu (tanpa library) */

.bdc {
  --bdc-indigo: #4F46E5;
  --bdc-indigo-2: #6366F1;
  --bdc-violet: #7C3AED;
  --bdc-zinc-800: rgba(39, 39, 42, .9);
  --bdc-line: rgba(255, 255, 255, .1);
  --bdc-line-soft: rgba(255, 255, 255, .06);
  --bdc-text: #F4F4F5;
  --bdc-dim: rgba(255, 255, 255, .6);
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  font-family: var(--sans);
}
.bdc-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- butang pelancar ---------- */
.bdc-launcher {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 56px; min-width: 56px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--bdc-indigo), var(--bdc-violet));
  color: #fff;
  font-family: var(--mono); font-size: .9375rem; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(99, 102, 241, .55), 0 0 0 1px rgba(255, 255, 255, .08) inset;
  transition: transform .2s cubic-bezier(.22, 1, .36, 1), box-shadow .2s ease;
}
.bdc-launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 36px -6px rgba(124, 58, 237, .65); }
.bdc-launcher:active { transform: scale(.96); }
.bdc.is-open .bdc-launcher .bdc-launch-label { display: none; }
.bdc-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--pink); color: #0A0B10;
  font-size: .75rem; font-weight: 700; line-height: 22px; text-align: center;
  box-shadow: 0 0 0 2px #0A0B10;
}

/* ---------- panel ---------- */
.bdc-panel {
  position: absolute; right: 0; bottom: 72px;
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 110px));
  display: flex; flex-direction: column;
  background: linear-gradient(to bottom, #18181B, #09090B);
  border: 1px solid var(--bdc-line); border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, .75), 0 0 0 1px rgba(99, 102, 241, .06);
  transform-origin: bottom right;
  animation: bdc-pop .28s cubic-bezier(.22, 1, .36, 1);
}
.bdc-panel[hidden] { display: none; }
@keyframes bdc-pop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 519px) {
  .bdc.is-open { inset: 0; right: 0; bottom: 0; }
  .bdc.is-open .bdc-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; animation: none; }
  .bdc.is-open .bdc-launcher { display: none; }
}

/* header */
.bdc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bdc-line-soft);
  background: rgba(255, 255, 255, .02);
}
.bdc-head-text { flex: 1; min-width: 0; }
.bdc-brand { margin: 0; font-family: var(--mono); font-weight: 600; font-size: .9375rem; color: #fff; }
.bdc-status { margin: 1px 0 0; display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--bdc-dim); }
.bdc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bdc-dim); flex: none; }
.bdc-dot.is-on { background: #4ADE80; box-shadow: 0 0 8px #4ADE80; }
.bdc-dot.is-off { background: var(--orange); }
.bdc-icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  background: rgba(255, 255, 255, .05); color: var(--bdc-dim);
  border: 0; border-radius: 10px; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.bdc-icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* avatar berkecerunan */
.bdc-av {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bdc-indigo-2), var(--bdc-violet));
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, .6);
}
.bdc-av .bdc-ico { width: 16px; height: 16px; stroke-width: 2; }
.bdc-av-admin { background: linear-gradient(135deg, #EC4899, var(--bdc-violet)); box-shadow: 0 4px 12px -4px rgba(236, 72, 153, .55); }
.bdc-av-head { width: 36px; height: 36px; }

/* ---------- log mesej ---------- */
.bdc-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .1) transparent;
}
.bdc-msg { display: flex; flex-direction: column; max-width: 100%; }
.bdc-line { display: flex; align-items: flex-end; gap: 8px; }
.bdc-col { display: flex; flex-direction: column; min-width: 0; }
.bdc-who { font-family: var(--mono); font-size: .6875rem; color: #F9A8D4; margin: 0 0 3px 4px; }
.bdc-bubble {
  padding: 10px 15px; border-radius: 18px;
  font-size: .875rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  transition: transform .2s ease;
}
.bdc-bubble:hover { transform: translateY(-1px) scale(1.01); }
.bdc-time { font-size: .6875rem; color: rgba(255, 255, 255, .55); margin: 4px 6px 0; }

/* bot & admin: kiri, kelabu kaca */
.bdc-bot, .bdc-admin { align-self: flex-start; max-width: 88%; animation: bdc-in-left .35s cubic-bezier(.22, 1, .36, 1); }
.bdc-bot .bdc-bubble, .bdc-admin .bdc-bubble {
  background: var(--bdc-zinc-800); color: var(--bdc-text);
  border: 1px solid var(--bdc-line); border-bottom-left-radius: 6px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, .3);
}
.bdc-admin .bdc-bubble { border-color: rgba(236, 72, 153, .25); }

/* pelanggan: kanan, kecerunan indigo→ungu */
.bdc-me { align-self: flex-end; align-items: flex-end; max-width: 80%; animation: bdc-in-right .35s cubic-bezier(.22, 1, .36, 1); }
.bdc-me .bdc-bubble {
  background: linear-gradient(90deg, var(--bdc-indigo), var(--bdc-violet)); color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 24px -4px rgba(99, 102, 241, .4);
}

/* sistem & tarikh */
.bdc-system { align-self: center; max-width: 92%; animation: bdc-fade .3s ease; }
.bdc-system .bdc-bubble {
  padding: 6px 12px; border-radius: 12px;
  font-size: .75rem; color: rgba(255, 255, 255, .65); text-align: center;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--bdc-line-soft);
}
.bdc-system .bdc-bubble:hover { transform: none; }
.bdc-date {
  align-self: center; margin: 2px 0;
  font-size: .6875rem; color: rgba(255, 255, 255, .6);
  padding: 3px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--bdc-line-soft);
}

@keyframes bdc-in-left  { from { opacity: 0; transform: translate(-16px, 10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes bdc-in-right { from { opacity: 0; transform: translate(16px, 10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes bdc-fade { from { opacity: 0; } to { opacity: 1; } }

/* sedang menaip */
.bdc-typing {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 13px 16px; border-radius: 18px; border-bottom-left-radius: 6px;
  background: var(--bdc-zinc-800); border: 1px solid var(--bdc-line);
}
.bdc-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .6);
  animation: bdc-dot .8s ease-in-out infinite;
}
.bdc-typing span:nth-child(2) { animation-delay: .15s; }
.bdc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bdc-dot { 0%, 100% { opacity: .4; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

/* ---------- kaki: menu / borang / penulis ---------- */
.bdc-foot { border-top: 1px solid var(--bdc-line-soft); padding: 12px; max-height: 58%; overflow-y: auto; }
.bdc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bdc-chip {
  display: inline-flex; align-items: center; min-height: 38px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--bdc-line); background: rgba(255, 255, 255, .04); color: var(--bdc-text);
  font-size: .8125rem; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.bdc-chip:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .2); transform: translateY(-1px); }
.bdc-chip-main {
  border: 0; color: #fff;
  background: linear-gradient(90deg, var(--bdc-indigo), var(--bdc-violet));
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .6);
}
.bdc-chip-main:hover { background: linear-gradient(90deg, var(--bdc-indigo-2), #8B5CF6); }
.bdc-chip-wa { border-color: rgba(74, 222, 128, .35); color: #86EFAC; }
.bdc-chip-wa:hover { border-color: #4ADE80; background: rgba(74, 222, 128, .08); }

.bdc-form { display: grid; gap: 10px; }
.bdc-field { display: grid; gap: 4px; }
.bdc-field span { font-size: .75rem; color: var(--bdc-dim); }
.bdc-form input, .bdc-form textarea {
  width: 100%;
  font: inherit; font-size: 1rem; color: #fff;
  background: rgba(39, 39, 42, .5); border: 1px solid var(--bdc-line); border-radius: 12px;
  padding: 10px 14px; min-height: 44px;
  transition: border-color .15s ease, background-color .15s ease;
}
.bdc-form textarea { resize: vertical; min-height: 70px; }
.bdc-form input:focus, .bdc-form textarea:focus { outline: none; border-color: rgba(255, 255, 255, .25); background: rgba(39, 39, 42, .75); }
.bdc-form ::placeholder, .bdc-pill ::placeholder { color: rgba(255, 255, 255, .58); }
.bdc-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.bdc-err { margin: 0; min-height: 1.2em; font-size: .75rem; color: var(--orange); }
.bdc-btn {
  min-height: 44px; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(90deg, var(--bdc-indigo), var(--bdc-violet)); color: #fff;
  font-family: var(--mono); font-weight: 600; font-size: .9375rem;
  box-shadow: 0 8px 22px -8px rgba(99, 102, 241, .7);
  transition: transform .15s ease, filter .15s ease;
}
.bdc-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.bdc-btn:disabled { opacity: .6; cursor: wait; transform: none; }
.bdc-link { background: none; border: 0; color: var(--bdc-dim); font-size: .8125rem; cursor: pointer; padding: 6px; }
.bdc-link:hover { color: #fff; }

/* kotak tulis kapsul */
.bdc-composer { display: block; }
.bdc-pill {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--bdc-line); border-radius: 14px;
  background: rgba(39, 39, 42, .5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color .15s ease, background-color .15s ease;
}
.bdc-pill:focus-within { border-color: rgba(255, 255, 255, .22); background: rgba(39, 39, 42, .75); }
.bdc-pill textarea {
  flex: 1; min-width: 0; resize: none; max-height: 120px;
  padding: 7px 0; border: 0; background: transparent; color: #fff;
  font: inherit; font-size: .9375rem; line-height: 1.45;
}
.bdc-pill textarea:focus { outline: none; }
.bdc-send {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .35);
  cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.bdc-send .bdc-ico { width: 17px; height: 17px; }
.bdc-pill.is-ready .bdc-send { background: var(--bdc-indigo); color: #fff; }
.bdc-pill.is-ready .bdc-send:hover { background: var(--bdc-indigo-2); transform: scale(1.06); }
.bdc-send:active { transform: scale(.92); }
.bdc-send:disabled { opacity: .6; }

.bdc-closed { display: grid; gap: 10px; text-align: center; }
.bdc-closed p { margin: 0; font-size: .8125rem; color: var(--bdc-dim); }

.bdc :focus-visible { outline: 2px solid var(--bdc-indigo-2); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .bdc *, .bdc-panel { animation: none !important; transition: none !important; }
}
