/* ── Punjab Saathi Chatbot Widget ──
   Design tokens matched to the real site (public/css/custom.css,
   public/css/psk-services-detail.css) — navy #040e26/#0f2050, orange
   #fc5e28, Roboto (already loaded globally, no local override needed). */
/* Alpine hasn't mounted yet on first paint (alpine.min.js loads with
   `defer`) — without this, #psk-chatbot-window briefly renders in its
   default visible state before Alpine applies x-show="open" (open is
   false), which looks like the chat window flashing open on page load. */
[x-cloak] { display: none !important; }

:root {
  --psk-primary:   #040e26;
  --psk-primary-2: #0f2050;
  --psk-accent:    #fc5e28;
  --psk-light:     #eef2f9;
  --psk-text:      #1f2937;
  --psk-muted:     #6b7280;
  --psk-border:    #d1d5db;
  --psk-radius:    14px;
  --psk-shadow:    0 8px 40px rgba(4,14,38,0.22);
}

#psk-chatbot-btn {
  /* bottom:96px, not 28px — the contact page has its own WhatsApp
     bubble fixed at bottom:24px/right:24px (same corner, same size);
     sitting above it keeps both buttons visible and clickable instead
     of stacking directly on top of each other. */
  position: fixed; bottom: 96px; right: 28px; z-index: 9998;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--psk-primary) 0%, var(--psk-primary-2) 100%);
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(4,14,38,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#psk-chatbot-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(4,14,38,0.5); }
#psk-chatbot-btn svg { width: 28px; height: 28px; fill: #fff; }

#psk-chatbot-window {
  position: fixed; bottom: 168px; right: 28px; z-index: 9999;
  width: 390px; max-height: 600px;
  background: #fff;
  border-radius: var(--psk-radius);
  box-shadow: var(--psk-shadow);
  display: flex; flex-direction: column;
  transition: opacity 0.25s, transform 0.25s;
  font-family: 'Roboto', sans-serif;
  overflow: hidden;
}
#psk-chatbot-window[x-show] { transform: translateY(16px) scale(0.97); }

.psk-header {
  background: linear-gradient(135deg, var(--psk-primary) 0%, var(--psk-primary-2) 100%);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.psk-header-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.psk-header-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.psk-header-info { flex: 1; min-width: 0; }
.psk-header-title { color: #fff; font-size: 15px; font-weight: 600; margin: 0; }
.psk-header-sub   { color: rgba(255,255,255,0.75); font-size: 12px; margin: 2px 0 0; }
.psk-header-badge {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.15); border-radius: 20px;
  padding: 3px 10px; color: #fff; font-size: 11px; flex-shrink: 0;
}
.psk-header-badge::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%; background: #4ade80;
}
.psk-close-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.8); padding: 4px;
  display: flex; align-items: center; justify-content: center;
}
.psk-close-btn:hover { color: #fff; }

/* Language selector */
.psk-lang-bar {
  background: var(--psk-light); border-bottom: 1px solid var(--psk-border);
  padding: 6px 14px; display: flex; align-items: center; gap: 6px;
}
.psk-lang-btn {
  padding: 3px 10px; border-radius: 20px; border: 1px solid var(--psk-border);
  background: #fff; cursor: pointer; font-size: 12px; color: var(--psk-muted);
  transition: all 0.15s;
}
.psk-lang-btn.active, .psk-lang-btn:hover {
  background: var(--psk-accent); color: #fff; border-color: var(--psk-accent);
}

/* Messages area */
.psk-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f8faff;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}
.psk-msg-row { display: flex; gap: 8px; align-items: flex-end; }
.psk-msg-row.user { flex-direction: row-reverse; }

/* Flex items default to min-width:auto, which floors their shrink at the
   content's min-content size — for text with word-break enabled, that
   floor can be as small as a single glyph, letting the bubble get
   squeezed far narrower than it needs and forcing short words to break
   mid-word (e.g. "Thanks" -> "Tha"/"nks"). min-width:0 removes that floor
   so the bubble sizes to its actual content instead. */
.psk-msg-content { min-width: 0; }

.psk-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--psk-primary); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.psk-msg-row.user .psk-avatar { background: var(--psk-accent); }

.psk-bubble {
  display: inline-block; width: fit-content; max-width: 78%;
  padding: 10px 14px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word;
}
.psk-bubble.bot  {
  background: #fff; color: var(--psk-text);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.psk-bubble.user {
  background: var(--psk-primary); color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.psk-bubble strong { font-weight: 600; }
.psk-bubble ul { margin: 6px 0 0 16px; padding: 0; }
.psk-bubble li { margin-bottom: 3px; }

.psk-timestamp {
  font-size: 10px; color: var(--psk-muted); margin-top: 3px;
  text-align: right;
}
.psk-msg-row.bot .psk-timestamp { text-align: left; }

/* Sources pill */
.psk-sources { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.psk-source-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 12px;
  background: var(--psk-light); color: var(--psk-primary);
  border: 1px solid rgba(4,14,38,0.15);
}

/* Quick replies */
.psk-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.psk-quick-btn {
  padding: 6px 12px; border-radius: 20px;
  border: 1.5px solid var(--psk-accent); background: #fff;
  color: var(--psk-accent); font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.psk-quick-btn:hover { background: var(--psk-accent); color: #fff; }

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

/* Input area */
.psk-input-area {
  padding: 10px 12px; border-top: 1px solid var(--psk-border);
  background: #fff; flex-shrink: 0;
}
.psk-input-row { display: flex; align-items: center; gap: 8px; }
.psk-chat-input {
  flex: 1; padding: 10px 14px; border-radius: 24px;
  border: 1.5px solid var(--psk-border);
  font-size: 13.5px; outline: none; resize: none;
  font-family: inherit; background: var(--psk-light);
  transition: border-color 0.15s;
  max-height: 100px; overflow-y: auto;
}
.psk-chat-input:focus { border-color: var(--psk-accent); background: #fff; }
.psk-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--psk-accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s; flex-shrink: 0;
}
.psk-send-btn:hover { background: #e0501f; }
.psk-send-btn:active { transform: scale(0.94); }
.psk-send-btn svg { width: 18px; height: 18px; fill: #fff; }
.psk-send-btn:disabled { background: var(--psk-border); cursor: not-allowed; }

.psk-input-hint {
  font-size: 10px; color: var(--psk-muted); margin-top: 6px; text-align: center;
}

/* Status pill in message */
.psk-status-approved,
.psk-status-completed { color: #15803d; font-weight: 600; }
.psk-status-pending   { color: #d97706; font-weight: 600; }
.psk-status-rejected  { color: #dc2626; font-weight: 600; }

@media (max-width: 480px) {
  #psk-chatbot-window { width: calc(100vw - 24px); right: 12px; bottom: 158px; max-height: 70vh; }
  #psk-chatbot-btn { right: 12px; width: 56px; height: 56px; }
  .psk-bubble { max-width: 85%; }
  .psk-send-btn { width: 44px; height: 44px; }
}
