/* ============================================================
   i-BnB Customer-Facing Chatbot Widget
   Design system matches i-BnB:
   --ib-red: #d3182a, --ib-ink: #1b1210, --ib-paper-warm: #faf5f2
   ============================================================ */

:root {
  --ib-chat-red: #d3182a;
  --ib-chat-red-deep: #96101f;
  --ib-chat-ink: #1b1210;
  --ib-chat-ink-soft: #5a4d4b;
  --ib-chat-bg: #faf5f2;
  --ib-chat-card: #ffffff;
  --ib-chat-rule: #e9dedb;
  --ib-chat-font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --ib-chat-display: "Plus Jakarta Sans", "Space Grotesk", sans-serif;
}

/* ---------------------------------------------------------
   Floating Launcher Button
   --------------------------------------------------------- */
.ibnb-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--ib-chat-red);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 30px -6px rgba(211, 24, 42, 0.55), 0 4px 12px rgba(27, 18, 16, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, box-shadow 0.25s ease;
  outline: none;
}

.ibnb-chat-launcher:hover {
  transform: scale(1.06);
  background: var(--ib-chat-red-deep);
  box-shadow: 0 16px 36px -6px rgba(211, 24, 42, 0.65);
}

.ibnb-chat-launcher:focus-visible {
  outline: 3px solid var(--ib-chat-ink);
  outline-offset: 3px;
}

.ibnb-chat-launcher .launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.ibnb-chat-launcher .launcher-icon-close {
  display: none;
}

.ibnb-chat-launcher.is-active .launcher-icon-open {
  display: none;
}

.ibnb-chat-launcher.is-active .launcher-icon-close {
  display: flex;
}

/* Pulsing notification indicator on launcher */
.ibnb-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #59c07a;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ibnb-chat-launcher.is-seen .ibnb-chat-badge,
.ibnb-chat-launcher.is-active .ibnb-chat-badge {
  display: none;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------
   Chat Window Drawer
   --------------------------------------------------------- */
.ibnb-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 120px);
  background: var(--ib-chat-bg);
  border-radius: 20px;
  border: 1px solid var(--ib-chat-rule);
  box-shadow: 0 28px 64px -16px rgba(27, 18, 16, 0.38), 0 4px 16px rgba(27, 18, 16, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s ease;
  font-family: var(--ib-chat-font);
}

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

/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */
.ibnb-chat-header {
  background: var(--ib-chat-ink);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ibnb-chat-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ibnb-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ib-chat-red);
  position: relative;
  flex-shrink: 0;
}

.ibnb-chat-avatar .status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #59c07a;
  border: 2px solid var(--ib-chat-ink);
}

.ibnb-chat-header-info h3 {
  font-family: var(--ib-chat-display);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  line-height: 1.2;
}

.ibnb-chat-header-info p {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.65);
  margin: 2px 0 0 0;
}

.ibnb-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ibnb-chat-btn-icon {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.ibnb-chat-btn-icon:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------------------------------------------------------
   Messages Stream
   --------------------------------------------------------- */
.ibnb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.ibnb-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.ibnb-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(27, 18, 16, 0.15);
  border-radius: 4px;
}

.ibnb-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: ibnb-fade-in 0.25s ease forwards;
}

@keyframes ibnb-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ibnb-chat-msg.bot {
  align-self: flex-start;
}

.ibnb-chat-msg.user {
  align-self: flex-end;
}

.ibnb-chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.ibnb-chat-msg.bot .ibnb-chat-bubble {
  background: var(--ib-chat-card);
  color: var(--ib-chat-ink);
  border: 1px solid var(--ib-chat-rule);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(27, 18, 16, 0.04);
}

.ibnb-chat-msg.user .ibnb-chat-bubble {
  background: var(--ib-chat-red);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(211, 24, 42, 0.25);
}

.ibnb-chat-bubble a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.ibnb-chat-bubble p {
  margin: 0 0 8px 0;
}

.ibnb-chat-bubble p:last-child {
  margin-bottom: 0;
}

.ibnb-chat-bubble ul,
.ibnb-chat-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.ibnb-chat-bubble li {
  margin-bottom: 4px;
}

.ibnb-chat-bubble li:last-child {
  margin-bottom: 0;
}

.ibnb-chat-bubble strong {
  font-weight: 700;
}

.ibnb-chat-bubble code {
  background: rgba(27, 18, 16, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: monospace;
}

.ibnb-chat-msg.user .ibnb-chat-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.ibnb-chat-timestamp {
  font-size: 10.5px;
  color: var(--ib-chat-ink-soft);
  opacity: 0.75;
  margin-top: 4px;
}

.ibnb-chat-msg.bot .ibnb-chat-timestamp {
  margin-left: 4px;
}

.ibnb-chat-msg.user .ibnb-chat-timestamp {
  align-self: flex-end;
  margin-right: 4px;
}

/* ---------------------------------------------------------
   Lead Captured Status Card
   --------------------------------------------------------- */
.ibnb-chat-lead-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eef8f1;
  border: 1px solid #c0e6cb;
  color: #1b6334;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  animation: ibnb-fade-in 0.3s ease forwards;
  margin: 4px 0;
  box-shadow: 0 2px 6px rgba(27, 99, 52, 0.08);
}

.ibnb-chat-lead-badge .material-symbols-outlined {
  color: #278d46;
  font-size: 20px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------
   Quick Action Suggestion Chips
   --------------------------------------------------------- */
.ibnb-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ibnb-chat-chip {
  background: var(--ib-chat-card);
  border: 1px solid var(--ib-chat-rule);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ib-chat-ink);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: var(--ib-chat-font);
}

.ibnb-chat-chip:hover {
  border-color: var(--ib-chat-red);
  color: var(--ib-chat-red);
  background: #fbe4e2;
  transform: translateY(-1px);
}

/* ---------------------------------------------------------
   Typing Indicator
   --------------------------------------------------------- */
.ibnb-chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--ib-chat-card);
  border: 1px solid var(--ib-chat-rule);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.ibnb-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ib-chat-red);
  animation: ibnb-bounce 1.3s infinite ease-in-out both;
}

.ibnb-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.ibnb-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
.ibnb-chat-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes ibnb-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------
   Input Bar
   --------------------------------------------------------- */
.ibnb-chat-footer {
  padding: 12px 16px 14px;
  background: var(--ib-chat-card);
  border-top: 1px solid var(--ib-chat-rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ibnb-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ib-chat-bg);
  border: 1.5px solid var(--ib-chat-rule);
  border-radius: 12px;
  padding: 6px 10px 6px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ibnb-chat-form:focus-within {
  border-color: var(--ib-chat-red);
  box-shadow: 0 0 0 3px rgba(211, 24, 42, 0.12);
}

.ibnb-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--ib-chat-ink);
  outline: none;
  font-family: var(--ib-chat-font);
}

.ibnb-chat-input::placeholder {
  color: var(--ib-chat-ink-soft);
  opacity: 0.7;
}

.ibnb-chat-submit {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--ib-chat-red);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.ibnb-chat-submit:hover:not(:disabled) {
  background: var(--ib-chat-red-deep);
  transform: scale(1.05);
}

.ibnb-chat-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ibnb-chat-disclaimer {
  font-size: 10px;
  color: var(--ib-chat-ink-soft);
  opacity: 0.7;
  text-align: center;
  margin: 0;
}

/* ---------------------------------------------------------
   Mobile Breakpoint (<480px)
   --------------------------------------------------------- */
@media (max-width: 480px) {
  .ibnb-chat-launcher {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
  }

  .ibnb-chat-window {
    inset: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .ibnb-chat-window.is-open ~ .ibnb-chat-launcher {
    display: none;
  }
}
