/* ── Price Rite Chat Widget ──────────────────────────────────── */

#pr-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #B45309;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(180, 83, 9, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
#pr-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(180, 83, 9, 0.5);
}
#pr-chat-bubble.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
#pr-chat-bubble svg { pointer-events: none; }

/* Panel -- desktop */
#pr-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-height: 560px;
  height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#pr-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
#pr-chat-header {
  background: linear-gradient(135deg, #0A1628 0%, #1A2B3D 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#pr-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pr-chat-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #B45309, #D97706);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}
.pr-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#pr-chat-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
#pr-chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}
.pr-status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pr-pulse 2s infinite;
}
@keyframes pr-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
#pr-chat-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
#pr-chat-close:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* Messages */
#pr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fb;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.pr-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: pr-msg-in 0.2s ease;
}
@keyframes pr-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.pr-msg-user {
  align-self: flex-end;
  background: #B45309;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pr-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: #1a2b3d;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.pr-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.pr-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: pr-bounce 1.2s infinite;
}
.pr-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.pr-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pr-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input */
#pr-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #edf0f3;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#pr-chat-input {
  flex: 1;
  border: 1.5px solid #d1d5db;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
#pr-chat-input:focus {
  border-color: #B45309;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1);
}
#pr-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #B45309;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
#pr-chat-send:hover { background: #92400E; transform: scale(1.05); }
#pr-chat-send:disabled { background: #d4a574; cursor: default; transform: none; }

/* Quick Action Chips */
.pr-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  animation: pr-msg-in 0.25s ease;
}
.pr-chip {
  background: #fff;
  border: 1.5px solid #B45309;
  color: #B45309;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.pr-chip:hover {
  background: #B45309;
  color: #fff;
  transform: translateY(-1px);
}
.pr-chip:active {
  transform: translateY(0);
}

/* Phone link in messages */
.pr-phone-link {
  color: #B45309;
  text-decoration: none;
  font-weight: 600;
}
.pr-phone-link:hover {
  text-decoration: underline;
}

/* Nudge tooltip */
#pr-nudge {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  background: #0A1628;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: pr-nudge-in 0.3s ease;
}
#pr-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: #0A1628;
  transform: rotate(45deg);
}
@keyframes pr-nudge-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Demo badge */
.pr-demo-badge {
  background: rgba(180, 83, 9, 0.1);
  color: #B45309;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

/* ── Mobile: fullscreen takeover ─────────────────────────── */
@media (max-width: 640px) {
  #pr-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  #pr-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: none;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    transform: translateY(100%);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #pr-chat-panel.open {
    transform: translateY(0);
  }

  #pr-chat-header {
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }

  #pr-chat-close {
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  #pr-chat-messages {
    padding: 14px 16px;
  }

  #pr-chat-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  #pr-chat-input {
    font-size: 16px;
    padding: 10px 16px;
  }

  .pr-msg {
    max-width: 88%;
    font-size: 15px;
  }
}

/* Body scroll lock when chat is open on mobile */
body.pr-chat-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}
