/**
 * PustakInk Smart Assistant - Stylesheet
 * Responsive, accessible, high-performance floating chatbot widget
 */

/* ==========================================================================
   Launcher Floating Button
   ========================================================================== */
#pustakink-chat-launcher {
  position: fixed;
  bottom: 105px;
  right: 30px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35), 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  user-select: none;
  font-family: inherit;
}

#pustakink-chat-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.45), 0 4px 8px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

#pustakink-chat-launcher .launcher-icon-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

#pustakink-chat-launcher .launcher-online-dot {
  position: absolute;
  top: -2px;
  right: -3px;
  width: 9px;
  height: 9px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #2563eb;
  box-shadow: 0 0 6px #10b981;
  animation: pPulseOnline 2s infinite;
}

@keyframes pPulseOnline {
  0% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

#pustakink-chat-launcher .launcher-text {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* ==========================================================================
   Chatbot Window
   ========================================================================== */
#pustakink-chat-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 60px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 48px -8px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999995;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#pustakink-chat-widget.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.pchat-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.pchat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pchat-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.pchat-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #1e293b;
}

.pchat-title-group h6 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.pchat-title-group span {
  font-size: 0.72rem;
  color: #94a3b8;
  display: block;
}

.pchat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pchat-btn-header {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pchat-btn-header:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Chat Body (Messages Stream) */
.pchat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.pchat-body::-webkit-scrollbar {
  width: 5px;
}
.pchat-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.pchat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Chat Bubbles */
.pchat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: pFadeSlide 0.25s ease-out;
}

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

.pchat-msg.bot {
  align-self: flex-start;
}

.pchat-msg.user {
  align-self: flex-end;
}

.pchat-bubble {
  padding: 13px 15px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.58;
  word-break: break-word;
}

.pchat-msg.bot .pchat-bubble {
  background: #ffffff;
  color: #0f172a;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #2563eb;
  box-shadow: 0 3px 12px -2px rgba(15, 23, 42, 0.05);
}

.pchat-msg.user .pchat-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28);
}

/* Paragraphs & Typography */
.pchat-para {
  margin: 0 0 9px 0;
  color: #1e293b;
  line-height: 1.55;
  font-size: 0.86rem;
}
.pchat-para:last-child {
  margin-bottom: 0;
}

/* Headings inside messages */
.pchat-section-header {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  margin: 10px 0 6px 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.pchat-section-header:first-child {
  margin-top: 0;
}

/* Step-by-Step Milestones / Numbered Lists */
.pchat-step-list {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pchat-step-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 11px;
  transition: all 0.2s ease;
}

.pchat-step-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.pchat-step-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.pchat-step-content {
  flex: 1;
  min-width: 0;
}

.pchat-step-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.pchat-step-desc {
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.45;
}

/* Structured Bullet Lists */
.pchat-bullet-list {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pchat-bullet-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.48;
}

.pchat-bullet-icon {
  color: #10b981;
  font-size: 0.8rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.pchat-bullet-text {
  flex: 1;
}

/* Inline Code & Links */
.pchat-inline-code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8em;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

.pchat-link {
  color: #2563eb;
  text-decoration: underline;
  font-weight: 600;
  word-break: break-all;
  transition: color 0.2s;
}
.pchat-link:hover {
  color: #1d4ed8;
  text-decoration: none;
}

.pchat-time {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}
.pchat-msg.user .pchat-time {
  text-align: right;
}

/* Rich Cards (Books) */
.pchat-cards-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 8px 2px;
  margin-top: 6px;
  scroll-snap-type: x mandatory;
}
.pchat-cards-container::-webkit-scrollbar {
  height: 4px;
}
.pchat-cards-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.pchat-card {
  flex: 0 0 180px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
}

.pchat-card-img-wrap {
  width: 100%;
  height: 110px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pchat-card-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.pchat-card-content {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.pchat-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pchat-card-author {
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pchat-card-price {
  font-size: 0.82rem;
  font-weight: 700;
  color: #2563eb;
  margin-top: auto;
  margin-bottom: 6px;
}

.pchat-card-btn {
  display: block;
  text-align: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.pchat-card-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Action Links / Buttons */
.pchat-actions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pchat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.2s;
}

.pchat-action-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Feedback Row */
.pchat-feedback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.72rem;
  color: #94a3b8;
}

.pchat-feedback-btn {
  background: none;
  border: 1px solid #e2e8f0;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 0.72rem;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.pchat-feedback-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.pchat-feedback-btn.rated {
  background: #ecfdf5;
  border-color: #10b981;
  color: #059669;
  cursor: default;
}

/* Quick Replies Strip */
.pchat-quick-replies {
  padding: 8px 12px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.pchat-quick-replies::-webkit-scrollbar {
  display: none;
}

.pchat-pill {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.pchat-pill:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* Footer / Input */
.pchat-footer {
  padding: 10px 12px 8px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.pchat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pchat-input-row:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: #ffffff;
}

.pchat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: #0f172a;
  padding: 6px 0;
}

.pchat-input::placeholder {
  color: #94a3b8;
  font-size: 0.84rem;
}

.pchat-btn-send {
  background: #2563eb;
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.pchat-btn-send:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

.pchat-btn-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

.pchat-footer-brand {
  text-align: center;
  font-size: 0.64rem;
  color: #94a3b8;
  margin-top: 6px;
  letter-spacing: 0.3px;
}

/* Typing Indicator */
.pchat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  width: fit-content;
  margin-top: 4px;
  animation: pFadeSlide 0.2s ease-out;
}

.pchat-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: pBounce 1.4s infinite ease-in-out both;
}

.pchat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.pchat-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.pchat-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes pBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive (Mobile & Small Tablets) */
@media (max-width: 576px) {
  #pustakink-chat-launcher {
    bottom: 80px;
    right: 16px;
    padding: 10px 14px;
  }
  #pustakink-chat-launcher .launcher-text {
    font-size: 0.8rem;
  }
  #pustakink-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
}

/* ==========================================================================
   In-Chat Confirmation Modal (Professional UI Popup)
   ========================================================================== */
.pchat-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pchat-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.pchat-modal-card {
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 20px 48px -10px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 320px;
  padding: 26px 20px 20px 20px;
  text-align: center;
  transform: translateY(18px) scale(0.92);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.pchat-modal-overlay.active .pchat-modal-card {
  transform: translateY(0) scale(1);
}

.pchat-modal-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px auto;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  border: 2px solid rgba(37, 99, 235, 0.22);
  animation: pSpinSlow 8s linear infinite;
}

@keyframes pSpinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pchat-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.pchat-modal-desc {
  font-size: 0.825rem;
  color: #64748b;
  margin: 0 0 20px 0;
  line-height: 1.45;
}

.pchat-modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pchat-modal-btn {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}

.pchat-modal-btn-cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.pchat-modal-btn-cancel:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.pchat-modal-btn-confirm {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.pchat-modal-btn-confirm:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}
