/* Rijam AI chat widget — dark theme + sage brand */

.rijam-chat {
  --chat-z: 1080;
  --chat-sage: #8fa88c;
  --chat-sage-deep: #3f5544;
  --chat-bg: #101010;
  --chat-panel: #161616;
  --chat-border: rgba(255, 255, 255, 0.12);
  --chat-muted: rgba(255, 255, 255, 0.68);
  --chat-text: rgba(255, 255, 255, 0.94);
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  left: auto;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: var(--chat-z);
  font-family: var(--font-body, "Satoshi", system-ui, sans-serif);
}

body:has(.whatsapp-float) .rijam-chat {
  bottom: max(5.25rem, calc(env(safe-area-inset-bottom) + 4.25rem));
}

.rijam-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.15rem 0.85rem 0.95rem;
  border: 1px solid rgba(143, 168, 140, 0.45);
  border-radius: 999px;
  background: var(--chat-sage-deep);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.rijam-chat__launcher:hover {
  background: #4d6752;
  transform: translateY(-2px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.48);
}

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

.rijam-chat__launcher-icon {
  display: inline-flex;
  width: 1.65rem;
  height: 1.65rem;
  align-items: center;
  justify-content: center;
  color: var(--chat-sage);
}

.rijam-chat__panel {
  position: absolute;
  right: 0;
  left: auto;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 2rem));
  height: min(620px, calc(100dvh - 2rem));
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  background: linear-gradient(165deg, #1a1a1a 0%, #0e0e0e 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  transform-origin: bottom right;
  animation: rijam-chat-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

.rijam-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.95rem;
  border-bottom: 1px solid var(--chat-border);
  background: linear-gradient(135deg, rgba(143, 168, 140, 0.16), rgba(63, 85, 68, 0.18));
}

.rijam-chat__title {
  display: block;
  font-family: var(--font-display, "Cormorant Garamond", serif);
  font-size: 1.15rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: #fff;
}

.rijam-chat__subtitle {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--chat-sage);
}

.rijam-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.06);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rijam-chat__close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.rijam-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rijam-chat__welcome {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--chat-border);
  color: var(--chat-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.rijam-chat__bubble {
  max-width: 92%;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.rijam-chat__bubble--user {
  align-self: flex-end;
  background: rgba(143, 168, 140, 0.18);
  border: 1px solid rgba(143, 168, 140, 0.4);
  color: var(--chat-text);
}

.rijam-chat__bubble--assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
}

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

.rijam-chat__bubble--error {
  align-self: stretch;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: #ffb4bc;
}

.rijam-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--chat-border);
}

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

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

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

.rijam-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 1rem 0.75rem;
}

.rijam-chat__chip {
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--chat-text);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.rijam-chat__chip:hover {
  background: rgba(143, 168, 140, 0.12);
  border-color: rgba(143, 168, 140, 0.45);
  color: #fff;
}

.rijam-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--chat-border);
  background: rgba(0, 0, 0, 0.28);
}

.rijam-chat__input {
  flex: 1;
  min-height: 2.5rem;
  max-height: 7rem;
  resize: none;
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--chat-text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
}

.rijam-chat__input:focus {
  outline: none;
  border-color: rgba(143, 168, 140, 0.65);
  box-shadow: 0 0 0 3px rgba(143, 168, 140, 0.15);
}

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

.rijam-chat__send:hover:not(:disabled) {
  background: #4d6752;
}

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

.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: 480px) {
  .rijam-chat__launcher-label {
    display: none;
  }

  .rijam-chat__launcher {
    width: 3.35rem;
    height: 3.35rem;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .rijam-chat__panel {
    width: calc(100vw - 1.25rem);
    height: min(78dvh, 620px);
  }
}
