/* ============================================================
   Saint AI Agent — Styles
   Position: fixed, bottom-right
   ============================================================ */

/* ---- Floating Trigger Button ---- */
#saint-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1e3a8a, #0a0e1a);
  border: 1px solid rgba(100, 150, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(100, 150, 255, 0.1),
    0 0 18px rgba(50, 100, 255, 0.35),
    0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: saint-float 3s ease-in-out infinite alternate;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#saint-trigger:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 0 1px rgba(100, 150, 255, 0.3),
    0 0 28px rgba(80, 130, 255, 0.6),
    0 8px 30px rgba(0, 0, 0, 0.5);
}

.saint-icon {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 0 6px rgba(100, 150, 255, 0.9));
}

@keyframes saint-float {
  from { box-shadow: 0 0 14px rgba(50, 100, 255, 0.3), 0 4px 20px rgba(0,0,0,0.5); }
  to   { box-shadow: 0 0 24px rgba(80, 140, 255, 0.55), 0 8px 30px rgba(0,0,0,0.5); }
}

/* ---- Chat Window ---- */
#saint-chat-ui {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 99998;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 490px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(9, 11, 18, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(100, 150, 255, 0.08);
  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

#saint-chat-ui.saint-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ---- Header ---- */
.saint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.saint-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saint-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1e40af, #0a0e1a);
  border: 1px solid rgba(100, 150, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.saint-avatar svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 0 4px rgba(100, 150, 255, 0.7));
}

.saint-name {
  font-size: 1rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.3px;
  line-height: 1;
}

.saint-status {
  font-size: 0.72rem;
  color: #6496ff;
  margin-top: 3px;
  line-height: 1;
}

.saint-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.saint-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* ---- Messages Area ---- */
.saint-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.saint-messages::-webkit-scrollbar { width: 4px; }
.saint-messages::-webkit-scrollbar-track { background: transparent; }
.saint-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ---- Message Bubbles ---- */
.saint-message {
  max-width: 88%;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}

.saint-message p {
  margin: 0 0 6px 0;
}
.saint-message p:last-child { margin-bottom: 0; }

.saint-msg-agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  padding: 12px 15px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.saint-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  color: #fff;
  padding: 12px 15px;
  border-radius: 14px;
  border-bottom-right-radius: 4px;
}

/* ---- Typing Indicator ---- */
.saint-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.saint-typing span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: block;
  animation: saint-bounce 1.3s ease-in-out infinite both;
}

.saint-typing span:nth-child(2) { animation-delay: 0.15s; }
.saint-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes saint-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ---- Input Area ---- */
.saint-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

#saint-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 10px 18px;
  color: #f1f5f9;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

body.saint-chat-open {
  overflow: hidden;
}

#saint-input:focus {
  border-color: rgba(100, 150, 255, 0.45);
}

#saint-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

#saint-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

#saint-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  transform: scale(1.05);
}

#saint-send:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
  transform: none;
}

/* ---- Mobile Full-Screen ---- */
@media (max-width: 520px) {
  #saint-chat-ui {
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: calc(100% - 24px);
    height: min(520px, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  .saint-input-area {
    padding: 12px;
    gap: 8px;
  }

  #saint-input {
    padding: 12px 14px;
    font-size: 16px;
  }

  #saint-send {
    width: 44px;
    height: 44px; /* Larger tap target for mobile */
  }

  #saint-trigger {
    bottom: 16px;
    right: 16px;
  }
}

/* ---- Ghost Trigger ---- */
.saint-trigger-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.8) !important;
}
