/**
 * Zia Ul Ain Portfolio - Luxury AI Chatbot Widget Styles
 * Powered by Groq API (openai/gpt-oss-120b)
 */

/* -------------------------------------------------------------------------
   Floating Action Buttons (Scroll-Top & AI Chatbot Vertical Alignment)
-------------------------------------------------------------------------- */
.scroll-top {
  position: fixed !important;
  right: 20px !important;
  bottom: -20px !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9990 !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15) !important;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.scroll-top.active {
  visibility: visible !important;
  opacity: 1 !important;
  bottom: 20px !important;
}

.scroll-top:hover {
  transform: translateY(-3px) scale(1.05) !important;
  box-shadow: 0 10px 24px rgba(5, 99, 187, 0.4) !important;
}

/* -------------------------------------------------------------------------
   1. Floating Launcher Button & Tooltip
-------------------------------------------------------------------------- */
.ai-chat-widget {
  position: fixed;
  bottom: 80px; /* Aligned directly above .scroll-top */
  right: 20px;  /* Exact same right coordinate as .scroll-top */
  z-index: 9999;
  font-family: var(--default-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

/* Callout Tooltip Bubble */
.ai-chat-tooltip {
  position: absolute;
  bottom: 62px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f8fafc;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  pointer-events: auto;
  animation: chatTooltipBounce 3.5s ease-in-out infinite;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-chat-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: rgba(15, 23, 42, 0.94);
  transform: rotate(45deg);
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.ai-chat-tooltip .sparkle-icon {
  font-size: 0.95rem;
  animation: chatSparkleSpin 3s linear infinite;
  display: inline-block;
}

.ai-chat-tooltip .tooltip-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0 0 4px;
  cursor: pointer;
  transition: color 0.2s;
}

.ai-chat-tooltip .tooltip-close-btn:hover {
  color: #ffffff;
}

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

@keyframes chatSparkleSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

/* Launcher Button (Matching 48px round FAB) */
.ai-chat-launcher {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0563bb 0%, #1d4ed8 50%, #4338ca 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(5, 99, 187, 0.42), 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.ai-chat-launcher:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 28px rgba(5, 99, 187, 0.55), 0 5px 10px rgba(0, 0, 0, 0.2);
}

.ai-chat-launcher:active {
  transform: translateY(0) scale(0.96);
}

/* Pulsing Glowing Aura around Launcher */
.launcher-aura {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.6);
  opacity: 0;
  animation: launcherPulse 2.4s cubic-bezier(0.24, 0, 0.38, 1) infinite;
  pointer-events: none;
}

@keyframes launcherPulse {
  0% {
    transform: scale(0.92);
    opacity: 0.8;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Status Indicator Dot on Launcher */
.launcher-online-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.launcher-online-dot::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border-radius: 50%;
  border: 1.5px solid #10b981;
  animation: dotPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes dotPing {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* -------------------------------------------------------------------------
   2. Chatbot Window Modal Container
-------------------------------------------------------------------------- */
.ai-chat-window {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 410px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 160px);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.26s;
  pointer-events: none;
  z-index: 10000;
}

.ai-chat-window.chat-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* -------------------------------------------------------------------------
   3. Window Header
-------------------------------------------------------------------------- */
.ai-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0369a1 100%);
  color: #ffffff;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 2;
}

.chat-avatar-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0563bb, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(5, 99, 187, 0.35);
  flex-shrink: 0;
}

.chat-avatar-circle {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

.chat-header-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  line-height: 1.2;
}

.chat-header-sub {
  font-size: 0.73rem;
  color: #94a3b8;
  margin-top: 2px;
}

.badge-online {
  color: #34d399;
  font-weight: 600;
}

.chat-control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-control-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  transform: scale(1.06);
}

/* -------------------------------------------------------------------------
   4. Chat Body & Scroll Area
-------------------------------------------------------------------------- */
.ai-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  gap: 12px;
}

/* Custom Chat Scrollbar */
.ai-chat-body::-webkit-scrollbar {
  width: 5px;
}
.ai-chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
.ai-chat-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* -------------------------------------------------------------------------
   5. Welcome Card & Quick Chips
-------------------------------------------------------------------------- */
.chat-welcome-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.urdu-greeting {
  font-family: 'Noto Nastaliq Urdu', 'Segoe UI', Tahoma, sans-serif;
  line-height: 2;
  font-size: 0.95rem;
  color: #1e3a8a;
  border-right: 3px solid #0563bb;
  padding-right: 10px;
  margin: 8px 0 12px 0;
}

.chat-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-chip-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.3;
}

.chat-chip-btn:hover {
  background: #0563bb;
  border-color: #0563bb;
  color: #ffffff;
  transform: translateY(-1.5px);
  box-shadow: 0 3px 8px rgba(5, 99, 187, 0.25);
}

.chat-chip-btn.chip-urdu {
  font-family: 'Noto Nastaliq Urdu', 'Segoe UI', Tahoma, sans-serif;
  direction: rtl;
  font-size: 0.8rem;
  padding: 4px 12px;
}

/* -------------------------------------------------------------------------
   6. Message Bubbles (User & Bot)
-------------------------------------------------------------------------- */
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: messageFadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* User Message */
.chat-message.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.user-message .message-bubble {
  background: linear-gradient(135deg, #0563bb 0%, #2563eb 100%);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  font-size: 0.87rem;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(5, 99, 187, 0.22);
  word-break: break-word;
}

/* Bot Message */
.chat-message.bot-message {
  align-self: flex-start;
}

.chat-message.bot-message .message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0563bb, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.82rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-message.bot-message .message-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 18px 18px 18px 4px;
  padding: 12px 15px;
  font-size: 0.87rem;
  line-height: 1.55;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  word-break: break-word;
}

/* Urdu Language Styling in Message Bubble */
.chat-message.is-urdu .message-bubble,
.chat-message .message-bubble.is-urdu,
.chat-message .message-bubble[dir="rtl"],
.urdu-text {
  direction: rtl;
  text-align: right;
  font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Segoe UI', Tahoma, sans-serif !important;
  font-size: 0.94rem !important;
  line-height: 2.1 !important;
}

.chat-message.is-urdu .message-bubble ul,
.chat-message .message-bubble[dir="rtl"] ul,
.chat-message.is-urdu .message-bubble ol,
.chat-message .message-bubble[dir="rtl"] ol {
  padding-right: 22px !important;
  padding-left: 0 !important;
  margin-top: 4px;
  margin-bottom: 8px;
}

.chat-message.is-urdu .message-bubble li,
.chat-message .message-bubble[dir="rtl"] li {
  margin-bottom: 6px;
  line-height: 2.2 !important;
}

/* -------------------------------------------------------------------------
   7. Markdown Elements inside Bot Message
-------------------------------------------------------------------------- */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
  color: #0f172a;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.message-bubble h3 { font-size: 0.98rem; }
.message-bubble h4 { font-size: 0.92rem; }
.message-bubble h5 { font-size: 0.86rem; }

.message-bubble p {
  margin-bottom: 8px;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
  padding-left: 18px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.message-bubble li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.message-bubble strong {
  color: #0f172a;
  font-weight: 600;
}

.message-bubble a {
  color: #0563bb;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: color 0.2s;
}

.message-bubble a:hover {
  color: #1d4ed8;
}

.message-bubble blockquote {
  border-left: 3px solid #0563bb;
  background: rgba(5, 99, 187, 0.05);
  margin: 8px 0;
  padding: 6px 12px;
  border-radius: 0 8px 8px 0;
  color: #334155;
  font-style: italic;
}

/* Inline Code */
.message-bubble code:not(pre code) {
  background: rgba(5, 99, 187, 0.08);
  color: #0563bb;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 0.82em;
  font-weight: 500;
}

/* Code Blocks with Header & Copy Button */
.code-block-wrapper {
  position: relative;
  margin: 10px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #1e293b;
  background: #0f172a;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
  padding: 5px 12px;
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: 'Fira Code', monospace;
  text-transform: uppercase;
}

.code-copy-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.code-copy-btn.copied {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #f1f5f9;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* Markdown Tables */
.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 8px 0;
  border-radius: 6px;
  overflow: hidden;
}

.message-bubble th,
.message-bubble td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.message-bubble th {
  background: #f1f5f9;
  font-weight: 600;
  color: #1e293b;
}

/* -------------------------------------------------------------------------
   8. Typing Indicator Bubble
-------------------------------------------------------------------------- */
.typing-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #0563bb;
  border-radius: 50%;
  opacity: 0.4;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* -------------------------------------------------------------------------
   9. Footer Input Bar
-------------------------------------------------------------------------- */
.ai-chat-footer {
  background: #ffffff;
  padding: 10px 14px 10px;
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 24px 24px;
}

.input-wrapper {
  display: flex;
  align-items: center;
}

.chat-input {
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 0.86rem;
  max-height: 100px;
  min-height: 38px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
  line-height: 1.4;
}

.chat-input:focus {
  background: #ffffff;
  border-color: #0563bb;
  box-shadow: 0 0 0 3px rgba(5, 99, 187, 0.12);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  background: linear-gradient(135deg, #0563bb, #2563eb);
  border: none;
  color: #ffffff;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(5, 99, 187, 0.35);
}

.chat-send-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.7;
}

/* -------------------------------------------------------------------------
   10. Mobile Responsive Adaptations
-------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .scroll-top {
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
  }

  .scroll-top.active {
    bottom: 16px !important;
  }

  .ai-chat-widget {
    bottom: 70px;
    right: 16px;
  }

  .ai-chat-tooltip {
    bottom: 54px;
    right: 0;
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  .ai-chat-launcher {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .ai-chat-window {
    position: fixed;
    bottom: 74px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    border-radius: 20px;
  }
}
