/* ─────────────────────────────────────────────────────────────
   SINELEC CHATBOT  — clean, anchored, fully responsive
   Architecture:
     .sinela-chatbot          zero-size fixed anchor, bottom-right viewport
       .sinela-chatbot-fab    absolute, sits at bottom-right
       .sinela-chatbot-window absolute, grows UP from above FAB
         header               flex-shrink 0
         body                 auto height (never forces empty space)
           messages           capped max-height, scrollable
           suggestion-block   below messages, above input
         inputbar             flex-shrink 0
   ───────────────────────────────────────────────────────────── */

/* ── Global reset for the widget ────────────────────────────── */
.sinela-chatbot,
.sinela-chatbot * {
  box-sizing: border-box;
}

/* ── Root anchor ─────────────────────────────────────────────── */
/*  Zero-size fixed point at bottom-right; children absolutely
    positioned from here.  pointer-events: none so the empty
    space in the corner never blocks page clicks.               */
.sinela-chatbot {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  z-index: calc(var(--z-overlay) - 1);
  pointer-events: none;
  overflow: visible;      /* children extend outside the 0×0 box */
}

/* re-enable clicks on interactive children */
.sinela-chatbot-fab,
.sinela-chatbot-window,
.sinela-chatbot-send,
.sinela-chatbot-close,
.sinela-chatbot-chip,
.sinela-chatbot-link,
.sinela-chatbot-input,
.sinela-chatbot-inputbar {
  pointer-events: auto;
}

/* ── FAB ─────────────────────────────────────────────────────── */
.sinela-chatbot-fab {
  position: absolute;
  right: 20px;
  bottom: 20px;

  height: 52px;
  padding: 0 20px 0 14px;
  gap: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a6e 50%, #1e40af 100%);
  color: #fff;
  cursor: pointer;

  box-shadow:
    0 8px 24px rgba(15,23,42,.38),
    0 2px 6px  rgba(30,64,175,.30),
    inset 0 1px 0 rgba(255,255,255,.12);

  transition: transform .22s ease, box-shadow .22s ease,
              opacity .22s ease, background .22s ease;
}
.sinela-chatbot-fab:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #131a2e 0%, #1e4080 50%, #2563eb 100%);
  box-shadow: 0 12px 32px rgba(15,23,42,.42), 0 4px 8px rgba(30,64,175,.36);
}
.sinela-chatbot-fab:focus-visible {
  outline: 2px solid #25d366;
  outline-offset: 3px;
}

/* badge */
.sinela-fab-badge {
  position: absolute;
  top: -6px; left: -6px;
  width: 19px; height: 19px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(239,68,68,.4);
}
.sinela-fab-badge.hidden { display: none; }

.sinela-fab-icon { display: inline-flex; align-items: center; color: #fff; flex: 0 0 auto; }
.sinela-fab-icon svg { display: block; width: 22px; height: 22px; }

.sinela-fab-label {
  font-size: 14px; font-weight: 700; color: #fff;
  white-space: nowrap; letter-spacing: .01em;
}

.sinela-fab-pulse {
  position: absolute; inset: -4px;
  border-radius: 56px;
  border: 2px solid rgba(30,64,175,.5);
  animation: sinelaPillPulse 2.4s ease-out infinite;
  pointer-events: none;
}

/* ── Chat window ─────────────────────────────────────────────── */
/*
   Grows upward from directly above the FAB.
   Width : min(400px, viewport-40px)
   Height: auto (sized by content) but capped so it never goes
           above the safe zone (≈80px top margin for navbars).

   Layout inside is a flex column:
     header   (shrink 0)
     body     (auto height — NO flex:1 so no empty space)
       messages     (capped max-height, scrolls when full)
       suggestion-block (auto height chips)
     inputbar (shrink 0)
*/
.sinela-chatbot-window {
  position: absolute;
  right: 20px;
  bottom: 20px;           /* FAB is hidden when window is open, so sit at the bottom */

  width: min(400px, calc(100vw - 40px));

  /* Auto-sizes to content; never taller than available viewport */
  max-height: min(700px, calc(100dvh - 40px));

  background: #fff;
  border: 1px solid rgba(18,38,78,.07);
  border-radius: 22px;
  box-shadow:
    0 24px 60px rgba(10,20,50,.20),
    0  4px 16px rgba(10,20,50,.08);
  overflow: hidden;

  display: flex;
  flex-direction: column;

  /* hide / show animation */
  opacity: 0;
  transform: translateY(10px) scale(.97);
  visibility: hidden;
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

.sinela-chatbot.is-open .sinela-chatbot-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.sinela-chatbot.is-open .sinela-chatbot-fab {
  opacity: 0;
  transform: translateY(6px) scale(.95);
  pointer-events: none;
}

/* ── Focus rings ─────────────────────────────────────────────── */
.sinela-chatbot-close:focus-visible,
.sinela-chatbot-send:focus-visible,
.sinela-chatbot-chip:focus-visible,
.sinela-chatbot-input:focus-visible {
  outline: 2px solid #25d366;
  outline-offset: 2px;
}

/* ── Header ──────────────────────────────────────────────────── */
.sinela-chatbot-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #131a2e 0%, #153a73 55%, #1c5ed7 100%);
  color: #fff;
}

.sinela-chatbot-brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}

.sinela-chatbot-brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,.15), rgba(255,255,255,.07));
  border: 1px solid rgba(255,255,255,.12);
  color: #fff; flex-shrink: 0;
}
.sinela-chatbot-brand-mark svg { display: block; width: 24px; height: 24px; }

.sinela-chatbot-title  { font-size: 15px; font-weight: 800; line-height: 1.2; }

.sinela-chatbot-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: rgba(255,255,255,.72); margin-top: 2px;
}
.sinela-chatbot-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #25d366;
  box-shadow: 0 0 0 4px rgba(37,211,102,.18);
}

.sinela-chatbot-close {
  width: 34px; height: 34px;
  border: none; border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s;
}
.sinela-chatbot-close:hover { background: rgba(255,255,255,.22); }

/* ── Body ────────────────────────────────────────────────────── */
/*  auto height — never forces empty space into the window.
    When max-height of window is reached, body + messages scroll. */
.sinela-chatbot-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 8px;
  overflow: hidden;
  /* DO NOT add flex:1 here — that forces the window to full height */
}

/* ── Messages ────────────────────────────────────────────────── */
/*  Capped height; scrolls when messages exceed cap.             */
.sinela-chatbot-messages {
  max-height: min(420px, calc(100dvh - 290px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.sinela-chatbot-messages::-webkit-scrollbar { width: 4px; }
.sinela-chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(19,26,46,.14);
  border-radius: 999px;
}

/* ── Bubbles ─────────────────────────────────────────────────── */
.sinela-chatbot-message          { display: flex; }
.sinela-chatbot-message--bot     { justify-content: flex-start; }
.sinela-chatbot-message--user    { justify-content: flex-end; }

.sinela-chatbot-bubble {
  max-width: 85%;
  border-radius: 18px;
  padding: 11px 14px;
  font-size: 13px; line-height: 1.56;
  box-shadow: 0 6px 16px rgba(19,26,46,.06);
}
.sinela-chatbot-message--bot .sinela-chatbot-bubble {
  background: #eef5ff;
  color: #18243d;
  border-top-left-radius: 5px;
}
.sinela-chatbot-message--user .sinela-chatbot-bubble {
  background: linear-gradient(135deg, #1b77f3, #1557c2);
  color: #fff;
  border-top-right-radius: 5px;
}

/* thinking dots */
.sinela-chatbot-bubble--thinking { padding: 10px 12px; }
.sinela-chatbot-thinking { display: inline-flex; align-items: center; gap: 5px; }
.sinela-chatbot-thinking span {
  width: 7px; height: 7px; border-radius: 50%; background: #5d7191;
  animation: sinelaThinkingDots 1.1s ease-in-out infinite;
}
.sinela-chatbot-thinking span:nth-child(2) { animation-delay: .15s; }
.sinela-chatbot-thinking span:nth-child(3) { animation-delay: .30s; }

/* bubble typography */
.sinela-chatbot-bubble p { margin: 0; }
.sinela-chatbot-bubble p + p,
.sinela-chatbot-bubble ul,
.sinela-chatbot-bubble .sinela-chatbot-links { margin-top: 8px; }
.sinela-chatbot-bubble ul  { padding-left: 18px; margin-bottom: 0; }
.sinela-chatbot-bubble li + li { margin-top: 4px; }

/* ── Links inside bubbles ────────────────────────────────────── */
.sinela-chatbot-links { display: flex; flex-wrap: wrap; gap: 8px; }
.sinela-chatbot-link {
  display: inline-flex; align-items: center;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(27,119,243,.12); color: #0b57c8;
  text-decoration: none; font-size: 12px; font-weight: 700;
}

/* ── Suggestion chips ────────────────────────────────────────── */
.sinela-chatbot-suggestion-block {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-bottom: 4px;
}

.sinela-chatbot-chip {
  border: 1px solid rgba(27,119,243,.15);
  background: #fff;
  color: #173056;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11.5px; font-weight: 700; line-height: 1.2;
  cursor: pointer;
  transition: transform .17s, background .17s, border-color .17s;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.sinela-chatbot-chip:hover {
  transform: translateY(-1px);
  background: #eef5ff;
  border-color: rgba(27,119,243,.28);
}
.sinela-chatbot-chip--whatsapp {
  background: linear-gradient(135deg, rgba(255,255,255,.97), rgba(242,255,247,.99));
  color: #1a9e53;
  border: 1px solid rgba(37,211,102,.20);
}
.sinela-chatbot-chip--whatsapp:hover { background: #f0fdf4; }
.sinela-chatbot-chip--more { color: #0b57c8; font-weight: 800; }

.sinela-chatbot-chip-icon {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #25d366; flex: 0 0 auto;
}

/* ── Input bar ───────────────────────────────────────────────── */
.sinela-chatbot-inputbar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(19,26,46,.06);
  background: #fff;
}

.sinela-chatbot-input {
  flex: 1; min-width: 0;
  height: 44px;
  border: 1.5px solid rgba(19,26,46,.13);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 13px;
  background: #f8fafc;
  color: #18243d;
  transition: border-color .15s, box-shadow .15s;
}
.sinela-chatbot-input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.09);
  outline: none;
}
.sinela-chatbot-input::placeholder { color: #adb5bd; }

.sinela-chatbot-send {
  width: 44px; height: 44px; padding: 0;
  border: 1.5px solid #cfe0f3; border-radius: 12px;
  background: linear-gradient(160deg, #f7fbff, #e8f2ff);
  color: #0a1a30; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(12,44,86,.10);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.sinela-chatbot-send:hover {
  background: #dceeff;
  border-color: #9ec6f4;
  box-shadow: 0 6px 18px rgba(12,44,86,.16);
}
.sinela-chatbot-send svg { display: block; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes sinelaPillPulse {
  0%   { transform: scale(1);    opacity: .7; }
  70%  { transform: scale(1.08); opacity: 0;  }
  100% { transform: scale(1.08); opacity: 0;  }
}
@keyframes sinelaThinkingDots {
  0%, 80%, 100% { transform: translateY(0);   opacity: .45; }
  40%           { transform: translateY(-3px); opacity: 1;   }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */

/* ── Tablet  641 – 1024px ────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 641px) {
  .sinela-chatbot-window {
    width: min(370px, calc(100vw - 36px));
    max-height: min(560px, calc(100dvh - 36px));
  }
  .sinela-chatbot-messages {
    max-height: min(280px, calc(100dvh - 260px));
  }
}

/* ── Mobile  ≤ 640px  — full-width bottom sheet ──────────────── */
@media (max-width: 640px) {
  /* Lock page scroll behind the sheet */
  body.sinela-chat-open { overflow: hidden; touch-action: none; }

  /* FAB stays bottom-right, slightly smaller */
  .sinela-chatbot-fab {
    right: 14px;
    bottom: 14px;
    height: 48px;
    padding: 0 16px 0 12px;
    gap: 8px;
  }
  .sinela-fab-label { font-size: 13px; }

  /* Window: edge-to-edge bottom sheet */
  .sinela-chatbot-window {
    /* override the absolute positioning for full-width */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;

    /* grows up to 90% of viewport; clips at viewport top */
    max-height: min(90dvh, 680px);

    border-radius: 22px 22px 0 0;
    border-bottom: none;
    transform-origin: bottom center;
  }

  .sinela-chatbot-messages {
    max-height: min(300px, calc(100dvh - 270px));
  }

  .sinela-chatbot-header  { padding: 14px 16px 12px; }
  .sinela-chatbot-body    { padding: 12px 12px 6px; }
  .sinela-chatbot-inputbar {
    padding: 8px 12px 20px; /* 20px bottom: clears home-bar on iOS */
    gap: 8px;
  }

  .sinela-chatbot-bubble { max-width: 90%; }
  .sinela-chatbot-input  { height: 42px; font-size: 14px; }
  .sinela-chatbot-send   { width: 42px; height: 42px; }
}

/* ── Very small  ≤ 390px ─────────────────────────────────────── */
@media (max-width: 390px) {
  .sinela-chatbot-fab {
    right: 10px; bottom: 10px;
    height: 44px; padding: 0 13px 0 10px; gap: 7px;
  }
  .sinela-fab-label  { font-size: 12px; }
  .sinela-chatbot-chip { font-size: 10.5px; padding: 5px 8px; }
  .sinela-chatbot-messages { max-height: min(260px, calc(100dvh - 270px)); }
}
