/* ======= صفحة المساعد (رفيقة نور) ======= */
.companion-wrap {
  height: min(680px, calc(100vh - 240px));
  min-height: 540px;
}
.companion-wrap .wrapper { height: 100%; }

.companion-quick { max-width: 100%; white-space: normal; text-align: start; text-align: right; }

/* ===== واجهة رفيقة نور — المحاكي المحلي ===== */
.rafiqa {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.rafiqa__head {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--grad-hero);
  color: #fff;
  padding: 14px 18px;
}
.rafiqa__ava {
  width: 42px; height: 42px; border-radius: 14px;
  background: rgba(255,255,255,.12);
  display: grid; place-items: center; color: #6FE3D8;
  flex: 0 0 auto;
}
.rafiqa__ava svg { width: 22px; height: 22px; }
.rafiqa__titles { flex: 1; min-width: 0; }
.rafiqa__name { font-family: var(--font-head); font-weight: 800; font-size: var(--fs-md); }
.rafiqa__status { font-size: var(--fs-xs); color: #A9BEDA; display: flex; align-items: center; gap: 6px; }
.rafiqa__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(23,182,180,.25);
}
.rafiqa__reset {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 10px; border: 0;
  background: rgba(255,255,255,.1); color: #C7D7EE;
  display: grid; place-items: center; cursor: pointer;
}
.rafiqa__reset:hover { background: rgba(255,255,255,.2); color: #fff; }
.rafiqa__reset svg { width: 16px; height: 16px; }

.rafiqa__log {
  flex: 1;
  overflow-y: auto;
  background: var(--surface-soft);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rafiqa__row { display: flex; gap: 8px; max-width: 86%; }
.rafiqa__row--user { align-self: flex-end; }
.rafiqa__row--bot { align-self: flex-start; }
.rafiqa__box { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rafiqa__bubble {
  border-radius: 16px;
  padding: 10px 14px;
  font-size: var(--fs-sm);
  line-height: 1.75;
  white-space: pre-wrap;
}
.rafiqa__row--user .rafiqa__bubble {
  background: var(--grad-purple);
  color: #fff;
  border-end-end-radius: 6px;
}
.rafiqa__row--bot .rafiqa__bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-600);
  border-start-start-radius: 6px;
}
.rafiqa__row--bot .rafiqa__bubble p { margin: 0; }
.rafiqa__mini {
  width: 30px; height: 30px; border-radius: 10px;
  background: var(--purple-100); color: var(--purple-700);
  display: grid; place-items: center;
  flex: 0 0 auto; margin-top: 2px;
}
.rafiqa__mini svg { width: 15px; height: 15px; }
.rafiqa__tag { font-size: 11px; font-weight: 800; color: var(--teal-700); }

.rafiqa__typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.rafiqa__typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-300);
  animation: rafiqaBlink 1.2s infinite;
}
.rafiqa__typing span:nth-child(2) { animation-delay: .15s; }
.rafiqa__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes rafiqaBlink {
  0%, 60%, 100% { opacity: .25; transform: none; }
  30% { opacity: 1; transform: translateY(-3px); }
}

.rafiqa__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 2px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.rafiqa__chip {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--navy-800);
  border-radius: var(--r-full);
  padding: 7px 13px;
  font-size: var(--fs-xs);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--tr-fast);
}
.rafiqa__chip:hover { background: var(--purple-50); border-color: var(--purple-500); color: var(--purple-700); }

.rafiqa__form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  background: var(--surface);
  border-top: 1px solid var(--line-soft);
}
.rafiqa__input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 11px 16px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: var(--ink-900);
}
.rafiqa__input:focus { outline: none; border-color: var(--purple-500); box-shadow: 0 0 0 3px rgba(124,92,252,.14); }
.rafiqa__send {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--grad-purple); color: #fff;
  display: grid; place-items: center;
  cursor: pointer; flex: 0 0 auto;
  transition: opacity var(--tr-fast);
}
.rafiqa__send:disabled { opacity: .5; cursor: default; }
.rafiqa__send svg { width: 18px; height: 18px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .companion-wrap { min-height: 480px; }
  .rafiqa__row { max-width: 92%; }
}