/* ═══════════════════════════════════════════════════════════════
   Pulsessivo WP Chatbot - Styles
   Mirrors the Next.js ChatBot component design exactly
   ═══════════════════════════════════════════════════════════════ */

/* Reset & container */
#pulsessivo-chatbot *,
#pulsessivo-chatbot *::before,
#pulsessivo-chatbot *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#pulsessivo-chatbot {
  position: fixed;
  bottom: 64px;
  right: 24px;
  z-index: 99999;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  direction: ltr;
}

/* ─── Toggle Button ──────────────────────────────── */

.pcb-toggle-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
  background: #171717;
  color: #fff;
}

.pcb-toggle-btn:hover {
  transform: scale(1.1);
}

.pcb-toggle-btn svg {
  width: 56px;
  height: 56px;
}

/* ─── Chat Window ────────────────────────────────── */

.pcb-window {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease-in-out;
  overflow: hidden;
}

.pcb-window.pcb-normal {
  width: 384px;
  height: 500px;
}

.pcb-window.pcb-expanded {
  width: 90vw;
  max-width: 768px;
  height: 80vh;
}

@media (max-width: 640px) {
  .pcb-window.pcb-normal {
    width: 320px;
  }
}

/* ─── Header ─────────────────────────────────────── */

.pcb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #cccccc;
}

.pcb-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pcb-header-logo {
  width: 24px;
  height: auto;
}

.pcb-header-title {
  font-weight: 500;
  font-size: 14px;
  color: #171717;
}

.pcb-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pcb-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  transition: background 0.15s ease;
}

.pcb-icon-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.pcb-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ─── Messages Area ──────────────────────────────── */

.pcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
}

.pcb-messages-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
  font-size: 14px;
}

/* ─── Message Row ────────────────────────────────── */

.pcb-msg-row {
  display: flex;
  width: 100%;
}

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

.pcb-msg-row.pcb-ai {
  justify-content: flex-start;
}

.pcb-msg-avatar {
  min-width: 24px;
  margin-right: 8px;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
}

.pcb-msg-avatar img {
  width: 20px;
  height: auto;
}

.pcb-msg-spacer {
  min-width: 24px;
}

/* ─── Message Bubble ─────────────────────────────── */

.pcb-bubble {
  display: inline-block;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 90%;
  hyphens: auto;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.pcb-bubble.pcb-bubble-user {
  background: #171717;
  color: #ffffff;
}

.pcb-bubble.pcb-bubble-ai {
  background: #f3f4f6;
  color: #171717;
}

/* RTL support */
[dir="rtl"] .pcb-bubble {
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  text-align: right;
  max-width: 100%;
  unicode-bidi: plaintext;
}

/* ─── Markdown Content ───────────────────────────── */

.pcb-markdown p {
  margin-bottom: 8px;
}

.pcb-markdown p:last-child {
  margin-bottom: 0;
}

.pcb-markdown strong {
  font-weight: 700;
}

.pcb-markdown em {
  font-style: italic;
}

.pcb-markdown h1,
.pcb-markdown h2,
.pcb-markdown h3,
.pcb-markdown h4 {
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 8px;
}

.pcb-markdown h1:first-child,
.pcb-markdown h2:first-child,
.pcb-markdown h3:first-child,
.pcb-markdown h4:first-child {
  margin-top: 0;
}

.pcb-markdown h1 {
  font-size: 1.25em;
}
.pcb-markdown h2 {
  font-size: 1.125em;
}
.pcb-markdown h3 {
  font-size: 1em;
}

.pcb-markdown ul,
.pcb-markdown ol {
  margin: 8px 0;
  padding-left: 20px;
}

.pcb-markdown ul {
  list-style-type: disc;
}
.pcb-markdown ol {
  list-style-type: decimal;
}

.pcb-markdown li {
  margin-bottom: 4px;
}

.pcb-markdown code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.85em;
}

.pcb-markdown pre {
  background: rgba(0, 0, 0, 0.1);
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.pcb-markdown a {
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
}

.pcb-markdown a:hover {
  text-decoration: none;
}

.pcb-markdown blockquote {
  border-left: 3px solid rgba(0, 0, 0, 0.2);
  padding-left: 16px;
  font-style: italic;
  margin: 8px 0;
}

.pcb-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 0.97em;
}

.pcb-markdown th,
.pcb-markdown td {
  border: 1px solid #d1d5db;
  padding: 6px 10px;
}

.pcb-markdown th {
  background: #f3f4f6;
  font-weight: bold;
}

/* ─── Typing Animation ───────────────────────────── */

.pcb-dot-typing {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 12px;
  padding: 0 2px;
}

.pcb-dot-typing::before,
.pcb-dot-typing::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: currentColor;
  margin: 0 2px;
  animation: pcb-blink-dots 1.4s infinite both;
}

.pcb-dot-typing::before {
  animation-delay: 0s;
}

.pcb-dot-typing-middle {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: currentColor;
  margin: 0 2px;
  animation: pcb-blink-dots 1.4s infinite both;
  animation-delay: 0.2s;
}

.pcb-dot-typing::after {
  animation-delay: 0.4s;
}

@keyframes pcb-blink-dots {
  0%,
  80%,
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── Input Area ─────────────────────────────────── */

.pcb-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
}

.pcb-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: #171717;
}

.pcb-input:focus {
  border-color: #171717;
  box-shadow: 0 0 0 2px rgba(23, 23, 23, 0.1);
}

.pcb-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pcb-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #171717;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.pcb-send-btn:hover {
  opacity: 0.85;
}

.pcb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pcb-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ─── Contact Form (inline in chat) ──────────────── */

.pcb-contact-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin: 8px 0;
}

.pcb-contact-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #171717;
}

.pcb-contact-desc {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.pcb-contact-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}

.pcb-contact-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: #171717;
}

.pcb-contact-input:focus {
  border-color: #171717;
  box-shadow: 0 0 0 2px rgba(23, 23, 23, 0.1);
}

.pcb-contact-error {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 10px;
}

.pcb-contact-buttons {
  display: flex;
  gap: 8px;
}

.pcb-contact-btn-submit {
  flex: 1;
  padding: 8px 16px;
  background: #171717;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}

.pcb-contact-btn-submit:hover {
  opacity: 0.85;
}

.pcb-contact-btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pcb-contact-btn-skip {
  padding: 8px 16px;
  background: transparent;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}

.pcb-contact-btn-skip:hover {
  background: #f3f4f6;
}

/* ─── Dark Mode support ──────────────────────────── */

.pcb-dark .pcb-window {
  background: #1a1a1a;
  border-color: #333;
}

.pcb-dark .pcb-header {
  background: #313131;
  border-color: #444;
}

.pcb-dark .pcb-header-title {
  color: #f5f5f5;
}

.pcb-dark .pcb-messages {
  background: #1a1a1a;
}

.pcb-dark .pcb-messages-placeholder {
  color: #6b7280;
}

.pcb-dark .pcb-bubble.pcb-bubble-ai {
  background: #2a2a2a;
  color: #f5f5f5;
}

.pcb-dark .pcb-bubble.pcb-bubble-user {
  background: #f5f5f5;
  color: #171717;
}

.pcb-dark .pcb-input-area {
  border-color: #444;
}

.pcb-dark .pcb-input {
  background: #2a2a2a;
  border-color: #444;
  color: #f5f5f5;
}

.pcb-dark .pcb-input:focus {
  border-color: #888;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.pcb-dark .pcb-icon-btn {
  color: #d1d5db;
}

.pcb-dark .pcb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pcb-dark .pcb-contact-card {
  background: #2a2a2a;
  border-color: #444;
}

.pcb-dark .pcb-contact-title {
  color: #f5f5f5;
}

.pcb-dark .pcb-contact-desc {
  color: #9ca3af;
}

.pcb-dark .pcb-contact-input {
  background: #1a1a1a;
  border-color: #444;
  color: #f5f5f5;
}

.pcb-dark .pcb-contact-btn-skip {
  color: #d1d5db;
  border-color: #555;
}

.pcb-dark .pcb-contact-btn-skip:hover {
  background: #333;
}

.pcb-dark .pcb-markdown code {
  background: rgba(255, 255, 255, 0.1);
}

.pcb-dark .pcb-markdown pre {
  background: rgba(255, 255, 255, 0.1);
}

.pcb-dark .pcb-markdown blockquote {
  border-left-color: rgba(255, 255, 255, 0.2);
}

.pcb-dark .pcb-markdown th {
  background: #232323;
}

.pcb-dark .pcb-markdown td {
  border-color: #555;
}

/* ─── Scrollbar ──────────────────────────────────── */

.pcb-messages::-webkit-scrollbar {
  width: 6px;
}

.pcb-messages::-webkit-scrollbar-track {
  background: transparent;
}

.pcb-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.pcb-dark .pcb-messages::-webkit-scrollbar-thumb {
  background: #555;
}
