/* ============================================================
   Poptides Chat Widget
   Brand tokens: coral #e8714a, navy #0d1117, white #ffffff
   Manus: feel free to restyle — keep class names intact.
   ============================================================ */

/* ── Root container ─────────────────────────────────────────── */
.pc-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Bubble ─────────────────────────────────────────────────── */
.pc-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e8714a;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232, 113, 74, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}

.pc-bubble:hover,
.pc-bubble:focus-visible {
  transform: scale(1.07);
  box-shadow: 0 6px 20px rgba(232, 113, 74, 0.55);
  outline: none;
}

.pc-bubble--active {
  background: #0d1117;
  box-shadow: 0 4px 16px rgba(13, 17, 23, 0.4);
}

/* ── Panel ──────────────────────────────────────────────────── */
.pc-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.pc-panel[hidden] {
  display: flex; /* keep flex, use opacity/pointer-events to hide */
}

.pc-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ─────────────────────────────────────────────────── */
.pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0d1117;
  color: #fff;
  flex-shrink: 0;
}

.pc-header__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.pc-header__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.pc-header__close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}

.pc-header__close:hover {
  color: #fff;
}

/* ── Messages ───────────────────────────────────────────────── */
.pc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.pc-messages::-webkit-scrollbar { width: 4px; }
.pc-messages::-webkit-scrollbar-track { background: transparent; }
.pc-messages::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 4px; }

/* ── Message rows ───────────────────────────────────────────── */
.pc-msg {
  display: flex;
}

.pc-msg--user {
  justify-content: flex-end;
}

.pc-msg--assistant {
  justify-content: flex-start;
}

.pc-msg__bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pc-msg--user .pc-msg__bubble {
  background: #e8714a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pc-msg--assistant .pc-msg__bubble {
  background: #f3f4f6;
  color: #0d1117;
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ───────────────────────────────────────── */
.pc-msg--typing .pc-msg__bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.pc-msg--typing .pc-msg__bubble span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: pc-bounce 1.2s infinite ease-in-out;
}

.pc-msg--typing .pc-msg__bubble span:nth-child(2) { animation-delay: 0.15s; }
.pc-msg--typing .pc-msg__bubble span:nth-child(3) { animation-delay: 0.30s; }

@keyframes pc-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-5px); }
}

/* ── Input area ─────────────────────────────────────────────── */
.pc-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}

.pc-input {
  flex: 1;
  resize: none;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: #0d1117;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
  overflow-y: auto;
}

.pc-input:focus {
  border-color: #e8714a;
  background: #fff;
}

.pc-input::placeholder {
  color: #9ca3af;
}

.pc-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e8714a;
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.pc-send:hover {
  background: #d4613c;
}

.pc-send:active {
  transform: scale(0.93);
}

.pc-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: none;
}

/* ── Inline links inside assistant bubbles ──────────────────── */
.pc-msg__bubble a.pc-link {
  color: #e8714a;
  text-decoration: underline;
  text-decoration-color: rgba(232, 113, 74, 0.45);
  text-underline-offset: 2px;
}

.pc-msg__bubble a.pc-link:hover {
  text-decoration-color: #e8714a;
}

/* ── Product cards ───────────────────────────────────────────── */
.pc-product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pc-product-card:hover {
  border-color: #e8714a;
  box-shadow: 0 2px 8px rgba(232, 113, 74, 0.14);
}

.pc-product-card__name {
  font-size: 13px;
  font-weight: 600;
  color: #0d1117;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-product-card__btn {
  font-size: 12px;
  color: #e8714a;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Inline shortcode container ─────────────────────────────── */
.poptides-chat-inline {
  /* Populated by JS if shortcode is used — placeholder for future inline mode */
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .pc-root {
    bottom: 16px;
    right: 16px;
  }

  .pc-panel {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 72px;
    height: 420px;
  }
}
