/* ========================================================
   Floating AI Chat Assistant Styles - Abbas Raza Portfolio
   ======================================================== */

#ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  border: none;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 99999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chat-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.55);
}

#ai-chat-fab .fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

#ai-chat-fab .fab-tooltip {
  position: absolute;
  right: 70px;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-family: inherit;
}

#ai-chat-fab:hover .fab-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Teaser greeting bubble */
#ai-chat-teaser {
  position: fixed;
  bottom: 92px;
  right: 24px;
  background: #111a2e;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 340px;
  z-index: 99999;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#ai-chat-teaser.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ai-teaser-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #3b82f6;
  flex-shrink: 0;
}

.ai-teaser-content {
  flex: 1;
  line-height: 1.4;
}

.ai-teaser-title {
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
}

.ai-teaser-text {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 3px;
}

#ai-teaser-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.2s;
  align-self: flex-start;
}

#ai-teaser-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.ai-teaser-arrow {
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #111a2e;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transform: rotate(45deg);
}

/* Background Backdrop */
#ai-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 23, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#ai-chat-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Chat Window */
#ai-chat-window {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: #111a2e;
  color: #f8fafc;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: aiChatSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), height 0.35s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.35s ease;
}

#ai-chat-window.open {
  display: flex;
}

#ai-chat-window.expanded {
  width: 470px;
  height: calc(100vh - 90px);
  max-height: 880px;
}

@keyframes aiChatSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
#ai-chat-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #3b82f6;
}

.ai-chat-title-group h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
}

.ai-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}

.ai-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  box-shadow: 0 0 6px #10b981;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-chat-icon-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.ai-chat-icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

/* Messages Area */
#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

#ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.ai-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.ai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg-bot {
  align-self: flex-start;
  background: #1b263b;
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.ai-msg-bot a {
  color: #60a5fa;
  text-decoration: underline;
}

.ai-msg-bot h3, .ai-msg-bot h4, .ai-msg-bot h5 {
  margin: 10px 0 6px 0;
  color: #93c5fd;
  font-weight: 600;
  line-height: 1.3;
}

.ai-msg-bot h3 { font-size: 15px; }
.ai-msg-bot h4 { font-size: 14px; }
.ai-msg-bot h5 { font-size: 13.5px; }

.ai-msg-bot ul, .ai-msg-bot ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ai-msg-bot p {
  margin: 4px 0;
}

.ai-msg-bot code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 5px;
  border-radius: 4px;
  color: #f43f5e;
  font-size: 12px;
}

/* Quick Suggestion Chips */
.ai-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ai-chip {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-chip:hover {
  background: rgba(59, 130, 246, 0.28);
  color: #fff;
  border-color: #60a5fa;
}

/* Loading Indicator */
.ai-loading-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
}

.ai-loading-dots span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: aiDotBounce 1.4s infinite ease-in-out both;
}

.ai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* Footer & Input */
#ai-chat-footer {
  padding: 12px;
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px 10px;
}

.ai-input-row:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
}

#ai-chat-input::placeholder {
  color: #64748b;
}

#ai-chat-send-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.2s;
}

#ai-chat-send-btn:hover {
  background: #1d4ed8;
}

.ai-disclaimer {
  font-size: 10.5px;
  color: #64748b;
  text-align: center;
  margin: 0;
}

@media (max-width: 520px) {
  #ai-chat-window, #ai-chat-window.expanded {
    right: 12px;
    bottom: 78px;
    width: calc(100vw - 24px);
    height: calc(100vh - 96px);
    max-height: none;
  }
  #ai-chat-teaser {
    right: 16px;
    bottom: 76px;
    max-width: calc(100vw - 32px);
  }
  #ai-chat-fab {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }
}
