/* ── ACSP Chat Widget (editorial theme) ──────────────────── */

#acsp-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--navy-900, #081a33);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 14px 30px -8px rgba(8,26,51,.45), 0 0 0 3px rgba(238,108,26,.25);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, background 0.2s;
}
#acsp-chat-bubble:hover {
  transform: scale(1.08);
  background: var(--navy-800, #0f2747);
  box-shadow: 0 18px 36px -10px rgba(8,26,51,.55), 0 0 0 4px rgba(238,108,26,.35);
}
#acsp-chat-bubble.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
#acsp-chat-bubble svg { pointer-events: none; }

/* Panel -- desktop */
#acsp-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-height: 560px;
  height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 60px -30px rgba(8,26,51,.4), 0 10px 20px -10px rgba(8,26,51,.15), 0 0 0 1px rgba(8,26,51,.05);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#acsp-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
#acsp-chat-header {
  background: linear-gradient(135deg, #081a33 0%, #0f2747 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
#acsp-chat-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.acsp-chat-avatar {
  height: 38px; width: auto; flex-shrink: 0;
  display: flex; align-items: center;
}
.acsp-chat-avatar img { height: 100%; width: auto; display: block; }
.acsp-chat-header-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#acsp-chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.65);
  white-space: nowrap;
}
.acsp-status-dot {
  width: 7px;
  height: 7px;
  background: #5fd67a;
  border-radius: 50%;
  animation: acsp-pulse 2s infinite;
}
@keyframes acsp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
#acsp-chat-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
#acsp-chat-close:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* Messages */
#acsp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f3ec;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.acsp-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: acsp-msg-in 0.2s ease;
}
@keyframes acsp-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.acsp-msg-user {
  align-self: flex-end;
  background: #081a33;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.acsp-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: #0b1628;
  border: 1px solid #eaf0f8;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(8,26,51,.04);
}

/* Typing indicator */
.acsp-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #eaf0f8;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.acsp-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: acsp-bounce 1.2s infinite;
}
.acsp-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.acsp-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes acsp-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input */
#acsp-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #eaf0f8;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#acsp-chat-input {
  flex: 1;
  border: 1.5px solid #dde4ef;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
  background: #f6f3ec;
  color: #0b1628;
}
#acsp-chat-input:focus {
  border-color: #1f4a8a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31,74,138,.12);
}
#acsp-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ee6c1a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 6px 14px -6px rgba(238,108,26,.6);
}
#acsp-chat-send:hover { background: #d95b0d; transform: scale(1.05); }
#acsp-chat-send:disabled { background: #f5c9a8; cursor: default; transform: none; box-shadow: none; }

/* Session limit */
.acsp-session-limit {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: #6b7280;
}
.acsp-session-limit button {
  background: #ee6c1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}
.acsp-session-limit button:hover { background: #d95b0d; }

/* Per-message action chips (injected when AI mentions booking/emergency) */
.acsp-msg-actions {
  align-self: flex-start;
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: -2px 0 4px;
  max-width: 85%;
}
.acsp-msg-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 999px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  line-height: 1; border: none; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.acsp-msg-chip svg { width: 14px; height: 14px; }
.acsp-msg-chip--book {
  background: #ee6c1a; color: #fff;
  box-shadow: 0 4px 12px -4px rgba(238,108,26,.55), inset 0 -2px 0 rgba(0,0,0,.1);
}
.acsp-msg-chip--book:hover {
  background: #d95b0d; transform: translateY(-1px);
}
.acsp-msg-chip--call {
  background: #fff; color: #081a33;
  border: 1.5px solid #dde4ef;
}
.acsp-msg-chip--call:hover {
  border-color: #081a33; background: #f6f3ec;
}

/* Quick Action Chips */
.acsp-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  animation: acsp-msg-in 0.25s ease;
}
.acsp-chip {
  background: #fff;
  border: 1.5px solid #1f4a8a;
  color: #081a33;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.acsp-chip:hover {
  background: #081a33;
  border-color: #081a33;
  color: #fff;
  transform: translateY(-1px);
}
.acsp-chip:active { transform: translateY(0); }

/* Phone link in messages */
.acsp-phone-link {
  color: #ee6c1a;
  text-decoration: none;
  font-weight: 600;
}
.acsp-phone-link:hover { text-decoration: underline; }

/* Nudge tooltip */
#acsp-nudge {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  background: #081a33;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(8,26,51,.3);
  animation: acsp-nudge-in 0.3s ease;
}
#acsp-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: #081a33;
  transform: rotate(45deg);
}
@keyframes acsp-nudge-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile: fullscreen takeover ─────────────────────────── */
@media (max-width: 640px) {
  #acsp-chat-bubble { bottom: 16px; right: 16px; width: 56px; height: 56px; }
  #acsp-chat-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: none;
    height: 100%; height: 100dvh;
    border-radius: 0; box-shadow: none;
    transform: translateY(100%);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #acsp-chat-panel.open { transform: translateY(0); }
  #acsp-chat-header {
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  #acsp-chat-close { width: 36px; height: 36px; font-size: 22px; }
  #acsp-chat-messages { padding: 14px 16px; }
  #acsp-chat-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #acsp-chat-input { font-size: 16px; padding: 10px 16px; }
  .acsp-msg { max-width: 88%; font-size: 15px; }
}

body.acsp-chat-open { overflow: hidden; position: fixed; width: 100%; height: 100%; }
