/* Ummah AI chat — cream / olive / pink brand */

.ummah-ai-chat {
  --chat-z: 1080;
  --chat-olive: #2f6b48;
  --chat-olive-dark: #245538;
  --chat-pink: #e591ac;
  --chat-cream: #faf8f5;
  --chat-border: #e8e2da;
  --chat-ink: #2a2a2a;
  --chat-muted: #6b6b6b;
  position: fixed;
  left: max(1.25rem, env(safe-area-inset-left));
  right: auto;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: var(--chat-z);
  font-family: "Tajawal", system-ui, sans-serif;
  direction: rtl;
}

.ummah-ai-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(18rem, calc(100vw - 2.5rem));
  padding: 0.8rem 1.1rem 0.8rem 0.9rem;
  border: 1px solid rgba(47, 107, 72, 0.28);
  border-radius: 999px;
  background: var(--chat-olive);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 10px 28px rgba(47, 107, 72, 0.32);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.ummah-ai-chat__launcher-label {
  text-align: start;
  white-space: normal;
}

.ummah-ai-chat__launcher:hover {
  background: var(--chat-olive-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(47, 107, 72, 0.4);
}

.ummah-ai-chat__launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.ummah-ai-chat__launcher-icon {
  display: inline-flex;
  width: 1.55rem;
  height: 1.55rem;
  align-items: center;
  justify-content: center;
  color: var(--chat-pink);
}

.ummah-ai-chat__panel {
  position: absolute;
  left: 0;
  right: auto;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2rem));
  height: min(580px, calc(100dvh - 2rem));
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  background: linear-gradient(165deg, #ffffff 0%, var(--chat-cream) 100%);
  box-shadow: 0 20px 48px rgba(47, 107, 72, 0.16);
  overflow: hidden;
  transform-origin: bottom left;
  animation: ummah-ai-chat-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.ummah-ai-chat__panel[hidden] {
  display: none !important;
}

@keyframes ummah-ai-chat-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ummah-ai-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--chat-border);
  background: linear-gradient(135deg, var(--chat-olive) 0%, #3a8558 100%);
  color: #fff;
}

.ummah-ai-chat__title {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.35;
}

.ummah-ai-chat__subtitle {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.76rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
}

.ummah-ai-chat__close {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ummah-ai-chat__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ummah-ai-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--chat-cream);
}

.ummah-ai-chat__welcome {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--chat-border);
  color: var(--chat-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.ummah-ai-chat__bubble {
  max-width: 92%;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
}

.ummah-ai-chat__bubble--user {
  align-self: flex-end;
  background: var(--chat-pink);
  color: #fff;
}

.ummah-ai-chat__bubble--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--chat-border);
  color: var(--chat-ink);
}

.ummah-ai-chat__bubble--assistant a {
  color: var(--chat-olive);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ummah-ai-chat__bubble--error {
  align-self: stretch;
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.28);
  color: #a12b38;
}

.ummah-ai-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--chat-border);
}

.ummah-ai-chat__typing span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--chat-olive);
  animation: ummah-ai-chat-dot 1.2s infinite ease-in-out;
}

.ummah-ai-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.ummah-ai-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ummah-ai-chat-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.ummah-ai-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 1rem 0.75rem;
  background: var(--chat-cream);
}

.ummah-ai-chat__chip {
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: #fff;
  color: var(--chat-olive);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ummah-ai-chat__chip:hover {
  background: rgba(229, 145, 172, 0.14);
  border-color: rgba(229, 145, 172, 0.55);
  color: var(--chat-ink);
}

.ummah-ai-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--chat-border);
  background: #fff;
}

.ummah-ai-chat__input {
  flex: 1;
  min-height: 2.5rem;
  max-height: 7rem;
  resize: none;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  background: var(--chat-cream);
  color: var(--chat-ink);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}

.ummah-ai-chat__input:focus {
  outline: none;
  border-color: rgba(47, 107, 72, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 107, 72, 0.12);
}

.ummah-ai-chat__send {
  display: inline-flex;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: var(--chat-olive);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ummah-ai-chat__send:hover:not(:disabled) {
  background: var(--chat-olive-dark);
}

.ummah-ai-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ummah-ai-chat .visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1199.98px) {
  .ummah-ai-chat {
    inset: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    pointer-events: none;
  }

  .ummah-ai-chat__launcher {
    display: none !important;
  }

  .ummah-ai-chat__panel {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: min(420px, calc(100dvh - 6.5rem));
    pointer-events: auto;
    transform-origin: bottom center;
  }
}

@media (min-width: 1200px) and (max-width: 480px) {
  .ummah-ai-chat__launcher-label {
    display: none;
  }

  .ummah-ai-chat__launcher {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
}
