/* =============================================
   SUSAN AI CHAT — TheBrill Digital
   Custom widget — replaces n8n default UI
   ============================================= */

.chat-window-toggle,
.n8n-chat .chat-toggle {
  display: none !important;
}

#susan-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#susan-tab-inner {
  background: linear-gradient(135deg, #1e4d96, #0ea5e9);
  border-radius: 16px 0 0 16px;
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: -4px 0 24px rgba(14, 165, 233, 0.35);
  transition: all 0.3s ease;
  position: relative;
}

#susan-tab-inner:hover {
  padding-right: 14px;
  box-shadow: -6px 0 32px rgba(14, 165, 233, 0.5);
}

#susan-tab-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

#susan-tab-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#susan-tab-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(255,255,255,0.5);
  animation: susanDotPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes susanDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

#susan-tab-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: susanBadgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes susanBadgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

#susan-teaser {
  position: fixed;
  top: 50%;
  right: 90px;
  transform: translateY(-50%) translateX(10px);
  z-index: 999998;
  background: #fff;
  color: #1e293b;
  border-radius: 16px;
  padding: 12px 34px 12px 16px;
  max-width: 200px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#susan-teaser.show {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

#susan-teaser::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -7px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 7px solid #fff;
}

#susan-teaser-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

#susan-teaser-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

/* ── CHAT PANEL — bottom-anchored so it can never get cut off at the top ── */
#susan-panel {
  position: fixed;
  right: -400px;
  bottom: 20px;
  top: auto;
  width: 340px;
  height: 560px;
  max-height: calc(100vh - 40px);
  z-index: 999999;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-radius: 20px 0 0 20px;
  overflow: hidden;
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
  font-family: 'Inter', sans-serif;
}

#susan-panel.open {
  right: 0;
}

#susan-header {
  background: linear-gradient(135deg, #0b1b3a 0%, #0f2d6e 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(14,165,233,0.15);
  position: relative;
}

#susan-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e4d96, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}

#susan-header-info {
  flex: 1;
  min-width: 0;
}

#susan-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

#susan-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
}

#susan-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: susanDotPulse 2s ease-in-out infinite;
}

#susan-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#susan-close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

#susan-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#susan-messages::-webkit-scrollbar { width: 4px; }
#susan-messages::-webkit-scrollbar-track { background: transparent; }
#susan-messages::-webkit-scrollbar-thumb { background: rgba(14,165,233,0.3); border-radius: 2px; }

.susan-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: susanMsgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes susanMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.susan-msg.bot { flex-direction: row; }
.susan-msg.user { flex-direction: row-reverse; }

.susan-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e4d96, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.susan-msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

.susan-msg.bot .susan-msg-bubble {
  background: #fff;
  color: #1e293b;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.susan-msg.user .susan-msg-bubble {
  background: linear-gradient(135deg, #1e4d96, #0ea5e9);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

#susan-quick-replies {
  padding: 8px 16px 4px;
  background: #f8fafc;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.susan-qr {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #1e4d96;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.susan-qr:hover {
  background: #1e4d96;
  color: #fff;
  border-color: #1e4d96;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(30,77,150,0.3);
}

.susan-qr i {
  margin-right: 4px;
  font-size: 11px;
}

#susan-typing {
  display: none;
  padding: 0 16px 4px;
  background: #f8fafc;
}

.susan-typing-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.susan-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: susanTyping 1.2s ease-in-out infinite;
}

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

@keyframes susanTyping {
  0%, 80%, 100% { transform: scale(1); opacity: 0.5; }
  40% { transform: scale(1.3); opacity: 1; }
}

#susan-input-area {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#susan-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  height: 38px;
  line-height: 1.4;
}

#susan-input:focus {
  border-color: #0ea5e9;
}

#susan-input::placeholder {
  color: #94a3b8;
}

#susan-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e4d96, #0ea5e9);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(14,165,233,0.4);
}

#susan-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(14,165,233,0.5);
}

#susan-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999997;
  backdrop-filter: blur(2px);
}

#susan-overlay.show { display: none; }

@media (max-width: 480px) {
  #susan-overlay.show { display: block; }

  #susan-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    top: 0;
    bottom: auto;
    right: -100vw;
  }
  #susan-panel.open { right: 0; }
  #susan-tab { top: auto; bottom: 100px; transform: none; }
  #susan-teaser {
    top: auto;
    bottom: 155px;
    right: 16px;
    transform: translateX(10px);
    max-width: 170px;
  }
  #susan-teaser.show {
    transform: translateX(0);
  }
  #susan-teaser::after {
    top: auto;
    bottom: -7px;
    right: 20px;
    transform: none;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid #fff;
    border-bottom: none;
  }
  #susan-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
