/* BHT Chat Widget — vanilla, zero deps */
.bhtw-root, .bhtw-root *, .bhtw-root *::before, .bhtw-root *::after {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.bhtw-root { position: fixed; z-index: 2147483000; bottom: 18px; right: 18px; }

/* Floating launcher */
.bhtw-launcher {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #1c7d92 0%, #269fb7 100%);
  border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(28,125,146,0.45);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.bhtw-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(28,125,146,0.55); }
.bhtw-launcher .bhtw-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; border-radius: 10px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center; padding: 0 6px;
}
.bhtw-launcher.bhtw-has-unread .bhtw-badge { display: flex; }

/* Panel */
.bhtw-panel {
  position: fixed; right: 18px; bottom: 90px;
  width: 360px; height: 540px; max-height: calc(100vh - 110px);
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 25px 60px rgba(15,23,42,0.35);
  display: none; flex-direction: column;
  animation: bhtw-slide-up 0.22s ease-out;
}
.bhtw-root.bhtw-open .bhtw-panel { display: flex; }
@keyframes bhtw-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Header */
.bhtw-header {
  background: linear-gradient(135deg, #1c7d92 0%, #1e2456 100%);
  color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.bhtw-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bhtw-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.bhtw-header-text { min-width: 0; }
.bhtw-title { font-size: 14px; font-weight: 700; line-height: 1.2; }
.bhtw-subtitle { font-size: 11px; opacity: 0.85; display: flex; align-items: center; gap: 4px; }
.bhtw-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.bhtw-close {
  background: none; border: none; color: #fff; font-size: 24px;
  cursor: pointer; padding: 0 4px; line-height: 1; opacity: 0.9;
}
.bhtw-close:hover { opacity: 1; }

/* Messages */
.bhtw-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  background: #f8fafc;
  display: flex; flex-direction: column; gap: 10px;
}
.bhtw-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; }
.bhtw-msg-bot { align-self: flex-start; background: #fff; color: #1f2937; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.bhtw-msg-user { align-self: flex-end; background: linear-gradient(135deg, #1c7d92, #269fb7); color: #fff; border-bottom-right-radius: 4px; }
.bhtw-msg-system { align-self: center; background: #fef3c7; color: #92400e; font-size: 11px; padding: 6px 10px; }
.bhtw-typing {
  align-self: flex-start; padding: 10px 14px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  display: none;
}
.bhtw-typing.bhtw-show { display: flex; gap: 4px; }
.bhtw-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
  animation: bhtw-bounce 1.2s infinite ease-in-out;
}
.bhtw-typing span:nth-child(2) { animation-delay: 0.2s; }
.bhtw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bhtw-bounce { 0%,80%,100%{transform:scale(0.7);opacity:0.5} 40%{transform:scale(1);opacity:1} }

/* Carousel */
.bhtw-carousel {
  align-self: stretch; max-width: 100%;
  display: flex; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: thin;
  padding: 4px 0 8px 0; margin: 2px 0;
  -webkit-overflow-scrolling: touch;
}
.bhtw-carousel::-webkit-scrollbar { height: 6px; }
.bhtw-carousel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.bhtw-card {
  flex: 0 0 220px; scroll-snap-align: start;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.bhtw-card-img {
  width: 100%; height: 130px; object-fit: cover; background: #f1f5f9;
  display: block;
}
.bhtw-card-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; }
.bhtw-card-title { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 3px; line-height: 1.2; }
.bhtw-card-sub { font-size: 11.5px; color: #64748b; margin-bottom: 8px; flex: 1; }
.bhtw-card-actions { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.bhtw-card-btn {
  border: none; padding: 7px 10px; border-radius: 7px; font-size: 11.5px; font-weight: 700;
  cursor: pointer; text-align: center; text-decoration: none; display: block;
  transition: filter 0.12s;
}
.bhtw-card-btn:hover { filter: brightness(1.08); }
.bhtw-card-btn-primary { background: #16a34a; color: #fff; }
.bhtw-card-btn-secondary { background: #f1f5f9; color: #1c7d92; }
.bhtw-card-btn-tertiary { background: transparent; color: #64748b; border: 1px solid #e2e8f0; padding: 6px 10px; font-size: 11px; }

/* Identify form */
.bhtw-identify {
  align-self: stretch; padding: 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.bhtw-identify-title { font-size: 13px; font-weight: 700; color: #0f172a; }
.bhtw-identify input {
  padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px;
  font-family: inherit; outline: none;
}
.bhtw-identify input:focus { border-color: #1c7d92; }
.bhtw-identify button {
  padding: 8px; background: #1c7d92; color: #fff; border: none; border-radius: 7px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}

/* Composer */
.bhtw-composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  background: #fff; border-top: 1px solid #e2e8f0; flex-shrink: 0;
}
.bhtw-composer textarea {
  flex: 1; resize: none; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none;
  max-height: 100px; min-height: 38px; line-height: 1.35;
}
.bhtw-composer textarea:focus { border-color: #1c7d92; }
.bhtw-send {
  background: #1c7d92; color: #fff; border: none; border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.bhtw-send:hover { background: #155e6f; }
.bhtw-send:disabled { background: #94a3b8; cursor: not-allowed; }

/* Mobile */
@media (max-width: 768px) {
  .bhtw-root { bottom: 12px; right: 12px; }
  .bhtw-launcher { width: 56px; height: 56px; font-size: 26px; }
  .bhtw-panel {
    right: 0; bottom: 0; left: 0; width: 100%;
    height: 100vh; max-height: 100vh; border-radius: 0;
  }
}
