/* ═══════════════════════════════════════════
   Chat Widget — simonecama.com
   Modernised glassmorphism design
   ═══════════════════════════════════════════ */

/* ── Toggle Button ─────────────────────── */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 28px rgba(79, 70, 229, 0.5),
              0 0 0 0 rgba(124, 58, 237, 0.4);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1),
              box-shadow 0.3s cubic-bezier(.4,0,.2,1);
  animation: chatPulseRing 3s ease-in-out infinite;
}
.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 36px rgba(79, 70, 229, 0.6),
              0 0 0 0 rgba(124, 58, 237, 0);
  animation: none;
}

@keyframes chatPulseRing {
  0%, 100% { box-shadow: 0 6px 28px rgba(79,70,229,0.5), 0 0 0 0 rgba(124,58,237,0.35); }
  50%      { box-shadow: 0 6px 28px rgba(79,70,229,0.5), 0 0 0 10px rgba(124,58,237,0); }
}

/* ── Container ─────────────────────────── */
.chat-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9998;
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: min(580px, calc(100dvh - 120px));
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(79, 70, 229, 0.1);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.14),
              0 0 0 1px rgba(79, 70, 229, 0.06);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.94);
  transition: opacity 0.35s cubic-bezier(.4,0,.2,1),
              transform 0.35s cubic-bezier(.4,0,.2,1);
}
.chat-container.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────── */
.chat-header {
  background: linear-gradient(135deg, #0a0a23 0%, #12123a 50%, #1d1060 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(79, 70, 229, 0.25);
  position: relative;
}
/* subtle header glow */
.chat-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.5), transparent);
}

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-header-info {
  flex: 1;
  min-width: 0;
}
.chat-header-info h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.chat-header-info p {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 5px;
}
/* online status dot */
.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.chat-close-btn {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
  flex-shrink: 0;
}
.chat-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ── Messages Area ─────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(244, 243, 250, 0.6);
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(79, 70, 229, 0.18);
  border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 70, 229, 0.35);
}

/* ── Messages ──────────────────────────── */
.chat-msg {
  max-width: 85%;
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 0.85rem;
  line-height: 1.6;
  word-break: break-word;
  animation: msgSlideIn 0.3s cubic-bezier(.4,0,.2,1) both;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg a {
  color: #4f46e5;
  text-decoration: underline;
  text-decoration-color: rgba(79, 70, 229, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}
.chat-msg a:hover {
  text-decoration-color: #4f46e5;
}
.chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
}
.chat-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #1a1a2e;
  border: 1px solid rgba(79, 70, 229, 0.08);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.chat-msg-bot strong {
  color: #4f46e5;
}

/* ── Markdown elements inside messages ─── */
.chat-msg-bot .chat-code-block {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 10px;
  padding: 8px 12px;
  margin: 4px 0 2px;
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  font-family: "Fira Code", "SF Mono", "Cascadia Mono", "Consolas", monospace;
}
.chat-msg-bot .chat-code-block code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
.chat-msg-bot .chat-inline-code {
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: "Fira Code", "SF Mono", "Cascadia Mono", "Consolas", monospace;
}
.chat-msg-bot .chat-heading {
  margin: 4px 0 1px;
  font-weight: 700;
  color: #312e81;
  line-height: 1.3;
}
.chat-msg-bot h3.chat-heading { font-size: 0.95rem; }
.chat-msg-bot h4.chat-heading { font-size: 0.88rem; }
.chat-msg-bot h5.chat-heading { font-size: 0.84rem; }
.chat-msg-bot em {
  font-style: italic;
  opacity: 0.88;
}
.chat-msg-bot ul,
.chat-msg-bot ol {
  margin: 2px 0;
  padding-left: 18px;
}
.chat-msg-bot li {
  margin: 0;
}
.chat-msg-bot ul { list-style-type: disc; }
.chat-msg-bot ol { list-style-type: decimal; }

/* ── Typing indicator ──────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  border: 1px solid rgba(79, 70, 229, 0.08);
  animation: msgSlideIn 0.3s cubic-bezier(.4,0,.2,1) both;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  opacity: 0.4;
  animation: chatBounce 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(79, 70, 229, 0.06);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid rgba(79, 70, 229, 0.12);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  background: rgba(250, 249, 255, 0.9);
}
.chat-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.chat-input::placeholder {
  color: #9ca3af;
}
.chat-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.4,0,.2,1),
              box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(79, 70, 229, 0.3);
}
.chat-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 18px rgba(79, 70, 229, 0.45);
}
.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Suggested Questions ───────────────── */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.chat-suggestion-btn {
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid rgba(79, 70, 229, 0.12);
  border-radius: 14px;
  padding: 9px 14px;
  font-size: 0.8rem;
  color: #4f46e5;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.chat-suggestion-btn:hover {
  background: rgba(79, 70, 229, 0.12);
  border-color: rgba(79, 70, 229, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.1);
}

/* ── Disclaimer ────────────────────────── */
.chat-disclaimer {
  font-size: 0.68rem;
  color: #6b7280;
  text-align: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(79, 70, 229, 0.04);
}

/* ── Dark mode ─────────────────────────── */
[data-bs-theme="dark"] .chat-container {
  background: rgba(14, 14, 30, 0.88);
  border-color: rgba(124, 58, 237, 0.15);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4),
              0 0 0 1px rgba(124, 58, 237, 0.1);
}
[data-bs-theme="dark"] .chat-messages {
  background: rgba(13, 17, 23, 0.5);
}
[data-bs-theme="dark"] .chat-msg-bot {
  background: rgba(22, 27, 34, 0.9);
  color: #e6edf3;
  border-color: rgba(124, 58, 237, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
[data-bs-theme="dark"] .chat-msg-bot strong {
  color: #a78bfa;
}
[data-bs-theme="dark"] .chat-msg-bot .chat-code-block {
  background: #11111b;
  color: #cdd6f4;
}
[data-bs-theme="dark"] .chat-msg-bot .chat-inline-code {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
}
[data-bs-theme="dark"] .chat-msg-bot .chat-heading {
  color: #c4b5fd;
}
[data-bs-theme="dark"] .chat-msg-user {
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
}
[data-bs-theme="dark"] .chat-msg a {
  color: #a78bfa;
  text-decoration-color: rgba(167, 139, 250, 0.3);
}
[data-bs-theme="dark"] .chat-msg a:hover {
  text-decoration-color: #a78bfa;
}
[data-bs-theme="dark"] .chat-typing {
  background: rgba(22, 27, 34, 0.9);
  border-color: rgba(124, 58, 237, 0.12);
}
[data-bs-theme="dark"] .chat-input-area {
  background: rgba(14, 14, 30, 0.6);
  border-color: rgba(124, 58, 237, 0.08);
}
[data-bs-theme="dark"] .chat-input {
  background: rgba(22, 27, 34, 0.9);
  border-color: rgba(124, 58, 237, 0.18);
  color: #e6edf3;
}
[data-bs-theme="dark"] .chat-input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
[data-bs-theme="dark"] .chat-input::placeholder {
  color: #6b7280;
}
[data-bs-theme="dark"] .chat-suggestion-btn {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.18);
  color: #a78bfa;
}
[data-bs-theme="dark"] .chat-suggestion-btn:hover {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: 0 3px 10px rgba(124, 58, 237, 0.15);
}
[data-bs-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.2);
}
[data-bs-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.4);
}
[data-bs-theme="dark"] .chat-disclaimer {
  background: rgba(14, 14, 30, 0.6);
  color: #9ca3af;
  border-color: rgba(124, 58, 237, 0.06);
}

/* ── Mobile ────────────────────────────── */
@media (max-width: 480px) {
  .chat-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
  }
  .chat-container.open {
    height: 100%;
  }
  .chat-toggle {
    bottom: 16px;
    right: 16px;
  }
  .chat-header {
    padding: 14px 16px;
  }
}
