#hpfai-root {
  --hpfai-brand: #17353c;
  --hpfai-brand-2: #24474e;
  --hpfai-accent: #d5b167;
  --hpfai-bg: #fbfaf8;
  --hpfai-surface: #ffffff;
  --hpfai-text: #1f2a2b;
  --hpfai-muted: #56625f;
  --hpfai-border: #e7e1d5;
  position: fixed;
  bottom: 20px;
  z-index: 99999;
  font-family: inherit;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.7;
  color: var(--hpfai-text);
}
#hpfai-root.hpfai-left { left: 20px; }
#hpfai-root.hpfai-right { right: 20px; }
#hpfai-root *, #hpfai-root *::before, #hpfai-root *::after { box-sizing: border-box; }

#hpfai-root .hpfai-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--hpfai-brand);
  box-shadow: 0 10px 28px rgba(25, 54, 58, .35);
  transition: transform .2s ease, background .2s ease;
}
#hpfai-root .hpfai-fab:hover { transform: translateY(-2px); background: var(--hpfai-brand-2); }
#hpfai-root .hpfai-fab:focus-visible { outline: 3px solid var(--hpfai-accent); outline-offset: 3px; }
#hpfai-root .hpfai-ico-close { display: none; }
#hpfai-root.hpfai-open .hpfai-ico-open { display: none; }
#hpfai-root.hpfai-open .hpfai-ico-close { display: block; }

#hpfai-root .hpfai-panel {
  position: absolute;
  bottom: 76px;
  width: 380px;
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--hpfai-bg);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  border: 1px solid var(--hpfai-border);
  animation: hpfai-in .22s ease;
}
#hpfai-root .hpfai-panel[hidden] { display: none; }
#hpfai-root.hpfai-left .hpfai-panel { left: 0; }
#hpfai-root.hpfai-right .hpfai-panel { right: 0; }
@keyframes hpfai-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#hpfai-root .hpfai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: var(--hpfai-brand);
}
#hpfai-root .hpfai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--hpfai-brand);
  background: var(--hpfai-accent);
  flex: none;
}
#hpfai-root .hpfai-head-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#hpfai-root .hpfai-head-text strong { font-size: 16px; }
#hpfai-root .hpfai-head-text span { font-size: 12px; opacity: .8; }
#hpfai-root .hpfai-hbtn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  width: 32px;
  height: 32px;
  min-width: 0;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
#hpfai-root .hpfai-hbtn:hover { background: rgba(255, 255, 255, .12); }

#hpfai-root .hpfai-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#hpfai-root .hpfai-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
#hpfai-root .hpfai-msg p { margin: 0 0 6px; }
#hpfai-root .hpfai-msg p:last-child { margin-bottom: 0; }
#hpfai-root .hpfai-msg ul { margin: 4px 0 6px; padding-inline-start: 20px; }
#hpfai-root .hpfai-msg a { color: var(--hpfai-brand); text-decoration: underline; }
#hpfai-root .hpfai-bot {
  align-self: flex-start;
  background: var(--hpfai-surface);
  border: 1px solid var(--hpfai-border);
  border-start-start-radius: 4px;
}
#hpfai-root .hpfai-user {
  align-self: flex-end;
  color: #fff;
  background: var(--hpfai-brand);
  border-start-end-radius: 4px;
}

#hpfai-root .hpfai-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
#hpfai-root .hpfai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hpfai-muted);
  animation: hpfai-dot 1.2s infinite ease-in-out;
}
#hpfai-root .hpfai-typing span:nth-child(2) { animation-delay: .15s; }
#hpfai-root .hpfai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hpfai-dot { 0%, 80%, 100% { opacity: .3; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

#hpfai-root .hpfai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
#hpfai-root .hpfai-quick:empty { display: none; }
#hpfai-root .hpfai-quick button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--hpfai-brand);
  background: var(--hpfai-surface);
  border: 1px solid var(--hpfai-accent);
}
#hpfai-root .hpfai-quick button:hover { background: var(--hpfai-border); }

#hpfai-root .hpfai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--hpfai-surface);
  border-top: 1px solid var(--hpfai-border);
}
#hpfai-root .hpfai-form textarea {
  flex: 1;
  resize: none;
  font: inherit;
  margin: 0;
  min-height: 42px;
  max-height: 120px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--hpfai-border);
  background: var(--hpfai-bg);
  color: var(--hpfai-text);
  outline: none;
}
#hpfai-root .hpfai-form textarea:focus { border-color: var(--hpfai-brand); }
#hpfai-root .hpfai-form button {
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  padding: 0;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--hpfai-brand);
}
#hpfai-root .hpfai-form button:disabled { opacity: .5; cursor: wait; }
#hpfai-root .hpfai-note {
  margin: 0;
  padding: 6px 12px 10px;
  font-size: 11px;
  text-align: center;
  color: var(--hpfai-muted);
  background: var(--hpfai-surface);
}

@media (max-width: 480px) {
  #hpfai-root { bottom: 16px; }
  #hpfai-root.hpfai-left { left: 16px; }
  #hpfai-root.hpfai-right { right: 16px; }
  #hpfai-root.hpfai-open .hpfai-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    border: 0;
  }
  #hpfai-root.hpfai-open .hpfai-fab { display: none; }
}

/* الثيم بيكبّر أول حرف في كل كلمة في الأزرار: نلغيه جوه الشات */
#hpfai-root button, #hpfai-root textarea, #hpfai-root strong { text-transform: none !important; letter-spacing: 0 !important; }

/* الوضع الداكن: الأزرار السريعة والروابط واضحة */
html[data-theme="dark"] #hpfai-root .hpfai-quick button { color: #f4efe4; background: #183840; border-color: #d5b167; }
html[data-theme="dark"] #hpfai-root .hpfai-quick button:hover { background: #d5b167; color: #12292e; }
html[data-theme="dark"] #hpfai-root .hpfai-user { background: #d5b167; color: #12292e; }
html[data-theme="dark"] #hpfai-root .hpfai-form textarea { color: #f4efe4; }
html[data-theme="dark"] #hpfai-root .hpfai-form textarea::placeholder { color: #a3b3b0; }
html[data-theme="dark"] #hpfai-root .hpfai-form button { background: #d5b167; color: #12292e; }
html[data-theme="dark"] #hpfai-root .hpfai-typing span { background: #a3b3b0; }
