/* Chatbot Pro - Frontend Styles
 * Slug: chatbot-pro
 * RTL-ready: uses direction on root and logical props where possible.
 */

:root {
  --cbp-primary: #2563eb;
  --cbp-primary-contrast: #ffffff;
  --cbp-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  --cbp-shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.12);
  --cbp-radius: 16px;
  --cbp-radius-sm: 12px;
  --cbp-border: rgba(0, 0, 0, 0.10);
  --cbp-bg: #ffffff;
  --cbp-text: #0f172a;
  --cbp-muted: rgba(15, 23, 42, 0.65);
  --cbp-panel: #ffffff;
  --cbp-surface: rgba(15, 23, 42, 0.04);
  --cbp-user-bubble: #0f172a;
  --cbp-user-text: #ffffff;
  --cbp-bot-bubble: #f1f5f9;
  --cbp-bot-text: #0f172a;
  --cbp-focus: rgba(37, 99, 235, 0.25);
}

.chatbot-pro {
  position: fixed;
  z-index: 999999;
  bottom: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color: var(--cbp-text);
  direction: inherit; /* set by JS to rtl/ltr */
}

/* Positioning */
.chatbot-pro[data-position="bottom-right"] { right: 18px; }
.chatbot-pro[data-position="bottom-left"] { left: 18px; }

/* Launcher */
.chatbot-pro__launcher {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  box-shadow: var(--cbp-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.chatbot-pro__launcher { background: var(--cbp-primary); }

.chatbot-pro__launcher:hover {
  transform: translateY(-2px);
  filter: brightness(1.02);
  box-shadow: var(--cbp-shadow-soft);
}

.chatbot-pro__launcher:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.chatbot-pro__launcher:focus-visible {
  box-shadow: var(--cbp-shadow), 0 0 0 4px var(--cbp-focus);
}

.chatbot-pro__launcher.is-hidden { display: none; }

.chatbot-pro__launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  color: #fff;
}

.chatbot-pro__launcher-icon svg { color: #fff; width: 30px; height: 30px; }
.chatbot-pro__launcher-img { width: 34px; height: 34px; object-fit: contain; display:block; }

/* Panel */
.chatbot-pro__panel {
  position: absolute;
  bottom: 0;
  width: 360px;
  max-width: calc(100vw - 36px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--cbp-panel);
  border-radius: var(--cbp-radius);
  box-shadow: var(--cbp-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

/* Anchor panel depending on position */
.chatbot-pro[data-position="bottom-right"] .chatbot-pro__panel { right: 0; }
.chatbot-pro[data-position="bottom-left"] .chatbot-pro__panel { left: 0; }

.chatbot-pro__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chatbot-pro__header {
  padding: 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--cbp-primary-contrast);
  background: var(--cbp-primary);
}

.chatbot-pro__title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72%;
}

.chatbot-pro__header-actions { display: inline-flex; gap: 6px; }

.chatbot-pro__btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 18px;
  padding: 0;
}

.chatbot-pro__btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
}

.chatbot-pro__btn:active { transform: translateY(0); }

.chatbot-pro__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

/* Body */
.chatbot-pro__body {
  flex: 1;
  background: var(--cbp-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatbot-pro__messages {
  flex: 1;
  overflow: auto;
  padding: 14px 12px;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chatbot-pro__messages::-webkit-scrollbar { width: 10px; }
.chatbot-pro__messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.9);
}
.chatbot-pro__messages::-webkit-scrollbar-track { background: transparent; }

/* Messages */
.chatbot-pro__msg {
  display: flex;
  margin: 10px 0;
  gap: 8px;
}

.chatbot-pro__msg--user { justify-content: flex-end; }
.chatbot-pro__msg--model { justify-content: flex-start; }

.chatbot-pro__bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: var(--cbp-radius-sm);
  font-size: 14px;
  line-height: 1.55;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.chatbot-pro__msg--user .chatbot-pro__bubble {
  background: var(--cbp-user-bubble);
  color: var(--cbp-user-text);
  border-top-right-radius: 6px;
  border-top-left-radius: var(--cbp-radius-sm);
}

.chatbot-pro__msg--model .chatbot-pro__bubble {
  background: var(--cbp-bot-bubble);
  color: var(--cbp-bot-text);
  border-top-left-radius: 6px;
  border-top-right-radius: var(--cbp-radius-sm);
}

/* Typing */
.chatbot-pro__typing {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--cbp-surface);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), #fff);
}

.chatbot-pro__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  animation: cbp-bounce 900ms infinite ease-in-out;
}
.chatbot-pro__typing-dot:nth-child(2) { animation-delay: 120ms; }
.chatbot-pro__typing-dot:nth-child(3) { animation-delay: 240ms; }

.chatbot-pro__typing-text {
  font-size: 12px;
  color: var(--cbp-muted);
  margin-inline-start: 6px;
}

@keyframes cbp-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.55; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Footer */
.chatbot-pro__footer {
  padding: 10px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid var(--cbp-surface);
  background: #fff;
}

.chatbot-pro__input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  resize: none;
  border-radius: 14px;
  border: 1px solid var(--cbp-border);
  background: rgba(15, 23, 42, 0.02);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cbp-text);
  outline: none;
  transition: box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.chatbot-pro__input:focus {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 4px var(--cbp-focus);
  background: rgba(37, 99, 235, 0.03);
}

.chatbot-pro__send {
  height: 40px;
  border: none;
  color: var(--cbp-primary-contrast);
  background: var(--cbp-primary);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.chatbot-pro__send:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.14);
}

.chatbot-pro__send:active { transform: translateY(0); filter: brightness(0.98); }

.chatbot-pro__send:focus-visible {
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12), 0 0 0 4px var(--cbp-focus);
}

/* Mobile */
@media (max-width: 480px) {
  .chatbot-pro { bottom: 12px; }
  .chatbot-pro[data-position="bottom-right"] { right: 12px; }
  .chatbot-pro[data-position="bottom-left"] { left: 12px; }

  .chatbot-pro__panel {
    width: calc(100vw - 24px);
    height: min(70vh, 520px);
    max-height: calc(100vh - 110px);
  }

  .chatbot-pro__bubble { max-width: 92%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chatbot-pro__panel,
  .chatbot-pro__launcher,
  .chatbot-pro__btn,
  .chatbot-pro__send { transition: none !important; }
  .chatbot-pro__typing-dot { animation: none !important; }
}

.chatbot-pro { font-variant-numeric: tabular-nums; }

/* Ensure textarea inherits direction properly */
.chatbot-pro__input { direction: inherit; text-align: start; }

/* Pre-chat form (Premium) */
.chatbot-pro__prechat {
  padding: 16px 14px 10px;
  border-bottom: 1px solid var(--cbp-surface);
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.02), rgba(255, 255, 255, 0));
}

.chatbot-pro__prechat-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--cbp-text);
}

.chatbot-pro__prechat-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.chatbot-pro__prechat input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--cbp-border);
  background: rgba(15, 23, 42, 0.02);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
}

.chatbot-pro__prechat input:focus {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 4px var(--cbp-focus);
  background: rgba(37, 99, 235, 0.03);
}

.chatbot-pro__prechat-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

.chatbot-pro__prechat-btn {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  background: #7ccfa8; /* mint/pistachio */
  color: #0b2c18;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.10);
}

.chatbot-pro__prechat-btn:hover { filter: brightness(0.98); transform: translateY(-1px); }
.chatbot-pro__prechat-btn:active { transform: translateY(0); filter: brightness(0.95); }

.chatbot-pro__prechat-note {
  margin: 12px 2px 2px;
  padding: 10px 10px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--cbp-border);
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--cbp-muted);
}
