/* ═══════════════════════════════════════════════════════════════════════════
   GRIM AI COMPANION (PURE CHAT INTERFACE)
   Cyberpunk / Dark Gothic Modern Aesthetic (Lightweight, No 3D/Audio)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --grim-ai-primary: #9d5cf8;
  --grim-ai-primary-hover: #b074ff;
  --grim-ai-glow: rgba(157, 92, 248, 0.4);
  --grim-ai-bg: rgba(11, 9, 22, 0.94);
  --grim-ai-drawer-bg: rgba(13, 11, 26, 0.95);
  --grim-ai-border: rgba(168, 85, 247, 0.32);
  --grim-ai-border-hover: rgba(192, 132, 252, 0.55);
  --grim-ai-text: #f1effa;
  --grim-ai-muted: #8b87a2;
}

#grim-companion-widget {
  position: fixed;
  bottom: 24px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  user-select: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#grim-companion-widget * {
  box-sizing: border-box;
}

/* ── FLOATING LAUNCHER TRIGGER BUTTON ── */
.grim-chat-trigger {
  pointer-events: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  background: linear-gradient(135deg, rgba(24, 16, 48, 0.95), rgba(12, 10, 24, 0.98));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--grim-ai-border);
  border-radius: 9999px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 20px rgba(157, 92, 248, 0.28);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.grim-chat-trigger:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--grim-ai-border-hover);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75), 0 0 30px rgba(157, 92, 248, 0.45);
}

.grim-chat-trigger:active {
  transform: translateY(-1px) scale(0.99);
}

.grim-trigger-inner {
  display: flex;
  align-items: center;
  gap: 9px;
}

.grim-trigger-icon {
  width: 18px;
  height: 18px;
  color: #c084fc;
  filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.6));
  transition: transform 0.3s ease;
}

.grim-chat-trigger:hover .grim-trigger-icon {
  transform: scale(1.12) rotate(-5deg);
}

.grim-trigger-label {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: linear-gradient(135deg, #ffffff 40%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.grim-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e, 0 0 16px rgba(34, 197, 94, 0.6);
  animation: grimPulseDot 2s infinite ease-in-out;
}

/* ── EXPANDED CHAT DRAWER ── */
.grim-chat-drawer {
  pointer-events: auto;
  position: fixed;
  bottom: 84px;
  right: 28px;
  width: 400px;
  height: 540px;
  max-height: calc(100vh - 110px);
  background: var(--grim-ai-drawer-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--grim-ai-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(157, 92, 248, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
}

.grim-chat-drawer.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── DRAWER HEADER ── */
.grim-drawer-header {
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grim-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grim-name-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a855f7;
  box-shadow: 0 0 10px #a855f7;
  animation: grimPulseDot 2.2s infinite;
}

.grim-title-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.grim-main-title {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: 0.3px;
}

.grim-sub-title {
  font-size: 10.5px;
  color: #a855f7;
  font-weight: 600;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.grim-vip-badge {
  display: inline-block;
  padding: 1px 5px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(236, 72, 153, 0.25));
  border: 1px solid rgba(168, 85, 247, 0.5);
  border-radius: 4px;
  color: #d8b4fe;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.grim-guest-badge {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: #cbd5e1;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.grim-drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grim-icon-btn {
  background: transparent;
  border: none;
  color: #8c89a0;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.grim-icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* ── CHAT BODY & MESSAGES ── */
.grim-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(168, 85, 247, 0.3) transparent;
}

.grim-chat-body::-webkit-scrollbar {
  width: 5px;
}

.grim-chat-body::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 10px;
}

.grim-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  animation: grimMsgIn 0.22s ease-out;
}

.grim-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.grim-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.grim-msg-bubble {
  padding: 11px 15px;
  word-break: break-word;
}

.grim-msg.user .grim-msg-bubble {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border-radius: 16px 16px 3px 16px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(109, 40, 217, 0.35);
}

.grim-msg.assistant .grim-msg-bubble {
  background: rgba(26, 20, 50, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.26);
  color: #eae6f5;
  border-radius: 16px 16px 16px 3px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.grim-msg-bubble strong {
  color: #d8b4fe;
  font-weight: 600;
}

.grim-msg-bubble code.grim-code {
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #f3e8ff;
  padding: 1px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12px;
}

.grim-msg-meta {
  font-size: 10.5px;
  font-weight: 500;
  color: #79768f;
  margin-top: 4px;
  padding: 0 4px;
  letter-spacing: 0.2px;
}

/* ── QUICK SUGGESTION PILLS ── */
.grim-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.grim-pill-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #b8b6c8;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.grim-pill-btn:hover {
  background: rgba(168, 85, 247, 0.22);
  color: #fff;
  border-color: rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
}

/* ── TYPING INDICATOR ── */
.grim-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: fit-content;
}

.grim-typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #a855f7;
  animation: grimDotJump 1.2s infinite ease-in-out;
}

.grim-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.grim-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* ── CHAT FOOTER / INPUT ── */
.grim-chat-footer {
  padding: 12px 14px;
  background: rgba(14, 12, 26, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grim-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 13px;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.grim-chat-input:focus {
  border-color: #a855f7;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.grim-chat-send-btn {
  background: #7c3aed;
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 14px rgba(124, 58, 237, 0.45);
}

.grim-chat-send-btn:hover {
  background: #8b5cf6;
  transform: scale(1.05);
}

.grim-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ── KEYFRAME ANIMATIONS ── */
@keyframes grimPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

@keyframes grimDotJump {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

@keyframes grimMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  #grim-companion-widget {
    bottom: 16px;
    right: 16px;
  }
  .grim-chat-drawer {
    right: 12px;
    left: 12px;
    bottom: 74px;
    width: auto;
    height: 480px;
  }
}
