/* Skin Maison Chatbot Widget */
#sm-chatbot-container {
  --sm-primary: #c9a87c;
  --sm-primary-dark: #b08d5e;
  --sm-primary-light: #dfc9a8;
  --sm-bg: #f9f7f4;
  --sm-bg-chat: #f7f5f2;
  --sm-text: #2c2c2c;
  --sm-text-light: #6b6b6b;
  --sm-border: #e8e2da;
  --sm-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --sm-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.18);
  --sm-radius: 16px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
}

/* ── Toggle Button (Syringe Icon) ────────────────── */
#sm-chatbot-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #f5f0e6;
  border: 2px solid var(--sm-primary);
  cursor: pointer;
  box-shadow: var(--sm-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  position: relative;
  padding: 5px;
}

#sm-chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 14px 52px rgba(201, 168, 124, 0.35);
}

#sm-chatbot-toggle img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

#sm-chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

/* Pulse ring */
#sm-chatbot-toggle::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--sm-primary);
  opacity: 0;
  animation: sm-pulse-ring 3s ease-out infinite;
}

@keyframes sm-pulse-ring {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* Hide pulse when chat is open */
#sm-chatbot-container.sm-chat-open #sm-chatbot-toggle::after { display: none; }

/* ── Teaser Bubble ───────────────────────────────── */
#sm-chatbot-teaser {
  position: absolute;
  bottom: 72px;
  right: 0;
  background: var(--sm-bg);
  color: var(--sm-text);
  padding: 10px 16px;
  border-radius: 12px 12px 4px 12px;
  box-shadow: var(--sm-shadow);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  border: 1px solid var(--sm-border);
}

#sm-chatbot-teaser.sm-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#sm-teaser-text {
  cursor: pointer;
}

#sm-teaser-text:hover {
  color: var(--sm-primary-dark);
}

#sm-chatbot-teaser .sm-teaser-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sm-bg);
  border: 1px solid var(--sm-border);
  color: var(--sm-text-light);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
}

#sm-chatbot-teaser .sm-teaser-close:hover { color: var(--sm-text); }

/* ── Chat Window ─────────────────────────────────── */
#sm-chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 540px;
  background: var(--sm-bg);
  border-radius: var(--sm-radius);
  box-shadow: var(--sm-shadow-lg);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--sm-border);
  /* Hidden by default with animation */
  display: flex;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#sm-chatbot-window.sm-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ──────────────────────────────────────── */
#sm-chatbot-header {
  background: linear-gradient(135deg, var(--sm-primary) 0%, var(--sm-primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#sm-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#sm-chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  overflow: hidden;
}

#sm-chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#sm-chatbot-header-text h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

#sm-chatbot-header-text p {
  margin: 0;
  font-size: 12px;
  opacity: 0.85;
}

/* Online dot */
.sm-online-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 4px;
  vertical-align: middle;
  animation: sm-dot-pulse 2s infinite;
}

@keyframes sm-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#sm-chatbot-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#sm-chatbot-close:hover { opacity: 1; }

/* ── Messages Area ───────────────────────────────── */
#sm-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--sm-bg-chat);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sm-msg-wrapper { display: flex; flex-direction: column; animation: sm-msg-in 0.3s ease-out; }
.sm-msg-wrapper-user { align-items: flex-end; }
.sm-msg-wrapper-bot { align-items: flex-start; }

@keyframes sm-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sm-message {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
}

.sm-message-bot br {
  display: block;
  content: "";
  margin-bottom: 6px;
}

/* Bot message row: avatar + message */
.sm-bot-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 95%;
}

.sm-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.sm-bot-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sm-message-bot {
  background: var(--sm-bg);
  color: var(--sm-text);
  border: 1px solid var(--sm-border);
  border-bottom-left-radius: 4px;
}

.sm-message-bot strong {
  font-weight: 700;
  color: var(--sm-primary-dark);
}

.sm-chat-link {
  display: inline-block;
  background: var(--sm-primary);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  margin: 2px 0;
  transition: background 0.2s;
}

.sm-chat-link:hover { background: var(--sm-primary-dark); }

/* Feedback buttons */
.sm-feedback {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.sm-msg-wrapper-bot:hover .sm-feedback,
.sm-feedback.sm-fb-voted { opacity: 1; }

.sm-fb-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--sm-text-light);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.sm-fb-btn:hover { background: var(--sm-bg-chat); border-color: var(--sm-border); color: var(--sm-text); }
.sm-fb-btn.sm-fb-active { background: var(--sm-primary); color: white; border-color: var(--sm-primary); }
.sm-fb-voted .sm-fb-btn:not(.sm-fb-active) { opacity: 0.3; pointer-events: none; }

.sm-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--sm-primary) 0%, var(--sm-primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

/* ── Typing Indicator ────────────────────────────── */
.sm-typing {
  align-self: flex-start;
  background: var(--sm-bg);
  border: 1px solid var(--sm-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: sm-msg-in 0.3s ease-out;
}

.sm-typing-label {
  font-size: 11px;
  color: var(--sm-text-light);
  margin-right: 4px;
}

.sm-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sm-primary);
  animation: sm-bounce 1.4s infinite ease-in-out;
}

.sm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes sm-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Actions ───────────────────────────────── */
#sm-chatbot-quick-actions {
  padding: 8px 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--sm-bg-chat);
  border-top: 1px solid var(--sm-border);
  flex-shrink: 0;
}

.sm-quick-btn {
  background: var(--sm-bg);
  border: 1px solid var(--sm-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--sm-text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.sm-quick-btn:hover {
  background: var(--sm-primary);
  color: white;
  border-color: var(--sm-primary);
  transform: translateY(-1px);
}

/* ── Dynamic Chips ──────────────────────────────── */
.sm-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-left: 0;
  animation: sm-msg-in 0.3s ease-out;
}

.sm-chip {
  background: var(--sm-bg);
  border: 1px solid var(--sm-primary);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--sm-primary-dark);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.sm-chip:hover {
  background: var(--sm-primary);
  color: white;
  transform: translateY(-1px);
}

/* ── Inline Follow-up Actions ────────────────────── */
.sm-inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-left: 34px;
  animation: sm-msg-in 0.3s ease-out;
}

.sm-inline-btn {
  background: var(--sm-bg);
  border: 1px solid var(--sm-primary);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--sm-primary-dark);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.sm-inline-btn:hover {
  background: var(--sm-primary);
  color: white;
  transform: translateY(-1px);
}

/* ── Input Area ──────────────────────────────────── */
#sm-chatbot-input-area {
  display: flex;
  padding: 12px 16px;
  gap: 8px;
  background: var(--sm-bg);
  border-top: 1px solid var(--sm-border);
  flex-shrink: 0;
}

#sm-chatbot-input {
  flex: 1;
  border: 1px solid var(--sm-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  background: var(--sm-bg-chat);
  color: var(--sm-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#sm-chatbot-input:focus {
  border-color: var(--sm-primary);
  box-shadow: 0 0 0 3px rgba(201, 168, 124, 0.12);
}

#sm-chatbot-input::placeholder { color: var(--sm-text-light); }

#sm-chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sm-primary) 0%, var(--sm-primary-dark) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

#sm-chatbot-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(201, 168, 124, 0.3);
}

#sm-chatbot-send:disabled {
  background: var(--sm-border);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#sm-chatbot-send svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* ── Footer ──────────────────────────────────────── */
#sm-chatbot-footer {
  text-align: center;
  padding: 4px;
  font-size: 10px;
  color: var(--sm-text-light);
  background: var(--sm-bg);
}

/* Mobile styles moved to bottom of file (#15 Full-Screen Mobile) */

/* ── Specials Popup ──────────────────────────────── */
#sm-specials-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999998;
  align-items: center;
  justify-content: center;
}

#sm-specials-overlay.sm-show { display: flex; }

#sm-specials-popup {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: sm-popup-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sm-popup-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

#sm-specials-popup h2 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #2c2c2c;
}

#sm-specials-popup .sm-specials-divider {
  width: 60px;
  height: 3px;
  background: var(--sm-primary);
  margin: 12px auto;
  border-radius: 2px;
}

#sm-specials-popup p {
  color: #6b6b6b;
  font-size: 15px;
  line-height: 1.6;
  margin: 16px 0;
}

#sm-specials-popup .sm-specials-cta,
#sm-specials-popup a.sm-specials-cta,
#sm-specials-popup a.sm-specials-cta:link,
#sm-specials-popup a.sm-specials-cta:visited,
#sm-specials-popup a.sm-specials-cta:active {
  display: inline-block !important;
  background: linear-gradient(135deg, #c9a87c 0%, #a8864a 100%) !important;
  color: #ffffff !important;
  padding: 12px 28px !important;
  border-radius: 24px !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  margin-top: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  visibility: visible !important;
  opacity: 1 !important;
  line-height: 1.4 !important;
  letter-spacing: 0 !important;
}

#sm-specials-popup .sm-specials-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201, 168, 124, 0.3);
}

#sm-specials-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  color: #999;
  cursor: pointer;
}

#sm-specials-close:hover { color: #333; }

/* ── Toggle Flip on Click ─────────────────────────── */
#sm-chatbot-toggle.sm-toggle-spin img {
  animation: sm-flip-click 0.6s ease-in-out;
}

@keyframes sm-flip-click {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

/* ── #12: Avatar Typing Pulse ────────────────────── */
#sm-chatbot-toggle img.sm-avatar-typing {
  animation: sm-avatar-pulse 1.2s ease-in-out infinite;
}

@keyframes sm-avatar-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.8; }
}

/* ── #9: Inline Booking Button ───────────────────── */
.sm-book-inline-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--sm-primary) 0%, var(--sm-primary-dark) 100%);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: center;
}

.sm-book-inline-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201, 168, 124, 0.35);
  color: white;
}

/* ── #15: Full-Screen Mobile ─────────────────────── */
@media (max-width: 480px) {
  #sm-chatbot-window.sm-open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: -webkit-fill-available;
    border-radius: 0;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
  }

  #sm-chatbot-container.sm-chat-open #sm-chatbot-toggle {
    display: none;
  }

  #sm-chatbot-header {
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    flex-shrink: 0;
  }

  #sm-chatbot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
  }

  #sm-chatbot-quick-actions {
    flex-shrink: 0;
  }

  #sm-chatbot-input-area {
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  #sm-chatbot-footer {
    flex-shrink: 0;
  }

  .sm-message {
    max-width: 92%;
    font-size: 16px;
  }

  .sm-bot-row {
    max-width: 98%;
  }

  #sm-chatbot-input {
    font-size: 16px;
  }

  .sm-quick-btn {
    padding: 8px 16px;
    font-size: 13px;
  }

  .sm-book-inline-btn {
    display: block;
    text-align: center;
    padding: 10px 20px;
    font-size: 14px;
  }

  /* Hide expand button on mobile — already full screen */
  #sm-chatbot-expand { display: none !important; }

  #sm-chatbot-teaser { display: none; }
}
