/* ==========================================================================
   ATAUR DIGITAL MARKETING AGENCY - AFREEN AI KNOWLEDGE ASSISTANT STYLESHEET
   Floating Launcher, Welcome Invite Bubble, Chat Panel & Interactive Chips
   ========================================================================== */

.afr-root {
  --afr-z: 900;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--afr-z);
  font-family: var(--font, 'Plus Jakarta Sans', system-ui, sans-serif);
  color: var(--text-primary, #0e0e11);
  line-height: 1.5;
}

.afr-root * {
  box-sizing: border-box;
}

.afr-root button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

.afr-root button:focus-visible,
.afr-root a:focus-visible {
  outline: 2px solid var(--red, #d7262e);
  outline-offset: 2px;
}

/* Floating Launch Button */
.afr-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 10px;
  border-radius: 999px;
  background: var(--card, #fff);
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  box-shadow: 0 10px 30px var(--shadow, rgba(0, 0, 0, 0.15));
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.afr-launch:hover {
  transform: translateY(-2px);
  border-color: var(--red, #d7262e);
  box-shadow: 0 16px 36px var(--shadow, rgba(215, 38, 46, 0.25));
}

.afr-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--red, #d7262e);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  flex: none;
  position: relative;
}

.afr-av::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--card, #fff);
}

.afr-launch-t {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

/* Invite Bubble */
.afr-invite {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: 260px;
  padding: 14px 34px 14px 14px;
  border-radius: 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  box-shadow: 0 12px 32px var(--shadow, rgba(14, 14, 17, 0.12));
  font-size: 13.5px;
  animation: afrUp 0.35s ease both;
}

.afr-invite button.afr-open-i {
  all: unset;
  cursor: pointer;
  display: block;
}

.afr-invite b {
  display: block;
  margin-bottom: 2px;
}

.afr-invite .afr-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary, #4f4f58);
}

/* Chat Panel */
.afr-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 384px;
  max-width: calc(100vw - 24px);
  height: min(620px, calc(100vh - 40px));
  height: min(620px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--bg, #fff);
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  border-radius: 22px;
  box-shadow: 0 24px 70px var(--shadow, rgba(14, 14, 17, 0.2));
  overflow: hidden;
  animation: afrUp 0.28s ease both;
}

.afr-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  background: var(--card, #fff);
}

.afr-head-t {
  flex: 1;
  min-width: 0;
}

.afr-head-t b {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.afr-head-t span {
  font-size: 12px;
  color: var(--text-secondary, #4f4f58);
}

.afr-ic {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  transition: background 0.2s ease;
}

.afr-ic:hover {
  background: var(--red-light, rgba(215, 38, 46, 0.08));
}

.afr-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-alt, #f5f5f2);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.afr-msg {
  background: var(--card, #fff);
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  animation: afrUp 0.25s ease both;
}

.afr-msg p {
  margin: 0 0 8px;
}

.afr-msg p:last-child {
  margin-bottom: 0;
}

.afr-msg ul {
  margin: 6px 0 8px;
  padding-left: 18px;
}

.afr-msg li {
  margin: 3px 0;
}

.afr-user {
  background: var(--red, #d7262e);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  margin-left: 36px;
  font-weight: 600;
  border-color: transparent;
}

.afr-note {
  font-size: 11.5px;
  color: var(--text-secondary, #4f4f58);
  margin: -4px 0 12px 2px;
}

.afr-h {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, #4f4f58);
  margin: 14px 0 8px;
}

.afr-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.afr-chip {
  text-align: left;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  background: var(--card, #fff);
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.afr-chip:hover {
  border-color: var(--red, #d7262e);
  background: var(--red-light, rgba(215, 38, 46, 0.08));
}

.afr-cat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.afr-cat small {
  color: var(--text-secondary, #4f4f58);
  font-weight: 600;
}

.afr-more {
  margin-top: 8px;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  color: var(--red, #d7262e);
  padding: 6px 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.afr-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--red, #d7262e);
  color: #fff !important;
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}

.afr-cta:hover {
  background: var(--red-hover, #b81f26);
}

.afr-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  background: var(--card, #fff);
}

.afr-fb {
  flex: 1;
  min-width: max-content;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(14, 14, 17, 0.09));
  background: transparent;
  font-size: 12.5px;
  font-weight: 700;
}

.afr-fb:hover {
  border-color: var(--red, #d7262e);
  color: var(--red, #d7262e);
}

.afr-fb[disabled] {
  opacity: 0.4;
  cursor: default;
}

@keyframes afrUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 520px) {
  .afr-root {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .afr-launch-t { display: none; }
  .afr-launch { padding: 8px; }
  .afr-panel {
    position: fixed;
    right: 8px;
    left: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: min(86dvh, 640px);
    height: min(86vh, 640px);
  }
  .afr-invite { width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .afr-root * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
