/* SabaqAI Chat Widget */

#sabaqai-container {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 99999;
  font-family: 'Inter', sans-serif;
}

/* ── Toggle Button — modern AI pill ── */
.sabaqai-toggle {
  height: 52px;
  padding: 0 20px 0 16px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1e2a4a 0%, #2d3a6a 60%, #3b2f6e 100%);
  box-shadow: 0 4px 24px rgba(30, 42, 90, 0.65),
              0 1px 0 rgba(255,255,255,0.08) inset,
              0 0 0 1px rgba(102,126,234,0.25);
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
  animation: sabaqai-pulse 3s ease-in-out infinite;
  position: relative;
  overflow: visible;
  white-space: nowrap;
}

.sabaqai-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 32px rgba(102,126,234,0.55),
              0 1px 0 rgba(255,255,255,0.1) inset,
              0 0 0 1px rgba(102,126,234,0.4);
  animation: none;
}

/* Sparkles icon */
.sabaqai-toggle .icon-sparkles {
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Label */
.sabaqai-toggle .btn-label {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Close icon — hidden by default, shown when open */
.sabaqai-toggle .icon-close {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.25s ease;
}

.sabaqai-toggle.is-open .icon-sparkles,
.sabaqai-toggle.is-open .btn-label {
  opacity: 0;
  transform: scale(0.7);
}

.sabaqai-toggle.is-open .icon-close {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

@keyframes sabaqai-pulse {
  0%, 100% {
    box-shadow: 0 4px 24px rgba(30,42,90,0.65),
                0 1px 0 rgba(255,255,255,0.08) inset,
                0 0 0 1px rgba(102,126,234,0.25);
  }
  50% {
    box-shadow: 0 4px 24px rgba(102,126,234,0.45),
                0 1px 0 rgba(255,255,255,0.08) inset,
                0 0 0 4px rgba(102,126,234,0.1);
  }
}

/* Notification dot */
.sabaqai-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 11px;
  height: 11px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid #1e2a4a;
  box-shadow: 0 0 6px rgba(74,222,128,0.7);
}

/* ── Chat Panel ── */
.sabaqai-panel {
  position: absolute;
  bottom: 68px;
  left: 0;
  width: 360px;
  height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(13, 27, 62, 0.92);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid rgba(102, 126, 234, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255,255,255,0.04) inset;
  transform-origin: bottom left;
  transform: scale(0.85) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.25s ease;
}

.sabaqai-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.sabaqai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(102,126,234,0.22) 0%, rgba(118,75,162,0.22) 100%);
  border-bottom: 1px solid rgba(102,126,234,0.18);
  flex-shrink: 0;
}

.sabaqai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(102,126,234,0.4);
}

.sabaqai-info { flex: 1; }
.sabaqai-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.sabaqai-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}
.sabaqai-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #4ade80;
  font-weight: 500;
}
.sabaqai-online::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(74,222,128,0.6);
  animation: sabaqai-blink 2s ease-in-out infinite;
}
@keyframes sabaqai-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.sabaqai-close-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sabaqai-close-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* Messages */
.sabaqai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.sabaqai-messages::-webkit-scrollbar { width: 4px; }
.sabaqai-messages::-webkit-scrollbar-track { background: transparent; }
.sabaqai-messages::-webkit-scrollbar-thumb {
  background: rgba(102,126,234,0.3);
  border-radius: 4px;
}

/* Individual message */
.sabaqai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: sabaqai-msgIn 0.25s ease;
}
@keyframes sabaqai-msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sabaqai-msg.user { align-self: flex-end; align-items: flex-end; }
.sabaqai-msg.bot  { align-self: flex-start; align-items: flex-start; }

.sabaqai-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.sabaqai-msg.user .sabaqai-bubble {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(102,126,234,0.3);
}

.sabaqai-msg.bot .sabaqai-bubble {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}

/* Markdown inside bot bubble */
.sabaqai-bubble strong { color: #a5b4fc; font-weight: 600; }
.sabaqai-bubble em { color: #c4b5fd; font-style: italic; }
.sabaqai-bubble code {
  background: rgba(102,126,234,0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: monospace;
  color: #818cf8;
}
.sabaqai-bubble a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sabaqai-bubble a:hover { color: #a5b4fc; }
.sabaqai-bubble ul {
  margin: 4px 0 4px 16px;
  padding: 0;
  list-style: disc;
}
.sabaqai-bubble li { margin: 2px 0; }
.sabaqai-bubble p  { margin: 0 0 4px; }
.sabaqai-bubble p:last-child { margin-bottom: 0; }

/* Typing indicator */
.sabaqai-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.sabaqai-typing span {
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: sabaqai-bounce 1.2s ease-in-out infinite;
}
.sabaqai-typing span:nth-child(2) { animation-delay: 0.18s; }
.sabaqai-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes sabaqai-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); background: rgba(102,126,234,0.8); }
}

/* Input area */
.sabaqai-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.sabaqai-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  caret-color: #818cf8;
}
.sabaqai-input::placeholder { color: rgba(255,255,255,0.3); }
.sabaqai-input:focus {
  border-color: rgba(102,126,234,0.5);
  background: rgba(255,255,255,0.1);
}

.sabaqai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 2px 10px rgba(102,126,234,0.35);
}
.sabaqai-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(102,126,234,0.55);
}
.sabaqai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Powered by footer */
.sabaqai-footer {
  text-align: center;
  padding: 6px 0 10px;
  font-size: 10.5px;
  color: rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.2);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.sabaqai-footer a {
  color: rgba(165,180,252,0.5);
  text-decoration: none;
}
.sabaqai-footer a:hover { color: rgba(165,180,252,0.8); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #sabaqai-container {
    bottom: 18px;
    left: 18px;
  }
  .sabaqai-panel {
    width: calc(100vw - 36px);
    height: 70vh;
    max-height: 520px;
  }
}
