/* widget/widget.css */
.b2bwb-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Opt-in only — added by widget.js when B2B_WEB_BOT_CONFIG.position is set
   to "bottom-left" (e.g. to avoid clashing with an existing WhatsApp button
   in the default bottom-right corner). Without that config, none of this
   applies and positioning is unchanged from above. */
.b2bwb-root.b2bwb-pos-left {
  right: auto;
  left: 20px;
  align-items: flex-start;
}
.b2bwb-root.b2bwb-pos-left .b2bwb-panel {
  transform-origin: bottom left;
}

.b2bwb-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #1F3A5F, #142943);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(20, 41, 67, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.b2bwb-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(20, 41, 67, 0.45);
}
.b2bwb-toggle svg { flex-shrink: 0; }

.b2bwb-panel {
  width: 350px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.b2bwb-hidden { display: none; }

.b2bwb-panel.b2bwb-opening {
  animation: b2bwb-pop-in 0.18s ease;
}
@keyframes b2bwb-pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.b2bwb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: linear-gradient(135deg, #1F3A5F, #142943);
  color: #fff;
  flex-shrink: 0;
}

.b2bwb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.b2bwb-header-text { flex: 1; min-width: 0; }
.b2bwb-header-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.b2bwb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
  flex-shrink: 0;
}
.b2bwb-header-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 2px;
}

.b2bwb-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.b2bwb-close:hover { background: rgba(255, 255, 255, 0.15); }

.b2bwb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F7F9FC;
}

.b2bwb-message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.b2bwb-user {
  align-self: flex-end;
  background: #1F3A5F;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.b2bwb-assistant {
  align-self: flex-start;
  background: #fff;
  color: #1B1F27;
  border: 1px solid #E5E9F0;
  border-bottom-left-radius: 4px;
}

.b2bwb-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px;
}
.b2bwb-chip {
  background: #fff;
  border: 1px solid #C9D4E3;
  color: #1F3A5F;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.b2bwb-chip:hover {
  background: #EAF0F9;
  border-color: #1F3A5F;
}

.b2bwb-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #E5E9F0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.b2bwb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9AA7BA;
  animation: b2bwb-bounce 1.2s infinite ease-in-out;
}
.b2bwb-typing span:nth-child(2) { animation-delay: 0.15s; }
.b2bwb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes b2bwb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.b2bwb-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #E5E9F0;
  background: #fff;
  flex-shrink: 0;
}
.b2bwb-input {
  flex: 1;
  border: 1px solid #E1E6ED;
  background: #F7F9FC;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.b2bwb-input:focus { border-color: #1F3A5F; }
.b2bwb-send {
  border: none;
  background: #1F3A5F;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.b2bwb-send:hover:not(:disabled) { background: #142943; }
.b2bwb-send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 420px) {
  .b2bwb-root { right: 12px; bottom: 12px; }
  .b2bwb-root.b2bwb-pos-left { right: auto; left: 12px; }
  .b2bwb-panel { width: calc(100vw - 24px); height: calc(100vh - 100px); }
}
