/* Bookwise Chat Widget
   Embeddable via: <script src="https://bookwise-2-aexx.polsia.app/widget.js"></script>
   Auto-initializes on load. */

#bw-widget * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'DM Sans', system-ui, sans-serif; }

#bw-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--accent, #c85a1a);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(200, 90, 26, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#bw-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(200, 90, 26, 0.5); }
#bw-launcher svg { fill: white; width: 28px; height: 28px; }

#bw-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.14);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
}
#bw-panel.open { display: flex; }

#bw-header {
  background: var(--accent, #c85a1a);
  color: white;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#bw-header-info { display: flex; flex-direction: column; gap: 2px; }
#bw-header-title { font-size: 15px; font-weight: 600; }
#bw-header-sub { font-size: 12px; opacity: 0.85; }
#bw-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  opacity: 0.8;
  padding: 4px;
}
#bw-close:hover { opacity: 1; }

#bw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  background: #faf8f5;
}

.bw-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  animation: bw-fadein 0.2s ease;
}
@keyframes bw-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.bw-msg.bot { align-self: flex-start; background: white; color: #1c1c1e; border: 1px solid #e5ddd4; border-bottom-left-radius: 4px; }
.bw-msg.user { align-self: flex-end; background: var(--accent, #c85a1a); color: white; border-bottom-right-radius: 4px; }

#bw-confirm {
  margin: 8px 0 0;
  padding: 10px 14px;
  background: #f2ede7;
  border-radius: 10px;
  font-size: 12px;
  border-left: 3px solid var(--accent, #c85a1a);
}
#bw-confirm strong { font-size: 14px; display: block; margin-bottom: 2px; }

#bw-input-row {
  padding: 12px 14px;
  border-top: 1px solid #e5ddd4;
  display: flex;
  gap: 8px;
  background: white;
}
#bw-input {
  flex: 1;
  border: 1px solid #e5ddd4;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #faf8f5;
}
#bw-input:focus { border-color: var(--accent, #c85a1a); }
#bw-send {
  background: var(--accent, #c85a1a);
  color: white;
  border: none;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#bw-send:hover { background: var(--accent-dark, #9e3f0e); }
#bw-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 440px) {
  #bw-panel { right: 12px; bottom: 88px; width: calc(100vw - 24px); }
  #bw-launcher { right: 16px; bottom: 16px; }
}