.rayan-ai-widget,
.rayan-ai-widget * {
  box-sizing: border-box;
}

.rayan-ai-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  direction: rtl;
  font-family: "Cairo", Tahoma, Arial, sans-serif;
}

.rayan-ai-toggle {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  cursor: pointer;
  color: #fff8e8;
  border: 1px solid rgba(201, 161, 74, 0.5);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.24), transparent 30%),
    linear-gradient(135deg, #123d24, #168a3a);
  box-shadow:
    0 18px 40px rgba(18, 61, 36, 0.34),
    0 0 0 8px rgba(201, 161, 74, 0.12);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.rayan-ai-toggle:hover {
  transform: translateY(-3px);
  box-shadow:
    0 22px 48px rgba(18, 61, 36, 0.42),
    0 0 0 10px rgba(201, 161, 74, 0.16);
}

.rayan-ai-toggle i {
  font-size: 24px;
}

.rayan-ai-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid rgba(16, 32, 21, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 70px rgba(16, 32, 21, 0.2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform-origin: bottom right;
  animation: rayanAiPanelIn 220ms ease both;
}

.rayan-ai-panel[hidden] {
  display: none;
}

.rayan-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(201, 161, 74, 0.35), transparent 38%),
    linear-gradient(135deg, #123d24, #0f2f1e);
}

.rayan-ai-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.rayan-ai-header p {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  color: rgba(255, 248, 232, 0.82);
  font-size: 12px;
  font-weight: 700;
}

.rayan-ai-header p span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #42d46b;
  box-shadow: 0 0 0 4px rgba(66, 212, 107, 0.18);
}

.rayan-ai-close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  cursor: pointer;
  color: #fff8e8;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.rayan-ai-training-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  color: #405144;
  border-bottom: 1px solid rgba(16, 32, 21, 0.07);
  background:
    linear-gradient(90deg, rgba(201, 161, 74, 0.13), rgba(22, 138, 58, 0.07)),
    #fbfaf4;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
}

.rayan-ai-training-note i {
  flex: 0 0 auto;
  margin-top: 2px;
  color: #c9a14a;
  font-size: 12px;
}

.rayan-ai-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(247, 248, 244, 0.7), rgba(247, 248, 244, 0.96)),
    #f7f8f4;
}

.rayan-ai-message {
  max-width: 86%;
  padding: 10px 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.8;
}

.rayan-ai-message--assistant {
  align-self: flex-start;
  color: #102015;
  border: 1px solid rgba(16, 32, 21, 0.08);
  border-radius: 16px 16px 16px 5px;
  background: #fff;
}

.rayan-ai-message--user {
  align-self: flex-end;
  color: #fff;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, #168a3a, #123d24);
}

.rayan-ai-typing {
  display: inline-flex;
  width: auto;
  gap: 5px;
  padding-block: 14px;
}

.rayan-ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9a14a;
  animation: rayanAiTyping 900ms ease-in-out infinite;
}

.rayan-ai-typing span:nth-child(2) {
  animation-delay: 140ms;
}

.rayan-ai-typing span:nth-child(3) {
  animation-delay: 280ms;
}

.rayan-ai-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 42px;
  margin-top: 10px;
  padding: 0 16px;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  background: #168a3a;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(22, 138, 58, 0.22);
}

.rayan-ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(16, 32, 21, 0.08);
  background: #fff;
}

.rayan-ai-input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: #102015;
  border: 1px solid rgba(16, 32, 21, 0.12);
  border-radius: 999px;
  background: #f7f8f4;
  font: inherit;
  outline: none;
}

.rayan-ai-input:focus {
  border-color: #168a3a;
  box-shadow: 0 0 0 4px rgba(22, 138, 58, 0.1);
}

.rayan-ai-send {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  cursor: pointer;
  color: #fff;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a14a, #168a3a);
  transition: opacity 180ms ease, transform 180ms ease;
}

.rayan-ai-send:hover {
  transform: translateY(-1px);
}

.rayan-ai-send:disabled,
.rayan-ai-input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

@keyframes rayanAiPanelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rayanAiTyping {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .rayan-ai-widget {
    right: 14px;
    bottom: 14px;
  }

  .rayan-ai-toggle {
    width: 56px;
    height: 56px;
  }

  .rayan-ai-panel {
    right: -2px;
    bottom: 70px;
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 96px));
    border-radius: 22px;
  }

  .rayan-ai-message {
    max-width: 92%;
  }
}
