.jamal-chat-root {
  --jamal-green: #1a7a42;
  --jamal-green-dark: #0d5c2e;
  --jamal-corner-offset: 24px;
  --jamal-btt-size: 42px;
  --jamal-stack-gap: 12px;
  position: fixed;
  z-index: 9990;
  inset-inline-end: var(--jamal-corner-offset);
  inset-block-end: calc(var(--jamal-corner-offset) + var(--jamal-btt-size) + var(--jamal-stack-gap));
  font-family: inherit;
}

.jamal-chat-root[hidden] {
  display: none !important;
}

.jamal-chat-toggle {
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--jamal-green), var(--jamal-green-dark));
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  transition: transform 0.2s ease;
}

.jamal-chat-toggle:hover {
  transform: scale(1.05);
}

.jamal-chat-panel {
  position: absolute;
  inset-inline-end: 0;
  inset-block-end: 4.25rem;
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(32rem, calc(100vh - 6rem));
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.jamal-chat-panel[hidden] {
  display: none !important;
}

.jamal-chat-header {
  background: linear-gradient(135deg, var(--jamal-green), var(--jamal-green-dark));
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.jamal-chat-header strong {
  font-size: 1rem;
}

.jamal-chat-header small {
  display: block;
  opacity: 0.9;
  font-size: 0.72rem;
}

.jamal-chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.jamal-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f7f9f8;
}

.jamal-chat-msg {
  max-width: 88%;
  padding: 0.55rem 0.75rem;
  border-radius: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.jamal-chat-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.jamal-chat-msg--user {
  align-self: flex-end;
  background: var(--jamal-green);
  color: #fff;
}

.jamal-chat-msg a {
  color: inherit;
  text-decoration: underline;
}

.jamal-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.85rem 0.5rem;
  background: #f7f9f8;
}

.jamal-chat-suggestions[hidden] {
  display: none !important;
}

.jamal-chat-suggestion {
  border: 1px solid rgba(26, 122, 66, 0.35);
  background: #fff;
  color: var(--jamal-green-dark);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.3;
  cursor: pointer;
  text-align: start;
  max-width: 100%;
}

.jamal-chat-suggestion:hover {
  background: rgba(26, 122, 66, 0.08);
}

.jamal-chat-typing {
  font-size: 0.8rem;
  color: #666;
  padding: 0 0.85rem 0.35rem;
}

.jamal-chat-form {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.jamal-chat-form input {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.jamal-chat-form button {
  border: 0;
  border-radius: 999px;
  background: var(--jamal-green);
  color: #fff;
  width: 2.35rem;
  height: 2.35rem;
  cursor: pointer;
}

.jamal-chat-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.jamal-chat-root[dir='rtl'] .jamal-chat-msg--user {
  align-self: flex-start;
}

.jamal-chat-root[dir='rtl'] .jamal-chat-msg--bot {
  align-self: flex-end;
}

@media (max-width: 480px) {
  .jamal-chat-root {
    inset-inline-end: var(--jamal-corner-offset);
    inset-block-end: calc(var(--jamal-corner-offset) + var(--jamal-btt-size) + var(--jamal-stack-gap));
  }

  .jamal-chat-panel {
    width: calc(100vw - 1.3rem);
  }
}
