/* ── Chat FAB ─────────────────────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 88px; /* above mobile tab bar */
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-forest-700), var(--c-forest-500));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  z-index: 900;
  color: #fff;
}
.chat-fab svg { width: 22px; height: 22px; }
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.chat-fab.active { background: linear-gradient(135deg, var(--c-gold-600), var(--c-gold-400)); }

.badge-unread {
  position: absolute;
  top: 6px; right: 6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #EF4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--c-bg);
}

/* ── Chat Window ─────────────────────────────────────── */
.chat-window {
  position: fixed;
  bottom: 156px;
  right: 20px;
  width: 360px;
  max-height: 520px;
  background: var(--c-surface-1);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  z-index: 899;
  opacity: 0;
  transform: translateY(16px) scale(.96);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  overflow: hidden;
}
.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--c-forest-900), var(--c-forest-700));
  color: #fff;
  border-radius: 20px 20px 0 0;
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-bot-avatar  { font-size: 24px; }
.chat-bot-name    { font-weight: 700; font-size: 14px; }
.chat-bot-status  { font-size: 11px; opacity: .7; }
.chat-close-btn {
  background: rgba(255,255,255,.12);
  border: none; cursor: pointer;
  color: #fff; border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-close-btn:hover { background: rgba(255,255,255,.22); }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--c-surface-2);
  border-bottom-left-radius: 4px;
  color: var(--c-text);
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--c-forest-700);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-time {
  font-size: 10px;
  opacity: .5;
  margin-top: 3px;
}
.chat-typing {
  display: flex; gap: 4px; align-items: center; padding: 8px 0;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-text-muted);
  animation: chatDot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%            { transform: scale(1); opacity: 1; }
}

/* Quick replies */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.chat-qr-btn {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.chat-qr-btn:hover {
  background: var(--c-forest-900);
  border-color: var(--c-forest-700);
  color: var(--c-forest-300);
}

/* Input area */
.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  background: var(--c-surface-1);
  border-radius: 0 0 20px 20px;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--ff-sans);
  background: var(--c-surface-2);
  color: var(--c-text);
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .15s;
}
.chat-input:focus { outline: none; border-color: var(--c-forest-500); }
.chat-input::placeholder { color: var(--c-text-muted); }
.chat-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--c-forest-600);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.chat-send-btn svg { width: 15px; height: 15px; }
.chat-send-btn:hover { background: var(--c-forest-500); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: .4; cursor: default; transform: none; }

/* ── App Loader ──────────────────────────────────────── */
#app-loader {
  position: fixed;
  inset: 0;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .4s ease;
}
.app-loader-inner { text-align: center; }
.loader-mosque { font-size: 48px; margin-bottom: 12px; animation: loaderPulse 1.2s ease-in-out infinite; }
.loader-text {
  font-family: var(--ff-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--c-forest-700);
  margin-bottom: 16px;
}
.loader-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-forest-600);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .8s linear infinite;
}
@keyframes loaderPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile chat adjustments */
@media (max-width: 480px) {
  .chat-window {
    bottom: 72px;
    right: 0; left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
  }
  .chat-fab { bottom: 80px; right: 16px; }
}
