/* Bitcode Software - Advanced AI Agent Widget Styles */
:root {
  --bc-ai-primary: #2563eb;
  --bc-ai-primary-hover: #1d4ed8;
  --bc-ai-bg: #ffffff;
  --bc-ai-dark-bg: #0b1120;
  --bc-ai-text: #0f172a;
  --bc-ai-text-muted: #64748b;
  --bc-ai-border: #e2e8f0;
  --bc-ai-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(37, 99, 235, 0.15);
}

/* Animated Interactive Robot Mascot Trigger */
#bitcode-ai-trigger {
  position: fixed;
  bottom: 20px;
  right: 25px;
  width: 78px;
  height: 94px;
  cursor: pointer;
  z-index: 999990;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.25)) drop-shadow(0 0 15px rgba(56, 189, 248, 0.4));
  user-select: none;
}

#bitcode-ai-trigger:hover {
  transform: scale(1.12) translateY(-6px);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 24px rgba(56, 189, 248, 0.7));
}

.bitcode-ai-mascot-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* 1. Floating Body Animation */
.robot-floating-body {
  animation: robotFloat 3.2s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes robotFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-9px);
  }
}

/* 2. Ground Shadow Pulsing */
.robot-shadow {
  animation: robotShadowPulse 3.2s ease-in-out infinite;
  transform-origin: 100px 225px;
}

@keyframes robotShadowPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(0.72);
    opacity: 0.25;
  }
}

/* 3. Blinking Eyes Animation */
.robot-eye {
  animation: robotBlink 3.6s infinite;
}

.robot-eye-left {
  transform-origin: 84px 83px;
}

.robot-eye-right {
  transform-origin: 116px 83px;
}

@keyframes robotBlink {
  0%, 90%, 100% {
    transform: scaleY(1);
  }
  92%, 96% {
    transform: scaleY(0.08);
  }
  94% {
    transform: scaleY(1);
  }
}

/* 4. Moveable Waving Hand */
.robot-waving-hand {
  transform-origin: 68px 148px;
  animation: robotWaveArm 2.4s ease-in-out infinite;
}

@keyframes robotWaveArm {
  0%, 100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-18deg);
  }
  40% {
    transform: rotate(14deg);
  }
  60% {
    transform: rotate(-12deg);
  }
  80% {
    transform: rotate(10deg);
  }
}

/* Hover: Fast Energetic Wave & Eye Glow */
#bitcode-ai-trigger:hover .robot-waving-hand {
  animation: robotWaveArmFast 0.65s ease-in-out infinite;
}

@keyframes robotWaveArmFast {
  0%, 100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(26deg);
  }
}

#bitcode-ai-trigger:hover .robot-eye {
  filter: drop-shadow(0 0 8px #38bdf8);
}

/* Proactive Floating Bubble */
#bitcode-ai-nudge {
  position: fixed;
  bottom: 95px;
  right: 25px;
  background: #ffffff;
  color: #0f172a;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 1px solid #e2e8f0;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 260px;
  z-index: 999989;
  display: none;
  animation: fadeInSlideUp 0.4s ease forwards;
}
#bitcode-ai-nudge::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 24px;
  border-width: 8px 8px 0;
  border-style: solid;
  border-color: #ffffff transparent;
}

/* Chat Window Container */
#bitcode-ai-window {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: var(--bc-ai-shadow);
  border: 1px solid var(--bc-ai-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  font-family: 'Inter', system-ui, sans-serif;
  animation: aiWindowOpen 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Header */
.ai-header {
  background: #0b1120;
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ai-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
  overflow: hidden;
  padding: 2px;
}
.ai-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
}
.ai-status {
  font-size: 0.72rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.ai-header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-tool-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}
.ai-tool-btn:hover { background: rgba(255,255,255,0.2); }

/* Message Stream Area */
.ai-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.ai-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.ai-msg-user {
  align-self: flex-end;
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}
.ai-msg-assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}
.ai-msg-assistant p { margin-bottom: 8px; }
.ai-msg-assistant p:last-child { margin-bottom: 0; }
.ai-msg-assistant ul { padding-left: 20px; margin: 6px 0; }
.ai-msg-assistant strong { color: #0f172a; }
.ai-msg-assistant a { color: #2563eb; font-weight: 600; text-decoration: none; }
.ai-msg-assistant a:hover { text-decoration: underline; }

/* Quick Action Pills */
.ai-quick-actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  scrollbar-width: none;
}
.ai-quick-actions::-webkit-scrollbar { display: none; }
.ai-pill {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.ai-pill:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Typing Indicator */
.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
}
.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typingDot 1.4s infinite ease-in-out both;
}
.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.ai-input-wrapper {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}
.ai-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.ai-action-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.ai-action-btn:hover { color: #2563eb; background: #eff6ff; }
.ai-btn-send {
  background: #2563eb;
  color: #ffffff;
  width: 36px;
  height: 36px;
}
.ai-btn-send:hover {
  background: #1d4ed8;
  color: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #bitcode-ai-window {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }
}

/* In-Chat Interactive Form Card */
.ai-form-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-form-card h4 {
  margin: 0 0 4px 0;
  font-family: "Outfit", sans-serif;
  font-size: 0.92rem;
  color: #0f172a;
}
.ai-form-card input,
.ai-form-card select,
.ai-form-card textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.84rem;
  font-family: "Inter", sans-serif;
  outline: none;
  background: #ffffff;
}
.ai-form-card input:focus,
.ai-form-card select:focus,
.ai-form-card textarea:focus {
  border-color: #2563eb;
}
.ai-form-card button {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}
.ai-form-card button:hover {
  background: #1d4ed8;
}


/* === RTL ARABIC SUPPORT FOR AI CHAT WIDGET === */
[dir="rtl"] #bitcode-ai-trigger {
  right: auto !important;
  left: 25px !important;
}

[dir="rtl"] #bitcode-ai-nudge {
  right: auto !important;
  left: 30px !important;
  text-align: right !important;
  direction: rtl !important;
}

[dir="rtl"] #bitcode-ai-nudge::after {
  right: auto !important;
  left: 45px !important;
}

[dir="rtl"] #bitcode-ai-window {
  right: auto !important;
  left: 25px !important;
  text-align: right !important;
  direction: rtl !important;
}

[dir="rtl"] #bitcode-ai-window * {
  font-family: "Cairo", system-ui, sans-serif !important;
}

[dir="rtl"] .ai-header-brand {
  flex-direction: row;
}

[dir="rtl"] .ai-header-tools {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .ai-msg-user {
  margin-left: 0 !important;
  margin-right: auto !important;
  border-bottom-right-radius: 14px !important;
  border-bottom-left-radius: 2px !important;
}

[dir="rtl"] .ai-msg-assistant {
  margin-right: 0 !important;
  margin-left: auto !important;
  border-bottom-left-radius: 14px !important;
  border-bottom-right-radius: 2px !important;
}

[dir="rtl"] .ai-input {
  text-align: right !important;
  direction: rtl !important;
}

[dir="rtl"] .ai-form-card {
  text-align: right !important;
  direction: rtl !important;
}

[dir="rtl"] .ai-form-card label {
  text-align: right !important;
}

[dir="rtl"] .ai-form-input {
  text-align: right !important;
  direction: rtl !important;
}
