/* ── Chat Widget ─────────────────────────────────────────────────────────── */
#chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 400px;
  height: 580px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(0,48,135,0.2);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  border: 1px solid #D1DCF0;
}

#chat-panel.open { display: flex; }

/* ── Chat Header ─────────────────────────────────────────────────────────── */
.chat-header {
  background: #003087;
  color: white;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chat-header-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  background: #0070CC;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-header-name {
  font-weight: 700;
  font-size: 15px;
}

.chat-header-status {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #4ADE80;
  border-radius: 50%;
  display: inline-block;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

.chat-header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-header-btn:hover { background: rgba(255,255,255,0.25); }
.chat-header-btn svg { width: 14px; height: 14px; }

/* ── Persona Bar ─────────────────────────────────────────────────────────── */
.persona-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  overflow: visible;
  flex-wrap: nowrap;
}

.persona-label {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
}

.persona-btn {
  position: relative;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px;
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.persona-btn:hover, .persona-btn.active {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.5);
}

.persona-btn.active {
  background: white;
  color: #003087;
  font-weight: 700;
}

/* Persona tooltip */
.persona-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: white;
  border: 1px solid #D1DCF0;
  border-radius: 12px;
  padding: 12px;
  width: 220px;
  box-shadow: 0 8px 24px rgba(0,48,135,0.15);
  color: #1A1A2E;
  z-index: 2000;
  pointer-events: none;
}

.persona-btn:hover .persona-tooltip { display: block; }

.persona-tooltip-name {
  font-weight: 700;
  font-size: 13px;
  color: #003087;
  margin-bottom: 2px;
}

.persona-tooltip-pet {
  font-size: 11px;
  color: #0070CC;
  font-weight: 600;
  margin-bottom: 8px;
}

.persona-tooltip-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #718096;
  margin-top: 8px;
  margin-bottom: 4px;
}

.persona-tooltip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.persona-tooltip-tag {
  background: #EBF0F8;
  color: #003087;
  border-radius: 100px;
  font-size: 10px;
  padding: 2px 7px;
  font-weight: 500;
}

.persona-clear-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px;
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  display: none;
}

.persona-clear-btn:hover { color: white; border-color: rgba(255,255,255,0.5); }
.persona-clear-btn.visible { display: block; }

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

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #D1DCF0; border-radius: 2px; }

/* Message bubbles */
.message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #003087;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.message-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.bot .message-bubble {
  background: #EBF0F8;
  color: #1A1A2E;
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
  background: #0070CC;
  color: white;
  border-bottom-right-radius: 4px;
}

/* Quick replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.quick-reply-btn {
  background: white;
  border: 1.5px solid #0070CC;
  color: #0070CC;
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.quick-reply-btn:hover {
  background: #0070CC;
  color: white;
}

/* Product card in chat — HORIZONTAL layout */
.chat-product-card {
  background: white;
  border: 1px solid #D1DCF0;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  gap: 0;
  margin: 4px 0;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  max-width: 300px;
}

.chat-product-card:hover {
  box-shadow: 0 4px 16px rgba(0,48,135,0.12);
  border-color: #0070CC;
}

.chat-product-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: #EBF0F8;
  flex-shrink: 0;
  padding: 6px;
}

.chat-product-img[src=""], .chat-product-img:not([src]) {
  background: #EBF0F8;
}

.chat-product-info {
  padding: 8px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.chat-product-brand {
  font-size: 10px;
  font-weight: 600;
  color: #0070CC;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.chat-product-name {
  font-size: 12px;
  font-weight: 600;
  color: #1A1A2E;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-product-price {
  font-size: 14px;
  font-weight: 700;
  color: #003087;
}

.chat-product-autoship {
  font-size: 10px;
  color: #0070CC;
}

.chat-product-reason {
  font-size: 11px;
  color: #718096;
  margin-top: 4px;
  font-style: italic;
  line-height: 1.4;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.typing-bubble {
  background: #EBF0F8;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: #718096;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Appointment flow in chat */
.appointment-container {
  background: white;
  border: 1px solid #D1DCF0;
  border-radius: 14px;
  overflow: hidden;
  max-width: 320px;
  margin: 4px 0;
}

.appointment-title {
  background: #003087;
  color: white;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
}

.store-cards-wrap {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.store-card {
  border: 2px solid #E8EEF8;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.store-card:hover, .store-card.selected {
  border-color: #0070CC;
  background: #EBF0F8;
}

.store-name {
  font-weight: 700;
  font-size: 13px;
  color: #003087;
  margin-bottom: 2px;
}

.store-distance {
  font-size: 11px;
  color: #0070CC;
  font-weight: 600;
}

.store-address {
  font-size: 11px;
  color: #718096;
}

.time-slots-wrap {
  padding: 10px;
}

.day-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.day-tab {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1.5px solid #D1DCF0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #4A5568;
  background: white;
  transition: all 0.15s;
}

.day-tab:hover, .day-tab.active {
  background: #0070CC;
  border-color: #0070CC;
  color: white;
}

.time-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.time-slot {
  padding: 7px 4px;
  text-align: center;
  border: 1.5px solid #D1DCF0;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: #4A5568;
  background: white;
  transition: all 0.15s;
}

.time-slot:hover, .time-slot.selected {
  background: #0070CC;
  border-color: #0070CC;
  color: white;
}

.time-slot.booked {
  opacity: 0.4;
  cursor: not-allowed;
}

.appt-confirm-btn {
  display: block;
  width: calc(100% - 20px);
  margin: 10px;
  padding: 10px;
  background: #0070CC;
  color: white;
  border: none;
  border-radius: 100px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.appt-confirm-btn:hover { background: #003087; }
.appt-confirm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.appt-confirmation-card {
  background: linear-gradient(135deg, #EBF0F8 0%, #D6E8FF 100%);
  border: 2px solid #0070CC;
  border-radius: 14px;
  padding: 16px;
  max-width: 300px;
}

.appt-confirmation-title {
  font-weight: 800;
  color: #003087;
  font-size: 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.appt-detail {
  font-size: 12px;
  color: #4A5568;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
}

.appt-detail-label {
  font-weight: 700;
  color: #003087;
  min-width: 60px;
}

.appt-id {
  margin-top: 10px;
  font-size: 11px;
  color: #718096;
}

/* Virtual vet banner in chat */
.virtual-vet-card {
  background: linear-gradient(135deg, #D6E8FF 0%, #B8D4F4 100%);
  border: 1px solid #B8D4F4;
  border-radius: 14px;
  padding: 14px 16px;
  max-width: 300px;
}

.virtual-vet-title {
  font-weight: 800;
  color: #003087;
  font-size: 14px;
  margin-bottom: 4px;
}

.virtual-vet-subtitle {
  font-size: 12px;
  color: #4A5568;
  margin-bottom: 12px;
}

.virtual-vet-price {
  font-size: 11px;
  color: #0070CC;
  font-weight: 700;
  margin-bottom: 10px;
}

.virtual-vet-btn {
  display: inline-block;
  background: #0070CC;
  color: white;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.virtual-vet-btn:hover { background: #003087; }

/* Autoship card in chat */
.autoship-card {
  background: white;
  border: 2px solid #0070CC;
  border-radius: 14px;
  padding: 14px 16px;
  max-width: 300px;
}

.autoship-title {
  font-weight: 800;
  color: #003087;
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.autoship-savings {
  background: #EBF0F8;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.autoship-price-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 2px;
}

.autoship-price-row .label { color: #718096; }
.autoship-price-row .value { font-weight: 700; color: #003087; }
.autoship-price-row .savings { font-weight: 700; color: #22C55E; }

.autoship-frequency {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.freq-btn {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1.5px solid #D1DCF0;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: #4A5568;
  transition: all 0.15s;
}

.freq-btn:hover, .freq-btn.selected {
  background: #0070CC;
  border-color: #0070CC;
  color: white;
}

.autoship-cta {
  display: block;
  width: 100%;
  padding: 10px;
  background: #0070CC;
  color: white;
  border: none;
  border-radius: 100px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.autoship-cta:hover { background: #003087; }

/* ── Chat Input ────────────────────────────────────────────────────────────── */
.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #E8EEF8;
  background: white;
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1.5px solid #D1DCF0;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.chat-input:focus { border-color: #0070CC; }

.chat-send-btn {
  width: 38px;
  height: 38px;
  background: #0070CC;
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.chat-send-btn:hover { background: #003087; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send-btn svg { width: 16px; height: 16px; }

/* ── Pop-out chat page ─────────────────────────────────────────────────────── */
.chat-page-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #EBF0F8;
}

.chat-page-layout .chat-header {
  flex-shrink: 0;
  border-radius: 0;
}

.chat-page-layout .chat-messages {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.chat-page-layout .chat-input-area {
  max-width: 800px;
  width: 100%;
  margin: 0 auto 20px;
  border-radius: 20px;
  border: 1px solid #D1DCF0;
  box-shadow: 0 2px 10px rgba(0,48,135,0.08);
}

.chat-popout-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: white;
  border-bottom: 1px solid #E8EEF8;
  color: #0070CC;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}

.chat-popout-back:hover { background: #EBF0F8; }
