/* ==========================================================================
   AI Photoshoot Booking Assistant — Minimalist Chatbot UI
   Colors: Warm Beige #EEE9E0  ·  Dark Brown #5D4004
   All rules scoped to #apba-chatbot-wrapper to prevent theme bleed.
   ========================================================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Design Tokens (scoped) ---------- */
#apba-chatbot-wrapper {
  --apba-brown: #5D4004;
  --apba-brown-light: #7A5A1E;
  --apba-brown-dark: #3E2A02;
  --apba-beige: #EEE9E0;
  --apba-beige-light: #F7F4EF;
  --apba-beige-mid: #E4DDD2;
  --apba-white: #FFFFFF;
  --apba-text: #3B2E1A;
  --apba-text-muted: #8C7B66;
  --apba-text-light: #B5A998;
  --apba-border: rgba(93, 64, 4, 0.10);
  --apba-shadow: 0 12px 40px rgba(62, 42, 2, 0.12);
  --apba-shadow-btn: 0 4px 20px rgba(93, 64, 4, 0.28);
  --apba-radius: 20px;
  --apba-radius-bubble: 18px;
  --apba-z-index: 999999;
  --apba-widget-width: 380px;
  --apba-widget-height: 560px;
  --apba-toggle-size: 60px;
  --apba-bottom-offset: 24px;
  --apba-side-offset: 24px;
  --apba-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --apba-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- Reset scope — prevent theme bleed ---------- */
#apba-chatbot-wrapper,
#apba-chatbot-wrapper *,
#apba-chatbot-wrapper *::before,
#apba-chatbot-wrapper *::after {
  box-sizing: border-box;
  font-family: var(--apba-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Selective resets — only on elements that themes commonly override */
#apba-chatbot-wrapper p,
#apba-chatbot-wrapper h1,
#apba-chatbot-wrapper h2,
#apba-chatbot-wrapper h3,
#apba-chatbot-wrapper h4,
#apba-chatbot-wrapper span {
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

#apba-chatbot-wrapper button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

#apba-chatbot-wrapper textarea {
  font-family: var(--apba-font);
}

#apba-chatbot-wrapper img {
  max-width: 100%;
  display: block;
}

#apba-chatbot-wrapper svg {
  display: block;
  flex-shrink: 0;
}

/* ---------- Widget Wrapper ---------- */
#apba-chatbot-wrapper {
  position: fixed;
  z-index: var(--apba-z-index);
  bottom: var(--apba-bottom-offset);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

#apba-chatbot-wrapper.apba-position-bottom-right {
  right: var(--apba-side-offset);
  align-items: flex-end;
}

#apba-chatbot-wrapper.apba-position-bottom-left {
  left: var(--apba-side-offset);
  align-items: flex-start;
}

/* ---------- Chat Window ---------- */
.apba-chat-window {
  pointer-events: auto;
  position: absolute;
  bottom: calc(var(--apba-toggle-size) + 12px);
  right: 0;
  width: var(--apba-widget-width);
  height: var(--apba-widget-height);
  background: var(--apba-beige-light);
  border-radius: var(--apba-radius);
  box-shadow: var(--apba-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--apba-border);

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.35s var(--apba-ease),
    transform 0.35s var(--apba-ease);
  transform-origin: bottom right;
  will-change: opacity, transform;
}

.apba-position-bottom-left .apba-chat-window {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

/* Open state */
.apba-chat-window.apba-is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
.apba-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--apba-brown);
  flex-shrink: 0;
  position: relative;
}

.apba-chat-header__avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.apba-chat-header__avatar img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.apba-default-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--apba-beige);
}

.apba-default-avatar svg {
  stroke: var(--apba-beige);
}

.apba-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #6ABF69;
  border-radius: 50%;
  border: 2px solid var(--apba-brown);
  animation: apba-pulse-dot 2.5s ease-in-out infinite;
}

@keyframes apba-pulse-dot {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.15);
    opacity: 0.7;
  }
}

.apba-chat-header__info {
  flex: 1;
  min-width: 0;
}

.apba-chat-header__name {
  margin: 0 0 1px;
  font-size: 15px;
  font-weight: 600;
  color: var(--apba-beige);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apba-chat-header__status {
  margin: 0;
  font-size: 11.5px;
  font-weight: 400;
  color: rgba(238, 233, 224, 0.6);
  letter-spacing: 0.01em;
}

.apba-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(238, 233, 224, 0.7);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.25s var(--apba-ease);
  flex-shrink: 0;
}

.apba-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--apba-beige);
  transform: rotate(90deg);
}

/* ---------- Messages Area ---------- */
.apba-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--apba-beige);
}

/* Scrollbar */
.apba-messages::-webkit-scrollbar {
  width: 4px;
}

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

.apba-messages::-webkit-scrollbar-thumb {
  background: var(--apba-beige-mid);
  border-radius: 2px;
}

.apba-messages::-webkit-scrollbar-thumb:hover {
  background: var(--apba-text-light);
}

/* Message bubbles */
.apba-msg {
  display: flex;
  max-width: 82%;
  animation: apba-msg-in 0.3s var(--apba-ease);
}

@keyframes apba-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.apba-msg--bot {
  align-self: flex-start;
  flex-direction: row;
  gap: 8px;
}

.apba-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.apba-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--apba-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: auto;
  color: var(--apba-beige);
}

.apba-msg__avatar svg {
  stroke: var(--apba-beige);
}

.apba-msg__bubble {
  padding: 10px 14px;
  border-radius: var(--apba-radius-bubble);
  line-height: 1.55;
  font-size: 13.5px;
  font-weight: 400;
  word-break: break-word;
  white-space: pre-wrap;
  letter-spacing: 0.005em;
}

.apba-msg--bot .apba-msg__bubble {
  background: var(--apba-white);
  color: var(--apba-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(93, 64, 4, 0.06);
}

.apba-msg--user .apba-msg__bubble {
  background: var(--apba-brown);
  color: var(--apba-beige);
  border-bottom-right-radius: 4px;
}

/* Timestamp */
.apba-msg__time {
  display: block;
  font-size: 10px;
  color: var(--apba-text-light);
  margin-top: 4px;
  text-align: right;
  font-weight: 400;
}

.apba-msg--bot .apba-msg__time {
  text-align: left;
}

.apba-msg--user .apba-msg__time {
  color: rgba(238, 233, 224, 0.5);
}

/* ---------- Typing Indicator ---------- */
.apba-typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  background: var(--apba-beige);
}

.apba-typing-indicator.apba-is-visible {
  display: flex;
}

.apba-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--apba-white);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(93, 64, 4, 0.06);
}

.apba-typing-bubble span {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--apba-text-muted);
  border-radius: 50%;
  animation: apba-typing-bounce 1.4s infinite both;
}

.apba-typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.apba-typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes apba-typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.apba-typing-text {
  margin: 0;
  font-size: 11px;
  color: var(--apba-text-muted);
  font-style: italic;
  font-weight: 400;
}

/* ---------- Input Area ---------- */
.apba-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--apba-beige-light);
  border-top: 1px solid var(--apba-border);
  flex-shrink: 0;
}

.apba-input {
  flex: 1;
  border: 1.5px solid var(--apba-beige-mid);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: var(--apba-font);
  font-weight: 400;
  color: var(--apba-text);
  background: var(--apba-white);
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 120px;
  overflow-y: auto;
}

.apba-input:focus {
  border-color: var(--apba-brown);
  box-shadow: 0 0 0 3px rgba(93, 64, 4, 0.08);
}

.apba-input::placeholder {
  color: var(--apba-text-light);
  font-weight: 400;
}

.apba-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--apba-brown);
  color: var(--apba-beige);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(93, 64, 4, 0.2);
}

.apba-send-btn:hover:not(:disabled) {
  background: var(--apba-brown-light);
  transform: scale(1.06);
}

.apba-send-btn:active {
  transform: scale(0.95);
}

.apba-send-btn:disabled {
  background: var(--apba-text-light);
  box-shadow: none;
  cursor: not-allowed;
}

/* ---------- Footer ---------- */
.apba-chat-footer {
  text-align: center;
  padding: 6px 14px 8px;
  background: var(--apba-beige-light);
  font-size: 10px;
  color: var(--apba-text-light);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  font-weight: 400;
}

/* ---------- Toggle Button ---------- */
.apba-toggle-btn {
  pointer-events: auto;
  position: relative;
  width: var(--apba-toggle-size);
  height: var(--apba-toggle-size);
  border: none;
  border-radius: 50%;
  background: var(--apba-brown);
  color: var(--apba-beige);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--apba-shadow-btn);
  transition: transform 0.3s var(--apba-ease), box-shadow 0.25s;
  overflow: visible;
  flex-shrink: 0;
}

.apba-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(93, 64, 4, 0.35);
}

.apba-toggle-btn:active {
  transform: scale(0.95);
}

.apba-toggle-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s, transform 0.3s var(--apba-ease);
}

.apba-toggle-icon--open {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.apba-toggle-icon--close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.apba-toggle-btn.apba-is-open .apba-toggle-icon--open {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.apba-toggle-btn.apba-is-open .apba-toggle-icon--close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notification dot */
.apba-notification-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: #6ABF69;
  border: 2px solid var(--apba-white);
  border-radius: 50%;
  display: none;
  animation: apba-pulse-dot 2.5s ease-in-out infinite;
}

.apba-notification-dot.apba-has-notification {
  display: block;
}

/* ---------- Proactive Greeting Bubble ---------- */
.apba-greeting-bubble {
  pointer-events: auto;
  position: relative;
  background: var(--apba-white);
  border-radius: 14px;
  padding: 14px 38px 14px 16px;
  box-shadow: 0 4px 20px rgba(93, 64, 4, 0.12);
  border: 1px solid var(--apba-border);
  max-width: 280px;

  /* hidden by default */
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.35s var(--apba-ease), transform 0.35s var(--apba-ease);
}

/* Small triangle pointer toward the toggle button */
.apba-greeting-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: var(--apba-white);
  border-right: 1px solid var(--apba-border);
  border-bottom: 1px solid var(--apba-border);
  transform: rotate(45deg);
}

.apba-position-bottom-left .apba-greeting-bubble::after {
  right: auto;
  left: 24px;
}

/* Visible state */
.apba-greeting-bubble.apba-is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.apba-greeting-bubble__text {
  font-size: 13.5px;
  color: var(--apba-text);
  line-height: 1.5;
  font-weight: 400;
}

.apba-greeting-bubble__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--apba-text-light);
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.apba-greeting-bubble__close:hover {
  color: var(--apba-text);
  background: rgba(93, 64, 4, 0.06);
}

/* ---------- Quick-Tap Suggestion Chips ---------- */
.apba-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 4px;
}

.apba-suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--apba-beige-mid);
  border-radius: 16px;
  background: var(--apba-white);
  color: var(--apba-white);
  background: #745825;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--apba-font);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
  transition: all 0.2s var(--apba-ease);
  line-height: 1.35;
  opacity: 0;
  transform: translateY(4px);
  animation: apba-chip-in 0.3s var(--apba-ease) forwards;
}

.apba-suggestion-chip:nth-child(1) {
  animation-delay: 0.04s;
}

.apba-suggestion-chip:nth-child(2) {
  animation-delay: 0.08s;
}

.apba-suggestion-chip:nth-child(3) {
  animation-delay: 0.12s;
}

.apba-suggestion-chip:nth-child(4) {
  animation-delay: 0.16s;
}

.apba-suggestion-chip:nth-child(5) {
  animation-delay: 0.20s;
}

.apba-suggestion-chip:nth-child(6) {
  animation-delay: 0.24s;
}

@keyframes apba-chip-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.apba-suggestion-chip:hover {
  background: #5D4004;
  border-color: #5D4004;
  color: #d1911b;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(93, 64, 4, 0.15);
}

.apba-suggestion-chip:active {
  transform: scale(0.96);
  box-shadow: none;
}

/* ---------- Error Message ---------- */
.apba-msg--error .apba-msg__bubble {
  background: #FDF2F0;
  color: #8B3A2E;
  border: 1px solid rgba(139, 58, 46, 0.15);
  font-size: 13px;
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 480px) {
  #apba-chatbot-wrapper {
    --apba-widget-width: calc(100vw - 24px);
    --apba-widget-height: 75vh;
    --apba-side-offset: 12px;
    --apba-bottom-offset: 16px;
    --apba-toggle-size: 54px;
  }

  .apba-chat-window {
    border-radius: 16px;
  }

  .apba-msg {
    max-width: 88%;
  }
}

@media (max-width: 360px) {
  #apba-chatbot-wrapper {
    --apba-widget-width: calc(100vw - 16px);
    --apba-side-offset: 8px;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {

  #apba-chatbot-wrapper .apba-chat-window,
  #apba-chatbot-wrapper .apba-toggle-btn,
  #apba-chatbot-wrapper .apba-close-btn,
  #apba-chatbot-wrapper .apba-msg,
  #apba-chatbot-wrapper .apba-typing-bubble span,
  #apba-chatbot-wrapper .apba-online-dot,
  #apba-chatbot-wrapper .apba-notification-dot,
  #apba-chatbot-wrapper .apba-suggestion-chip,
  #apba-chatbot-wrapper .apba-greeting-bubble {
    animation: none !important;
    transition: none !important;
  }
}