/* WP Chatbot — Amy default widget styles */
/* All colours driven by CSS variables — fully overridable via admin */

:root {
  --wpcb-primary:    #5B4FE8;
  --wpcb-secondary:  #F5F5FF;
  --wpcb-font:       inherit;
  --wpcb-radius:     16px;
  --wpcb-radius-sm:  10px;
  --wpcb-shadow:     0 8px 32px rgba(91,79,232,0.18), 0 2px 8px rgba(0,0,0,0.10);
  --wpcb-bubble-sz:  56px;
  --wpcb-panel-w:    380px;
  --wpcb-panel-h:    580px;
  --wpcb-bot-bg:     #ffffff;
  --wpcb-user-bg:    var(--wpcb-primary);
  --wpcb-user-color: #ffffff;
  --wpcb-bot-color:  #1a1a2e;
  --wpcb-header-bg:  var(--wpcb-primary);
  --wpcb-header-color: #ffffff;
  --wpcb-input-bg:   #f9f9ff;
  --wpcb-star-color: #f5a623;
}

/* ── Bubble ────────────────────────────────────────────────────────────────── */

#wpcb-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: var(--wpcb-bubble-sz);
  height: var(--wpcb-bubble-sz);
  border-radius: 50%;
  background: var(--wpcb-primary);
  box-shadow: var(--wpcb-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#wpcb-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(91,79,232,0.28);
}

#wpcb-bubble:active { transform: scale(0.97); }

#wpcb-bubble svg,
#wpcb-bubble img {
  width: 28px;
  height: 28px;
  pointer-events: none;
}

#wpcb-bubble img { border-radius: 50%; object-fit: cover; }

/* Unread badge */
#wpcb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

/* Position: left */
.wpcb-pos-left #wpcb-bubble,
.wpcb-pos-left #wpcb-panel {
  right: auto;
  left: 24px;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */

#wpcb-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 99998;
  width: var(--wpcb-panel-w);
  height: var(--wpcb-panel-h);
  background: #fff;
  border-radius: var(--wpcb-radius);
  box-shadow: var(--wpcb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), opacity 0.22s ease;
  font-family: var(--wpcb-font);
}

#wpcb-panel.wpcb-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

#wpcb-header {
  background: var(--wpcb-header-bg);
  color: var(--wpcb-header-color);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#wpcb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

#wpcb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#wpcb-header-info { flex: 1; min-width: 0; }

#wpcb-bot-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#wpcb-status {
  font-size: 11px;
  opacity: 0.82;
  display: flex;
  align-items: center;
  gap: 4px;
}

#wpcb-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

#wpcb-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(255,255,255,0.85);
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}

#wpcb-close-btn:hover { background: rgba(255,255,255,0.15); }

/* ── Messages ──────────────────────────────────────────────────────────────── */

#wpcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#wpcb-messages::-webkit-scrollbar { width: 4px; }
#wpcb-messages::-webkit-scrollbar-thumb { background: rgba(91,79,232,0.18); border-radius: 2px; }

.wpcb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: wpcbFadeIn 0.2s ease;
}

.wpcb-msg:has(.wpcb-escalation-form),
.wpcb-msg:has(.wpcb-otp-form),
.wpcb-msg:has(.wpcb-rating-widget) {
  max-width: 100%;
  width: 100%;
}

@keyframes wpcbFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.wpcb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wpcb-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wpcb-msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.wpcb-bubble-text {
  padding: 10px 14px;
  border-radius: var(--wpcb-radius-sm);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  max-width: 100%;
}

.wpcb-msg-bot .wpcb-bubble-text {
  background: var(--wpcb-bot-bg);
  color: var(--wpcb-bot-color);
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}

.wpcb-msg-user .wpcb-bubble-text {
  background: var(--wpcb-user-bg);
  color: var(--wpcb-user-color);
  border-bottom-right-radius: 4px;
}

/* Markdown-style bold */
.wpcb-bubble-text strong { font-weight: 600; }
.wpcb-bubble-text a { color: var(--wpcb-primary); text-decoration: underline; }
.wpcb-bubble-text ul, .wpcb-bubble-text ol { padding-left: 18px; margin: 6px 0; }
.wpcb-bubble-text li { margin-bottom: 3px; }

/* Typing indicator */
.wpcb-typing { display: flex; gap: 4px; align-items: center; padding: 10px 14px; }
.wpcb-typing span {
  width: 7px; height: 7px;
  background: #bbb;
  border-radius: 50%;
  animation: wpcbBounce 1.2s infinite;
}
.wpcb-typing span:nth-child(2) { animation-delay: 0.2s; }
.wpcb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes wpcbBounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── Special UI components ─────────────────────────────────────────────────── */

/* Star rating */
.wpcb-rating-widget {
  background: var(--wpcb-secondary);
  border-radius: var(--wpcb-radius-sm);
  padding: 14px;
  margin-top: 6px;
}

.wpcb-rating-widget p {
  font-size: 13px;
  color: #555;
  margin: 0 0 10px;
  text-align: center;
}

.wpcb-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.wpcb-star {
  font-size: 30px;
  cursor: pointer;
  color: #ddd;
  transition: color 0.15s, transform 0.12s;
  line-height: 1;
  user-select: none;
}

.wpcb-star:hover,
.wpcb-star.wpcb-star-active { color: var(--wpcb-star-color); transform: scale(1.18); }

.wpcb-star-label {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: 6px;
  min-height: 16px;
}

/* Feedback input area */
.wpcb-feedback-area {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wpcb-feedback-area textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--wpcb-font);
  resize: none;
  height: 72px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.wpcb-feedback-area textarea:focus { border-color: var(--wpcb-primary); }

/* OTP form */
.wpcb-otp-form {
  background: var(--wpcb-secondary);
  border-radius: var(--wpcb-radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.wpcb-otp-form input {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--wpcb-font);
  transition: border-color 0.15s;
}

.wpcb-otp-form input:focus { border-color: var(--wpcb-primary); }

.wpcb-otp-digits {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.wpcb-otp-digits input {
  width: 42px !important;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

/* Escalation form */
.wpcb-escalation-form {
  background: var(--wpcb-secondary);
  border-radius: var(--wpcb-radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.wpcb-escalation-form label {
  font-size: 12px;
  color: #666;
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}

.wpcb-escalation-form input,
.wpcb-escalation-form textarea,
.wpcb-escalation-form select {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--wpcb-font);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.wpcb-escalation-form input:focus,
.wpcb-escalation-form textarea:focus,
.wpcb-escalation-form select:focus { border-color: var(--wpcb-primary); }

.wpcb-escalation-form textarea { height: 72px; resize: none; }

/* Options list (eservice selection) */
.wpcb-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.wpcb-option-btn {
  background: #fff;
  border: 1.5px solid var(--wpcb-primary);
  color: var(--wpcb-primary);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--wpcb-font);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.wpcb-option-btn:hover {
  background: var(--wpcb-primary);
  color: #fff;
}

/* Certificate / invoice download list */
.wpcb-doc-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.wpcb-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
}
.wpcb-doc-item a {
  color: var(--wpcb-primary);
  font-weight: 600;
  text-decoration: none;
  font-size: 12px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.wpcb-btn {
  background: var(--wpcb-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--wpcb-font);
  transition: opacity 0.15s;
  width: 100%;
}

.wpcb-btn:hover { opacity: 0.88; }
.wpcb-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wpcb-btn-secondary {
  background: transparent;
  color: var(--wpcb-primary);
  border: 1.5px solid var(--wpcb-primary);
}

.wpcb-btn-secondary:hover { background: var(--wpcb-secondary); opacity: 1; }

/* ── Input row ──────────────────────────────────────────────────────────────── */

#wpcb-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #eee;
  background: var(--wpcb-input-bg);
  flex-shrink: 0;
}

#wpcb-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--wpcb-font);
  outline: none;
  resize: none;
  max-height: 96px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.15s;
  background: #fff;
}

#wpcb-input:focus { border-color: var(--wpcb-primary); }

#wpcb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wpcb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#wpcb-send-btn:hover { opacity: 0.85; }
#wpcb-send-btn svg { width: 18px; height: 18px; }

/* ── Closed state overlay ──────────────────────────────────────────────────── */

#wpcb-closed-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--wpcb-radius);
  display: none;
}

#wpcb-closed-overlay p {
  font-size: 15px;
  color: #555;
  text-align: center;
  max-width: 260px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 440px) {
  #wpcb-panel {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  #wpcb-bubble { bottom: 16px; right: 16px; }
  .wpcb-pos-left #wpcb-bubble { left: 16px; }
}
