/* ==========================================
   WebÜret Chatbot Widget
   ========================================== */

/* ---- Toggle Button ---- */
.wb-chat-btn {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  width: 58px;
  height: 58px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(224, 64, 53, 0.45);
  z-index: 9997;
  transition: transform .35s var(--transition-bounce), box-shadow .3s ease;
  color: white;
  outline: none;
}

.wb-chat-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(224, 64, 53, 0.55);
}

.wb-chat-btn .wb-icon-chat { display: flex; transition: opacity .2s, transform .2s; }
.wb-chat-btn .wb-icon-close { display: none; opacity: 0; transform: rotate(-90deg); transition: opacity .2s, transform .2s; }

.wb-chat-btn.is-open .wb-icon-chat { display: none; }
.wb-chat-btn.is-open .wb-icon-close { display: flex; opacity: 1; transform: rotate(0deg); }

.wb-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid white;
  animation: wb-pulse 2.2s ease-in-out infinite;
}

@keyframes wb-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

/* ---- Chat Window ---- */
.wb-window {
  position: fixed;
  bottom: 10rem;
  right: 2rem;
  width: 390px;
  max-width: calc(100vw - 2.5rem);
  height: 540px;
  max-height: calc(100vh - 11rem);
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.13), 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  z-index: 9996;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform .38s var(--transition-bounce), opacity .25s ease;
}

.wb-window.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ---- Header ---- */
.wb-header {
  background: var(--black);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-shrink: 0;
}

.wb-header-avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent), #ff7b6e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: .7rem;
  color: white;
  flex-shrink: 0;
  letter-spacing: -.01em;
}

.wb-header-info { flex: 1; min-width: 0; }

.wb-header-name {
  font-weight: 700;
  font-size: .9rem;
  font-family: 'Montserrat', sans-serif;
  line-height: 1.2;
}

.wb-header-sub {
  font-size: .72rem;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: 2px;
}

.wb-status-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: wb-pulse 2.2s ease-in-out infinite;
}

.wb-header-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}

.wb-header-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ---- Messages ---- */
.wb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  scroll-behavior: smooth;
}

.wb-messages::-webkit-scrollbar { width: 3px; }
.wb-messages::-webkit-scrollbar-track { background: transparent; }
.wb-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Message ---- */
.wb-msg {
  display: flex;
  align-items: flex-end;
  gap: .45rem;
  max-width: 88%;
  animation: wb-msg-in .3s var(--transition-spring) both;
}

@keyframes wb-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.wb-msg.bot  { align-self: flex-start; }
.wb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.wb-msg-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff7b6e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .5rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  font-family: 'Montserrat', sans-serif;
}

.wb-msg-text {
  padding: .6rem .95rem;
  border-radius: 18px;
  font-size: .84rem;
  line-height: 1.55;
  font-family: 'Roboto', sans-serif;
  word-break: break-word;
}

.wb-msg.bot .wb-msg-text {
  background: var(--gray-light);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.wb-msg.user .wb-msg-text {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

/* ---- Typing indicator ---- */
.wb-typing {
  display: flex;
  align-items: flex-end;
  gap: .45rem;
  align-self: flex-start;
  animation: wb-msg-in .3s var(--transition-spring) both;
}

.wb-typing-bubble {
  background: var(--gray-light);
  padding: .65rem 1rem;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.wb-dot {
  width: 6px;
  height: 6px;
  background: var(--gray-medium);
  border-radius: 50%;
  animation: wb-dot-bounce 1.4s infinite ease-in-out;
}
.wb-dot:nth-child(2) { animation-delay: .18s; }
.wb-dot:nth-child(3) { animation-delay: .36s; }

@keyframes wb-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ---- Quick Replies ---- */
.wb-quick {
  padding: .1rem 1rem .6rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  flex-shrink: 0;
}

.wb-qbtn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: .32rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  font-family: 'Roboto', sans-serif;
  white-space: nowrap;
  line-height: 1.4;
}

.wb-qbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(224, 64, 53, 0.05);
}

/* ---- Input Area ---- */
.wb-input-row {
  padding: .7rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--white);
}

.wb-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .55rem .85rem;
  font-size: .84rem;
  font-family: 'Roboto', sans-serif;
  background: var(--gray-bg);
  color: var(--text-primary);
  resize: none;
  max-height: 100px;
  min-height: 38px;
  outline: none;
  line-height: 1.5;
  transition: border-color .2s, background .2s;
  overflow-y: auto;
}

.wb-input:focus {
  border-color: var(--accent);
  background: var(--white);
}

.wb-input::placeholder { color: var(--text-muted); }

.wb-send {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
  outline: none;
}

.wb-send:hover:not(:disabled)  { background: var(--accent-dark); transform: scale(1.06); }
.wb-send:disabled { background: var(--gray-medium); cursor: default; }

/* ---- Error message ---- */
.wb-error {
  font-size: .78rem;
  color: var(--accent);
  text-align: center;
  padding: .25rem .5rem;
  flex-shrink: 0;
  font-family: 'Roboto', sans-serif;
  display: none;
}
.wb-error.visible { display: block; }

/* ---- Dark Mode ---- */
[data-theme="dark"] .wb-window {
  background: #1c1f35;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.07);
}

[data-theme="dark"] .wb-msg.bot .wb-msg-text {
  background: #282c46;
  color: #dde1f0;
}

[data-theme="dark"] .wb-typing-bubble {
  background: #282c46;
}

[data-theme="dark"] .wb-dot { background: #6b7280; }

[data-theme="dark"] .wb-qbtn {
  border-color: rgba(255,255,255,0.1);
  color: #9ca3af;
}

[data-theme="dark"] .wb-qbtn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(224,64,53,0.08);
}

[data-theme="dark"] .wb-input-row {
  background: #1c1f35;
  border-top-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .wb-input {
  background: #282c46;
  border-color: rgba(255,255,255,0.1);
  color: #dde1f0;
}

[data-theme="dark"] .wb-input:focus {
  background: #282c46;
  border-color: var(--accent);
}

[data-theme="dark"] .wb-badge,
[data-theme="dark"] .wb-chat-btn { border-color: #1c1f35; }

[data-theme="dark"] .wb-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .wb-window {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
  }

  .wb-chat-btn {
    bottom: 1.5rem;
    right: 1.5rem;
  }
}
