/* ============================================================
   Peotuju Chatbot — Joosep
   ============================================================ */

#peotuju-chatbot-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---- Toggle button ---- */
#pcb-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 18px 10px 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  font-size: 15px;
  font-weight: 600;
  transition: transform .15s, box-shadow .15s, background .15s;
  position: relative;
}
#pcb-toggle:hover {
  background: #c1121f;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.24);
}
#pcb-toggle-avatar svg {
  display: block;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5);
}

/* Unread badge */
#pcb-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ffd60a;
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pcb-pulse 1.5s infinite;
}
@keyframes pcb-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* ---- Proactive bubble ---- */
#pcb-bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: 300px;
  background: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
  padding: 14px 16px 14px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(10px) scale(.96);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
#pcb-bubble.pcb-bubble-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#pcb-bubble-avatar svg {
  border-radius: 50%;
  flex-shrink: 0;
}
#pcb-bubble-content { flex: 1; }
#pcb-bubble-text {
  margin: 0 0 10px;
  font-size: 14px;
  color: #1a1a1a;
  line-height: 1.5;
}
#pcb-bubble-actions {
  display: flex;
  gap: 6px;
}
#pcb-bubble-yes {
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
#pcb-bubble-yes:hover { background: #c1121f; }
#pcb-bubble-no {
  background: none;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
#pcb-bubble-no:hover { border-color: #aaa; color: #555; }
#pcb-bubble-close {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-top: -2px;
  transition: color .15s;
}
#pcb-bubble-close:hover { color: #888; }

/* ---- Chat window ---- */
#pcb-window {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
#pcb-window.pcb-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Header ---- */
#pcb-header {
  background: #e63946;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#pcb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
#pcb-header-avatar svg {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  display: block;
}
#pcb-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}
#pcb-status {
  font-size: 11px;
  opacity: .85;
  margin-top: 1px;
}
#pcb-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}
#pcb-close:hover { color: #fff; }

/* ---- Messages ---- */
#pcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  background: #f8f8f8;
}
#pcb-messages::-webkit-scrollbar { width: 4px; }
#pcb-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.pcb-msg-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.pcb-msg-wrap--user {
  flex-direction: row-reverse;
}
.pcb-msg-avatar {
  flex-shrink: 0;
  margin-bottom: 2px;
}
.pcb-msg-avatar svg { border-radius: 50%; display: block; }

.pcb-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.pcb-msg--user {
  background: #e63946;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pcb-msg--bot {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.pcb-msg--bot a {
  color: #c1121f;
  text-decoration: underline;
  font-weight: 600;
}
.pcb-msg--bot ul { margin: 6px 0 0; padding-left: 16px; }
.pcb-msg--bot li { margin-bottom: 4px; }

/* ---- Typing indicator ---- */
.pcb-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  min-width: 52px;
}
.pcb-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ccc;
  animation: pcb-bounce 1.1s infinite ease-in-out;
}
.pcb-typing span:nth-child(2) { animation-delay: .18s; }
.pcb-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes pcb-bounce {
  0%,80%,100% { transform: scale(.8); opacity: .5; }
  40%         { transform: scale(1.2); opacity: 1; }
}

/* ---- Input row ---- */
/* #pcb-input-row old border-top removed — moved to #pcb-footer */
#pcb-input-row-REMOVED {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
}
#pcb-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  background: #f8f8f8;
}
#pcb-input:focus { border-color: #e63946; background: #fff; }
#pcb-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: #e63946;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#pcb-send:hover { background: #c1121f; transform: scale(1.05); }
#pcb-send:disabled, #pcb-input:disabled { opacity: .55; }

/* ---- Mobile ---- */
@media (max-width: 420px) {
  #peotuju-chatbot-root { bottom: 16px; right: 16px; }
  #pcb-window { width: calc(100vw - 32px); }
  #pcb-bubble { width: calc(100vw - 64px); }
  #pcb-toggle-label { display: none; }
  #pcb-toggle { padding: 10px; border-radius: 50%; }
}

/* ---- Transcript bar ---- */
#pcb-footer {
  display: flex;
  flex-direction: column;
  border-top: 1px solid #eee;
  background: #fff;
}
/* #pcb-input-row old border-top removed — moved to #pcb-footer */
#pcb-input-row-REMOVED {
  display: flex;
  gap: 8px;
  padding: 10px 12px 8px;
}
#pcb-transcript-bar {
  display: none;
  justify-content: center;
  padding: 0 12px 10px;
}
#pcb-transcript-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 20px;
  transition: color .15s, background .15s;
  font-family: inherit;
}
#pcb-transcript-btn:hover {
  color: #e63946;
  background: #fff3f3;
}

/* ---- Modal overlay ---- */
#pcb-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
#pcb-modal.pcb-modal-visible {
  opacity: 1;
  pointer-events: auto;
}
#pcb-modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  overflow: hidden;
  transform: translateY(10px) scale(.97);
  transition: transform .25s;
}
#pcb-modal.pcb-modal-visible #pcb-modal-box {
  transform: translateY(0) scale(1);
}
#pcb-modal-header {
  background: #e63946;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}
#pcb-modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  transition: color .15s;
}
#pcb-modal-close:hover { color: #fff; }
#pcb-modal-body {
  padding: 18px 18px 8px;
}
.pcb-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 5px;
}
#pcb-modal-body input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}
#pcb-modal-body input:focus { border-color: #e63946; }
#pcb-modal-status {
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 6px;
}
.pcb-status-ok    { color: #2e7d32; font-weight: 600; }
.pcb-status-error { color: #c62828; }
#pcb-modal-footer {
  padding: 12px 18px 18px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.pcb-btn-primary {
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.pcb-btn-primary:hover:not(:disabled) { background: #c1121f; }
.pcb-btn-primary:disabled { opacity: .65; cursor: not-allowed; }
.pcb-btn-secondary {
  background: none;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
}
.pcb-btn-secondary:hover { border-color: #aaa; color: #333; }
