/* ===== Helpline widget: bot + WhatsApp (includes/helpline.php) ===== */
.hl { --hl-spring: cubic-bezier(.34, 1.45, .55, 1); --hl-smooth: cubic-bezier(.22, 1, .36, 1); --hl-wa: #25d366;
  --hl-bottom: calc(var(--nav-h, 82px) + 18px + env(safe-area-inset-bottom)); }
.hl.hl-nonav { --hl-bottom: calc(20px + env(safe-area-inset-bottom)); }
html.hl-lock, html.hl-lock body { overflow: hidden; }

/* ---------- floating button ---------- */
.hl-fab { position: fixed; right: 16px; bottom: var(--hl-bottom); z-index: 90; width: 58px; height: 58px; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--on-primary, #fff); font-size: 1.45rem;
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 70%, #fff), var(--primary) 60%);
  box-shadow: 0 14px 30px -8px rgba(var(--primary-rgb), .85), inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .45s var(--hl-spring), box-shadow .3s; -webkit-tap-highlight-color: transparent; }
.hl-fab::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(var(--primary-rgb), .6); animation: hlBreath 2.8s ease-out infinite; pointer-events: none; }
.hl-fab:hover { transform: scale(1.07); }
.hl-fab:active { transform: scale(.92); }
.hl-fab i { grid-area: 1 / 1; transition: transform .45s var(--hl-spring), opacity .25s; }
.hl-ic-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.hl.open .hl-ic-open { opacity: 0; transform: rotate(90deg) scale(.5); }
.hl.open .hl-ic-close { opacity: 1; transform: none; }
.hl.open .hl-fab::before { animation: none; opacity: 0; }
.hl-online { position: absolute; top: 3px; right: 3px; width: 13px; height: 13px; border-radius: 50%; background: var(--hl-wa); border: 2.5px solid var(--bg, #0b0820); }
@keyframes hlBreath { from { transform: scale(1); opacity: .8; } to { transform: scale(1.55); opacity: 0; } }

/* hint bubble */
.hl-hint { position: fixed; right: 84px; bottom: calc(var(--hl-bottom) + 12px); z-index: 89; padding: 9px 14px; border-radius: 16px 16px 4px 16px; cursor: pointer;
  font-size: .88rem; white-space: nowrap; color: var(--text); background: color-mix(in srgb, var(--bg) 82%, #fff 6%); border: 1px solid var(--border);
  box-shadow: 0 12px 28px -12px rgba(0,0,0,.6); opacity: 0; transform: translateX(14px) scale(.9); transform-origin: right bottom; pointer-events: none;
  transition: opacity .35s var(--hl-smooth), transform .5s var(--hl-spring); }
.hl-hint b { color: var(--primary); }
.hl-hint.show { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- panel ---------- */
.hl-backdrop { position: fixed; inset: 0; z-index: 118; background: rgba(0,0,0,.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--hl-smooth); }
.hl-panel { position: fixed; z-index: 120; display: flex; flex-direction: column; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--border); box-shadow: 0 30px 80px -20px rgba(0,0,0,.75);
  /* phone: bottom sheet */
  left: 0; right: 0; bottom: 0; height: min(84dvh, 680px); border-radius: 26px 26px 0 0; border-bottom: 0;
  transform: translateY(105%); transition: transform .5s var(--hl-smooth); }
.hl-panel[hidden] { display: none; }
.hl.open .hl-panel { transform: none; }
.hl.open .hl-backdrop { opacity: 1; pointer-events: auto; }
.hl-panel.dragging { transition: none; }

/* header */
.hl-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 20px 16px 14px; touch-action: none;
  background: linear-gradient(180deg, rgba(var(--primary-rgb), .16), transparent); }
.hl-grab { position: absolute; top: 7px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: rgba(255,255,255,.22); }
.hl-ava { position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 15px; font-size: 1.35rem; color: var(--on-primary, #fff);
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 65%, #fff), var(--primary)); box-shadow: 0 10px 22px -10px rgba(var(--primary-rgb), .9); }
.hl.open .hl-ava i { animation: hlWave 1.1s .35s var(--hl-spring); }
@keyframes hlWave { 30% { transform: rotate(-14deg) scale(1.1); } 60% { transform: rotate(10deg); } }
.hl-who { flex: 1; min-width: 0; }
.hl-who b { display: block; font-size: 1.02rem; }
.hl-who small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hl-wa); box-shadow: 0 0 8px var(--hl-wa); flex: none; }
.hl-x { width: 38px; height: 38px; flex: none; border: 0; border-radius: 12px; cursor: pointer; color: var(--text); font-size: 1.05rem;
  background: rgba(255,255,255,.07); transition: background .2s, transform .3s var(--hl-spring); }
.hl-x:hover { background: rgba(255,255,255,.13); }
.hl-x:active { transform: scale(.9); }

/* messages */
.hl-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 14px 6px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.hl-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; }
.hl-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.hl-mini { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: .9rem; color: var(--primary);
  background: rgba(var(--primary-rgb), .14); }
.hl-bub { padding: 10px 13px; border-radius: 18px 18px 18px 6px; font-size: .93rem; line-height: 1.55; overflow-wrap: anywhere;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
.hl-msg.me .hl-bub { border-radius: 18px 18px 6px 18px; color: var(--on-primary, #fff); border-color: transparent;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 80%, #fff), var(--primary)); }
.hl-msg.in.bot { animation: hlInL .5s var(--hl-spring) both; transform-origin: left bottom; }
.hl-msg.in.me { animation: hlInR .45s var(--hl-spring) both; transform-origin: right bottom; }
@keyframes hlInL { from { opacity: 0; transform: translate(-10px, 10px) scale(.92); } }
@keyframes hlInR { from { opacity: 0; transform: translate(10px, 10px) scale(.92); } }

.hl-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.hl-act { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; font-size: .8rem; font-weight: 700; text-decoration: none;
  color: var(--primary); background: rgba(var(--primary-rgb), .12); border: 1px solid rgba(var(--primary-rgb), .3); transition: transform .3s var(--hl-spring); }
.hl-act:active { transform: scale(.95); }
.hl-act.wa { color: #fff; background: linear-gradient(135deg, #2fe07a, #128c4a); border-color: transparent; }
.hl-act.tg { color: #fff; background: linear-gradient(135deg, #3ec3ff, #1f8fd1); border-color: transparent; }

/* typing dots */
.hl-typing .hl-bub { display: flex; gap: 4px; padding: 13px 14px; }
.hl-typing .hl-bub i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: hlDot 1.1s infinite ease-in-out; }
.hl-typing .hl-bub i:nth-child(2) { animation-delay: .15s; }
.hl-typing .hl-bub i:nth-child(3) { animation-delay: .3s; }
@keyframes hlDot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

/* quick topics */
.hl-chips { display: flex; gap: 7px; overflow-x: auto; padding: 8px 14px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); }
.hl-chips::-webkit-scrollbar { display: none; }
.hl-chips button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .83rem; font-weight: 600; color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--border);
  transition: transform .3s var(--hl-spring), background .2s, border-color .2s; }
.hl-chips button i { color: var(--primary); }
.hl-chips button:hover { border-color: rgba(var(--primary-rgb), .5); background: rgba(var(--primary-rgb), .1); }
.hl-chips button:active { transform: scale(.93); }
.hl.open .hl-chips button { animation: hlChip .5s var(--hl-spring) both; animation-delay: calc(.18s + var(--i, 0) * 45ms); }
@keyframes hlChip { from { opacity: 0; transform: translateY(10px) scale(.9); } }

/* input */
.hl-input { display: flex; gap: 8px; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); }
.hl-input input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; font: inherit; font-size: 16px; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid var(--border); outline: none; transition: border-color .2s, background .2s; }
.hl-input input:focus { border-color: rgba(var(--primary-rgb), .6); background: rgba(255,255,255,.09); }
.hl-input button { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.05rem; color: var(--on-primary, #fff);
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 70%, #fff), var(--primary)); transition: transform .3s var(--hl-spring); }
.hl-input button:active { transform: scale(.88) rotate(-12deg); }

/* ---------- tablet / desktop: floating card above the button ---------- */
@media (min-width: 640px) {
  .hl-backdrop { display: none; }
  .hl-panel { left: auto; right: 20px; bottom: calc(var(--hl-bottom) + 72px); width: 384px; height: min(600px, calc(100dvh - var(--hl-bottom) - 100px));
    border-radius: 24px; border-bottom: 1px solid var(--border); transform-origin: right bottom;
    opacity: 0; transform: translateY(16px) scale(.88); transition: transform .5s var(--hl-spring), opacity .25s ease; }
  .hl.open .hl-panel { opacity: 1; }
  .hl-grab { display: none; }
  .hl-head { padding-top: 16px; }
}
@media (min-width: 900px) {
  .hl { --hl-bottom: 24px; }
  .hl-fab { right: 24px; }
  .hl-panel { right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .hl-fab::before { animation: none; }
}

/* ---------- WhatsApp button (separate from chat) ---------- */
.hl-wa-fab { position: fixed; right: 18px; bottom: var(--hl-bottom); z-index: 90; height: 54px; min-width: 54px; padding: 0; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; overflow: hidden;
  background: linear-gradient(145deg, #4cf08f, #25d366 45%, #128c4a); box-shadow: 0 14px 28px -10px rgba(37,211,102,.85), inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .45s var(--hl-spring), opacity .3s, padding .45s var(--hl-smooth), box-shadow .3s;
  animation: hlPop .6s .5s var(--hl-spring) both, hlNudge 1s 4s ease-in-out 2; -webkit-tap-highlight-color: transparent; }
.hl-wa-fab i { font-size: 1.6rem; width: 54px; flex: none; text-align: center; }
.hl-wa-label { max-width: 0; opacity: 0; white-space: nowrap; font-weight: 700; font-size: .92rem; transition: max-width .45s var(--hl-smooth), opacity .3s, margin .45s; }
.hl-wa-fab:active { transform: scale(.92); }
.hl.has-chat .hl-wa-fab { right: 20px; height: 50px; min-width: 50px; bottom: calc(var(--hl-bottom) + 70px); }
.hl.has-chat .hl-wa-fab i { width: 50px; font-size: 1.45rem; }
.hl.open .hl-wa-fab { opacity: 0; transform: scale(.4) translateY(20px); pointer-events: none; animation: none; }
@keyframes hlPop { from { opacity: 0; transform: scale(.3) translateY(16px); } }
@keyframes hlNudge { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg) scale(1.06); } 40% { transform: rotate(10deg) scale(1.06); } 60% { transform: rotate(-6deg); } 80% { transform: rotate(3deg); } }
/* mouse users: the button opens into a labelled pill */
@media (hover: hover) and (pointer: fine) {
  .hl-wa-fab:hover { padding-right: 18px; box-shadow: 0 18px 34px -10px rgba(37,211,102,.95); }
  .hl-wa-fab:hover .hl-wa-label { max-width: 140px; opacity: 1; }
}
@media (min-width: 900px) {
  .hl-wa-fab { right: 26px; }
  .hl.has-chat .hl-wa-fab { right: 28px; }
}
@media (prefers-reduced-motion: reduce) { .hl-wa-fab { animation: none; } }
