/* ==========================================================================
   QARI.AI - MODERN INTERACTIVE AI CHATBOT STYLES
   Hafiz Saddique Quran Academy
   ========================================================================== */

:root {
  --qari-navy-dark: #081421;
  --qari-navy: #0D2033;
  --qari-navy-light: #16324F;
  --qari-gold: #D4AF37;
  --qari-gold-light: #E5C365;
  --qari-gold-dark: #B8860B;
  --qari-gold-glow: rgba(212, 175, 55, 0.35);
  --qari-cream: #FAF7F2;
  --qari-cream-dark: #F0ECE1;
  --qari-white: #FFFFFF;
  --qari-text-dark: #1E293B;
  --qari-text-muted: #64748B;
  --qari-text-light: #F8FAFC;
  --qari-emerald: #10B981;
  --qari-shadow-sm: 0 4px 12px rgba(8, 20, 33, 0.08);
  --qari-shadow-md: 0 10px 30px rgba(8, 20, 33, 0.16);
  --qari-shadow-lg: 0 20px 50px rgba(8, 20, 33, 0.28);
  --qari-radius-sm: 10px;
  --qari-radius-md: 16px;
  --qari-radius-lg: 24px;
  --qari-radius-full: 9999px;
  --qari-transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --qari-font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   1. FLOATING LAUNCHER BUTTON & BADGE
   -------------------------------------------------------------------------- */
.qari-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-family: var(--qari-font-main);
  transition: var(--qari-transition);
}

.qari-launcher-pill {
  background: var(--qari-navy-dark);
  color: var(--qari-white);
  padding: 8px 14px;
  border-radius: var(--qari-radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1.5px solid var(--qari-gold);
  box-shadow: var(--qari-shadow-md);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
  animation: qariPillGlow 3s infinite ease-in-out;
  transition: var(--qari-transition);
}

.qari-launcher-pill .qari-sparkle {
  color: var(--qari-gold);
  font-size: 0.95rem;
}

.qari-launcher-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--qari-navy) 0%, var(--qari-navy-dark) 100%);
  border: 2.5px solid var(--qari-gold);
  box-shadow: 0 8px 30px rgba(13, 32, 51, 0.4), 0 0 20px var(--qari-gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: var(--qari-transition);
  animation: qariLauncherBounce 4s ease-in-out infinite;
}

.qari-launcher-btn:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 12px 35px rgba(13, 32, 51, 0.5), 0 0 25px rgba(212, 175, 55, 0.55);
}

.qari-launcher-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--qari-transition);
}

.qari-launcher-badge-online {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--qari-emerald);
  border: 2.5px solid var(--qari-navy-dark);
  box-shadow: 0 0 8px var(--qari-emerald);
}

.qari-launcher-close-icon {
  display: none;
  width: 26px;
  height: 26px;
  color: var(--qari-gold);
}

.qari-chat-launcher.is-active .qari-launcher-avatar,
.qari-chat-launcher.is-active .qari-launcher-badge-online,
.qari-chat-launcher.is-active .qari-launcher-pill {
  display: none;
}

.qari-chat-launcher.is-active .qari-launcher-close-icon {
  display: block;
  animation: qariRotateIn 0.3s ease;
}

.qari-chat-launcher.is-active .qari-launcher-btn {
  background: var(--qari-navy-dark);
  border-color: var(--qari-gold);
  transform: scale(0.95);
}

/* Floating WhatsApp Adjustment for Perfect Harmony */
.floating-whatsapp-btn {
  bottom: 102px !important;
  right: 28px !important;
  width: 54px !important;
  height: 54px !important;
  z-index: 9998 !important;
}

/* --------------------------------------------------------------------------
   2. CHAT WINDOW CONTAINER
   -------------------------------------------------------------------------- */
.qari-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: var(--qari-cream);
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  border-radius: var(--qari-radius-lg);
  box-shadow: var(--qari-shadow-lg);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--qari-font-main);
  opacity: 0;
  transform: scale(0.85) translateY(30px);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.qari-chat-window.is-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* --------------------------------------------------------------------------
   3. CHAT HEADER
   -------------------------------------------------------------------------- */
.qari-chat-header {
  background: linear-gradient(135deg, var(--qari-navy-dark) 0%, var(--qari-navy) 100%);
  color: var(--qari-white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--qari-gold);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 10;
}

.qari-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qari-header-avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--qari-gold);
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.qari-header-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qari-header-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--qari-emerald);
  border: 2px solid var(--qari-navy-dark);
}

.qari-header-info {
  display: flex;
  flex-direction: column;
}

.qari-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qari-header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--qari-white);
  margin: 0;
  line-height: 1.2;
}

.qari-header-ai-badge {
  background: rgba(212, 175, 55, 0.2);
  color: var(--qari-gold);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--qari-gold);
  text-transform: uppercase;
}

.qari-header-subtitle {
  font-size: 0.78rem;
  color: #D1DDE8;
  margin: 2px 0 0 0;
}

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

.qari-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #E2E8F0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--qari-transition);
}

.qari-header-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  color: var(--qari-gold);
  border-color: var(--qari-gold);
}

.qari-header-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   4. CHAT MESSAGES BODY
   -------------------------------------------------------------------------- */
.qari-chat-body {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #FAF7F2;
  background-image: radial-gradient(rgba(212, 175, 55, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
}

.qari-chat-body::-webkit-scrollbar {
  width: 6px;
}

.qari-chat-body::-webkit-scrollbar-thumb {
  background: rgba(13, 32, 51, 0.18);
  border-radius: 4px;
}

/* Welcome Card Screen */
.qari-welcome-box {
  background: #FFFFFF;
  border: 1.5px solid var(--qari-cream-dark);
  border-radius: var(--qari-radius-md);
  padding: 18px;
  box-shadow: var(--qari-shadow-sm);
  text-align: center;
  animation: qariFadeUp 0.4s ease forwards;
}

.qari-welcome-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid var(--qari-gold);
  margin: 0 auto 12px;
  display: block;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.25);
}

.qari-welcome-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--qari-navy);
  margin: 0 0 6px 0;
}

.qari-welcome-text {
  font-size: 0.85rem;
  color: var(--qari-text-muted);
  line-height: 1.5;
  margin: 0 0 16px 0;
}

.qari-suggestions-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--qari-gold-dark);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: block;
}

.qari-suggestions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qari-suggestion-btn {
  background: #FDFBF7;
  border: 1.2px solid rgba(212, 175, 55, 0.35);
  color: var(--qari-navy);
  padding: 10px 14px;
  border-radius: var(--qari-radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--qari-transition);
}

.qari-suggestion-btn:hover {
  background: var(--qari-navy);
  color: var(--qari-white);
  border-color: var(--qari-gold);
  transform: translateX(4px);
}

.qari-suggestion-btn svg {
  width: 14px;
  height: 14px;
  color: var(--qari-gold);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   5. MESSAGE BUBBLES
   -------------------------------------------------------------------------- */
.qari-message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: qariFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.qari-message-row.is-user {
  justify-content: flex-end;
}

.qari-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--qari-gold);
  flex-shrink: 0;
  background: #fff;
}

.qari-message-content {
  max-width: 82%;
  display: flex;
  flex-direction: column;
}

.qari-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  position: relative;
  word-wrap: break-word;
  box-shadow: var(--qari-shadow-sm);
}

/* User Message Bubble */
.qari-message-row.is-user .qari-bubble {
  background: linear-gradient(135deg, var(--qari-navy) 0%, var(--qari-navy-light) 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

/* AI Message Bubble */
.qari-message-row.is-ai .qari-bubble {
  background: #FFFFFF;
  color: var(--qari-text-dark);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.25);
}

.qari-bubble p {
  margin: 0 0 8px 0;
}

.qari-bubble p:last-child {
  margin-bottom: 0;
}

.qari-bubble ul, .qari-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.qari-bubble li {
  margin-bottom: 4px;
}

.qari-bubble strong {
  color: var(--qari-navy);
  font-weight: 700;
}

.qari-message-row.is-user .qari-bubble strong {
  color: var(--qari-gold-light);
}

/* Rich Links & Action Buttons in AI Messages */
.qari-bubble a {
  color: #0A58CA;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-word;
}

.qari-action-btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--qari-gold) 0%, var(--qari-gold-dark) 100%);
  color: #0A192F !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  padding: 7px 14px;
  border-radius: 8px;
  margin: 6px 4px 6px 0;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.35);
  transition: var(--qari-transition);
}

.qari-action-btn-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.5);
  filter: brightness(1.08);
}

.qari-action-btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
  color: #FFFFFF !important;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35) !important;
}

.qari-action-btn-whatsapp:hover {
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.5) !important;
}

/* Message Meta (Timestamp & Copy) */
.qari-message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--qari-text-muted);
}

.qari-message-row.is-user .qari-message-meta {
  justify-content: flex-end;
}

.qari-copy-btn {
  background: none;
  border: none;
  color: var(--qari-text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.qari-copy-btn:hover {
  opacity: 1;
  color: var(--qari-gold-dark);
}

/* --------------------------------------------------------------------------
   6. TYPING INDICATOR
   -------------------------------------------------------------------------- */
.qari-typing-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: qariFadeUp 0.3s ease;
}

.qari-typing-bubble {
  background: #FFFFFF;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--qari-shadow-sm);
}

.qari-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--qari-gold);
  animation: qariTypingPulse 1.4s infinite ease-in-out;
}

.qari-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.qari-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* --------------------------------------------------------------------------
   7. QUICK REPLIES CHIP ROW
   -------------------------------------------------------------------------- */
.qari-chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 16px 10px;
  background: #FAF7F2;
  border-top: 1px solid rgba(212, 175, 55, 0.15);
  scrollbar-width: none;
}

.qari-chips-row::-webkit-scrollbar {
  display: none;
}

.qari-chip-btn {
  white-space: nowrap;
  background: #FFFFFF;
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--qari-navy);
  padding: 6px 12px;
  border-radius: var(--qari-radius-full);
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  transition: var(--qari-transition);
  flex-shrink: 0;
}

.qari-chip-btn:hover {
  background: var(--qari-navy);
  color: var(--qari-gold);
  border-color: var(--qari-gold);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   8. CHAT INPUT BAR
   -------------------------------------------------------------------------- */
.qari-chat-footer {
  background: #FFFFFF;
  border-top: 1.5px solid var(--qari-cream-dark);
  padding: 12px 16px;
  position: relative;
  z-index: 10;
}

.qari-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 22px;
  padding: 6px 12px;
  transition: var(--qari-transition);
}

.qari-input-container:focus-within {
  border-color: var(--qari-gold);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.qari-textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--qari-text-dark);
  max-height: 100px;
  line-height: 1.4;
  padding: 4px 0;
}

.qari-textarea::placeholder {
  color: #94A3B8;
}

.qari-send-btn {
  background: linear-gradient(135deg, var(--qari-navy) 0%, var(--qari-navy-light) 100%);
  color: var(--qari-gold);
  border: 1.5px solid var(--qari-gold);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--qari-transition);
}

.qari-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  background: var(--qari-navy-dark);
  box-shadow: 0 4px 12px var(--qari-gold-glow);
}

.qari-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qari-send-btn svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.qari-footer-disclaimer {
  text-align: center;
  font-size: 0.68rem;
  color: #94A3B8;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   9. ERROR STATE & RETRY
   -------------------------------------------------------------------------- */
.qari-error-bubble {
  background: #FEF2F2 !important;
  border-color: #F87171 !important;
  color: #991B1B !important;
}

.qari-retry-btn {
  background: var(--qari-navy);
  color: #FFFFFF;
  border: 1px solid var(--qari-gold);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.qari-retry-btn:hover {
  background: var(--qari-navy-dark);
}

/* --------------------------------------------------------------------------
   10. ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes qariLauncherBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes qariPillGlow {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(8, 20, 33, 0.16);
    border-color: var(--qari-gold);
  }
  50% {
    box-shadow: 0 6px 18px rgba(212, 175, 55, 0.4);
    border-color: var(--qari-gold-light);
  }
}

@keyframes qariRotateIn {
  from {
    transform: rotate(-90deg) scale(0.6);
    opacity: 0;
  }
  to {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

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

@keyframes qariTypingPulse {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   11. RESPONSIVE MOBILE STYLES
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .qari-chat-launcher {
    bottom: 18px;
    right: 18px;
  }

  .qari-launcher-pill {
    display: none;
  }

  .qari-launcher-btn {
    width: 58px;
    height: 58px;
  }

  .floating-whatsapp-btn {
    bottom: 88px !important;
    right: 18px !important;
    width: 50px !important;
    height: 50px !important;
  }

  .qari-chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

  .qari-chat-header {
    border-radius: 0;
    padding: 14px 16px;
  }

  .qari-bubble {
    max-width: 88%;
  }
}
