/* BloomBot Widget — scoped styles (no global resets) */

#bloom-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #F13E93;
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(241,62,147,0.4);
  transition: transform 0.2s;
}
#bloom-fab svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#bloom-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  animation: badge-pulse 2s infinite;
}
@keyframes badge-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.8; } }

#bloom-widget {
  --bloom-mobile-panel-height: 78svh;
  position: fixed;
  bottom: 96px; right: 16px;
  width: min(390px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 160px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: panel-in 0.28s cubic-bezier(.34,1.4,.64,1);
}
@keyframes panel-in { from { opacity: 0; transform: scale(0.85) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
#bloom-widget.open { display: flex; }

.bloom-header {
  background: #F13E93;
  padding: 18px 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bloom-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.bloom-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bloom-header-info { flex: 1; min-width: 0; }
.bloom-header-name { color: #fff; font-weight: 700; font-size: 15px; }
.bloom-header-sub { color: rgba(255,255,255,0.75); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.bloom-header-sub::before { content: ''; display: inline-block; width: 7px; height: 7px; background: #00c060; border-radius: 50%; }
.bloom-minimize {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bloom-minimize:hover { background: rgba(255,255,255,0.25); }
.bloom-minimize svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 2.5; fill: none; }

#bloom-auth {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  gap: 18px;
}
.bloom-auth-logo {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F13E9322, #00c06022);
  border: 2px solid rgba(241,62,147,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bloom-auth-logo svg { width: 32px; height: 32px; fill: none; stroke: #00c060; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bloom-auth-title { font-size: 18px; font-weight: 700; color: #1e1b4b; text-align: center; }
.bloom-auth-sub { font-size: 13px; color: #6b7280; text-align: center; line-height: 1.5; }
#bloom-chat { flex: 1; display: none; flex-direction: column; overflow: hidden; }
#bloom-chat.open { display: flex; }

#bloom-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#bloom-messages::-webkit-scrollbar { width: 4px; }
#bloom-messages::-webkit-scrollbar-track { background: transparent; }
#bloom-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.bloom-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.bloom-msg.user { align-self: flex-end; background: #F13E93; color: #fff; border-bottom-right-radius: 4px; }
.bloom-msg.assistant { align-self: flex-start; background: #f3f4f6; color: #1f2937; border-bottom-left-radius: 4px; }
.bloom-msg.error { align-self: flex-start; background: #fee2e2; color: #991b1b; font-size: 13px; }

.bloom-typing {
  align-self: flex-start;
  background: #f3f4f6;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.bloom-typing span { width: 7px; height: 7px; background: #9ca3af; border-radius: 50%; animation: typing-bounce 1.4s infinite ease-in-out; }
.bloom-typing span:nth-child(1) { animation-delay: 0s; }
.bloom-typing span:nth-child(2) { animation-delay: 0.2s; }
.bloom-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.bloom-input-area {
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
}
#bloom-user-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 42px;
  line-height: 1.5;
  transition: border-color 0.2s;
  font-family: inherit;
}
#bloom-user-input:focus { border-color: #F13E93; }
#bloom-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #F13E93;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
#bloom-send-btn:hover { opacity: 0.88; transform: scale(1.05); }
#bloom-send-btn:active { transform: scale(0.95); }
#bloom-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#bloom-send-btn svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 480px) {
  #bloom-fab { bottom: 20px; right: 16px; width: 56px; height: 56px; }
  #bloom-widget { bottom: 88px; right: 10px; width: calc(100vw - 20px); height: calc(100vh - 130px); }
}
@media (hover: hover) { #bloom-fab:hover { transform: scale(1.1); } }

/* Lock mobile viewport — no pinch zoom, fixed touch */
#bloom-fab, #bloom-widget, #bloom-chat, #bloom-messages {
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
#bloom-user-input {
  touch-action: manipulation;
  font-size: 16px; /* prevents iOS auto-zoom on focus */
}
@media (max-width: 480px) {
  #bloom-widget {
    position: fixed;
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: var(--bloom-mobile-panel-height, 78svh);
    max-width: calc(100vw - 20px);
    max-height: min(80svh, calc(100svh - 18px - env(safe-area-inset-bottom, 0px)));
    border-radius: 18px;
    margin: 0;
  }
  #bloom-auth, #bloom-chat {
    height: 100%;
  }
}

